entities
list | max_stars_repo_path
stringlengths 6
131
| max_stars_repo_name
stringlengths 9
67
| max_stars_count
int64 0
17k
| content
stringlengths 25
1M
| id
stringlengths 1
5
| new_content
stringlengths 17
1M
| modified
bool 1
class | references
stringlengths 32
1M
|
---|---|---|---|---|---|---|---|---|
[
{
"context": "by AdaCore --\n-- (http://www.adacore.com). ",
"end": 2787,
"score": 0.7214107513427734,
"start": 2782,
"tag": "EMAIL",
"value": "acore"
},
{
"context": " return An_Elaborate_All_Pragma; -- 10.2.1(19), B(8)\n\n elsif Pragma_Chars = Name_E",
"end": 113271,
"score": 0.6896079182624817,
"start": 113270,
"tag": "IP_ADDRESS",
"value": "1"
},
{
"context": " return An_Elaborate_All_Pragma; -- 10.2.1(19), B(8)\n\n elsif Pragma_Chars = Name_Elab",
"end": 113274,
"score": 0.635957658290863,
"start": 113273,
"tag": "IP_ADDRESS",
"value": "2"
},
{
"context": " return A_Preelaborate_Pragma; -- 10.2.1(3), B(6)\n\n elsif Pragma_Chars = Name_Priorit",
"end": 115005,
"score": 0.8282565474510193,
"start": 114999,
"tag": "IP_ADDRESS",
"value": "10.2.1"
}
] | src/asis/a4g-mapping.adb | My-Colaborations/dynamo | 15 | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . M A P P I N G --
-- --
-- B o d y --
-- --
-- Copyright (C) 1995-2012, Free Software Foundation, Inc. --
-- --
-- ASIS-for-GNAT is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore --
-- (http://www.adacore.com). --
-- --
------------------------------------------------------------------------------
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Asis; use Asis;
with Asis.Compilation_Units; use Asis.Compilation_Units;
with Asis.Elements; use Asis.Elements;
with Asis.Set_Get; use Asis.Set_Get;
with A4G.A_Debug; use A4G.A_Debug;
with A4G.A_Output; use A4G.A_Output;
with A4G.A_Sem; use A4G.A_Sem;
with A4G.A_Sinput; use A4G.A_Sinput;
with A4G.Asis_Tables; use A4G.Asis_Tables;
with A4G.Contt; use A4G.Contt;
with A4G.Norm; use A4G.Norm;
with A4G.Vcheck; use A4G.Vcheck;
with Atree; use Atree;
with Einfo; use Einfo;
with Elists; use Elists;
with Namet; use Namet;
with Nlists; use Nlists;
with Output; use Output;
with Snames; use Snames;
with Stand; use Stand;
with Uintp; use Uintp;
with Urealp; use Urealp;
package body A4G.Mapping is
-------------------------------------------
-- Tree nodes onto ASIS Elements Mapping --
-------------------------------------------
-- The kernel of the mapping from tree nodes onto ASIS Elements is
-- determining the ASIS kind of the Element which should be built on top
-- of a given node. We are computing the Element position in the internal
-- flat classification, that is, the corresponding value of
-- Internal_Element_Kinds (which is further referred simply as Element
-- kind in this unit).
--
-- Mapping of tree nodes onto Element kinds is implemented as two-level
-- switching based on look-up tables. Both look-up tables are one-dimension
-- arrays indexed by Node_Kind type).
--
-- The first table has Internal_Element_Kinds as its component type. It
-- defines the mapping of Node_Kind values onto Internal_Element_Kinds
-- values as pairs index_value -> component_value, the semantics of this
-- mapping depends on the component value in the following way:
--
-- Component value First switch mapping semantics
--
-- A_Xxx, where A_Xxx corresponds - Element which should be based on
-- to some position in the original any node having the corresponding
-- ASIS element classification Node_Kind will always be of A_Xxx
-- hierarchy (such as An_Identifier) ASIS kind, no more computation
-- of Element kind is needed
--
-- Non_Trivial_Mapping - Elements which can be built on
-- nodes having the corresponding
-- Node_Kind may have different ASIS
-- kinds, therefore a special function
-- computing the ASIS kind should be
-- used, this function is defined by
-- the second look-up table
--
-- No_Mapping - no ASIS Element kind corresponds to
-- nodes of the corresponding
-- Node_Kind in the framework of the
-- given node-to-Element mapping
--
-- Not_Implemented_Mapping - this value was used during the
-- development phase and now it is
-- kept as the value for 'others'
-- choice in the initialization
-- aggregate just in case if a new
-- value appear in Node_Kind type
--
-- No_Mapping does not mean, that for a given Node_Kind value no Element
-- can be created at all, it means, that automatic Element kind
-- determination is impossible for these nodes because of any reason.
--
-- Both No_Mapping and Not_Implemented_Mapping mapping items, when chosen.
-- resulted in raising the ASIS_Failed exception. The reason because of
-- which we keep Not_Implemented_Mapping value after finishing the
-- development stage is to catch possible changes in Node_Kind definition.
-- No_Mapping means that for sure there is no mapping for a given Node_Kind
-- value, and Not_Implemented_Mapping means that processing of the given
-- Node_Kind value is missed in the existing code.
--
-- The second look-up table defines functions to be used to compute
-- Element kind for those Node_Kind values for which the first table
-- defines Non_Trivial_Mapping. All these functions are supposed to be
-- called for nodes of the Node_Kind from the corresponding mapping item
-- defined by the second table, it is erroneous to call them for other
-- nodes.
--
-- The structure, documentation and naming policy for look-up tables
-- implementing note-to-Element mapping are based on the GNAT Sinfo
-- package, and, in particular, on the Sinfo.Node_Kind type definition.
-- Rather old version of the spec of Sinfo is used, so some deviations
-- with the latest version may be possible
------------------------------------------------------
-- Tree nodes lists onto ASIS Element lists Mapping --
------------------------------------------------------
-- ASIS Element lists are built from tree node lists: when constructing an
-- ASIS Element_List value, the corresponding routine goes trough the
-- corresponding tree node list, checks which nodes should be used as a
-- basis for ASIS Elements to be placed in the result Element_List, and
-- which should not, and then calls node-to-Element conversion function
-- for the selected nodes. Therefore, two main components of node list to
-- Element list mapping are filters for the nodes in the argument node
-- list and node-to-Element mapping
-----------------------
-- Local subprograms --
-----------------------
procedure Normalize_Name (Capitalized : Boolean := False);
-- This procedure "normalizes" a name stored in Namet.Name_Buffer by
-- capitalizing its firs letter and all the letters following underscores
-- (if any). If Capitalized is set ON, all the letters are converted to
-- upper case, this is used for some defining names from Standard (such as
-- ASCII)
function Is_Protected_Procedure_Call (N : Node_Id) return Boolean;
-- In case if N is of N_Entry_Call_Statement, it checks if this is a call
-- to a protected subprogram (if it is, the corresponding ASIS Element
-- should be classified as A_Procedure_Call_Statement, but not as
-- An_Entry_Call_Statement
function Is_Stub_To_Body_Instanse_Replacement
(N : Node_Id)
return Boolean;
-- Checks if the node corresponds to the body which replaces the body stub
-- within the instance. The reason why we need this is that Sloc
-- field is not set to point into the instance copy if the source for
-- such node, so the ordinary Is_From_Instance check does not work
-- for this node (see 8930-001)
function Is_Config_Pragma (N : Node_Id) return Boolean;
-- Checks if N represents a configuration pragma
function Requires_Parentheses
(N : Node_Id)
return Boolean;
-- Checks if N represents a conditional or quantified expression in the
-- context that requires the expression to be in parentheses. The problem
-- is that in this case Parent_Count is 0. This function is supposed to be
-- called if Parent_Count (N) = 0
--------------------------------------------------------------
-- Subprograms for the second Note-to-Element Look-Up Table --
--------------------------------------------------------------
procedure No_Mapping (Node : Node_Id);
function Not_Implemented_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
procedure Not_Implemented_Mapping (Source_Node_Kind : Node_Kind);
-- These three subprograms raise ASIS_Failed with the appropriate
-- Diagnosis string
pragma No_Return (Not_Implemented_Mapping);
pragma No_Return (No_Mapping);
-- Individual mapping components:
function N_Pragma_Mapping (Node : Node_Id) return Internal_Element_Kinds;
function N_Defining_Identifier_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Defining_Operator_Symbol_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Expanded_Name_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Identifier_Mapping
(Node : Node_Id)
return Internal_Element_Kinds renames N_Expanded_Name_Mapping;
function N_Attribute_Reference_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Function_Call_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Range_Mapping (Node : Node_Id) return Internal_Element_Kinds;
function N_Allocator_Mapping (Node : Node_Id) return Internal_Element_Kinds;
function N_Aggregate_Mapping (Node : Node_Id) return Internal_Element_Kinds;
-- |A2005 start
function N_Incomplete_Type_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
-- |A2005 end
function N_Subtype_Indication_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
-- |A2012 start
function N_Formal_Type_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Iterator_Specification_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Quantified_Expression_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
-- |A2012 end
function N_Object_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Access_Function_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Access_Procedure_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Subprogram_Body_Stub_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Subprogram_Body_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Generic_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Constrained_Array_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Unconstrained_Array_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Subprogram_Renaming_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Loop_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Requeue_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Abstract_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Accept_Alternative_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
-- --|A2005 start
function N_Access_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
-- --|A2005 end
function N_Access_To_Object_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Component_Association_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Derived_Type_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Delay_Alternative_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Formal_Package_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Formal_Private_Type_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Formal_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Index_Or_Discriminant_Constraint_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Number_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Procedure_Call_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Range_Constraint_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Record_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Use_Type_Clause_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Terminate_Alternative_Mapping
(Node : Node_Id)
return Internal_Element_Kinds renames N_Accept_Alternative_Mapping;
-----------------------------------------
-- Node lists to Element lists filters --
-----------------------------------------
function May_Be_Included (Node : Node_Id) return Boolean;
-- Top-level filter for selecting nodes from a node list to be used to
-- create ASIS Elements which are members of some ASIS Element List.
function Ordinary_Inclusion_Condition (Node : Node_Id) return Boolean;
-- Defines the general condition for a separate node list member to be
-- used to construct an Element to be returned by some ASIS query. This
-- function does not make the final decision, because the node may be
-- duplicated, and this is checked in the May_Be_Included function
procedure Skip_Normalized_Declarations (Node : in out Node_Id);
-- This procedure is applied in case when the compiler normalizes a
-- multi-identifier declaration (or multi-name with clause) in a set of
-- equivalent one-identifier (one-name) declarations (clauses). It is
-- intended to be called for Node representing the first declaration
-- (clause) in this normalized sequence, and it resets its parameter
-- to point to the last declaration (clause) in this sequence
-----------------------------------------
-- Node-to-Element First Look-Up Table --
-----------------------------------------
Node_To_Element_Kind_Mapping_First_Switch :
constant array (Node_Kind) of Internal_Element_Kinds := (
N_Unused_At_Start => No_Mapping,
N_At_Clause => An_At_Clause,
N_Component_Clause => A_Component_Clause,
N_Enumeration_Representation_Clause => An_Enumeration_Representation_Clause,
N_Mod_Clause => No_Mapping,
N_Record_Representation_Clause => A_Record_Representation_Clause,
N_Attribute_Definition_Clause => An_Attribute_Definition_Clause,
N_Empty => No_Mapping,
N_Error => No_Mapping,
N_Pragma => Non_Trivial_Mapping,
N_Pragma_Argument_Association => A_Pragma_Argument_Association,
N_Defining_Character_Literal => A_Defining_Character_Literal,
N_Defining_Identifier => Non_Trivial_Mapping,
N_Defining_Operator_Symbol => Non_Trivial_Mapping,
N_Expanded_Name => Non_Trivial_Mapping,
N_Identifier => Non_Trivial_Mapping,
N_Character_Literal => A_Character_Literal,
N_Operator_Symbol => Non_Trivial_Mapping,
N_Op_Add => A_Function_Call,
N_Op_And => A_Function_Call,
N_And_Then => An_And_Then_Short_Circuit,
N_Op_Concat => A_Function_Call,
N_Op_Divide => A_Function_Call,
N_Op_Eq => A_Function_Call,
N_Op_Expon => A_Function_Call,
N_Op_Ge => A_Function_Call,
N_Op_Gt => A_Function_Call,
-- N_In => Non_Trivial_Mapping,
N_In => An_In_Membership_Test,
N_Op_Le => A_Function_Call,
N_Op_Lt => A_Function_Call,
N_Op_Mod => A_Function_Call,
N_Op_Multiply => A_Function_Call,
N_Op_Ne => A_Function_Call,
-- N_Not_In => Non_Trivial_Mapping,
N_Not_In => A_Not_In_Membership_Test,
N_Op_Or => A_Function_Call,
N_Or_Else => An_Or_Else_Short_Circuit,
N_Op_Rem => A_Function_Call,
N_Op_Subtract => A_Function_Call,
N_Op_Xor => A_Function_Call,
N_Op_Abs => A_Function_Call,
N_Op_Minus => A_Function_Call,
N_Op_Not => A_Function_Call,
N_Op_Plus => A_Function_Call,
N_Attribute_Reference => Non_Trivial_Mapping,
N_Conditional_Expression => An_If_Expression,
N_Explicit_Dereference => An_Explicit_Dereference,
N_Function_Call => Non_Trivial_Mapping,
N_Indexed_Component => An_Indexed_Component,
N_Integer_Literal => An_Integer_Literal,
N_Null => A_Null_Literal,
N_Procedure_Call_Statement => Non_Trivial_Mapping,
N_Qualified_Expression => A_Qualified_Expression,
N_Quantified_Expression => Non_Trivial_Mapping,
N_Raise_Constraint_Error => No_Mapping,
N_Range => Non_Trivial_Mapping,
N_Real_Literal => A_Real_Literal,
N_Selected_Component => A_Selected_Component,
N_Type_Conversion => A_Type_Conversion,
N_Allocator => Non_Trivial_Mapping,
N_Case_Expression => A_Case_Expression, -- ASIS 2012
N_Aggregate => Non_Trivial_Mapping,
N_Extension_Aggregate => An_Extension_Aggregate,
N_Slice => A_Slice,
N_String_Literal => A_String_Literal,
N_Subtype_Indication => Non_Trivial_Mapping,
N_Component_Declaration => A_Component_Declaration,
N_Entry_Body => An_Entry_Body_Declaration,
N_Entry_Declaration => An_Entry_Declaration,
-- N_Expression_Function => An_Expression_Function_Declaration, (SCz)
N_Entry_Index_Specification => An_Entry_Index_Specification,
N_Formal_Object_Declaration => A_Formal_Object_Declaration,
N_Formal_Type_Declaration => Non_Trivial_Mapping,
N_Freeze_Entity => No_Mapping,
N_Full_Type_Declaration => An_Ordinary_Type_Declaration,
-- --|A2005 start
-- N_Incomplete_Type_Declaration => An_Incomplete_Type_Declaration,
N_Incomplete_Type_Declaration => Non_Trivial_Mapping,
-- --|A2005 end
-- --|A2012 start
N_Iterator_Specification => Non_Trivial_Mapping,
-- --|A2012 end
N_Loop_Parameter_Specification => A_Loop_Parameter_Specification,
N_Object_Declaration => Non_Trivial_Mapping,
N_Private_Extension_Declaration => A_Private_Extension_Declaration,
N_Private_Type_Declaration => A_Private_Type_Declaration,
N_Subtype_Declaration => A_Subtype_Declaration,
N_Protected_Type_Declaration => A_Protected_Type_Declaration,
N_Accept_Statement => An_Accept_Statement,
N_Function_Specification => No_Mapping,
N_Procedure_Specification => No_Mapping,
N_Access_Function_Definition => Non_Trivial_Mapping,
N_Access_Procedure_Definition => Non_Trivial_Mapping,
N_Task_Type_Declaration => A_Task_Type_Declaration,
N_Package_Body_Stub => A_Package_Body_Stub,
N_Protected_Body_Stub => A_Protected_Body_Stub,
N_Subprogram_Body_Stub => Non_Trivial_Mapping,
N_Task_Body_Stub => A_Task_Body_Stub,
N_Function_Instantiation => A_Function_Instantiation,
N_Package_Instantiation => A_Package_Instantiation,
N_Procedure_Instantiation => A_Procedure_Instantiation,
N_Package_Body => A_Package_Body_Declaration,
N_Subprogram_Body => Non_Trivial_Mapping,
N_Implicit_Label_Declaration => No_Mapping,
N_Package_Declaration => A_Package_Declaration,
N_Single_Task_Declaration => A_Single_Task_Declaration,
N_Subprogram_Declaration => Non_Trivial_Mapping,
N_Task_Body => A_Task_Body_Declaration,
N_Use_Package_Clause => A_Use_Package_Clause,
N_Generic_Package_Declaration => A_Generic_Package_Declaration,
N_Generic_Subprogram_Declaration => Non_Trivial_Mapping,
N_Constrained_Array_Definition => Non_Trivial_Mapping,
N_Unconstrained_Array_Definition => Non_Trivial_Mapping,
N_Exception_Renaming_Declaration => An_Exception_Renaming_Declaration,
N_Object_Renaming_Declaration => An_Object_Renaming_Declaration,
N_Package_Renaming_Declaration => A_Package_Renaming_Declaration,
N_Subprogram_Renaming_Declaration => Non_Trivial_Mapping,
N_Generic_Function_Renaming_Declaration =>
A_Generic_Function_Renaming_Declaration,
N_Generic_Package_Renaming_Declaration =>
A_Generic_Package_Renaming_Declaration,
N_Generic_Procedure_Renaming_Declaration =>
A_Generic_Procedure_Renaming_Declaration,
N_Abort_Statement => An_Abort_Statement,
N_Assignment_Statement => An_Assignment_Statement,
N_Block_Statement => A_Block_Statement,
N_Case_Statement => A_Case_Statement,
N_Code_Statement => A_Code_Statement,
N_Delay_Relative_Statement => A_Delay_Relative_Statement,
N_Delay_Until_Statement => A_Delay_Until_Statement,
N_Entry_Call_Statement => An_Entry_Call_Statement,
N_Exit_Statement => An_Exit_Statement,
N_Free_Statement => No_Mapping,
N_Goto_Statement => A_Goto_Statement,
N_If_Statement => An_If_Statement,
N_Loop_Statement => Non_Trivial_Mapping,
N_Null_Statement => A_Null_Statement,
N_Raise_Statement => A_Raise_Statement,
N_Requeue_Statement => Non_Trivial_Mapping,
N_Return_Statement => A_Return_Statement,
N_Extended_Return_Statement => An_Extended_Return_Statement,
N_Abortable_Part => A_Then_Abort_Path,
N_Abstract_Subprogram_Declaration => Non_Trivial_Mapping,
N_Accept_Alternative => Non_Trivial_Mapping,
-- --|A2005 start
N_Access_Definition => Non_Trivial_Mapping,
-- --|A2005 end
N_Access_To_Object_Definition => Non_Trivial_Mapping,
-- --|A2012 start
N_Aspect_Specification => An_Aspect_Specification,
N_Case_Expression_Alternative => A_Case_Expression_Path,
-- --|A2012 end
N_Asynchronous_Select => An_Asynchronous_Select_Statement,
N_Case_Statement_Alternative => A_Case_Path,
N_Compilation_Unit => No_Mapping,
N_Component_Association => Non_Trivial_Mapping,
N_Component_Definition => A_Component_Definition,
N_Conditional_Entry_Call => A_Conditional_Entry_Call_Statement,
N_Derived_Type_Definition => Non_Trivial_Mapping,
N_Decimal_Fixed_Point_Definition => A_Decimal_Fixed_Point_Definition,
N_Defining_Program_Unit_Name => A_Defining_Expanded_Name,
N_Delay_Alternative => Non_Trivial_Mapping,
N_Delta_Constraint => A_Delta_Constraint,
N_Digits_Constraint => A_Digits_Constraint,
N_Discriminant_Association => A_Discriminant_Association,
N_Discriminant_Specification => A_Discriminant_Specification,
N_Elsif_Part => An_Elsif_Path,
N_Enumeration_Type_Definition => An_Enumeration_Type_Definition,
N_Entry_Call_Alternative => A_Select_Path,
N_Exception_Declaration => An_Exception_Declaration,
N_Exception_Handler => An_Exception_Handler,
N_Floating_Point_Definition => A_Floating_Point_Definition,
N_Formal_Decimal_Fixed_Point_Definition =>
A_Formal_Decimal_Fixed_Point_Definition,
N_Formal_Derived_Type_Definition => A_Formal_Derived_Type_Definition,
N_Formal_Discrete_Type_Definition => A_Formal_Discrete_Type_Definition,
N_Formal_Floating_Point_Definition => A_Formal_Floating_Point_Definition,
N_Formal_Modular_Type_Definition => A_Formal_Modular_Type_Definition,
N_Formal_Ordinary_Fixed_Point_Definition =>
A_Formal_Ordinary_Fixed_Point_Definition,
N_Formal_Package_Declaration => Non_Trivial_Mapping,
N_Formal_Private_Type_Definition => Non_Trivial_Mapping,
N_Formal_Signed_Integer_Type_Definition =>
A_Formal_Signed_Integer_Type_Definition,
N_Formal_Subprogram_Declaration => Non_Trivial_Mapping,
N_Generic_Association => A_Generic_Association,
N_Index_Or_Discriminant_Constraint => Non_Trivial_Mapping,
N_Label => No_Mapping,
N_Modular_Type_Definition => A_Modular_Type_Definition,
N_Number_Declaration => Non_Trivial_Mapping,
N_Ordinary_Fixed_Point_Definition => An_Ordinary_Fixed_Point_Definition,
N_Others_Choice => An_Others_Choice,
N_Package_Specification => No_Mapping,
N_Parameter_Association => A_Parameter_Association,
N_Parameter_Specification => A_Parameter_Specification,
N_Protected_Body => A_Protected_Body_Declaration,
N_Protected_Definition => A_Protected_Definition,
N_Range_Constraint => Non_Trivial_Mapping,
N_Real_Range_Specification => A_Simple_Expression_Range,
N_Record_Definition => Non_Trivial_Mapping,
N_Selective_Accept => A_Selective_Accept_Statement,
N_Signed_Integer_Type_Definition => A_Signed_Integer_Type_Definition,
N_Single_Protected_Declaration => A_Single_Protected_Declaration,
N_Subunit => No_Mapping,
N_Task_Definition => A_Task_Definition,
N_Terminate_Alternative => Non_Trivial_Mapping,
N_Timed_Entry_Call => A_Timed_Entry_Call_Statement,
N_Triggering_Alternative => A_Select_Path,
N_Use_Type_Clause => Non_Trivial_Mapping,
N_Variant => A_Variant,
N_Variant_Part => A_Variant_Part,
N_With_Clause => A_With_Clause,
N_Unused_At_End => No_Mapping,
others => Not_Implemented_Mapping);
------------------------------------------
-- Node-to-Element Second Look-Up Table --
------------------------------------------
type Mapping_Item is access function (Node : Node_Id)
return Internal_Element_Kinds;
Node_To_Element_Kind_Mapping_Second_Switch :
constant array (Node_Kind) of Mapping_Item := (
N_Pragma => N_Pragma_Mapping'Access,
N_Defining_Identifier => N_Defining_Identifier_Mapping'Access,
N_Defining_Operator_Symbol => N_Defining_Operator_Symbol_Mapping'Access,
N_Expanded_Name => N_Expanded_Name_Mapping'Access,
N_Identifier => N_Identifier_Mapping'Access,
N_Operator_Symbol => N_Operator_Symbol_Mapping'Access,
N_Attribute_Reference => N_Attribute_Reference_Mapping'Access,
N_Function_Call => N_Function_Call_Mapping'Access,
N_Quantified_Expression => N_Quantified_Expression_Mapping'Access,
N_Range => N_Range_Mapping'Access,
N_Allocator => N_Allocator_Mapping'Access,
N_Aggregate => N_Aggregate_Mapping'Access,
N_Subtype_Indication => N_Subtype_Indication_Mapping'Access,
-- --|A2012 start
N_Formal_Type_Declaration => N_Formal_Type_Declaration_Mapping'Access,
-- --|A2012 end
-- --|A2005 start
-- N_Incomplete_Type_Declaration => An_Incomplete_Type_Declaration,
N_Incomplete_Type_Declaration =>
N_Incomplete_Type_Declaration_Mapping'Access,
-- --|A2005 end
-- --|A2012 start
N_Iterator_Specification => N_Iterator_Specification_Mapping'Access,
-- --|A2012 end
N_Object_Declaration => N_Object_Declaration_Mapping'Access,
N_Access_Function_Definition =>
N_Access_Function_Definition_Mapping'Access,
N_Access_Procedure_Definition =>
N_Access_Procedure_Definition_Mapping'Access,
N_Subprogram_Body_Stub => N_Subprogram_Body_Stub_Mapping'Access,
N_Subprogram_Body => N_Subprogram_Body_Mapping'Access,
N_Subprogram_Declaration => N_Subprogram_Declaration_Mapping'Access,
N_Generic_Subprogram_Declaration =>
N_Generic_Subprogram_Declaration_Mapping'Access,
N_Constrained_Array_Definition =>
N_Constrained_Array_Definition_Mapping'Access,
N_Unconstrained_Array_Definition =>
N_Unconstrained_Array_Definition_Mapping'Access,
N_Subprogram_Renaming_Declaration =>
N_Subprogram_Renaming_Declaration_Mapping'Access,
N_Loop_Statement => N_Loop_Statement_Mapping'Access,
N_Requeue_Statement => N_Requeue_Statement_Mapping'Access,
N_Abstract_Subprogram_Declaration =>
N_Abstract_Subprogram_Declaration_Mapping'Access,
N_Accept_Alternative => N_Accept_Alternative_Mapping'Access,
-- --|A2005 start
N_Access_Definition => N_Access_Definition_Mapping'Access,
-- --|A2005 end
N_Access_To_Object_Definition =>
N_Access_To_Object_Definition_Mapping'Access,
N_Component_Association => N_Component_Association_Mapping'Access,
N_Derived_Type_Definition => N_Derived_Type_Definition_Mapping'Access,
N_Delay_Alternative => N_Delay_Alternative_Mapping'Access,
N_Formal_Package_Declaration =>
N_Formal_Package_Declaration_Mapping'Access,
N_Formal_Private_Type_Definition =>
N_Formal_Private_Type_Definition_Mapping'Access,
N_Formal_Subprogram_Declaration =>
N_Formal_Subprogram_Declaration_Mapping'Access,
N_Index_Or_Discriminant_Constraint =>
N_Index_Or_Discriminant_Constraint_Mapping'Access,
N_Number_Declaration => N_Number_Declaration_Mapping'Access,
N_Range_Constraint => N_Range_Constraint_Mapping'Access,
N_Record_Definition => N_Record_Definition_Mapping'Access,
N_Terminate_Alternative => N_Terminate_Alternative_Mapping'Access,
N_Use_Type_Clause => N_Use_Type_Clause_Mapping'Access,
N_Procedure_Call_Statement => N_Procedure_Call_Statement_Mapping'Access,
others => Not_Implemented_Mapping'Access);
----------------------------------------------------
-- Node List to Element List Filter Look-Up Table --
----------------------------------------------------
-- The following look-up table defines the first, very rough filter for
-- selecting node list elements to be used as a basis for ASIS Element
-- list components: it defines which Node_Kind values could never be used
-- for creating Elements in Element List (for them False is set in the
-- table)
May_Be_Included_Switch : constant array (Node_Kind) of Boolean := (
N_Unused_At_Start => False,
N_Freeze_Entity => False,
N_Implicit_Label_Declaration => False,
N_Label => False,
others => True);
--------------------------------
-- Asis_Internal_Element_Kind --
--------------------------------
function Asis_Internal_Element_Kind
(Node : Node_Id)
return Internal_Element_Kinds
is
Mapping_Case : Internal_Element_Kinds;
Source_Node_Kind : Node_Kind;
begin -- two-level switching only!
Source_Node_Kind := Nkind (Node);
Mapping_Case := Node_To_Element_Kind_Mapping_First_Switch
(Source_Node_Kind);
case Mapping_Case is
when Non_Trivial_Mapping =>
return Node_To_Element_Kind_Mapping_Second_Switch
(Source_Node_Kind) (Node);
when Not_Implemented_Mapping =>
Not_Implemented_Mapping (Source_Node_Kind);
when No_Mapping =>
No_Mapping (Node);
when others => -- all trivial cases!
return Mapping_Case;
end case;
end Asis_Internal_Element_Kind;
--------------------------------------
-- Defining_Id_List_From_Normalized --
--------------------------------------
function Defining_Id_List_From_Normalized
(N : Node_Id;
From_Declaration : Asis.Element)
return Asis.Defining_Name_List
is
Res_Max_Len : constant Natural :=
Natural (List_Length (List_Containing (N)));
-- to avoid two loops through the list of declarations/specifications,
-- we use the rough estimation of the length of the result
-- Defining_Name_List - it cannot contain more elements that the
-- number of nodes in the tree node list containing (normalized)
-- declarations
Res_Act_Len : Natural := 1;
-- the actual number of defining identifiers in the normalized
-- declaration
Result_List : Defining_Name_List (1 .. Res_Max_Len);
Decl_Node : Node_Id := N;
Decl_Nkind : constant Node_Kind := Nkind (Decl_Node);
Def_Id_Node : Node_Id;
begin
Def_Id_Node := Defining_Identifier (Decl_Node);
Result_List (Res_Act_Len) :=
Node_To_Element_New (Node => Def_Id_Node,
Starting_Element => From_Declaration,
Internal_Kind => A_Defining_Identifier);
while More_Ids (Decl_Node) loop
Decl_Node := Next (Decl_Node);
while Nkind (Decl_Node) /= Decl_Nkind loop
-- some implicit subtype declarations may be inserted by
-- the compiler in between the normalized declarations, so:
Decl_Node := Next (Decl_Node);
end loop;
Def_Id_Node := Defining_Identifier (Decl_Node);
Res_Act_Len := Res_Act_Len + 1;
Result_List (Res_Act_Len) :=
Node_To_Element_New (Node => Def_Id_Node,
Starting_Element => From_Declaration,
Internal_Kind => A_Defining_Identifier);
end loop;
return Result_List (1 .. Res_Act_Len);
end Defining_Id_List_From_Normalized;
------------------------------------------
-- Discrete_Choice_Node_To_Element_List --
------------------------------------------
function Discrete_Choice_Node_To_Element_List
(Choice_List : List_Id;
Starting_Element : Asis.Element)
return Asis.Element_List
is
Result_List : Asis.Element_List
(1 .. ASIS_Integer (List_Length (Choice_List)));
-- List_Length (Choice_List) cannot be 0 for the DISCRETE_CHOICE_LIST!
Current_Node : Node_Id;
Current_Original_Node : Node_Id;
Element_Already_Composed : Boolean;
Result_Kind : Internal_Element_Kinds;
begin
Current_Node := First (Choice_List);
-- first list element to process cannot be Empty!
Current_Original_Node := Original_Node (Current_Node);
for I in 1 .. ASIS_Integer (List_Length (Choice_List)) loop
Element_Already_Composed := False;
if Paren_Count (Current_Original_Node) > 0 then
-- Corner but legal case of discrete choice like
--
-- when (1) =>
--
-- or
--
-- When (A.B.C) =>
Result_Kind := Not_An_Element;
else
case Nkind (Current_Original_Node) is
-- DISCRETE_CHOICE_LIST ::= DISCRETE_CHOICE {| DISCRETE_CHOICE}
-- DISCRETE_CHOICE ::= EXPRESSION | DISCRETE_RANGE | others
when N_Others_Choice => -- DISCRETE_CHOICE ::= ... | others
Result_Kind := An_Others_Choice;
-- DISCRETE_CHOICE ::= ... | DISCRETE_RANGE | ...
-- DISCRETE_RANGE ::= discrete_SUBTYPE_INDICATION | RANGE
when N_Subtype_Indication =>
-- DISCRETE_RANGE ::= discrete_SUBTYPE_INDICATION | ...
--
-- The problem is that GNAT reduces the subtype_indication
-- having NO constraint directly to subtype_mark
-- (-> N_Identifier, N_Expanded_Name). May be, it is a
-- pathological case, but it can also be represented by
-- ...'Base construction (-> N_Attribute_Reference)
Result_Kind := A_Discrete_Subtype_Indication;
when N_Identifier =>
if Ekind (Entity (Current_Original_Node)) in Discrete_Kind then
-- discrete subtype mark!!
Result_Kind := A_Discrete_Subtype_Indication;
elsif Ekind (Entity (Current_Original_Node)) =
E_Enumeration_Literal
then
Result_Kind := An_Enumeration_Literal;
else
Result_Kind := An_Identifier;
end if;
when N_Expanded_Name =>
if Ekind (Entity (Current_Original_Node)) in Discrete_Kind then
-- discrete subtype mark!!
Result_Kind := A_Discrete_Subtype_Indication;
else
-- expression
Result_Kind := A_Selected_Component;
end if;
-- DISCRETE_RANGE ::= ... | RANGE
-- RANGE ::=
-- RANGE_ATTRIBUTE_REFERENCE
-- | SIMPLE_EXPRESSION .. SIMPLE_EXPRESSION
when N_Range =>
-- RANGE ::= ...
-- | SIMPLE_EXPRESSION .. SIMPLE_EXPRESSION
Result_Kind := A_Discrete_Simple_Expression_Range;
when N_Attribute_Reference =>
-- RANGE ::= RANGE_ATTRIBUTE_REFERENCE | ...
-- Sinfo.ads:
-- A range attribute designator is represented
-- in the tree using the normal N_Attribute_Reference
-- node.
-- But if the tree corresponds to the compilable Compilation
-- Unit, the RANGE_ATTRIBUTE_REFERENCE is the only construct
-- which could be in this position --W_R_O_N_G !!! T'Base!!!
if Attribute_Name (Current_Original_Node) = Name_Range then
Result_Kind := A_Discrete_Range_Attribute_Reference;
else
-- attribute denoting a type/subtype or yielding a value:
Result_List (I) := Node_To_Element_New (
Node => Current_Node,
Starting_Element => Starting_Element);
Element_Already_Composed := True;
end if;
-- DISCRETE_CHOICE ::= EXPRESSION | ...
when others =>
-- In the tree corresponding to the compilable Compilation
-- Unit the only possibility in the others choice is the
-- EXPRESSION as the DISCRETE_CHOICE.
Result_List (I) := Node_To_Element_New (
Node => Current_Node,
Starting_Element => Starting_Element);
Element_Already_Composed := True;
end case;
end if;
if not Element_Already_Composed then
Result_List (I) := Node_To_Element_New (
Node => Current_Node,
Internal_Kind => Result_Kind,
Starting_Element => Starting_Element);
end if;
Current_Node := Next (Current_Node);
Current_Original_Node := Original_Node (Current_Node);
end loop;
return Result_List;
end Discrete_Choice_Node_To_Element_List;
----------------------
-- Is_Config_Pragma --
----------------------
function Is_Config_Pragma (N : Node_Id) return Boolean is
begin
return True
and then Nkind (N) = N_Pragma
and then Pragma_Name (N) in
First_Pragma_Name .. Last_Configuration_Pragma_Name;
end Is_Config_Pragma;
-------------------------------
-- Is_GNAT_Attribute_Routine --
-------------------------------
function Is_GNAT_Attribute_Routine (N : Node_Id) return Boolean is
Attribute_Chars : Name_Id;
Result : Boolean := False;
begin
Attribute_Chars := Attribute_Name (N);
if Attribute_Chars = Name_Asm_Input or else
Attribute_Chars = Name_Asm_Output or else
Attribute_Chars = Name_Enum_Rep or else
Attribute_Chars = Name_Enum_Val or else
Attribute_Chars = Name_Fixed_Value or else
Attribute_Chars = Name_Integer_Value or else
Attribute_Chars = Name_Ref
then
Result := True;
end if;
return Result;
end Is_GNAT_Attribute_Routine;
-------------------------------------------
-- Is_Rewritten_Function_Prefix_Notation --
-------------------------------------------
function Is_Rewritten_Function_Prefix_Notation
(N : Node_Id)
return Boolean
is
Result : Boolean := False;
begin
if Nkind (N) = N_Function_Call
and then
Is_Rewrite_Substitution (N)
and then
Nkind (Original_Node (N)) not in N_Op
and then
Present (Parameter_Associations (N))
and then
not Is_Empty_List (Parameter_Associations (N))
and then
Sloc (First (Parameter_Associations (N))) < Sloc (Sinfo.Name (N))
then
Result := True;
end if;
return Result;
end Is_Rewritten_Function_Prefix_Notation;
------------------------------------------------------
-- Is_Rewritten_Impl_Deref_Function_Prefix_Notation --
------------------------------------------------------
function Is_Rewritten_Impl_Deref_Function_Prefix_Notation
(N : Node_Id)
return Boolean
is
Result : Boolean := False;
begin
if Nkind (N) = N_Function_Call
and then
Present (Parameter_Associations (N))
and then
not Is_Empty_List (Parameter_Associations (N))
and then
Sloc (First (Parameter_Associations (N))) < Sloc (Sinfo.Name (N))
then
Result := True;
end if;
return Result;
end Is_Rewritten_Impl_Deref_Function_Prefix_Notation;
-----------------------------------
-- Get_Next_Configuration_Pragma --
-----------------------------------
function Get_Next_Configuration_Pragma (N : Node_Id) return Node_Id is
Result : Node_Id := N;
begin
while not (Is_Config_Pragma (Result) or else
No (Result))
loop
Result := Next (Result);
end loop;
return Result;
end Get_Next_Configuration_Pragma;
----------------------------
-- Is_Not_Duplicated_Decl --
----------------------------
function Is_Not_Duplicated_Decl (Node : Node_Id) return Boolean is
Prev_List_Elem : Node_Id;
begin
-- the idea is to check if the previous list member (and we are
-- sure that Node itself is a list member) to be included
-- in the list is the rewritten tree structure representing
-- just the same Ada construct
--
-- If we change Prev_Non_Pragma to Next_Non_Pragma, then this
-- function will return False for the first, but not for the second
-- of the two duplicated declarations
if not (Nkind (Node) = N_Full_Type_Declaration or else
Nkind (Node) = N_Private_Type_Declaration or else
Nkind (Node) = N_Subtype_Declaration)
then
return True;
-- as far as we know for now, the problem of duplicated
-- declaration exists only for type declarations
end if;
Prev_List_Elem := Prev_Non_Pragma (Node);
while Present (Prev_List_Elem) loop
if Ordinary_Inclusion_Condition (Prev_List_Elem)
and then
(Nkind (Prev_List_Elem) = N_Full_Type_Declaration or else
Nkind (Prev_List_Elem) = N_Subtype_Declaration)
and then
Chars (Defining_Identifier (Prev_List_Elem)) =
Chars (Defining_Identifier (Node))
then
return False;
end if;
Prev_List_Elem := Prev_Non_Pragma (Prev_List_Elem);
end loop;
return True;
end Is_Not_Duplicated_Decl;
---------------------------------
-- Is_Protected_Procedure_Call --
---------------------------------
function Is_Protected_Procedure_Call (N : Node_Id) return Boolean is
Result : Boolean := False;
Tmp_Node : Node_Id;
begin
Tmp_Node := Sinfo.Name (N);
if Nkind (Tmp_Node) = N_Indexed_Component then
-- Call to an entry from an entry family,
Tmp_Node := Prefix (Tmp_Node);
end if;
if Nkind (Tmp_Node) = N_Selected_Component then
Tmp_Node := Selector_Name (Tmp_Node);
end if;
Tmp_Node := Entity (Tmp_Node);
Result := Ekind (Tmp_Node) = E_Procedure;
return Result;
end Is_Protected_Procedure_Call;
------------------
-- Is_Statement --
------------------
function Is_Statement (N : Node_Id) return Boolean is
Arg_Kind : constant Node_Kind := Nkind (N);
begin
return Arg_Kind in N_Statement_Other_Than_Procedure_Call or else
Arg_Kind = N_Procedure_Call_Statement;
end Is_Statement;
------------------------------------------
-- Is_Stub_To_Body_Instanse_Replacement --
------------------------------------------
function Is_Stub_To_Body_Instanse_Replacement
(N : Node_Id)
return Boolean
is
Arg_Kind : constant Node_Kind := Nkind (N);
Result : Boolean := False;
begin
if Arg_Kind in N_Proper_Body and then
Was_Originally_Stub (N)
then
case Arg_Kind is
when N_Subprogram_Body =>
Result := Is_From_Instance (Sinfo.Specification (N));
when N_Package_Body =>
Result := Is_From_Instance (Sinfo.Defining_Unit_Name (N));
when others =>
Result := Is_From_Instance (Sinfo.Defining_Identifier (N));
end case;
end if;
return Result;
end Is_Stub_To_Body_Instanse_Replacement;
---------------------
-- May_Be_Included --
---------------------
function May_Be_Included (Node : Node_Id) return Boolean is
begin
return Ordinary_Inclusion_Condition (Node) and then
Is_Not_Duplicated_Decl (Node);
end May_Be_Included;
-----------------------------------------------
-- N_Abstract_Subprogram_Declaration_Mapping --
-----------------------------------------------
function N_Abstract_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Procedure_Declaration
-- A_Function_Declaration
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Function_Declaration;
else
return A_Procedure_Declaration;
end if;
end N_Abstract_Subprogram_Declaration_Mapping;
----------------------------------
-- N_Accept_Alternative_Mapping --
----------------------------------
function N_Accept_Alternative_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Select_Path
-- An_Or_Path
if No (Prev (Node)) then
return A_Select_Path;
else
return An_Or_Path;
end if;
end N_Accept_Alternative_Mapping;
------------------------------------------
-- N_Access_Function_Definition_Mapping --
------------------------------------------
function N_Access_Function_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Four Internal_Element_Kinds values may be possible:
--
-- An_Access_To_Function
-- An_Access_To_Protected_Function
--
-- A_Formal_Access_To_Function
-- A_Formal_Access_To_Protected_Function
if Nkind (Parent (Node)) = N_Formal_Type_Declaration then
if Protected_Present (Node) then
return A_Formal_Access_To_Protected_Function;
else
return A_Formal_Access_To_Function;
end if;
else
if Protected_Present (Node) then
return An_Access_To_Protected_Function;
else
return An_Access_To_Function;
end if;
end if;
end N_Access_Function_Definition_Mapping;
-------------------------------------------
-- N_Access_Procedure_Definition_Mapping --
-------------------------------------------
function N_Access_Procedure_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Four Internal_Element_Kinds values may be possible:
--
-- An_Access_To_Procedure
-- An_Access_To_Protected_Procedure
--
-- A_Formal_Access_To_Procedure
-- A_Formal_Access_To_Protected_Procedure
if Nkind (Parent (Node)) = N_Formal_Type_Declaration then
if Protected_Present (Node) then
return A_Formal_Access_To_Protected_Procedure;
else
return A_Formal_Access_To_Procedure;
end if;
else
if Protected_Present (Node) then
return An_Access_To_Protected_Procedure;
else
return An_Access_To_Procedure;
end if;
end if;
end N_Access_Procedure_Definition_Mapping;
-- --|A2005 start
---------------------------------
-- N_Access_Definition_Mapping --
---------------------------------
function N_Access_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := Not_An_Element;
Tmp : constant Node_Id :=
Sinfo.Access_To_Subprogram_Definition (Node);
begin
case Nkind (Tmp) is
when N_Empty =>
if Constant_Present (Node) then
Result := An_Anonymous_Access_To_Constant;
else
Result := An_Anonymous_Access_To_Variable;
end if;
when N_Access_Function_Definition =>
if Protected_Present (Tmp) then
Result := An_Anonymous_Access_To_Protected_Function;
else
Result := An_Anonymous_Access_To_Function;
end if;
when N_Access_Procedure_Definition =>
if Protected_Present (Tmp) then
Result := An_Anonymous_Access_To_Protected_Procedure;
else
Result := An_Anonymous_Access_To_Procedure;
end if;
when others =>
pragma Assert (False);
null;
end case;
return Result;
end N_Access_Definition_Mapping;
-- --|A2005 end
-------------------------------------------
-- N_Access_To_Object_Definition_Mapping --
-------------------------------------------
function N_Access_To_Object_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Six Internal_Element_Kinds values may be possible:
--
-- A_Pool_Specific_Access_To_Variable
-- An_Access_To_Variable
-- An_Access_To_Constant
--
-- A_Formal_Pool_Specific_Access_To_Variable
-- A_Formal_Access_To_Variable
-- A_Formal_Access_To_Constant
if Nkind (Parent (Node)) = N_Formal_Type_Declaration then
if All_Present (Node) then
return A_Formal_Access_To_Variable;
elsif Constant_Present (Node) then
return A_Formal_Access_To_Constant;
else
return A_Formal_Pool_Specific_Access_To_Variable;
end if;
else
if All_Present (Node) then
return An_Access_To_Variable;
elsif Constant_Present (Node) then
return An_Access_To_Constant;
else
return A_Pool_Specific_Access_To_Variable;
end if;
end if;
end N_Access_To_Object_Definition_Mapping;
-------------------------
-- N_Aggregate_Mapping --
-------------------------
function N_Aggregate_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Aggregate_Type : Node_Id := Etype (Node);
begin
-- Three Internal_Element_Kinds values may be possible:
-- A_Record_Aggregate
-- A_Positional_Array_Aggregate
-- A_Named_Array_Aggregate
-- the following fragment is a result of the current setting
-- of Etype field in the tree, see open problems #77
-- for multi-dimensional array aggregates, Etype field for
-- inner aggregates is set to Empty!!
if Present (Aggregate_Type) and then
Ekind (Aggregate_Type) in Private_Kind and then
not (Ekind (Aggregate_Type) in Array_Kind or else
Ekind (Aggregate_Type) in Record_Kind)
then
-- we need a full view of the type!
Aggregate_Type := Full_View (Aggregate_Type);
end if;
-- Special case:
if No (Aggregate_Type)
and then
(Nkind (Parent (Node)) = N_Pragma_Argument_Association
or else
Nkind (Parent (Node)) = N_Aspect_Specification)
then
return A_Record_Aggregate;
end if;
if Present (Aggregate_Type) and then
Ekind (Aggregate_Type) in Record_Kind
then
return A_Record_Aggregate;
else
if Present (Expressions (Node)) then
return A_Positional_Array_Aggregate;
else
return A_Named_Array_Aggregate;
end if;
end if;
end N_Aggregate_Mapping;
-------------------------
-- N_Allocator_Mapping --
-------------------------
function N_Allocator_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- An_Allocation_From_Subtype
-- An_Allocation_From_Qualified_Expression
if Nkind (Sinfo.Expression (Node)) = N_Qualified_Expression then
return An_Allocation_From_Qualified_Expression;
else
return An_Allocation_From_Subtype;
end if;
end N_Allocator_Mapping;
-----------------------------------
-- N_Attribute_Reference_Mapping --
-----------------------------------
function N_Attribute_Reference_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Attribute_Chars : constant Name_Id := Attribute_Name (Node);
Context_Kind : constant Node_Kind :=
Nkind (Original_Node (Parent_Node));
begin
-- The following Internal_Element_Kinds values may be possible:
--
-- For range attribute reference:
--
-- A_Discrete_Range_Attribute_Reference_As_Subtype_Definition
-- A_Discrete_Range_Attribute_Reference
-- A_Range_Attribute_Reference
--
-- For attribute reference corresponding to the attributes which are
-- functions
--
-- Adjacent
-- Ceiling
-- Compose
-- Copy_Sign
-- Exponent
-- Floor
-- Fraction
-- Image
-- Input
-- Leading_Part
-- Machine
-- Max
-- Min
-- Model
-- Pos
-- Pred
-- Remainder
-- Round
-- Rounding
-- Scaling
-- Succ
-- Truncation
-- Unbiased_Rounding
-- Val
-- Value
-- Wide_Image
-- Wide_Value
-- |A2005 start
--
-- Ada 2005 attributes that are functions:
--
-- Machine_Rounding
-- Mod
-- Wide_Wide_Image
-- |A2005 end
--
-- plus GNAT-specific attributes:
-- Enum_Rep
-- Fixed_Value
-- Integer_Value
-- Result
--
-- the Element of A_Function_Call Internal_Element_Kinds value should be
-- created, and the determination of the prefix kind should further be
-- done by hand (function Asis_Expressions.Prefix)
--
-- For attribute reference corresponding to the attributes which are
-- procedures
--
-- Output
-- Read
-- Write
--
-- the Element of A_Procedure_Call_Statement kind should be created
--
-- For attributes returning types:
-- Base
-- Class
-- the Element of A_Type_Conversion should be created if the node is
-- rewritten into N_Type_Conversion node. But this is done by the
-- Node_To_Element function (together with setting the Special_Case
-- Element field, which is then taken into account by functions
-- decomposing A_Type_Conversion Element.
if Attribute_Chars = Name_Range then
-- processing the range attribute reference
-- range attribute reference is the part of the RANGE
-- Syntax Cross Reference extraction for RANGE:
--
-- range
-- discrete_range 3.6.1
-- discrete_choice 3.8.1
-- discrete_choice_list 3.8.1
-- array_component_association 4.3.3
-- named_array_aggregate 4.3.3
-- case_statement_alternative 5.4
-- variant 3.8.1
-- index_constraint 3.6.1
-- slice 4.1.2
-- discrete_subtype_definition 3.6
-- constrained_array_definition 3.6
-- entry_declaration 9.5.2
-- entry_index_specification 9.5.2
-- loop_parameter_specification 5.5
-- range_constraint 3.5
-- delta_constraint J.3
-- digits_constraint 3.5.9
-- scalar_constraint 3.2.2
-- relation 4.4
case Context_Kind is -- should be reorganized when complete
when
-- discrete_range
N_Component_Association
| N_Case_Statement_Alternative
| N_Variant
| N_Index_Or_Discriminant_Constraint
| N_Slice
=>
return A_Discrete_Range_Attribute_Reference;
when -- discrete_subtype_definition
N_Constrained_Array_Definition
| N_Entry_Index_Specification
| N_Loop_Parameter_Specification
| N_Entry_Declaration
=>
return A_Discrete_Range_Attribute_Reference_As_Subtype_Definition;
when N_Range_Constraint => -- range_constraint ???
return A_Range_Attribute_Reference;
when N_In -- relation
| N_Not_In
=>
return A_Range_Attribute_Reference;
when others => -- impossible cases:
raise Internal_Implementation_Error;
end case;
elsif -- language-defined attributes which are functions:
Attribute_Chars = Name_Adjacent or else
Attribute_Chars = Name_Ceiling or else
Attribute_Chars = Name_Compose or else
Attribute_Chars = Name_Copy_Sign or else
Attribute_Chars = Name_Exponent or else
Attribute_Chars = Name_Floor or else
Attribute_Chars = Name_Fraction or else
Attribute_Chars = Name_Image or else
Attribute_Chars = Name_Input or else
Attribute_Chars = Name_Leading_Part or else
Attribute_Chars = Name_Machine or else
Attribute_Chars = Name_Max or else
Attribute_Chars = Name_Min or else
Attribute_Chars = Name_Model or else
Attribute_Chars = Name_Pos or else
Attribute_Chars = Name_Pred or else
Attribute_Chars = Name_Remainder or else
Attribute_Chars = Name_Round or else
Attribute_Chars = Name_Rounding or else
Attribute_Chars = Name_Scaling or else
Attribute_Chars = Name_Succ or else
Attribute_Chars = Name_Truncation or else
Attribute_Chars = Name_Unbiased_Rounding or else
Attribute_Chars = Name_Val or else
Attribute_Chars = Name_Value or else
Attribute_Chars = Name_Wide_Image or else
Attribute_Chars = Name_Wide_Value or else
-- |A2005 start
-- Ada 2005 attributes that are functions:
Attribute_Chars = Name_Machine_Rounding or else
Attribute_Chars = Name_Mod or else
Attribute_Chars = Name_Wide_Wide_Image or else
Attribute_Chars = Name_Wide_Wide_Value or else
-- |A2012 start
-- Ada 2012 attributes that are functions:
-- Attribute_Chars = Name_Overlaps_Storage or else (SCz)
-- |A2012 end
-- |A2005 end
-- Implementation Dependent Attributes-Functions:
Attribute_Chars = Name_Asm_Input or else
Attribute_Chars = Name_Asm_Output or else
Attribute_Chars = Name_Enum_Rep or else
Attribute_Chars = Name_Enum_Val or else
Attribute_Chars = Name_Fixed_Value or else
Attribute_Chars = Name_Integer_Value or else
Attribute_Chars = Name_Ref
then
return A_Function_Call;
elsif -- language-defined attributes which are procedures:
Attribute_Chars = Name_Output or else
Attribute_Chars = Name_Read or else
Attribute_Chars = Name_Write
then
return A_Procedure_Call_Statement;
-- language-defined attributes:
elsif Attribute_Chars = Name_Access then
return An_Access_Attribute;
elsif Attribute_Chars = Name_Address then
return An_Address_Attribute;
elsif Attribute_Chars = Name_Aft then
return An_Aft_Attribute;
elsif Attribute_Chars = Name_Alignment then
return An_Alignment_Attribute;
elsif Attribute_Chars = Name_Base then
return A_Base_Attribute;
elsif Attribute_Chars = Name_Bit_Order then
return A_Bit_Order_Attribute;
elsif Attribute_Chars = Name_Body_Version then
return A_Body_Version_Attribute;
elsif Attribute_Chars = Name_Callable then
return A_Callable_Attribute;
elsif Attribute_Chars = Name_Caller then
return A_Caller_Attribute;
elsif Attribute_Chars = Name_Class then
return A_Class_Attribute;
elsif Attribute_Chars = Name_Component_Size then
return A_Component_Size_Attribute;
elsif Attribute_Chars = Name_Constrained then
return A_Constrained_Attribute;
elsif Attribute_Chars = Name_Count then
return A_Count_Attribute;
elsif Attribute_Chars = Name_Definite then
return A_Definite_Attribute;
elsif Attribute_Chars = Name_Delta then
return A_Delta_Attribute;
elsif Attribute_Chars = Name_Denorm then
return A_Denorm_Attribute;
elsif Attribute_Chars = Name_Digits then
return A_Digits_Attribute;
elsif Attribute_Chars = Name_External_Tag then
return An_External_Tag_Attribute;
elsif Attribute_Chars = Name_First then
return A_First_Attribute;
elsif Attribute_Chars = Name_First_Bit then
return A_First_Bit_Attribute;
elsif Attribute_Chars = Name_Fore then
return A_Fore_Attribute;
elsif Attribute_Chars = Name_Identity then
return An_Identity_Attribute;
elsif Attribute_Chars = Name_Last then
return A_Last_Attribute;
elsif Attribute_Chars = Name_Last_Bit then
return A_Last_Bit_Attribute;
elsif Attribute_Chars = Name_Length then
return A_Length_Attribute;
elsif Attribute_Chars = Name_Machine_Emax then
return A_Machine_Emax_Attribute;
elsif Attribute_Chars = Name_Machine_Emin then
return A_Machine_Emin_Attribute;
elsif Attribute_Chars = Name_Machine_Mantissa then
return A_Machine_Mantissa_Attribute;
elsif Attribute_Chars = Name_Machine_Overflows then
return A_Machine_Overflows_Attribute;
elsif Attribute_Chars = Name_Machine_Radix then
return A_Machine_Radix_Attribute;
elsif Attribute_Chars = Name_Machine_Rounds then
return A_Machine_Rounds_Attribute;
elsif Attribute_Chars = Name_Max_Size_In_Storage_Elements then
return A_Max_Size_In_Storage_Elements_Attribute;
elsif Attribute_Chars = Name_Model_Emin then
return A_Model_Emin_Attribute;
elsif Attribute_Chars = Name_Model_Epsilon then
return A_Model_Epsilon_Attribute;
elsif Attribute_Chars = Name_Model_Mantissa then
return A_Model_Mantissa_Attribute;
elsif Attribute_Chars = Name_Model_Small then
return A_Model_Small_Attribute;
elsif Attribute_Chars = Name_Modulus then
return A_Modulus_Attribute;
elsif Attribute_Chars = Name_Partition_ID then
return A_Partition_ID_Attribute;
elsif Attribute_Chars = Name_Position then
return A_Position_Attribute;
elsif Attribute_Chars = Name_Range then -- this alternative
return A_Range_Attribute; -- never works!
elsif Attribute_Chars = Name_Safe_First then
return A_Safe_First_Attribute;
elsif Attribute_Chars = Name_Safe_Last then
return A_Safe_Last_Attribute;
elsif Attribute_Chars = Name_Scale then
return A_Scale_Attribute;
elsif Attribute_Chars = Name_Signed_Zeros then
return A_Signed_Zeros_Attribute;
elsif Attribute_Chars = Name_Size then
return A_Size_Attribute;
elsif Attribute_Chars = Name_Small then
return A_Small_Attribute;
elsif Attribute_Chars = Name_Storage_Pool then
return A_Storage_Pool_Attribute;
elsif Attribute_Chars = Name_Storage_Size then
return A_Storage_Size_Attribute;
elsif Attribute_Chars = Name_Tag then
return A_Tag_Attribute;
elsif Attribute_Chars = Name_Terminated then
return A_Terminated_Attribute;
elsif Attribute_Chars = Name_Unchecked_Access then
return An_Unchecked_Access_Attribute;
elsif Attribute_Chars = Name_Valid then
return A_Valid_Attribute;
elsif Attribute_Chars = Name_Version then
return A_Version_Attribute;
elsif Attribute_Chars = Name_Wide_Width then
return A_Wide_Width_Attribute;
elsif Attribute_Chars = Name_Width then
return A_Width_Attribute;
-- New Ada 2005/2012 attributes:
elsif Attribute_Chars = Name_Priority then
return A_Priority_Attribute;
elsif Attribute_Chars = Name_Stream_Size then
return A_Stream_Size_Attribute;
elsif Attribute_Chars = Name_Wide_Wide_Width then
return A_Wide_Wide_Width_Attribute;
elsif Attribute_Chars = Name_Max_Alignment_For_Allocation then
return A_Max_Alignment_For_Allocation_Attribute;
-- New Ada 2005/2012 attributes:
-- Implementation Dependent Attributes:
elsif Attribute_Chars = Name_Abort_Signal or else
Attribute_Chars = Name_Address_Size or else
Attribute_Chars = Name_Asm_Input or else
Attribute_Chars = Name_Asm_Output or else
Attribute_Chars = Name_AST_Entry or else -- VMS
Attribute_Chars = Name_Bit or else
Attribute_Chars = Name_Bit_Position or else
Attribute_Chars = Name_Code_Address or else
Attribute_Chars = Name_Compiler_Version or else
Attribute_Chars = Name_Default_Bit_Order or else
-- Attribute_Chars = Name_Elab_Subp_Body or else (SCz)
Attribute_Chars = Name_Elaborated or else
Attribute_Chars = Name_Emax or else -- Ada 83
Attribute_Chars = Name_Enabled or else
Attribute_Chars = Name_Enum_Rep or else
Attribute_Chars = Name_Enum_Val or else
Attribute_Chars = Name_Epsilon or else -- Ada 83
Attribute_Chars = Name_Fixed_Value or else
Attribute_Chars = Name_Has_Access_Values or else
Attribute_Chars = Name_Has_Discriminants or else
Attribute_Chars = Name_Img or else
Attribute_Chars = Name_Integer_Value or else
Attribute_Chars = Name_Invalid_Value or else
Attribute_Chars = Name_Large or else -- Ada 83
Attribute_Chars = Name_Machine_Size or else
Attribute_Chars = Name_Mantissa or else -- Ada 83
Attribute_Chars = Name_Maximum_Alignment or else
Attribute_Chars = Name_Mechanism_Code or else
Attribute_Chars = Name_Null_Parameter or else
Attribute_Chars = Name_Object_Size or else
Attribute_Chars = Name_Old or else
Attribute_Chars = Name_Passed_By_Reference or else
Attribute_Chars = Name_Range_Length or else
Attribute_Chars = Name_Ref or else
Attribute_Chars = Name_Result or else
Attribute_Chars = Name_Safe_Emax or else -- Ada 83
Attribute_Chars = Name_Safe_Large or else -- Ada 83
Attribute_Chars = Name_Safe_Small or else -- Ada 83
Attribute_Chars = Name_Storage_Unit or else
-- Attribute_Chars = Name_System_Allocator_Alignment or else (SCz)
Attribute_Chars = Name_Target_Name or else
Attribute_Chars = Name_To_Address or else
Attribute_Chars = Name_Type_Class or else
Attribute_Chars = Name_UET_Address or else
Attribute_Chars = Name_Universal_Literal_String or else
Attribute_Chars = Name_Unrestricted_Access or else
Attribute_Chars = Name_VADS_Size or else
Attribute_Chars = Name_Value_Size or else
Attribute_Chars = Name_Wchar_T_Size or else
Attribute_Chars = Name_Word_Size or else
Attribute_Chars = Name_Elab_Body or else
Attribute_Chars = Name_Elab_Spec
then
return An_Implementation_Defined_Attribute;
else
return An_Unknown_Attribute;
end if;
end N_Attribute_Reference_Mapping;
-------------------------------------
-- N_Component_Association_Mapping --
-------------------------------------
function N_Component_Association_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Special cases first:
case Nkind (Parent (Parent (Node))) is
when N_Enumeration_Representation_Clause =>
return An_Array_Component_Association;
when N_Pragma_Argument_Association |
N_Aspect_Specification =>
return A_Record_Component_Association;
when others =>
null;
end case;
-- Regular case:
if Nkind (Parent (Parent (Node))) = N_Enumeration_Representation_Clause
or else
Ekind (Etype (Parent (Node))) in Array_Kind
then
return An_Array_Component_Association;
else
return A_Record_Component_Association;
end if;
end N_Component_Association_Mapping;
--------------------------------------------
-- N_Constrained_Array_Definition_Mapping --
--------------------------------------------
function N_Constrained_Array_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Constrained_Array_Definition
-- A_Formal_Constrained_Array_Definition
if Nkind (Parent (Node)) = N_Formal_Type_Declaration then
return A_Formal_Constrained_Array_Definition;
else
return A_Constrained_Array_Definition;
end if;
end N_Constrained_Array_Definition_Mapping;
-----------------------------------
-- N_Defining_Identifier_Mapping --
-----------------------------------
function N_Defining_Identifier_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Template_Node : Node_Id := Empty;
begin
-- Several Internal_Element_Kinds values may be possible for automatic
-- Internal Kind Determination:
--
-- A_Defining_Identifier
-- A_Defining_Enumeration_Literal
-- Internal Defining Name kinds, this happens for the extended
-- code of the function instantiation in case if the instance
-- defines an operator symbol - in this case the defining name of
-- the extended function spec and body is represented by
-- N_Defining_Identifier node.
--
-- Some other Internal_Element_Kinds values could be set "by-hand",
-- for example:
--
-- An_Enumeration_Literal_Specification
if Sloc (Node) > Standard_Location and then
Get_Character (Sloc (Node)) = '"'
then
Template_Node := Parent (Parent (Node));
if Pass_Generic_Actual (Template_Node) then
-- This is the case of subprogram renaming that passes an actual
-- for a formal operator function
Template_Node := Corresponding_Formal_Spec (Template_Node);
else
-- This is the case of expanded generic subprogram having a
-- defining operator symbol, it comes as the defining name from
-- the corresponding instance, but is represented by
-- N_Defining_Identifier node in the expanded code. We just
-- go to the defining name from the instance and call
-- N_Defining_Operator_Symbol_Mapping for it
Template_Node := Parent (Template_Node);
if Nkind (Template_Node) = N_Package_Specification then
Template_Node := Parent (Template_Node);
end if;
Template_Node := Next (Template_Node);
if Nkind (Template_Node) = N_Package_Body then
-- skipping the body of wrapper package for extended subprogram
-- body
Template_Node := Next (Template_Node);
end if;
Template_Node := Defining_Unit_Name (Template_Node);
end if;
pragma Assert (Nkind (Template_Node) = N_Defining_Operator_Symbol);
return N_Defining_Operator_Symbol_Mapping (Template_Node);
else
if Nkind (Parent (Node)) = N_Enumeration_Type_Definition then
return A_Defining_Enumeration_Literal;
else
return A_Defining_Identifier;
end if;
end if;
end N_Defining_Identifier_Mapping;
----------------------------------------
-- N_Defining_Operator_Symbol_Mapping --
----------------------------------------
function N_Defining_Operator_Symbol_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Operator_Chars : constant Name_Id := Chars (Node);
Parameter_Number : Nat range 1 .. 2;
-- see the GNAT components Namet.ads and Snames.ads
-- N_Operator_Symbol_Mapping uses just the same approach,
-- (except computing the Parameter_Number value)
-- so if there is any error in it, then both functions contain it
begin
-- The following Internal_Element_Kinds values may be possible:
--
-- A_Defining_And_Operator, -- and
-- A_Defining_Or_Operator, -- or
-- A_Defining_Xor_Operator, -- xor
-- A_Defining_Equal_Operator, -- =
-- A_Defining_Not_Equal_Operator, -- /=
-- A_Defining_Less_Than_Operator, -- <
-- A_Defining_Less_Than_Or_Equal_Operator, -- <=
-- A_Defining_Greater_Than_Operator, -- >
-- A_Defining_Greater_Than_Or_Equal_Operator, -- >=
-- A_Defining_Plus_Operator, -- +
-- A_Defining_Minus_Operator, -- -
-- A_Defining_Concatenate_Operator, -- &
-- A_Defining_Unary_Plus_Operator, -- +
-- A_Defining_Unary_Minus_Operator, -- -
-- A_Defining_Multiply_Operator, -- *
-- A_Defining_Divide_Operator, -- /
-- A_Defining_Mod_Operator, -- mod
-- A_Defining_Rem_Operator, -- rem
-- A_Defining_Exponentiate_Operator, -- **
-- A_Defining_Abs_Operator, -- abs
-- A_Defining_Not_Operator, -- not
if Operator_Chars = Name_Op_And then
return A_Defining_And_Operator;
elsif Operator_Chars = Name_Op_Or then
return A_Defining_Or_Operator;
elsif Operator_Chars = Name_Op_Xor then
return A_Defining_Xor_Operator;
elsif Operator_Chars = Name_Op_Eq then
return A_Defining_Equal_Operator;
elsif Operator_Chars = Name_Op_Ne then
return A_Defining_Not_Equal_Operator;
elsif Operator_Chars = Name_Op_Lt then
return A_Defining_Less_Than_Operator;
elsif Operator_Chars = Name_Op_Le then
return A_Defining_Less_Than_Or_Equal_Operator;
elsif Operator_Chars = Name_Op_Gt then
return A_Defining_Greater_Than_Operator;
elsif Operator_Chars = Name_Op_Ge then
return A_Defining_Greater_Than_Or_Equal_Operator;
elsif Operator_Chars = Name_Op_Concat then
return A_Defining_Concatenate_Operator;
elsif Operator_Chars = Name_Op_Multiply then
return A_Defining_Multiply_Operator;
elsif Operator_Chars = Name_Op_Divide then
return A_Defining_Divide_Operator;
elsif Operator_Chars = Name_Op_Mod then
return A_Defining_Mod_Operator;
elsif Operator_Chars = Name_Op_Rem then
return A_Defining_Rem_Operator;
elsif Operator_Chars = Name_Op_Expon then
return A_Defining_Exponentiate_Operator;
elsif Operator_Chars = Name_Op_Abs then
return A_Defining_Abs_Operator;
elsif Operator_Chars = Name_Op_Not then
return A_Defining_Not_Operator;
else
-- for + and - operator signs binary and unary cases
-- should be distinguished
if Nkind (Parent_Node) = N_Function_Instantiation then
-- we have to compute the number of parameters
-- from the declaration of the corresponding generic
-- function
Parent_Node := Parent (Entity (Sinfo.Name (Parent_Node)));
if Nkind (Parent_Node) = N_Defining_Program_Unit_Name then
Parent_Node := Parent (Parent_Node);
end if;
end if;
Parameter_Number :=
List_Length (Parameter_Specifications (Parent_Node));
if Operator_Chars = Name_Op_Add then
if Parameter_Number = 1 then
return A_Defining_Unary_Plus_Operator;
else
return A_Defining_Plus_Operator;
end if;
else -- Operator_Chars = "-"
if Parameter_Number = 1 then
return A_Defining_Unary_Minus_Operator;
else
return A_Defining_Minus_Operator;
end if;
end if;
end if;
end N_Defining_Operator_Symbol_Mapping;
---------------------------------
-- N_Delay_Alternative_Mapping --
---------------------------------
function N_Delay_Alternative_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Select_Path
-- An_Or_Path
if Is_List_Member (Node) then
-- a delay alternative in a selective accept statement,
-- processing is the same as for N_Accept_Alternative
return N_Accept_Alternative_Mapping (Node);
else
-- a relay alternative in a timed entry call
return An_Or_Path;
end if;
end N_Delay_Alternative_Mapping;
---------------------------------------
-- N_Derived_Type_Definition_Mapping --
---------------------------------------
function N_Derived_Type_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := A_Derived_Type_Definition;
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Derived_Type_Definition
-- A_Derived_Record_Extension_Definition
-- --|A2005 start
-- Plus the following values for Ada 2005:
-- An_Ordinary_Interface
-- A_Limited_Interface
-- A_Task_Interface
-- A_Protected_Interface
-- A_Synchronized_Interface
-- --|A2005 end
-- Implementation revised for Ada 2005
if Interface_Present (Node) then
if Limited_Present (Node) then
Result := A_Limited_Interface;
elsif Task_Present (Node) then
Result := A_Task_Interface;
elsif Protected_Present (Node) then
Result := A_Protected_Interface;
elsif Synchronized_Present (Node) then
Result := A_Synchronized_Interface;
else
Result := An_Ordinary_Interface;
end if;
elsif Present (Record_Extension_Part (Node)) then
Result := A_Derived_Record_Extension_Definition;
end if;
return Result;
-- --|A2005 end
end N_Derived_Type_Definition_Mapping;
-----------------------------
-- N_Expanded_Name_Mapping --
-----------------------------
function N_Expanded_Name_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Context : constant Node_Id := Parent_Node;
Context_Kind : constant Node_Kind := Nkind (Context);
Temp_Node : Node_Id;
begin
-- The following Internal_Element_Kinds values may be possible:
--
-- A_Subtype_Indication
-- A_Discrete_Subtype_Indication_As_Subtype_Definition
-- A_Discrete_Subtype_Indication
-- A_Selected_Component
-- An_Identifier (we use this routine for An_Identifier node as well)
-- A_Function_Call (F in F.X)
-- An_Attribute_Reference
case Context_Kind is
-- special cases should be reorganized when complete ???
when N_Object_Declaration =>
if Node = Object_Definition (Context) then
return A_Subtype_Indication;
else
-- an initializing expression in an object declaration
goto Expr;
end if;
when N_Derived_Type_Definition
| N_Access_To_Object_Definition
=>
-- --|A2005 start
if Is_List_Member (Node) then
-- The node represents an interface name from some interface
-- list
if Nkind (Node) = N_Expanded_Name then
return A_Selected_Component;
else
return An_Identifier;
end if;
else
return A_Subtype_Indication;
end if;
-- --|A2005 end
when N_Constrained_Array_Definition |
N_Entry_Declaration =>
return A_Discrete_Subtype_Indication_As_Subtype_Definition;
when N_Unconstrained_Array_Definition =>
if Is_List_Member (Node) then
-- this for sure means, that node represents one of index
-- subtype definitions
-- CODE SHARING WITH N_IDENTIFIER MAPPING ITEM :-[#]
if Nkind (Node) = N_Expanded_Name then
return A_Selected_Component;
else
return An_Identifier;
end if;
else
-- this is a component definition!
return A_Component_Definition;
end if;
when N_Index_Or_Discriminant_Constraint =>
if Asis_Internal_Element_Kind (Context) =
An_Index_Constraint
then
return A_Discrete_Subtype_Indication;
end if;
when N_Slice =>
-- A.B(C.D) <- Context
-- / \
-- Prefix Discrete_Range
if Node = Sinfo.Discrete_Range (Context) then
return A_Discrete_Subtype_Indication;
end if;
-- when N_??? => should be implemented
when N_Selected_Component =>
-- This corresponds to a special case: F.A, where F is
-- a function call
Temp_Node := Prefix (Context);
if Is_Rewrite_Substitution (Temp_Node) and then
Nkind (Temp_Node) = N_Function_Call and then
Original_Node (Temp_Node) = Node
then
return A_Function_Call;
end if;
when N_Parameter_Specification =>
-- See FA13-008. In case if we have an implicit "/="
-- declaration, and in the corresponding explicit "="
-- declaration parameter type is defined by a 'Class attribute,
-- in the parameter specification of "/=" the front-end uses
-- the reference to the internal type entity node
if Nkind (Node) = N_Identifier
and then
not Comes_From_Source (Node)
and then
Ekind (Entity (Node)) = E_Class_Wide_Type
then
return A_Class_Attribute;
end if;
when others =>
null;
end case;
-- general case, the following if statement is necessary because
-- of sharing of this code between N_Expanded_Name and N_Identifier
-- mapping items.
-- IS THIS CODE SHARING A REALLY GOOD THING???
<<Expr>> -- here we are analyzing the "ordinary" expression
if Nkind (Node) = N_Expanded_Name then
return A_Selected_Component;
elsif Context_Kind /= N_Defining_Program_Unit_Name then
if (Nkind (Node) in N_Has_Entity
or else
Nkind (Node) = N_Attribute_Definition_Clause)
and then
Entity_Present (Node)
and then
Ekind (Entity (Node)) = E_Enumeration_Literal
then
return An_Enumeration_Literal;
else
return An_Identifier;
end if;
else
return An_Identifier;
end if;
end N_Expanded_Name_Mapping;
---------------------------------------
-- N_Formal_Type_Declaration_Mapping --
---------------------------------------
function N_Formal_Type_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- if Nkind (Sinfo.Formal_Type_Definition (Node)) = (SCz)
-- N_Formal_Incomplete_Type_Definition
-- then
-- return A_Formal_Incomplete_Type_Declaration;
-- else
return A_Formal_Type_Declaration;
-- end if;
end N_Formal_Type_Declaration_Mapping;
------------------------------------------
-- N_Formal_Package_Declaration_Mapping --
------------------------------------------
function N_Formal_Package_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Formal_Package_Declaration,
-- A_Formal_Package_Declaration_With_Box
if Box_Present (Node) then
return A_Formal_Package_Declaration_With_Box;
else
return A_Formal_Package_Declaration;
end if;
end N_Formal_Package_Declaration_Mapping;
----------------------------------------------
-- N_Formal_Private_Type_Definition_Mapping --
----------------------------------------------
function N_Formal_Private_Type_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Formal_Private_Type_Definition
-- A_Formal_Tagged_Private_Type_Definition
if Tagged_Present (Node) then
return A_Formal_Tagged_Private_Type_Definition;
else
return A_Formal_Private_Type_Definition;
end if;
end N_Formal_Private_Type_Definition_Mapping;
---------------------------------------------
-- N_Formal_Subprogram_Declaration_Mapping --
---------------------------------------------
function N_Formal_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Formal_Procedure_Declaration
-- A_Formal_Function_Declaration.
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Formal_Function_Declaration;
else
return A_Formal_Procedure_Declaration;
end if;
end N_Formal_Subprogram_Declaration_Mapping;
-----------------------------
-- N_Function_Call_Mapping --
-----------------------------
function N_Function_Call_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Called_Name : Node_Id;
Called_Function : Node_Id := Empty;
Result : Internal_Element_Kinds := A_Function_Call;
begin
-- Three Internal_Element_Kinds values may be possible:
-- A_Function_Call (usual situation)
-- A_Selected_Component
-- An_Enumeration_Literal
-- The last two cases correspond to a reference to an overloaded
-- enumeration literal (either qualified or direct)
if No (Parameter_Associations (Node)) then
Called_Name := Sinfo.Name (Node);
if Nkind (Called_Name) in N_Has_Entity then
Called_Function := Entity (Called_Name);
end if;
if Nkind (Parent (Called_Function)) =
N_Enumeration_Type_Definition
then
if Nkind (Called_Name) = N_Selected_Component or else -- ???
Nkind (Called_Name) = N_Expanded_Name
then
Result := A_Selected_Component;
elsif Nkind (Called_Name) = N_Identifier then
Result := An_Enumeration_Literal;
end if;
end if;
end if;
return Result;
end N_Function_Call_Mapping;
----------------------------------------------
-- N_Generic_Subprogram_Declaration_Mapping --
----------------------------------------------
function N_Generic_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Generic_Procedure_Declaration and A_Generic_Function_Declaration
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Generic_Function_Declaration;
else
return A_Generic_Procedure_Declaration;
end if;
end N_Generic_Subprogram_Declaration_Mapping;
-- |A2005 start
-------------------------------------------
-- N_Incomplete_Type_Declaration_Mapping --
-------------------------------------------
function N_Incomplete_Type_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := An_Incomplete_Type_Declaration;
begin
if Tagged_Present (Node) then
Result := A_Tagged_Incomplete_Type_Declaration;
end if;
return Result;
end N_Incomplete_Type_Declaration_Mapping;
-- |A2005 end
------------------------------------------------
-- N_Index_Or_Discriminant_Constraint_Mapping --
------------------------------------------------
function N_Index_Or_Discriminant_Constraint_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
First_Item : Node_Id;
-- the first element in the list of discrete ranges or discriminant
-- associations, this element is the only one used to determine the kind
-- of the constraint being analyzed
First_Item_Kind : Node_Kind;
Type_Entity : Node_Id;
-- Needed in case when we can not make the decision using the syntax
-- information only. Represents the type or subtype entity to which the
-- constraint is applied
begin
-- Two Internal_Element_Kinds values may be possible:
-- An_Index_Constraint
-- A_Discriminant_Constraint
First_Item := First (Constraints (Node));
First_Item_Kind := Nkind (First_Item);
-- analyzing the syntax structure of First_Item:
if First_Item_Kind = N_Discriminant_Association then
return A_Discriminant_Constraint;
elsif First_Item_Kind = N_Subtype_Indication or else
First_Item_Kind = N_Range
then
return An_Index_Constraint;
elsif First_Item_Kind = N_Attribute_Reference then
-- analyzing the attribute designator:
if Attribute_Name (First_Item) = Name_Range then
return An_Index_Constraint;
else
return A_Discriminant_Constraint;
end if;
elsif not (First_Item_Kind = N_Identifier or else
First_Item_Kind = N_Expanded_Name)
then
-- First_Item is an expression and it could not be interpreted as a
-- subtype_mark from a discrete_subtype_indication, so what we have
-- in this case is:
return A_Discriminant_Constraint;
end if;
-- First_Item is of N_Identifier or N_Expanded_Name kind, and it may be
-- either an expression in index constraint or a subtype mark in a
-- discriminant constraint. In this case it is easier to analyze the
-- type to which the constraint is applied, but not the constraint
-- itself.
Type_Entity := Entity (Sinfo.Subtype_Mark (Parent (Node)));
while Ekind (Type_Entity) in Access_Kind loop
Type_Entity := Directly_Designated_Type (Type_Entity);
end loop;
if Has_Discriminants (Type_Entity) then
return A_Discriminant_Constraint;
else
return An_Index_Constraint;
end if;
end N_Index_Or_Discriminant_Constraint_Mapping;
--------------------------------------
-- N_Iterator_Specification_Mapping --
--------------------------------------
function N_Iterator_Specification_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := A_Generalized_Iterator_Specification;
begin
if Of_Present (Node) then
Result := An_Element_Iterator_Specification;
end if;
return Result;
end N_Iterator_Specification_Mapping;
------------------------------
-- N_Loop_Statement_Mapping --
------------------------------
function N_Loop_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Iteration : Node_Id;
begin
-- Three Internal_Element_Kinds values may be possible:
-- A_Loop_Statement,
-- A_While_Loop_Statement,
-- A_For_Loop_Statement,
Iteration := Iteration_Scheme (Node);
if Present (Iteration) then
if Present (Condition (Iteration)) then
return A_While_Loop_Statement;
else
return A_For_Loop_Statement;
end if;
else
return A_Loop_Statement;
end if;
end N_Loop_Statement_Mapping;
----------------------------------
-- N_Number_Declaration_Mapping --
----------------------------------
function N_Number_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- An_Integer_Number_Declaration
-- A_Real_Number_Declaration
if Ekind (Defining_Identifier (Node)) = E_Named_Integer then
return An_Integer_Number_Declaration;
else
return A_Real_Number_Declaration;
end if;
end N_Number_Declaration_Mapping;
----------------------------------
-- N_Object_Declaration_Mapping --
----------------------------------
function N_Object_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds;
begin
-- Three Internal_Element_Kinds values may be possible:
-- A_Variable_Declaration,
-- A_Constant_Declaration,
-- A_Deferred_Constant_Declaration.
-- |A2005 start
-- A_Return_Variable_Specification
-- A_Return_Constant_Specification
-- |A2005 end
if Nkind (Parent (Node)) = N_Extended_Return_Statement then
if not Constant_Present (Node) then
Result := A_Return_Variable_Specification;
else
Result := A_Return_Constant_Specification;
end if;
elsif not Constant_Present (Node) then
Result := A_Variable_Declaration;
elsif Present (Sinfo.Expression (Node)) then
Result := A_Constant_Declaration;
else
Result := A_Deferred_Constant_Declaration;
end if;
return Result;
end N_Object_Declaration_Mapping;
-------------------------------
-- N_Operator_Symbol_Mapping --
-------------------------------
function N_Operator_Symbol_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Tmp : Node_Id;
Operator_Chars : constant Name_Id := Chars (Node);
Parameter_Number : Nat range 1 .. 2;
-- see the GNAT components Namet.ads and Snames.ads
-- N_Defining_Operator_Symbol_Mapping uses just the same approach,
-- so if there is any error in it, then both functions contain it
begin
-- The following Internal_Element_Kinds values may be possible:
--
-- A_And_Operator, -- and
-- A_Or_Operator, -- or
-- A_Xor_Operator, -- xor
-- A_Equal_Operator, -- =
-- A_Not_Equal_Operator, -- /=
-- A_Less_Than_Operator, -- <
-- A_Less_Than_Or_Equal_Operator, -- <=
-- A_Greater_Than_Operator, -- >
-- A_Greater_Than_Or_Equal_Operator, -- >=
-- A_Plus_Operator, -- +
-- A_Minus_Operator, -- -
-- A_Concatenate_Operator, -- &
-- A_Unary_Plus_Operator, -- +
-- A_Unary_Minus_Operator, -- -
-- A_Multiply_Operator, -- *
-- A_Divide_Operator, -- /
-- A_Mod_Operator, -- mod
-- A_Rem_Operator, -- rem
-- A_Exponentiate_Operator, -- **
-- A_Abs_Operator, -- abs
-- A_Not_Operator, -- not
if Operator_Chars = Name_Op_And then
return An_And_Operator;
elsif Operator_Chars = Name_Op_Or then
return An_Or_Operator;
elsif Operator_Chars = Name_Op_Xor then
return An_Xor_Operator;
elsif Operator_Chars = Name_Op_Eq then
return An_Equal_Operator;
elsif Operator_Chars = Name_Op_Ne then
return A_Not_Equal_Operator;
elsif Operator_Chars = Name_Op_Lt then
return A_Less_Than_Operator;
elsif Operator_Chars = Name_Op_Le then
return A_Less_Than_Or_Equal_Operator;
elsif Operator_Chars = Name_Op_Gt then
return A_Greater_Than_Operator;
elsif Operator_Chars = Name_Op_Ge then
return A_Greater_Than_Or_Equal_Operator;
elsif Operator_Chars = Name_Op_Concat then
return A_Concatenate_Operator;
elsif Operator_Chars = Name_Op_Multiply then
return A_Multiply_Operator;
elsif Operator_Chars = Name_Op_Divide then
return A_Divide_Operator;
elsif Operator_Chars = Name_Op_Mod then
return A_Mod_Operator;
elsif Operator_Chars = Name_Op_Rem then
return A_Rem_Operator;
elsif Operator_Chars = Name_Op_Expon then
return An_Exponentiate_Operator;
elsif Operator_Chars = Name_Op_Abs then
return An_Abs_Operator;
elsif Operator_Chars = Name_Op_Not then
return A_Not_Operator;
else
-- for + and - operator signs binary and unary cases
-- should be distinguished
-- A simple case - we have an entity:
if Entity_Present (Node) then
Tmp := Entity (Node);
if First_Entity (Tmp) = Last_Entity (Tmp) then
Parameter_Number := 1;
else
Parameter_Number := 2;
end if;
else
Parent_Node := Parent (Node);
if Nkind (Parent_Node) = N_Integer_Literal or else
Nkind (Parent_Node) = N_Real_Literal
then
-- Static expression of the form "+"(1, 2) rewritten into
-- a literal value
Parent_Node := Original_Node (Parent_Node);
end if;
-- we have to do this assignment also here, because this
-- function may be called outside Node_To_Element
-- convertors
-- because of the possible tree rewriting, the parent node
-- may be either of N_Function_Call or of N_Op_Xxx type)
-- it can be also of N_Formal_Subprogram_Declaration kind,
-- or even of N_Expanded_Name kind,
while Nkind (Parent_Node) = N_Expanded_Name loop
Parent_Node := Parent (Parent_Node);
if Nkind (Parent_Node) = N_Integer_Literal or else
Nkind (Parent_Node) = N_Real_Literal
then
-- Static expression of the form
-- Prefix_Name."+"(1, 2)
-- rewritten into a literal value
Parent_Node := Original_Node (Parent_Node);
end if;
end loop;
if Nkind (Parent_Node) = N_Op_Plus or else
Nkind (Parent_Node) = N_Op_Minus
then
Parameter_Number := 1;
elsif Nkind (Parent_Node) = N_Op_Add or else
Nkind (Parent_Node) = N_Op_Subtract
then
Parameter_Number := 2;
elsif Nkind (Parent_Node) = N_Function_Call then
Parameter_Number :=
List_Length (Parameter_Associations (Parent_Node));
elsif Nkind (Parent_Node) = N_Subprogram_Renaming_Declaration
or else
Nkind (Parent_Node) in N_Formal_Subprogram_Declaration
then
Parameter_Number := List_Length
(Parameter_Specifications (Specification (Parent_Node)));
elsif Nkind (Parent_Node) = N_Indexed_Component then
Parameter_Number := List_Length
(Sinfo.Expressions (Parent_Node));
elsif Nkind (Parent_Node) = N_Pragma_Argument_Association then
-- this is for pragma inline ("+");
Parameter_Number := 2;
-- this choice is somewhat arbitrary :)
elsif Nkind (Parent_Node) = N_Generic_Association then
Tmp := Defining_Gen_Parameter (Node);
Parameter_Number := List_Length
(Parameter_Specifications (Parent (Tmp)));
else
-- Impossible case
raise Internal_Implementation_Error;
end if;
end if;
if Operator_Chars = Name_Op_Add then
if Parameter_Number = 1 then
return A_Unary_Plus_Operator;
else
return A_Plus_Operator;
end if;
else -- Operator_Chars = "-"
if Parameter_Number = 1 then
return A_Unary_Minus_Operator;
else
return A_Minus_Operator;
end if;
end if;
end if;
end N_Operator_Symbol_Mapping;
----------------------
-- N_Pragma_Mapping --
----------------------
function N_Pragma_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Pragma_Chars : constant Name_Id := Pragma_Name (Node);
begin
-- Language-Defined Pragmas --
if Pragma_Chars = Name_All_Calls_Remote then
return An_All_Calls_Remote_Pragma; -- I.2.3(6)
elsif Pragma_Chars = Name_Asynchronous then
return An_Asynchronous_Pragma; -- I.4.1(3)
elsif Pragma_Chars = Name_Atomic then
return An_Atomic_Pragma; -- G.5(3)
elsif Pragma_Chars = Name_Atomic_Components then
return An_Atomic_Components_Pragma; -- G.5(3)
elsif Pragma_Chars = Name_Attach_Handler then
return An_Attach_Handler_Pragma; -- G.3.1(3)
elsif Pragma_Chars = Name_Controlled then
return A_Controlled_Pragma; -- 13.11.3(3), B(12)
elsif Pragma_Chars = Name_Convention then
return A_Convention_Pragma; -- B(16), M.1(5)
elsif Pragma_Chars = Name_Discard_Names then
return A_Discard_Names_Pragma; -- C.5(2)
elsif Pragma_Chars = Name_Elaborate then
return An_Elaborate_Pragma; -- 10.2.1(20)
elsif Pragma_Chars = Name_Elaborate_All then
return An_Elaborate_All_Pragma; -- 10.2.1(19), B(8)
elsif Pragma_Chars = Name_Elaborate_Body then
return An_Elaborate_Body_Pragma; -- 10.2.1(21), B(9)
elsif Pragma_Chars = Name_Export then
return An_Export_Pragma; -- B(15), M.1(5)
elsif Pragma_Chars = Name_Import then
return An_Import_Pragma; -- B(14), M.1(5)
elsif Pragma_Chars = Name_Inline then
return An_Inline_Pragma; -- 6.3.2(4), B(5)
elsif Pragma_Chars = Name_Inspection_Point then
return An_Inspection_Point_Pragma; -- L.2.2(2)
elsif Pragma_Chars = Name_Interrupt_Handler then
return An_Interrupt_Handler_Pragma; -- G.3.1(2)
elsif Pragma_Chars = Name_Interrupt_Priority then
return An_Interrupt_Priority_Pragma; -- H.1(4)
elsif Pragma_Chars = Name_Linker_Options then
return A_Linker_Options_Pragma; -- B.1(8)
elsif Pragma_Chars = Snames.Name_List then
return A_List_Pragma; -- 2.8(18), B(2)
elsif Pragma_Chars = Name_Locking_Policy then
return A_Locking_Policy_Pragma; -- H.3(3)
elsif Pragma_Chars = Name_Normalize_Scalars then
return A_Normalize_Scalars_Pragma; -- L.1.1(2)
elsif Pragma_Chars = Name_Optimize then
return An_Optimize_Pragma; -- 2.8(18), B(4)
elsif Pragma_Chars = Name_Pack then
return A_Pack_Pragma; -- 13.2(2), B(11)
elsif Pragma_Chars = Name_Page then
return A_Page_Pragma; -- 2.8(18), B(3)
elsif Pragma_Chars = Name_Preelaborate then
return A_Preelaborate_Pragma; -- 10.2.1(3), B(6)
elsif Pragma_Chars = Name_Priority then
return A_Priority_Pragma; -- H.1(3)
elsif Pragma_Chars = Name_Pure then
return A_Pure_Pragma; -- 10.2.1(13), B(7)
elsif Pragma_Chars = Name_Queuing_Policy then
return A_Queuing_Policy_Pragma; -- H.4(3)
elsif Pragma_Chars = Name_Remote_Call_Interface then
return A_Remote_Call_Interface_Pragma; -- I.2.3(4)
elsif Pragma_Chars = Name_Remote_Types then
return A_Remote_Types_Pragma; -- I.2.2(4)
elsif Pragma_Chars = Name_Restrictions then
return A_Restrictions_Pragma; -- 13.12(2), B(13)
elsif Pragma_Chars = Name_Reviewable then
return A_Reviewable_Pragma; -- L.2.1(2)
elsif Pragma_Chars = Name_Shared_Passive then
return A_Shared_Passive_Pragma; -- I.2.1(4)
elsif Pragma_Chars = Name_Storage_Size then
-- the same name entry as for 'Storage_Size attribute!
return A_Storage_Size_Pragma; -- 13.3(62)
elsif Pragma_Chars = Name_Suppress then
return A_Suppress_Pragma; -- 11.5(4), B(10)
elsif Pragma_Chars = Name_Task_Dispatching_Policy then
return A_Task_Dispatching_Policy_Pragma; -- H.2.2(2)
elsif Pragma_Chars = Name_Volatile then
return A_Volatile_Pragma; -- G.5(3)
elsif Pragma_Chars = Name_Volatile_Components then
return A_Volatile_Components_Pragma; -- G.5(3)
-- --|A2005 start
-- New Ada 2005 pragmas. To be alphabetically ordered later
elsif Pragma_Chars = Name_Assert then
return An_Assert_Pragma;
elsif Pragma_Chars = Name_Assertion_Policy then
return An_Assertion_Policy_Pragma;
elsif Pragma_Chars = Name_Detect_Blocking then
return A_Detect_Blocking_Pragma;
elsif Pragma_Chars = Name_No_Return then
return A_No_Return_Pragma;
-- A_Partition_Elaboration_Policy_Pragma - not implemented yet!
elsif Pragma_Chars = Name_Preelaborable_Initialization then
return A_Preelaborable_Initialization_Pragma;
elsif Pragma_Chars = Name_Priority_Specific_Dispatching then
return A_Priority_Specific_Dispatching_Pragma;
elsif Pragma_Chars = Name_Profile then
return A_Profile_Pragma;
elsif Pragma_Chars = Name_Relative_Deadline then
return A_Relative_Deadline_Pragma;
elsif Pragma_Chars = Name_Unchecked_Union then
return An_Unchecked_Union_Pragma;
elsif Pragma_Chars = Name_Unsuppress then
return An_Unsuppress_Pragma;
-- --|A2005 end
-- --|A2012 start
-- New Ada 2012 pragmas. To be alphabetically ordered later
elsif Pragma_Chars = Name_Default_Storage_Pool then
return A_Default_Storage_Pool_Pragma;
-- elsif Pragma_Chars = Name_Dispatching_Domain then SCz
-- return A_Dispatching_Domain_Pragma;
elsif Pragma_Chars = Name_CPU then
return A_CPU_Pragma;
elsif Pragma_Chars = Name_Independent then
return An_Independent_Pragma;
elsif Pragma_Chars = Name_Independent_Components then
return A_Independent_Components_Pragma;
-- To be continued...
-- --|A2012 end
-- Implementation(GNAT)-Defined Pragmas --
elsif Pragma_Chars in First_Pragma_Name .. Last_Pragma_Name then
-- We have already checked for all the standard pragma names, so
-- all the rest known as pragma name should be GNAT-specific pragmas.
return An_Implementation_Defined_Pragma; -- Vendor Appendix M
else
return An_Unknown_Pragma; -- Unknown to the compiler.
end if;
end N_Pragma_Mapping;
----------------------------------------
-- N_Procedure_Call_Statement_Mapping --
----------------------------------------
function N_Procedure_Call_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Parent_N : Node_Id := Parent (Parent (Node));
Result : Internal_Element_Kinds := A_Procedure_Call_Statement;
begin
-- The only special case we have to process is a procedure call that is
-- an argument of a pragma Debug. To satisfy the Ada syntax, we have to
-- classify it as A_Function_Call (see G330-002).
if Nkind (Parent_N) = N_Block_Statement
and then
not Comes_From_Source (Parent_N)
then
Parent_N := Parent (Parent_N);
if Nkind (Parent_N) = N_If_Statement
and then
Nkind (Original_Node (Parent_N)) = N_Pragma
and then
Pragma_Name (Original_Node (Parent_N)) = Name_Debug
then
Result := A_Function_Call;
end if;
end if;
return Result;
end N_Procedure_Call_Statement_Mapping;
-------------------------------------
-- N_Quantified_Expression_Mapping --
-------------------------------------
function N_Quantified_Expression_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := A_For_Some_Quantified_Expression;
begin
if All_Present (Node) then
Result := A_For_All_Quantified_Expression;
end if;
return Result;
end N_Quantified_Expression_Mapping;
--------------------------------
-- N_Range_Constraint_Mapping --
--------------------------------
function N_Range_Constraint_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Range_Attribute_Reference
-- A_Simple_Expression_Range
if Nkind (Original_Node (Range_Expression (Node))) = N_Range then
return A_Simple_Expression_Range;
else
return A_Range_Attribute_Reference;
end if;
end N_Range_Constraint_Mapping;
---------------------
-- N_Range_Mapping --
---------------------
function N_Range_Mapping (Node : Node_Id) return Internal_Element_Kinds is
Context_Kind : constant Node_Kind := Nkind (Original_Node (Parent_Node));
begin
-- The following Internal_Element_Kinds values may be possible:
-- A_Discrete_Simple_Expression_Range_As_Subtype_Definition
-- A_Discrete_Simple_Expression_Range
-- ???
-- Other values should be added during constructing the
-- full implementation
case Context_Kind is
when N_Constrained_Array_Definition
| N_Entry_Declaration =>
return A_Discrete_Simple_Expression_Range_As_Subtype_Definition;
when N_Index_Or_Discriminant_Constraint |
N_Slice |
N_Case_Statement_Alternative |
N_Component_Association
=>
return A_Discrete_Simple_Expression_Range;
when N_In |
N_Not_In =>
return A_Simple_Expression_Range;
when others => -- not implemented cases (???)
Not_Implemented_Mapping (Nkind (Node));
end case;
end N_Range_Mapping;
---------------------------------
-- N_Record_Definition_Mapping --
---------------------------------
function N_Record_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := A_Record_Type_Definition;
Is_Formal : constant Boolean :=
Nkind (Original_Node (Parent (Node))) = N_Formal_Type_Declaration;
begin
-- Two Internal_Element_Kinds values may be possible (Ada 95):
-- A_Record_Type_Definition
-- A_Tagged_Record_Type_Definition
-- --|A2005 start
-- Plus the following values for Ada 2005:
--
-- An_Ordinary_Interface
-- A_Limited_Interface
-- A_Task_Interface
-- A_Protected_Interface
-- A_Synchronized_Interface
--
-- A_Formal_Ordinary_Interface
-- A_Formal_Limited_Interface
-- A_Formal_Task_Interface
-- A_Formal_Protected_Interface
-- A_Formal_Synchronized_Interface
-- --|A2005 end
-- Implementation revised for Ada 2005
if Interface_Present (Node) then
if Limited_Present (Node) then
if Is_Formal then
Result := A_Formal_Limited_Interface;
else
Result := A_Limited_Interface;
end if;
elsif Task_Present (Node) then
if Is_Formal then
Result := A_Formal_Task_Interface;
else
Result := A_Task_Interface;
end if;
elsif Protected_Present (Node) then
if Is_Formal then
Result := A_Formal_Protected_Interface;
else
Result := A_Protected_Interface;
end if;
elsif Synchronized_Present (Node) then
if Is_Formal then
Result := A_Formal_Synchronized_Interface;
else
Result := A_Synchronized_Interface;
end if;
else
if Is_Formal then
Result := A_Formal_Ordinary_Interface;
else
Result := An_Ordinary_Interface;
end if;
end if;
elsif Tagged_Present (Node) then
Result := A_Tagged_Record_Type_Definition;
end if;
return Result;
-- --|A2005 end
end N_Record_Definition_Mapping;
---------------------------------
-- N_Requeue_Statement_Mapping --
---------------------------------
function N_Requeue_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Requeue_Statement
-- A_Requeue_Statement_With_Abort
if Abort_Present (Node) then
return A_Requeue_Statement_With_Abort;
else
return A_Requeue_Statement;
end if;
end N_Requeue_Statement_Mapping;
-------------------------------
-- N_Subprogram_Body_Mapping --
-------------------------------
function N_Subprogram_Body_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Procedure_Body_Declaration and A_Function_Body_Declaration
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Function_Body_Declaration;
else
return A_Procedure_Body_Declaration;
end if;
end N_Subprogram_Body_Mapping;
------------------------------------
-- N_Subprogram_Body_Stub_Mapping --
------------------------------------
function N_Subprogram_Body_Stub_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Procedure_Body_Stub and A_Function_Body_Stub,
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Function_Body_Stub;
else
return A_Procedure_Body_Stub;
end if;
end N_Subprogram_Body_Stub_Mapping;
--------------------------------------
-- N_Subprogram_Declaration_Mapping --
--------------------------------------
function N_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Procedure_Declaration
-- A_Function_Declaration
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Function_Declaration;
-- --|A2005 start
elsif Null_Present (Specification (Node)) then
return A_Null_Procedure_Declaration;
-- --|A2005 end
else
return A_Procedure_Declaration;
end if;
end N_Subprogram_Declaration_Mapping;
-----------------------------------------------
-- N_Subprogram_Renaming_Declaration_Mapping --
-----------------------------------------------
function N_Subprogram_Renaming_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Procedure_Renaming_Declaration and A_Function_Renaming_Declaration
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Function_Renaming_Declaration;
else
return A_Procedure_Renaming_Declaration;
end if;
end N_Subprogram_Renaming_Declaration_Mapping;
----------------------------------
-- N_Subtype_Indication_Mapping --
----------------------------------
function N_Subtype_Indication_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- The following Internal_Element_Kinds values may be possible:
-- A_Discrete_Subtype_Indication_As_Subtype_Definition
-- A_Discrete_Subtype_Indication
-- A_Subtype_Indication
case Nkind (Parent_Node) is
when N_Constrained_Array_Definition =>
if Is_List_Member (Node) then
return A_Discrete_Subtype_Indication_As_Subtype_Definition;
end if;
when N_Entry_Declaration =>
return A_Discrete_Subtype_Indication_As_Subtype_Definition;
when N_Index_Or_Discriminant_Constraint |
N_Slice =>
return A_Discrete_Subtype_Indication;
when others =>
null;
end case;
return A_Subtype_Indication;
end N_Subtype_Indication_Mapping;
-------------------------------
-- N_Use_Type_Clause_Mapping --
-------------------------------
function N_Use_Type_Clause_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
if All_Present (Node) then
return A_Use_All_Type_Clause;
else
return A_Use_Type_Clause;
end if;
end N_Use_Type_Clause_Mapping;
----------------------
-- N_To_E_List_New --
----------------------
function N_To_E_List_New
(List : List_Id;
Include_Pragmas : Boolean := False;
Starting_Element : Asis.Element := Asis.Nil_Element;
Node_Knd : Node_Kind := N_Empty;
Internal_Kind : Internal_Element_Kinds := Not_An_Element;
Special_Case : Special_Cases := Not_A_Special_Case;
Norm_Case : Normalization_Cases := Is_Not_Normalized;
In_Unit : Asis.Compilation_Unit := Asis.Nil_Compilation_Unit)
return Asis.Element_List
is
begin
Set_Element_List
(List,
Include_Pragmas,
Starting_Element,
Node_Knd,
Internal_Kind,
Special_Case,
Norm_Case,
In_Unit);
return Asis.Association_List
(Internal_Asis_Element_Table.Table
(1 .. Internal_Asis_Element_Table.Last));
end N_To_E_List_New;
----------------------------------------------
-- N_Unconstrained_Array_Definition_Mapping --
----------------------------------------------
function N_Unconstrained_Array_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- An_Unconstrained_Array_Definition
-- A_Formal_Unconstrained_Array_Definition
if Nkind (Parent (Node)) = N_Formal_Type_Declaration then
return A_Formal_Unconstrained_Array_Definition;
else
return An_Unconstrained_Array_Definition;
end if;
end N_Unconstrained_Array_Definition_Mapping;
----------------
-- No_Mapping --
----------------
procedure No_Mapping (Node : Node_Id) is
begin
-- This function should never be called!
raise Internal_Implementation_Error;
end No_Mapping;
-------------------------
-- Node_To_Element_New --
-------------------------
function Node_To_Element_New
(Node : Node_Id;
Node_Field_1 : Node_Id := Empty;
Node_Field_2 : Node_Id := Empty;
Starting_Element : Asis.Element := Asis.Nil_Element;
Internal_Kind : Internal_Element_Kinds := Not_An_Element;
Spec_Case : Special_Cases := Not_A_Special_Case;
Norm_Case : Normalization_Cases := Is_Not_Normalized;
Considering_Parent_Count : Boolean := True;
Using_Original_Node : Boolean := True;
Inherited : Boolean := False;
In_Unit : Asis.Compilation_Unit :=
Asis.Nil_Compilation_Unit)
return Asis.Element
is
R_Node : Node_Id;
Res_Node : Node_Id;
Res_Node_Field_1 : Node_Id := Empty;
Res_Node_Field_2 : Node_Id := Empty;
Res_Internal_Kind : Internal_Element_Kinds := Internal_Kind;
Res_Enclosing_Unit : Asis.Compilation_Unit;
Res_Is_Part_Of_Implicit : Boolean := False;
Res_Is_Part_Of_Inherited : Boolean := False;
Res_Is_Part_Of_Instance : Boolean := False;
Res_Spec_Case : Special_Cases := Spec_Case;
Res_Char_Code : Char_Code := 0;
Res_Parenth_Count : Nat := 0;
begin
-- first, check if Node is not Empty and return Nil_Element otherwise:
if No (Node) then
return Nil_Element;
end if;
if Using_Original_Node
and then
Is_Rewrite_Substitution (Node)
and then
not Is_Rewritten_Function_Prefix_Notation (Node)
then
-- Note that for a function call in Object.Operation notation we do
-- not use the original node at all, because the original tree
-- structure is not properly decorated and analyzed, but the
-- rewritten subtree contains all we need
Res_Node := Original_Node (Node);
if Is_Rewrite_Substitution (Res_Node) then
Res_Node := Original_Node (Res_Node);
end if;
else
Res_Node := Node;
end if;
-- setting the global Parent_Node needed for computing the kind of
-- the returned Element
Parent_Node := Parent (Node);
if not Is_Nil (Starting_Element) then
-- We need this to define the enclosing unit for the new Element
Res_Spec_Case := Special_Case (Starting_Element);
end if;
-- setting result's enclosing unit:
if Exists (In_Unit) then
-- if In_Unit is set, we take information about the result's
-- enclosing unit from it, unless we have to create a configuration
-- pragma or component thereof.
if Spec_Case = Configuration_File_Pragma then
Res_Enclosing_Unit := Get_Configuration_CU (In_Unit);
else
Res_Enclosing_Unit := In_Unit;
end if;
elsif not Is_Nil (Starting_Element) then
-- if Starting_Element is set, but In_Unit is not, we take
-- information about the result's enclosing unit from
-- Starting_Element
Res_Enclosing_Unit := Encl_Unit (Starting_Element);
else
-- we can be here only if both Starting_Element and In_Unit are
-- nor set. This is definitely an error.
raise Internal_Implementation_Error;
end if;
-- if Starting_Element is set, we "transfer" everything what is
-- possible from it to the result:
if not Is_Nil (Starting_Element) then
if Nkind (Res_Node) = N_Null_Statement
and then
not (Comes_From_Source (Res_Node))
then
-- Implicit NULL statement'floating' labels are attached to
Res_Is_Part_Of_Implicit := True;
elsif Nkind (Res_Node) = N_Label then
-- Needed in case of 'floating' labels
Res_Is_Part_Of_Implicit := False;
else
Res_Is_Part_Of_Implicit := Is_From_Implicit (Starting_Element);
end if;
Res_Is_Part_Of_Inherited := Is_From_Inherited (Starting_Element);
Res_Is_Part_Of_Instance := Is_From_Instance (Starting_Element);
-- Res_Spec_Case is already set!
if Present (Node_Field_1_Value (Starting_Element)) then
Res_Node_Field_1 := Node_Field_1_Value (Starting_Element);
pragma Assert (Get_Current_Tree = Encl_Tree (Starting_Element));
-- We can not use Asis.Set_Get.Node_Field_1 here, because it
-- might reset the tree.
end if;
if Present (Node_Field_2_Value (Starting_Element)) then
Res_Node_Field_2 := Node_Field_2_Value (Starting_Element);
pragma Assert (Get_Current_Tree = Encl_Tree (Starting_Element));
-- We can not use Asis.Set_Get.Node_Field_2 here, because it
-- might reset the tree.
end if;
if Internal_Kind = A_Defining_Character_Literal or else
Internal_Kind = An_Enumeration_Literal_Specification
then
-- We keep Character_Code unless the result is type definition
-- (it that case keeping Character_Code would make Is_Equal test
-- not work properly
Res_Char_Code := Character_Code (Starting_Element);
end if;
if Res_Spec_Case in Expanded_Spec then
-- We have to reset Res_Spec_Case from
-- Expanded_Package_Instantiation or
-- Expanded_Subprogram_Instantiation to Not_A_Special_Case;
-- because only (the whole) expanded generic declarations can have
-- the value of Special_Case from Expanded_Spec
Res_Spec_Case := Not_A_Special_Case;
end if;
elsif Res_Spec_Case in Expanded_Spec then
Res_Is_Part_Of_Implicit := False;
else
if Is_From_Instance (Original_Node (Node)) or else
Is_Name_Of_Expanded_Subprogram (Res_Node) or else
Part_Of_Pass_Generic_Actual (Original_Node (Node)) or else
Is_Stub_To_Body_Instanse_Replacement (Node) or else
Spec_Case = Expanded_Package_Instantiation or else
Spec_Case = Expanded_Subprogram_Instantiation
then
Res_Is_Part_Of_Instance := True;
end if;
if Inherited then
Res_Is_Part_Of_Inherited := True;
Res_Is_Part_Of_Implicit := True;
end if;
if not Comes_From_Source (Res_Node)
and then
(not Part_Of_Pass_Generic_Actual (Res_Node)
or else
Norm_Case = Is_Normalized_Defaulted_For_Box)
and then
not Is_Name_Of_Expanded_Subprogram (Res_Node)
then
Res_Is_Part_Of_Implicit := True;
end if;
end if;
-- This patch below is really terrible!!! requires revising!!!
-- ???
if Spec_Case = Expanded_Package_Instantiation or else
Spec_Case = Expanded_Subprogram_Instantiation
then
Res_Is_Part_Of_Instance := True;
end if;
-- if Spec_Case is set explicitly, we should set (or reset)
-- Res_Spec_Case from it
if Spec_Case /= Not_A_Special_Case then
Res_Spec_Case := Spec_Case;
end if;
-- computing the kind of the result and correcting Special_Case,
-- if needed
if Res_Internal_Kind = Not_An_Element then
-- Res_Internal_Kind is initialized by the value of the
-- Internal_Kind parameter. If this value differs from
-- Not_An_Element, we simply does not change it
if Considering_Parent_Count and then
(Parenth_Count (Res_Node, Node) > 0
or else
Requires_Parentheses (Res_Node))
then
-- special processing for A_Parenthesized_Expression
Res_Internal_Kind := A_Parenthesized_Expression;
if Parenth_Count (Res_Node, Node) > 0 then
Res_Parenth_Count := Parenth_Count (Res_Node, Node);
if Requires_Parentheses (Res_Node) then
Res_Parenth_Count := Res_Parenth_Count + 1;
end if;
else
-- (conditional expression)
Res_Parenth_Count := 1;
end if;
else
-- from Sinfo (spec, rev. 1.334):
---------------------------------
-- 9.5.3 Entry Call Statement --
---------------------------------
-- ENTRY_CALL_STATEMENT ::= entry_NAME [ACTUAL_PARAMETER_PART];
-- The parser may generate a procedure call for this construct. The
-- semantic pass must correct this misidentification where needed.
if Res_Node /= Node and then
((Nkind (Res_Node) = N_Procedure_Call_Statement and then
Nkind (Node) = N_Entry_Call_Statement and then
not Is_Protected_Procedure_Call (Node))
or else
(Nkind (Res_Node) = N_Explicit_Dereference and then
Nkind (Node) = N_Function_Call))
then
Res_Node := Node; -- ???
-- There is no need to keep the original structure in this
-- case, it is definitely wrong
if Nkind (Node) = N_Entry_Call_Statement then
Res_Internal_Kind := An_Entry_Call_Statement;
else
Res_Internal_Kind := A_Function_Call;
end if;
else
if (Nkind (Node) = N_Integer_Literal or else
Nkind (Node) = N_Real_Literal)
and then
((not Is_Rewrite_Substitution (Node))
or else
Nkind (Original_Node (Node)) = N_Identifier)
and then
Comes_From_Source (Node) = False
and then
Is_Static_Expression (Node)
and then
Present (Original_Entity (Node))
then
-- See BB10-002: The special case of named numbers rewritten
-- into numeric literals.
Res_Spec_Case := Rewritten_Named_Number;
Res_Internal_Kind := An_Identifier;
else
Res_Internal_Kind := Asis_Internal_Element_Kind (Res_Node);
end if;
end if;
end if;
end if;
-- and now we have to check if the Element to be returned is from the
-- Standard package, and if it is, we have to correct Res_Spec_Case:
if Res_Spec_Case = Not_A_Special_Case and then
Sloc (Res_Node) <= Standard_Location
then
if Nkind (Node) = N_Defining_Character_Literal then
Res_Spec_Case := Stand_Char_Literal;
else
Res_Spec_Case := Explicit_From_Standard;
end if;
end if;
if Res_Spec_Case = Explicit_From_Standard or else
Res_Spec_Case = Stand_Char_Literal
then
Res_Is_Part_Of_Implicit := False;
end if;
-- ??? This assignment is not necessary and has been
-- introduced to workaround a problem with the sgi n32 compiler
R_Node := Node;
if Nkind (Node) = N_Function_Call and then
(Res_Internal_Kind = A_Selected_Component or else
Res_Internal_Kind = An_Enumeration_Literal)
then
-- a reference to an overloaded enumeration literal represented as a
-- function call, we have to go one step down:
R_Node := Sinfo.Name (Node);
Res_Node := R_Node;
else
R_Node := Node;
end if;
if Present (Node_Field_1) then
Res_Node_Field_1 := Node_Field_1;
end if;
if Present (Node_Field_2) then
Res_Node_Field_2 := Node_Field_2;
end if;
if Res_Spec_Case = From_Limited_View then
Res_Is_Part_Of_Implicit := True;
end if;
return Set_Element (
Node => Res_Node,
R_Node => R_Node,
Node_Field_1 => Res_Node_Field_1,
Node_Field_2 => Res_Node_Field_2,
Encl_Unit => Res_Enclosing_Unit,
Int_Kind => Res_Internal_Kind,
Implicit => Res_Is_Part_Of_Implicit,
Inherited => Res_Is_Part_Of_Inherited,
Instance => Res_Is_Part_Of_Instance,
Spec_Case => Res_Spec_Case,
Norm_Case => Norm_Case,
Par_Count => Res_Parenth_Count,
Character_Code => Res_Char_Code);
end Node_To_Element_New;
--------------------
-- Normalize_Name --
--------------------
procedure Normalize_Name (Capitalized : Boolean := False) is
begin
if Namet.Name_Len = 0 then
return;
end if;
Namet.Name_Buffer (1) := To_Upper (Namet.Name_Buffer (1));
for I in 1 .. Namet.Name_Len - 1 loop
if Capitalized or else
Namet.Name_Buffer (I) = '_'
then
Namet.Name_Buffer (I + 1) := To_Upper (Namet.Name_Buffer (I + 1));
end if;
end loop;
end Normalize_Name;
-----------------------------
-- Normalized_Namet_String --
-----------------------------
function Normalized_Namet_String (Node : Node_Id) return String is
Capitalize : Boolean := False;
begin
Namet.Get_Name_String (Chars (Node));
if Node = Standard_ASCII or else
Node in SE (S_LC_A) .. SE (S_LC_Z) or else
Node in SE (S_NUL) .. SE (S_US) or else
Node = SE (S_DEL)
then
Capitalize := True;
end if;
Normalize_Name (Capitalize);
return Namet.Name_Buffer (1 .. Namet.Name_Len);
end Normalized_Namet_String;
-----------------------------
-- Not_Implemented_Mapping --
-----------------------------
function Not_Implemented_Mapping
(Node : Node_Id)
return Internal_Element_Kinds is
begin
Not_Implemented_Yet (Diagnosis =>
"AST Node -> Asis.Element mapping for the "
& Node_Kind'Image (Nkind (Node))
& " Node Kind value has not been implemented yet");
return Not_An_Element; -- to make the code syntactically correct;
end Not_Implemented_Mapping;
procedure Not_Implemented_Mapping (Source_Node_Kind : Node_Kind) is
begin
Not_Implemented_Yet (Diagnosis =>
"AST Node -> Asis.Element mapping for the "
& Node_Kind'Image (Source_Node_Kind)
& " Node Kind value has not been implemented yet");
end Not_Implemented_Mapping;
----------------------------------
-- Ordinary_Inclusion_Condition --
----------------------------------
function Ordinary_Inclusion_Condition (Node : Node_Id) return Boolean is
O_Node : constant Node_Id := Original_Node (Node);
Arg_Kind : constant Node_Kind := Nkind (Node);
Result : Boolean := True;
begin
if Is_Rewrite_Insertion (Node) or else
May_Be_Included_Switch (Nkind (Node)) = False or else
(Nkind (Node) = N_With_Clause
and then
Implicit_With (Node)) or else
(Nkind (Node) = N_Entry_Call_Statement
and then
Node = O_Node)
then
Result := False;
elsif not Comes_From_Source (O_Node) then
if Arg_Kind = N_Null_Statement then
-- We have to include implicit null statements 'floating' labels
-- are attached to
if not (No (Next (Node))
and then
Present (Prev (Node))
and then
Nkind (Prev (Node)) = N_Label
and then
Comes_From_Source (Prev (Node)))
then
Result := False;
end if;
elsif Arg_Kind = N_Object_Renaming_Declaration then
-- For FB02-008
if (Nkind (Sinfo.Name (Node)) = N_Identifier
and then
Is_Internal_Name (Chars (Sinfo.Name (Node))))
or else
(Nkind (Sinfo.Subtype_Mark (Node)) = N_Identifier
and then
Is_Internal_Name (Chars (Sinfo.Subtype_Mark (Node))))
then
Result := False;
end if;
elsif not ((Arg_Kind = N_Object_Declaration
and then
not Is_Internal_Name (Chars (Defining_Identifier (O_Node))))
or else
Arg_Kind = N_Component_Declaration
or else
Arg_Kind = N_Discriminant_Specification
or else
Arg_Kind = N_Parameter_Specification
or else
Arg_Kind = N_Component_Association
or else
((Arg_Kind = N_Integer_Literal
or else
Arg_Kind = N_Real_Literal)
and then
Is_Static_Expression (Node))
-- This condition describes the special case of a named
-- number rewritten into a literal node, see BB10-002
or else
Sloc (Node) <= Standard_Location
or else
Is_Rewritten_Function_Prefix_Notation (Parent (Node))
or else
Pass_Generic_Actual (Node))
then
Result := False;
end if;
end if;
return Result;
end Ordinary_Inclusion_Condition;
-------------------
-- Parenth_Count --
-------------------
function Parenth_Count
(N : Node_Id;
Original_N : Node_Id)
return Nat
is
Result : Nat := Paren_Count (N);
begin
if Result > 0 and then
Nkind (Original_Node (Parent (Original_N))) = N_Qualified_Expression
then
Result := Result - 1;
end if;
return Result;
end Parenth_Count;
--------------------------
-- Requires_Parentheses --
--------------------------
function Requires_Parentheses
(N : Node_Id)
return Boolean
is
Left_Par_Sloc : Source_Ptr;
Result : Boolean := False;
begin
if Nkind (N) = N_Conditional_Expression
or else
Nkind (N) = N_Case_Expression
or else
Nkind (N) = N_Quantified_Expression
then
Result := True;
-- And now - cases when the expression does not require parentheses:
if Nkind (Parent (N)) = N_Qualified_Expression
or else
Nkind (Parent (N)) = N_Type_Conversion
or else
(Is_List_Member (N)
and then
List_Length (List_Containing (N)) = 1)
then
-- There is a corner case here:
-- P ((if A then B else C));
Left_Par_Sloc := Sloc (N);
Left_Par_Sloc := Search_Prev_Word (Left_Par_Sloc);
pragma Assert (Get_Character (Left_Par_Sloc) = '(');
Left_Par_Sloc := Search_Prev_Word (Left_Par_Sloc);
if Get_Character (Left_Par_Sloc) /= '(' then
Result := False;
end if;
end if;
end if;
-- if Nkind (N) = N_Conditional_Expression
-- or else
-- Nkind (N) = N_Case_Expression
-- or else
-- Nkind (N) = N_Quantified_Expression
-- then
-- Left_Par_Sloc := Sloc (N);
-- Left_Par_Sloc := Search_Prev_Word (Left_Par_Sloc);
-- Result := Get_Character (Left_Par_Sloc) = '(';
-- end if;
-- if Result then
-- -- We have to check if this '(' belongs to some other construct:
-- Left_Par_Sloc := Search_Prev_Word (Left_Par_Sloc);
-- if Get_Character (Left_Par_Sloc) /= '(' then
-- case Nkind (Parent (N)) is
-- when N_Qualified_Expression |
-- N_Type_Conversion =>
-- Result := False;
-- when N_Function_Call |
-- N_Indexed_Component |
-- N_Procedure_Call_Statement |
-- N_Entry_Call_Statement =>
-- -- ??? Is this list complete???
-- if Get_Character (Left_Par_Sloc) /= ',' then
-- Result := False;
-- end if;
-- when others =>
-- null;
-- end case;
-- end if;
-- end if;
return Result;
end Requires_Parentheses;
-----------------------------------------
-- Set_Concurrent_Inherited_Components --
-----------------------------------------
procedure Set_Concurrent_Inherited_Components
(Type_Def : Asis.Element;
Include_Discs : Boolean := True)
is
Type_Entity : Entity_Id;
Next_Comp_Node : Node_Id;
begin
Asis_Element_Table.Init;
Type_Entity := Defining_Identifier (Parent (R_Node (Type_Def)));
if Present (First_Entity (Type_Entity)) then
if Include_Discs then
Next_Comp_Node := First_Entity (Type_Entity);
while Ekind (Next_Comp_Node) = E_Discriminant loop
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Parent (Next_Comp_Node),
Starting_Element => Type_Def));
Set_Node_Field_2
(Asis_Element_Table.Table (Asis_Element_Table.Last),
Next_Comp_Node);
-- This is needed to unify the processing of inherited
-- discriminants in Asis.Declarations.Names
Next_Comp_Node := Next_Entity (Next_Comp_Node);
end loop;
end if;
-- To set all the non-discriminant components, we have to go to the
-- definition of the root concurrent type and to traverse it to
-- grab all this components, because the (non-discrimiinant)
-- entities attached to the entity of the derived concurrent type
-- are artificial entities created for further tree expansion
while Type_Entity /= Etype (Type_Entity) loop
Type_Entity := Etype (Type_Entity);
end loop;
Type_Entity := Parent (Type_Entity);
if Nkind (Type_Entity) = N_Task_Type_Declaration then
Type_Entity := Task_Definition (Type_Entity);
else
Type_Entity := Protected_Definition (Type_Entity);
end if;
Next_Comp_Node :=
First_Non_Pragma (Visible_Declarations (Type_Entity));
while Present (Next_Comp_Node) loop
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Next_Comp_Node,
Starting_Element => Type_Def));
Next_Comp_Node := Next_Non_Pragma (Next_Comp_Node);
end loop;
if Present (Private_Declarations (Type_Entity)) then
Next_Comp_Node :=
First_Non_Pragma (Private_Declarations (Type_Entity));
while Present (Next_Comp_Node) loop
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Next_Comp_Node,
Starting_Element => Type_Def));
Next_Comp_Node := Next_Non_Pragma (Next_Comp_Node);
end loop;
end if;
end if;
end Set_Concurrent_Inherited_Components;
----------------------
-- Set_Element_List --
----------------------
-- At the moment, the implementation is just a copy from N_To_E_List_New
-- with changes related to building the result list in Element Table
procedure Set_Element_List
(List : List_Id;
Include_Pragmas : Boolean := False;
Starting_Element : Asis.Element := Asis.Nil_Element;
Node_Knd : Node_Kind := N_Empty;
Internal_Kind : Internal_Element_Kinds := Not_An_Element;
Special_Case : Special_Cases := Not_A_Special_Case;
Norm_Case : Normalization_Cases := Is_Not_Normalized;
In_Unit : Asis.Compilation_Unit := Asis.Nil_Compilation_Unit;
Append : Boolean := False)
is
List_El : Node_Id;
List_El_Kind : Node_Kind;
function First_List_Element (List : List_Id) return Node_Id;
-- returns the first element of List, taking into account
-- the value of Include_Pragmas
function Next_List_Element (Node : Node_Id) return Node_Id;
-- returns the first element of List, taking into account
-- the value of Include_Pragmas
procedure Skip_Pragmas (N : in out Node_Id);
-- Supposes that Is_List_Member (N). If N is of N_Pragma kind and if
-- Include_Pragmas is set OFF, moves N to the next element of the same
-- list that is not of N_Pragma kinds or set it to Empty if there is no
-- such node. We can not just use Nlists.First_Non_Pragma and
-- Nlists.Next_Non_Pragma, because they also skip N_Null_Statement
-- nodes.
------------------------
-- First_List_Element --
------------------------
function First_List_Element (List : List_Id) return Node_Id is
Result : Node_Id;
begin
Result := First (List);
Skip_Pragmas (Result);
if Is_Rewrite_Substitution (Result)
and then
Nkind (Result) = N_Loop_Statement
and then
Nkind (Original_Node (Result)) = N_Goto_Statement
then
-- This is the case when infinite loop implemented as
--
-- <<Target>> ...
-- ...
-- goto Target;
--
-- Is rewritten into N_Loop_Statement
if not Is_Empty_List (Statements (Result)) then
Result := First (Statements (Result));
end if;
end if;
return Result;
end First_List_Element;
-----------------------
-- Next_List_Element --
-----------------------
function Next_List_Element (Node : Node_Id) return Node_Id is
Tmp : Node_Id;
Result : Node_Id;
begin
Result := Next (Node);
Skip_Pragmas (Result);
if Is_Rewrite_Substitution (Result)
and then
Nkind (Result) = N_Loop_Statement
and then
Nkind (Original_Node (Result)) = N_Goto_Statement
then
-- This is the case when infinite loop implemented as
--
-- <<Target>> ...
-- ...
-- goto Target;
--
-- Is rewritten into N_Loop_Statement
if not Is_Empty_List (Statements (Result)) then
Result := First (Statements (Result));
end if;
end if;
if No (Result) then
Tmp := Parent (Node);
if Is_Rewrite_Substitution (Tmp)
and then
Nkind (Tmp) = N_Loop_Statement
and then
Nkind (Original_Node (Tmp)) = N_Goto_Statement
then
-- We have just finished traversing of the artificial loop
-- statement created for goto, so it's tome to
-- return this goto itself. Note, that we are returning the
-- rewritten N_Loop_Statement to keep list and parent
-- references
Result := Tmp;
end if;
end if;
return Result;
end Next_List_Element;
------------------
-- Skip_Pragmas --
------------------
procedure Skip_Pragmas (N : in out Node_Id) is
begin
if not Include_Pragmas then
while Present (N)
and then
Nkind (Original_Node (N)) = N_Pragma
loop
N := Next (N);
end loop;
end if;
end Skip_Pragmas;
begin
if not Append then
Internal_Asis_Element_Table.Init;
end if;
if No (List) or else Is_Empty_List (List) then
return;
end if;
List_El := First_List_Element (List);
while Present (List_El) loop
if Debug_Flag_L then
Write_Node (N => List_El,
Prefix => "Set_Element_List debug info-> ");
Write_Str ("May_Be_Included is ");
Write_Str (Boolean'Image (May_Be_Included (List_El)));
Write_Eol;
Write_Eol;
end if;
List_El_Kind := Nkind (List_El);
if May_Be_Included (List_El) and then
not ((Node_Knd /= N_Empty) and then (List_El_Kind /= Node_Knd))
then
Internal_Asis_Element_Table.Append
(Node_To_Element_New
(Starting_Element => Starting_Element,
Node => List_El,
Internal_Kind => Internal_Kind,
Spec_Case => Special_Case,
Norm_Case => Norm_Case,
In_Unit => In_Unit));
if List_El_Kind = N_Object_Declaration or else
List_El_Kind = N_Number_Declaration or else
List_El_Kind = N_Discriminant_Specification or else
List_El_Kind = N_Component_Declaration or else
List_El_Kind = N_Parameter_Specification or else
List_El_Kind = N_Exception_Declaration or else
List_El_Kind = N_Formal_Object_Declaration or else
List_El_Kind = N_With_Clause
then
Skip_Normalized_Declarations (List_El);
end if;
end if;
List_El := Next_List_Element (List_El);
end loop;
end Set_Element_List;
---------------------------------
-- Set_Inherited_Discriminants --
---------------------------------
procedure Set_Inherited_Discriminants (Type_Def : Asis.Element) is
Next_Discr_Elmt : Elmt_Id;
Next_Elem_Node : Node_Id;
begin
Next_Elem_Node := Defining_Identifier (Parent (R_Node (Type_Def)));
if Present (Stored_Constraint (Next_Elem_Node)) then
Asis_Element_Table.Init;
Next_Discr_Elmt := First_Elmt (Stored_Constraint (Next_Elem_Node));
while Present (Next_Discr_Elmt) loop
Next_Elem_Node := Parent (Entity (Node (Next_Discr_Elmt)));
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Next_Elem_Node,
Internal_Kind => A_Discriminant_Specification,
Starting_Element => Type_Def));
Next_Discr_Elmt := Next_Elmt (Next_Discr_Elmt);
end loop;
end if;
end Set_Inherited_Discriminants;
------------------------------
-- Set_Inherited_Components --
------------------------------
procedure Set_Inherited_Components
(Type_Def : Asis.Element;
Include_Discs : Boolean := True)
is
Next_Comp_Node : Node_Id;
function Is_Implicit_Component (E : Entity_Id) return Boolean;
-- Checks if E is an entity representing implicit inherited
-- component
function Is_Implicit_Component (E : Entity_Id) return Boolean is
Result : Boolean := False;
begin
if Ekind (E) = E_Component then
Result :=
(E /= Original_Record_Component (E)) or else
not Comes_From_Source (Parent (E));
elsif Ekind (E) = E_Discriminant and then Include_Discs then
Result := not Is_Completely_Hidden (E);
end if;
return Result;
end Is_Implicit_Component;
begin
Asis_Element_Table.Init;
Next_Comp_Node := Defining_Identifier (Parent (R_Node (Type_Def)));
if Ekind (Next_Comp_Node) = E_Record_Subtype then
-- For subtypes we may have components depending on discriminants
-- skipped in case of static discriminant constraints
Next_Comp_Node := Etype (Next_Comp_Node);
end if;
if Present (First_Entity (Next_Comp_Node)) then
Next_Comp_Node := First_Entity (Next_Comp_Node);
while Present (Next_Comp_Node) loop
if Is_Implicit_Component (Next_Comp_Node) then
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Parent (Next_Comp_Node),
Starting_Element => Type_Def));
Set_Node_Field_2
(Asis_Element_Table.Table (Asis_Element_Table.Last),
Next_Comp_Node);
Set_From_Implicit
(Asis_Element_Table.Table (Asis_Element_Table.Last), True);
Set_From_Inherited
(Asis_Element_Table.Table (Asis_Element_Table.Last), True);
end if;
Next_Comp_Node := Next_Entity (Next_Comp_Node);
end loop;
end if;
end Set_Inherited_Components;
----------------------------
-- Set_Inherited_Literals --
----------------------------
procedure Set_Inherited_Literals (Type_Def : Asis.Element) is
Next_Literal_Node : Node_Id;
Res_Etype : Entity_Id;
Encl_Type : constant Node_Id := Parent (R_Node (Type_Def));
begin
Asis_Element_Table.Init;
Next_Literal_Node := Defining_Identifier (Parent (R_Node (Type_Def)));
if Present (First_Literal (Next_Literal_Node)) then
Next_Literal_Node := First_Literal (Next_Literal_Node);
Res_Etype := Etype (Next_Literal_Node);
while Present (Next_Literal_Node) and then
Etype (Next_Literal_Node) = Res_Etype
loop
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Next_Literal_Node,
Internal_Kind => An_Enumeration_Literal_Specification,
Starting_Element => Type_Def));
Set_Node_Field_1
(Asis_Element_Table.Table (Asis_Element_Table.Last),
Encl_Type);
Set_From_Implicit
(Asis_Element_Table.Table (Asis_Element_Table.Last), True);
Set_From_Inherited
(Asis_Element_Table.Table (Asis_Element_Table.Last), True);
Next_Literal_Node := Next_Entity (Next_Literal_Node);
end loop;
else
Not_Implemented_Yet
(Diagnosis =>
"Asis.Definitions.Implicit_Inherited_Declarations "
& "(derived from Standard character type)");
end if;
end Set_Inherited_Literals;
----------------------------------
-- Skip_Normalized_Declarations --
----------------------------------
procedure Skip_Normalized_Declarations (Node : in out Node_Id) is
Arg_Kind : constant Node_Kind := Nkind (Node);
begin
loop
if Arg_Kind = N_Object_Declaration or else
Arg_Kind = N_Number_Declaration or else
Arg_Kind = N_Discriminant_Specification or else
Arg_Kind = N_Component_Declaration or else
Arg_Kind = N_Parameter_Specification or else
Arg_Kind = N_Exception_Declaration or else
Arg_Kind = N_Formal_Object_Declaration
then
if More_Ids (Node) then
Node := Next (Node);
while Nkind (Node) /= Arg_Kind loop
-- some implicit subtype declarations may be inserted by
-- the compiler in between the normalized declarations, so:
Node := Next (Node);
end loop;
else
return;
end if;
else
-- Arg_Kind = N_With_Clause.
-- Note that we should skip implicit clauses that can be added by
-- front-end.
if Comes_From_Source (Node) and then Last_Name (Node) then
return;
else
Node := Next (Node);
end if;
end if;
end loop;
end Skip_Normalized_Declarations;
-------------------------------
-- Subprogram_Attribute_Kind --
-------------------------------
function Subprogram_Attribute_Kind
(Node : Node_Id)
return Internal_Element_Kinds
is
Attribute_Chars : Name_Id;
begin
Attribute_Chars := Attribute_Name (Node);
-- language-defined attributes which are functions:
if Attribute_Chars = Name_Adjacent then
return An_Adjacent_Attribute;
elsif Attribute_Chars = Name_Ceiling then
return A_Ceiling_Attribute;
elsif Attribute_Chars = Name_Compose then
return A_Compose_Attribute;
elsif Attribute_Chars = Name_Copy_Sign then
return A_Copy_Sign_Attribute;
elsif Attribute_Chars = Name_Exponent then
return An_Exponent_Attribute;
elsif Attribute_Chars = Name_Floor then
return A_Floor_Attribute;
elsif Attribute_Chars = Name_Fraction then
return A_Fraction_Attribute;
elsif Attribute_Chars = Name_Image then
return An_Image_Attribute;
elsif Attribute_Chars = Name_Input then
return An_Input_Attribute;
elsif Attribute_Chars = Name_Leading_Part then
return A_Leading_Part_Attribute;
elsif Attribute_Chars = Name_Machine then
return A_Machine_Attribute;
elsif Attribute_Chars = Name_Max then
return A_Max_Attribute;
elsif Attribute_Chars = Name_Min then
return A_Min_Attribute;
elsif Attribute_Chars = Name_Model then
return A_Model_Attribute;
elsif Attribute_Chars = Name_Pos then
return A_Pos_Attribute;
elsif Attribute_Chars = Name_Pred then
return A_Pred_Attribute;
elsif Attribute_Chars = Name_Remainder then
return A_Remainder_Attribute;
elsif Attribute_Chars = Name_Round then
return A_Round_Attribute;
elsif Attribute_Chars = Name_Rounding then
return A_Rounding_Attribute;
elsif Attribute_Chars = Name_Scaling then
return A_Scaling_Attribute;
elsif Attribute_Chars = Name_Succ then
return A_Succ_Attribute;
elsif Attribute_Chars = Name_Truncation then
return A_Truncation_Attribute;
elsif Attribute_Chars = Name_Unbiased_Rounding then
return An_Unbiased_Rounding_Attribute;
elsif Attribute_Chars = Name_Val then
return A_Val_Attribute;
elsif Attribute_Chars = Name_Value then
return A_Value_Attribute;
elsif Attribute_Chars = Name_Wide_Image then
return A_Wide_Image_Attribute;
elsif Attribute_Chars = Name_Wide_Value then
return A_Wide_Value_Attribute;
-- |A2005 start
-- Ada 2005 attributes that are functions:
elsif Attribute_Chars = Name_Machine_Rounding then
return A_Machine_Rounding_Attribute;
elsif Attribute_Chars = Name_Mod then
return A_Mod_Attribute;
elsif Attribute_Chars = Name_Wide_Wide_Image then
return A_Wide_Wide_Image_Attribute;
elsif Attribute_Chars = Name_Wide_Wide_Value then
return A_Wide_Wide_Value_Attribute;
-- |A2005 end
-- |A2012 start
-- Ada 2012 attributes that are functions:
-- elsif Attribute_Chars = Name_Overlaps_Storage then (SCz)
-- return An_Overlaps_Storage_Attribute;
-- |A2012 end
-- language-defined attributes which are procedures:
elsif Attribute_Chars = Name_Output then
return An_Output_Attribute;
elsif Attribute_Chars = Name_Read then
return A_Read_Attribute;
elsif Attribute_Chars = Name_Write then
return A_Write_Attribute;
-- Implementation Dependent Attributes-Functions --
elsif Attribute_Chars = Name_Asm_Input or else
Attribute_Chars = Name_Asm_Output or else
Attribute_Chars = Name_Enum_Rep or else
Attribute_Chars = Name_Enum_Val or else
Attribute_Chars = Name_Fixed_Value or else
Attribute_Chars = Name_Integer_Value or else
Attribute_Chars = Name_Ref
then
return An_Implementation_Defined_Attribute;
else
return An_Unknown_Attribute;
end if;
end Subprogram_Attribute_Kind;
-----------------
-- Ureal_Image --
-----------------
function Ureal_Image (N : Node_Id) return String is
Result : String (1 .. 256);
Res_Len : Natural range 0 .. 256 := 0;
-- bad solution!!! ASIS needs a general-purpose String buffer
-- somewhere!!! ???
Real : constant Ureal := Realval (N);
Nom : constant Uint := Norm_Num (Real);
Den : constant Uint := Norm_Den (Real);
Dot_Outputed : Boolean := False;
begin
if UR_Is_Negative (Real) then
Res_Len := Res_Len + 1;
Result (Res_Len) := '(';
Res_Len := Res_Len + 1;
Result (Res_Len) := '-';
end if;
UI_Image (Nom, Decimal);
for I in 1 .. UI_Image_Length loop
if UI_Image_Buffer (I) = 'E' then
Res_Len := Res_Len + 1;
Result (Res_Len) := '.';
Res_Len := Res_Len + 1;
Result (Res_Len) := '0';
Res_Len := Res_Len + 1;
Result (Res_Len) := 'E';
Dot_Outputed := True;
else
Res_Len := Res_Len + 1;
Result (Res_Len) := UI_Image_Buffer (I);
end if;
end loop;
if not Dot_Outputed then
Res_Len := Res_Len + 1;
Result (Res_Len) := '.';
Res_Len := Res_Len + 1;
Result (Res_Len) := '0';
end if;
Dot_Outputed := False;
Res_Len := Res_Len + 1;
Result (Res_Len) := '/';
UI_Image (Den, Decimal);
for I in 1 .. UI_Image_Length loop
if UI_Image_Buffer (I) = 'E' then
Res_Len := Res_Len + 1;
Result (Res_Len) := '.';
Res_Len := Res_Len + 1;
Result (Res_Len) := '0';
Res_Len := Res_Len + 1;
Result (Res_Len) := 'E';
Dot_Outputed := True;
else
Res_Len := Res_Len + 1;
Result (Res_Len) := UI_Image_Buffer (I);
end if;
end loop;
if not Dot_Outputed then
Res_Len := Res_Len + 1;
Result (Res_Len) := '.';
Res_Len := Res_Len + 1;
Result (Res_Len) := '0';
end if;
if UR_Is_Negative (Real) then
Res_Len := Res_Len + 1;
Result (Res_Len) := ')';
end if;
return Result (1 .. Res_Len);
end Ureal_Image;
end A4G.Mapping;
| 8211 | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . M A P P I N G --
-- --
-- B o d y --
-- --
-- Copyright (C) 1995-2012, Free Software Foundation, Inc. --
-- --
-- ASIS-for-GNAT is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore --
-- (http://www.ad<EMAIL>.com). --
-- --
------------------------------------------------------------------------------
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Asis; use Asis;
with Asis.Compilation_Units; use Asis.Compilation_Units;
with Asis.Elements; use Asis.Elements;
with Asis.Set_Get; use Asis.Set_Get;
with A4G.A_Debug; use A4G.A_Debug;
with A4G.A_Output; use A4G.A_Output;
with A4G.A_Sem; use A4G.A_Sem;
with A4G.A_Sinput; use A4G.A_Sinput;
with A4G.Asis_Tables; use A4G.Asis_Tables;
with A4G.Contt; use A4G.Contt;
with A4G.Norm; use A4G.Norm;
with A4G.Vcheck; use A4G.Vcheck;
with Atree; use Atree;
with Einfo; use Einfo;
with Elists; use Elists;
with Namet; use Namet;
with Nlists; use Nlists;
with Output; use Output;
with Snames; use Snames;
with Stand; use Stand;
with Uintp; use Uintp;
with Urealp; use Urealp;
package body A4G.Mapping is
-------------------------------------------
-- Tree nodes onto ASIS Elements Mapping --
-------------------------------------------
-- The kernel of the mapping from tree nodes onto ASIS Elements is
-- determining the ASIS kind of the Element which should be built on top
-- of a given node. We are computing the Element position in the internal
-- flat classification, that is, the corresponding value of
-- Internal_Element_Kinds (which is further referred simply as Element
-- kind in this unit).
--
-- Mapping of tree nodes onto Element kinds is implemented as two-level
-- switching based on look-up tables. Both look-up tables are one-dimension
-- arrays indexed by Node_Kind type).
--
-- The first table has Internal_Element_Kinds as its component type. It
-- defines the mapping of Node_Kind values onto Internal_Element_Kinds
-- values as pairs index_value -> component_value, the semantics of this
-- mapping depends on the component value in the following way:
--
-- Component value First switch mapping semantics
--
-- A_Xxx, where A_Xxx corresponds - Element which should be based on
-- to some position in the original any node having the corresponding
-- ASIS element classification Node_Kind will always be of A_Xxx
-- hierarchy (such as An_Identifier) ASIS kind, no more computation
-- of Element kind is needed
--
-- Non_Trivial_Mapping - Elements which can be built on
-- nodes having the corresponding
-- Node_Kind may have different ASIS
-- kinds, therefore a special function
-- computing the ASIS kind should be
-- used, this function is defined by
-- the second look-up table
--
-- No_Mapping - no ASIS Element kind corresponds to
-- nodes of the corresponding
-- Node_Kind in the framework of the
-- given node-to-Element mapping
--
-- Not_Implemented_Mapping - this value was used during the
-- development phase and now it is
-- kept as the value for 'others'
-- choice in the initialization
-- aggregate just in case if a new
-- value appear in Node_Kind type
--
-- No_Mapping does not mean, that for a given Node_Kind value no Element
-- can be created at all, it means, that automatic Element kind
-- determination is impossible for these nodes because of any reason.
--
-- Both No_Mapping and Not_Implemented_Mapping mapping items, when chosen.
-- resulted in raising the ASIS_Failed exception. The reason because of
-- which we keep Not_Implemented_Mapping value after finishing the
-- development stage is to catch possible changes in Node_Kind definition.
-- No_Mapping means that for sure there is no mapping for a given Node_Kind
-- value, and Not_Implemented_Mapping means that processing of the given
-- Node_Kind value is missed in the existing code.
--
-- The second look-up table defines functions to be used to compute
-- Element kind for those Node_Kind values for which the first table
-- defines Non_Trivial_Mapping. All these functions are supposed to be
-- called for nodes of the Node_Kind from the corresponding mapping item
-- defined by the second table, it is erroneous to call them for other
-- nodes.
--
-- The structure, documentation and naming policy for look-up tables
-- implementing note-to-Element mapping are based on the GNAT Sinfo
-- package, and, in particular, on the Sinfo.Node_Kind type definition.
-- Rather old version of the spec of Sinfo is used, so some deviations
-- with the latest version may be possible
------------------------------------------------------
-- Tree nodes lists onto ASIS Element lists Mapping --
------------------------------------------------------
-- ASIS Element lists are built from tree node lists: when constructing an
-- ASIS Element_List value, the corresponding routine goes trough the
-- corresponding tree node list, checks which nodes should be used as a
-- basis for ASIS Elements to be placed in the result Element_List, and
-- which should not, and then calls node-to-Element conversion function
-- for the selected nodes. Therefore, two main components of node list to
-- Element list mapping are filters for the nodes in the argument node
-- list and node-to-Element mapping
-----------------------
-- Local subprograms --
-----------------------
procedure Normalize_Name (Capitalized : Boolean := False);
-- This procedure "normalizes" a name stored in Namet.Name_Buffer by
-- capitalizing its firs letter and all the letters following underscores
-- (if any). If Capitalized is set ON, all the letters are converted to
-- upper case, this is used for some defining names from Standard (such as
-- ASCII)
function Is_Protected_Procedure_Call (N : Node_Id) return Boolean;
-- In case if N is of N_Entry_Call_Statement, it checks if this is a call
-- to a protected subprogram (if it is, the corresponding ASIS Element
-- should be classified as A_Procedure_Call_Statement, but not as
-- An_Entry_Call_Statement
function Is_Stub_To_Body_Instanse_Replacement
(N : Node_Id)
return Boolean;
-- Checks if the node corresponds to the body which replaces the body stub
-- within the instance. The reason why we need this is that Sloc
-- field is not set to point into the instance copy if the source for
-- such node, so the ordinary Is_From_Instance check does not work
-- for this node (see 8930-001)
function Is_Config_Pragma (N : Node_Id) return Boolean;
-- Checks if N represents a configuration pragma
function Requires_Parentheses
(N : Node_Id)
return Boolean;
-- Checks if N represents a conditional or quantified expression in the
-- context that requires the expression to be in parentheses. The problem
-- is that in this case Parent_Count is 0. This function is supposed to be
-- called if Parent_Count (N) = 0
--------------------------------------------------------------
-- Subprograms for the second Note-to-Element Look-Up Table --
--------------------------------------------------------------
procedure No_Mapping (Node : Node_Id);
function Not_Implemented_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
procedure Not_Implemented_Mapping (Source_Node_Kind : Node_Kind);
-- These three subprograms raise ASIS_Failed with the appropriate
-- Diagnosis string
pragma No_Return (Not_Implemented_Mapping);
pragma No_Return (No_Mapping);
-- Individual mapping components:
function N_Pragma_Mapping (Node : Node_Id) return Internal_Element_Kinds;
function N_Defining_Identifier_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Defining_Operator_Symbol_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Expanded_Name_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Identifier_Mapping
(Node : Node_Id)
return Internal_Element_Kinds renames N_Expanded_Name_Mapping;
function N_Attribute_Reference_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Function_Call_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Range_Mapping (Node : Node_Id) return Internal_Element_Kinds;
function N_Allocator_Mapping (Node : Node_Id) return Internal_Element_Kinds;
function N_Aggregate_Mapping (Node : Node_Id) return Internal_Element_Kinds;
-- |A2005 start
function N_Incomplete_Type_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
-- |A2005 end
function N_Subtype_Indication_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
-- |A2012 start
function N_Formal_Type_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Iterator_Specification_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Quantified_Expression_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
-- |A2012 end
function N_Object_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Access_Function_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Access_Procedure_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Subprogram_Body_Stub_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Subprogram_Body_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Generic_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Constrained_Array_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Unconstrained_Array_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Subprogram_Renaming_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Loop_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Requeue_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Abstract_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Accept_Alternative_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
-- --|A2005 start
function N_Access_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
-- --|A2005 end
function N_Access_To_Object_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Component_Association_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Derived_Type_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Delay_Alternative_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Formal_Package_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Formal_Private_Type_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Formal_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Index_Or_Discriminant_Constraint_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Number_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Procedure_Call_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Range_Constraint_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Record_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Use_Type_Clause_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Terminate_Alternative_Mapping
(Node : Node_Id)
return Internal_Element_Kinds renames N_Accept_Alternative_Mapping;
-----------------------------------------
-- Node lists to Element lists filters --
-----------------------------------------
function May_Be_Included (Node : Node_Id) return Boolean;
-- Top-level filter for selecting nodes from a node list to be used to
-- create ASIS Elements which are members of some ASIS Element List.
function Ordinary_Inclusion_Condition (Node : Node_Id) return Boolean;
-- Defines the general condition for a separate node list member to be
-- used to construct an Element to be returned by some ASIS query. This
-- function does not make the final decision, because the node may be
-- duplicated, and this is checked in the May_Be_Included function
procedure Skip_Normalized_Declarations (Node : in out Node_Id);
-- This procedure is applied in case when the compiler normalizes a
-- multi-identifier declaration (or multi-name with clause) in a set of
-- equivalent one-identifier (one-name) declarations (clauses). It is
-- intended to be called for Node representing the first declaration
-- (clause) in this normalized sequence, and it resets its parameter
-- to point to the last declaration (clause) in this sequence
-----------------------------------------
-- Node-to-Element First Look-Up Table --
-----------------------------------------
Node_To_Element_Kind_Mapping_First_Switch :
constant array (Node_Kind) of Internal_Element_Kinds := (
N_Unused_At_Start => No_Mapping,
N_At_Clause => An_At_Clause,
N_Component_Clause => A_Component_Clause,
N_Enumeration_Representation_Clause => An_Enumeration_Representation_Clause,
N_Mod_Clause => No_Mapping,
N_Record_Representation_Clause => A_Record_Representation_Clause,
N_Attribute_Definition_Clause => An_Attribute_Definition_Clause,
N_Empty => No_Mapping,
N_Error => No_Mapping,
N_Pragma => Non_Trivial_Mapping,
N_Pragma_Argument_Association => A_Pragma_Argument_Association,
N_Defining_Character_Literal => A_Defining_Character_Literal,
N_Defining_Identifier => Non_Trivial_Mapping,
N_Defining_Operator_Symbol => Non_Trivial_Mapping,
N_Expanded_Name => Non_Trivial_Mapping,
N_Identifier => Non_Trivial_Mapping,
N_Character_Literal => A_Character_Literal,
N_Operator_Symbol => Non_Trivial_Mapping,
N_Op_Add => A_Function_Call,
N_Op_And => A_Function_Call,
N_And_Then => An_And_Then_Short_Circuit,
N_Op_Concat => A_Function_Call,
N_Op_Divide => A_Function_Call,
N_Op_Eq => A_Function_Call,
N_Op_Expon => A_Function_Call,
N_Op_Ge => A_Function_Call,
N_Op_Gt => A_Function_Call,
-- N_In => Non_Trivial_Mapping,
N_In => An_In_Membership_Test,
N_Op_Le => A_Function_Call,
N_Op_Lt => A_Function_Call,
N_Op_Mod => A_Function_Call,
N_Op_Multiply => A_Function_Call,
N_Op_Ne => A_Function_Call,
-- N_Not_In => Non_Trivial_Mapping,
N_Not_In => A_Not_In_Membership_Test,
N_Op_Or => A_Function_Call,
N_Or_Else => An_Or_Else_Short_Circuit,
N_Op_Rem => A_Function_Call,
N_Op_Subtract => A_Function_Call,
N_Op_Xor => A_Function_Call,
N_Op_Abs => A_Function_Call,
N_Op_Minus => A_Function_Call,
N_Op_Not => A_Function_Call,
N_Op_Plus => A_Function_Call,
N_Attribute_Reference => Non_Trivial_Mapping,
N_Conditional_Expression => An_If_Expression,
N_Explicit_Dereference => An_Explicit_Dereference,
N_Function_Call => Non_Trivial_Mapping,
N_Indexed_Component => An_Indexed_Component,
N_Integer_Literal => An_Integer_Literal,
N_Null => A_Null_Literal,
N_Procedure_Call_Statement => Non_Trivial_Mapping,
N_Qualified_Expression => A_Qualified_Expression,
N_Quantified_Expression => Non_Trivial_Mapping,
N_Raise_Constraint_Error => No_Mapping,
N_Range => Non_Trivial_Mapping,
N_Real_Literal => A_Real_Literal,
N_Selected_Component => A_Selected_Component,
N_Type_Conversion => A_Type_Conversion,
N_Allocator => Non_Trivial_Mapping,
N_Case_Expression => A_Case_Expression, -- ASIS 2012
N_Aggregate => Non_Trivial_Mapping,
N_Extension_Aggregate => An_Extension_Aggregate,
N_Slice => A_Slice,
N_String_Literal => A_String_Literal,
N_Subtype_Indication => Non_Trivial_Mapping,
N_Component_Declaration => A_Component_Declaration,
N_Entry_Body => An_Entry_Body_Declaration,
N_Entry_Declaration => An_Entry_Declaration,
-- N_Expression_Function => An_Expression_Function_Declaration, (SCz)
N_Entry_Index_Specification => An_Entry_Index_Specification,
N_Formal_Object_Declaration => A_Formal_Object_Declaration,
N_Formal_Type_Declaration => Non_Trivial_Mapping,
N_Freeze_Entity => No_Mapping,
N_Full_Type_Declaration => An_Ordinary_Type_Declaration,
-- --|A2005 start
-- N_Incomplete_Type_Declaration => An_Incomplete_Type_Declaration,
N_Incomplete_Type_Declaration => Non_Trivial_Mapping,
-- --|A2005 end
-- --|A2012 start
N_Iterator_Specification => Non_Trivial_Mapping,
-- --|A2012 end
N_Loop_Parameter_Specification => A_Loop_Parameter_Specification,
N_Object_Declaration => Non_Trivial_Mapping,
N_Private_Extension_Declaration => A_Private_Extension_Declaration,
N_Private_Type_Declaration => A_Private_Type_Declaration,
N_Subtype_Declaration => A_Subtype_Declaration,
N_Protected_Type_Declaration => A_Protected_Type_Declaration,
N_Accept_Statement => An_Accept_Statement,
N_Function_Specification => No_Mapping,
N_Procedure_Specification => No_Mapping,
N_Access_Function_Definition => Non_Trivial_Mapping,
N_Access_Procedure_Definition => Non_Trivial_Mapping,
N_Task_Type_Declaration => A_Task_Type_Declaration,
N_Package_Body_Stub => A_Package_Body_Stub,
N_Protected_Body_Stub => A_Protected_Body_Stub,
N_Subprogram_Body_Stub => Non_Trivial_Mapping,
N_Task_Body_Stub => A_Task_Body_Stub,
N_Function_Instantiation => A_Function_Instantiation,
N_Package_Instantiation => A_Package_Instantiation,
N_Procedure_Instantiation => A_Procedure_Instantiation,
N_Package_Body => A_Package_Body_Declaration,
N_Subprogram_Body => Non_Trivial_Mapping,
N_Implicit_Label_Declaration => No_Mapping,
N_Package_Declaration => A_Package_Declaration,
N_Single_Task_Declaration => A_Single_Task_Declaration,
N_Subprogram_Declaration => Non_Trivial_Mapping,
N_Task_Body => A_Task_Body_Declaration,
N_Use_Package_Clause => A_Use_Package_Clause,
N_Generic_Package_Declaration => A_Generic_Package_Declaration,
N_Generic_Subprogram_Declaration => Non_Trivial_Mapping,
N_Constrained_Array_Definition => Non_Trivial_Mapping,
N_Unconstrained_Array_Definition => Non_Trivial_Mapping,
N_Exception_Renaming_Declaration => An_Exception_Renaming_Declaration,
N_Object_Renaming_Declaration => An_Object_Renaming_Declaration,
N_Package_Renaming_Declaration => A_Package_Renaming_Declaration,
N_Subprogram_Renaming_Declaration => Non_Trivial_Mapping,
N_Generic_Function_Renaming_Declaration =>
A_Generic_Function_Renaming_Declaration,
N_Generic_Package_Renaming_Declaration =>
A_Generic_Package_Renaming_Declaration,
N_Generic_Procedure_Renaming_Declaration =>
A_Generic_Procedure_Renaming_Declaration,
N_Abort_Statement => An_Abort_Statement,
N_Assignment_Statement => An_Assignment_Statement,
N_Block_Statement => A_Block_Statement,
N_Case_Statement => A_Case_Statement,
N_Code_Statement => A_Code_Statement,
N_Delay_Relative_Statement => A_Delay_Relative_Statement,
N_Delay_Until_Statement => A_Delay_Until_Statement,
N_Entry_Call_Statement => An_Entry_Call_Statement,
N_Exit_Statement => An_Exit_Statement,
N_Free_Statement => No_Mapping,
N_Goto_Statement => A_Goto_Statement,
N_If_Statement => An_If_Statement,
N_Loop_Statement => Non_Trivial_Mapping,
N_Null_Statement => A_Null_Statement,
N_Raise_Statement => A_Raise_Statement,
N_Requeue_Statement => Non_Trivial_Mapping,
N_Return_Statement => A_Return_Statement,
N_Extended_Return_Statement => An_Extended_Return_Statement,
N_Abortable_Part => A_Then_Abort_Path,
N_Abstract_Subprogram_Declaration => Non_Trivial_Mapping,
N_Accept_Alternative => Non_Trivial_Mapping,
-- --|A2005 start
N_Access_Definition => Non_Trivial_Mapping,
-- --|A2005 end
N_Access_To_Object_Definition => Non_Trivial_Mapping,
-- --|A2012 start
N_Aspect_Specification => An_Aspect_Specification,
N_Case_Expression_Alternative => A_Case_Expression_Path,
-- --|A2012 end
N_Asynchronous_Select => An_Asynchronous_Select_Statement,
N_Case_Statement_Alternative => A_Case_Path,
N_Compilation_Unit => No_Mapping,
N_Component_Association => Non_Trivial_Mapping,
N_Component_Definition => A_Component_Definition,
N_Conditional_Entry_Call => A_Conditional_Entry_Call_Statement,
N_Derived_Type_Definition => Non_Trivial_Mapping,
N_Decimal_Fixed_Point_Definition => A_Decimal_Fixed_Point_Definition,
N_Defining_Program_Unit_Name => A_Defining_Expanded_Name,
N_Delay_Alternative => Non_Trivial_Mapping,
N_Delta_Constraint => A_Delta_Constraint,
N_Digits_Constraint => A_Digits_Constraint,
N_Discriminant_Association => A_Discriminant_Association,
N_Discriminant_Specification => A_Discriminant_Specification,
N_Elsif_Part => An_Elsif_Path,
N_Enumeration_Type_Definition => An_Enumeration_Type_Definition,
N_Entry_Call_Alternative => A_Select_Path,
N_Exception_Declaration => An_Exception_Declaration,
N_Exception_Handler => An_Exception_Handler,
N_Floating_Point_Definition => A_Floating_Point_Definition,
N_Formal_Decimal_Fixed_Point_Definition =>
A_Formal_Decimal_Fixed_Point_Definition,
N_Formal_Derived_Type_Definition => A_Formal_Derived_Type_Definition,
N_Formal_Discrete_Type_Definition => A_Formal_Discrete_Type_Definition,
N_Formal_Floating_Point_Definition => A_Formal_Floating_Point_Definition,
N_Formal_Modular_Type_Definition => A_Formal_Modular_Type_Definition,
N_Formal_Ordinary_Fixed_Point_Definition =>
A_Formal_Ordinary_Fixed_Point_Definition,
N_Formal_Package_Declaration => Non_Trivial_Mapping,
N_Formal_Private_Type_Definition => Non_Trivial_Mapping,
N_Formal_Signed_Integer_Type_Definition =>
A_Formal_Signed_Integer_Type_Definition,
N_Formal_Subprogram_Declaration => Non_Trivial_Mapping,
N_Generic_Association => A_Generic_Association,
N_Index_Or_Discriminant_Constraint => Non_Trivial_Mapping,
N_Label => No_Mapping,
N_Modular_Type_Definition => A_Modular_Type_Definition,
N_Number_Declaration => Non_Trivial_Mapping,
N_Ordinary_Fixed_Point_Definition => An_Ordinary_Fixed_Point_Definition,
N_Others_Choice => An_Others_Choice,
N_Package_Specification => No_Mapping,
N_Parameter_Association => A_Parameter_Association,
N_Parameter_Specification => A_Parameter_Specification,
N_Protected_Body => A_Protected_Body_Declaration,
N_Protected_Definition => A_Protected_Definition,
N_Range_Constraint => Non_Trivial_Mapping,
N_Real_Range_Specification => A_Simple_Expression_Range,
N_Record_Definition => Non_Trivial_Mapping,
N_Selective_Accept => A_Selective_Accept_Statement,
N_Signed_Integer_Type_Definition => A_Signed_Integer_Type_Definition,
N_Single_Protected_Declaration => A_Single_Protected_Declaration,
N_Subunit => No_Mapping,
N_Task_Definition => A_Task_Definition,
N_Terminate_Alternative => Non_Trivial_Mapping,
N_Timed_Entry_Call => A_Timed_Entry_Call_Statement,
N_Triggering_Alternative => A_Select_Path,
N_Use_Type_Clause => Non_Trivial_Mapping,
N_Variant => A_Variant,
N_Variant_Part => A_Variant_Part,
N_With_Clause => A_With_Clause,
N_Unused_At_End => No_Mapping,
others => Not_Implemented_Mapping);
------------------------------------------
-- Node-to-Element Second Look-Up Table --
------------------------------------------
type Mapping_Item is access function (Node : Node_Id)
return Internal_Element_Kinds;
Node_To_Element_Kind_Mapping_Second_Switch :
constant array (Node_Kind) of Mapping_Item := (
N_Pragma => N_Pragma_Mapping'Access,
N_Defining_Identifier => N_Defining_Identifier_Mapping'Access,
N_Defining_Operator_Symbol => N_Defining_Operator_Symbol_Mapping'Access,
N_Expanded_Name => N_Expanded_Name_Mapping'Access,
N_Identifier => N_Identifier_Mapping'Access,
N_Operator_Symbol => N_Operator_Symbol_Mapping'Access,
N_Attribute_Reference => N_Attribute_Reference_Mapping'Access,
N_Function_Call => N_Function_Call_Mapping'Access,
N_Quantified_Expression => N_Quantified_Expression_Mapping'Access,
N_Range => N_Range_Mapping'Access,
N_Allocator => N_Allocator_Mapping'Access,
N_Aggregate => N_Aggregate_Mapping'Access,
N_Subtype_Indication => N_Subtype_Indication_Mapping'Access,
-- --|A2012 start
N_Formal_Type_Declaration => N_Formal_Type_Declaration_Mapping'Access,
-- --|A2012 end
-- --|A2005 start
-- N_Incomplete_Type_Declaration => An_Incomplete_Type_Declaration,
N_Incomplete_Type_Declaration =>
N_Incomplete_Type_Declaration_Mapping'Access,
-- --|A2005 end
-- --|A2012 start
N_Iterator_Specification => N_Iterator_Specification_Mapping'Access,
-- --|A2012 end
N_Object_Declaration => N_Object_Declaration_Mapping'Access,
N_Access_Function_Definition =>
N_Access_Function_Definition_Mapping'Access,
N_Access_Procedure_Definition =>
N_Access_Procedure_Definition_Mapping'Access,
N_Subprogram_Body_Stub => N_Subprogram_Body_Stub_Mapping'Access,
N_Subprogram_Body => N_Subprogram_Body_Mapping'Access,
N_Subprogram_Declaration => N_Subprogram_Declaration_Mapping'Access,
N_Generic_Subprogram_Declaration =>
N_Generic_Subprogram_Declaration_Mapping'Access,
N_Constrained_Array_Definition =>
N_Constrained_Array_Definition_Mapping'Access,
N_Unconstrained_Array_Definition =>
N_Unconstrained_Array_Definition_Mapping'Access,
N_Subprogram_Renaming_Declaration =>
N_Subprogram_Renaming_Declaration_Mapping'Access,
N_Loop_Statement => N_Loop_Statement_Mapping'Access,
N_Requeue_Statement => N_Requeue_Statement_Mapping'Access,
N_Abstract_Subprogram_Declaration =>
N_Abstract_Subprogram_Declaration_Mapping'Access,
N_Accept_Alternative => N_Accept_Alternative_Mapping'Access,
-- --|A2005 start
N_Access_Definition => N_Access_Definition_Mapping'Access,
-- --|A2005 end
N_Access_To_Object_Definition =>
N_Access_To_Object_Definition_Mapping'Access,
N_Component_Association => N_Component_Association_Mapping'Access,
N_Derived_Type_Definition => N_Derived_Type_Definition_Mapping'Access,
N_Delay_Alternative => N_Delay_Alternative_Mapping'Access,
N_Formal_Package_Declaration =>
N_Formal_Package_Declaration_Mapping'Access,
N_Formal_Private_Type_Definition =>
N_Formal_Private_Type_Definition_Mapping'Access,
N_Formal_Subprogram_Declaration =>
N_Formal_Subprogram_Declaration_Mapping'Access,
N_Index_Or_Discriminant_Constraint =>
N_Index_Or_Discriminant_Constraint_Mapping'Access,
N_Number_Declaration => N_Number_Declaration_Mapping'Access,
N_Range_Constraint => N_Range_Constraint_Mapping'Access,
N_Record_Definition => N_Record_Definition_Mapping'Access,
N_Terminate_Alternative => N_Terminate_Alternative_Mapping'Access,
N_Use_Type_Clause => N_Use_Type_Clause_Mapping'Access,
N_Procedure_Call_Statement => N_Procedure_Call_Statement_Mapping'Access,
others => Not_Implemented_Mapping'Access);
----------------------------------------------------
-- Node List to Element List Filter Look-Up Table --
----------------------------------------------------
-- The following look-up table defines the first, very rough filter for
-- selecting node list elements to be used as a basis for ASIS Element
-- list components: it defines which Node_Kind values could never be used
-- for creating Elements in Element List (for them False is set in the
-- table)
May_Be_Included_Switch : constant array (Node_Kind) of Boolean := (
N_Unused_At_Start => False,
N_Freeze_Entity => False,
N_Implicit_Label_Declaration => False,
N_Label => False,
others => True);
--------------------------------
-- Asis_Internal_Element_Kind --
--------------------------------
function Asis_Internal_Element_Kind
(Node : Node_Id)
return Internal_Element_Kinds
is
Mapping_Case : Internal_Element_Kinds;
Source_Node_Kind : Node_Kind;
begin -- two-level switching only!
Source_Node_Kind := Nkind (Node);
Mapping_Case := Node_To_Element_Kind_Mapping_First_Switch
(Source_Node_Kind);
case Mapping_Case is
when Non_Trivial_Mapping =>
return Node_To_Element_Kind_Mapping_Second_Switch
(Source_Node_Kind) (Node);
when Not_Implemented_Mapping =>
Not_Implemented_Mapping (Source_Node_Kind);
when No_Mapping =>
No_Mapping (Node);
when others => -- all trivial cases!
return Mapping_Case;
end case;
end Asis_Internal_Element_Kind;
--------------------------------------
-- Defining_Id_List_From_Normalized --
--------------------------------------
function Defining_Id_List_From_Normalized
(N : Node_Id;
From_Declaration : Asis.Element)
return Asis.Defining_Name_List
is
Res_Max_Len : constant Natural :=
Natural (List_Length (List_Containing (N)));
-- to avoid two loops through the list of declarations/specifications,
-- we use the rough estimation of the length of the result
-- Defining_Name_List - it cannot contain more elements that the
-- number of nodes in the tree node list containing (normalized)
-- declarations
Res_Act_Len : Natural := 1;
-- the actual number of defining identifiers in the normalized
-- declaration
Result_List : Defining_Name_List (1 .. Res_Max_Len);
Decl_Node : Node_Id := N;
Decl_Nkind : constant Node_Kind := Nkind (Decl_Node);
Def_Id_Node : Node_Id;
begin
Def_Id_Node := Defining_Identifier (Decl_Node);
Result_List (Res_Act_Len) :=
Node_To_Element_New (Node => Def_Id_Node,
Starting_Element => From_Declaration,
Internal_Kind => A_Defining_Identifier);
while More_Ids (Decl_Node) loop
Decl_Node := Next (Decl_Node);
while Nkind (Decl_Node) /= Decl_Nkind loop
-- some implicit subtype declarations may be inserted by
-- the compiler in between the normalized declarations, so:
Decl_Node := Next (Decl_Node);
end loop;
Def_Id_Node := Defining_Identifier (Decl_Node);
Res_Act_Len := Res_Act_Len + 1;
Result_List (Res_Act_Len) :=
Node_To_Element_New (Node => Def_Id_Node,
Starting_Element => From_Declaration,
Internal_Kind => A_Defining_Identifier);
end loop;
return Result_List (1 .. Res_Act_Len);
end Defining_Id_List_From_Normalized;
------------------------------------------
-- Discrete_Choice_Node_To_Element_List --
------------------------------------------
function Discrete_Choice_Node_To_Element_List
(Choice_List : List_Id;
Starting_Element : Asis.Element)
return Asis.Element_List
is
Result_List : Asis.Element_List
(1 .. ASIS_Integer (List_Length (Choice_List)));
-- List_Length (Choice_List) cannot be 0 for the DISCRETE_CHOICE_LIST!
Current_Node : Node_Id;
Current_Original_Node : Node_Id;
Element_Already_Composed : Boolean;
Result_Kind : Internal_Element_Kinds;
begin
Current_Node := First (Choice_List);
-- first list element to process cannot be Empty!
Current_Original_Node := Original_Node (Current_Node);
for I in 1 .. ASIS_Integer (List_Length (Choice_List)) loop
Element_Already_Composed := False;
if Paren_Count (Current_Original_Node) > 0 then
-- Corner but legal case of discrete choice like
--
-- when (1) =>
--
-- or
--
-- When (A.B.C) =>
Result_Kind := Not_An_Element;
else
case Nkind (Current_Original_Node) is
-- DISCRETE_CHOICE_LIST ::= DISCRETE_CHOICE {| DISCRETE_CHOICE}
-- DISCRETE_CHOICE ::= EXPRESSION | DISCRETE_RANGE | others
when N_Others_Choice => -- DISCRETE_CHOICE ::= ... | others
Result_Kind := An_Others_Choice;
-- DISCRETE_CHOICE ::= ... | DISCRETE_RANGE | ...
-- DISCRETE_RANGE ::= discrete_SUBTYPE_INDICATION | RANGE
when N_Subtype_Indication =>
-- DISCRETE_RANGE ::= discrete_SUBTYPE_INDICATION | ...
--
-- The problem is that GNAT reduces the subtype_indication
-- having NO constraint directly to subtype_mark
-- (-> N_Identifier, N_Expanded_Name). May be, it is a
-- pathological case, but it can also be represented by
-- ...'Base construction (-> N_Attribute_Reference)
Result_Kind := A_Discrete_Subtype_Indication;
when N_Identifier =>
if Ekind (Entity (Current_Original_Node)) in Discrete_Kind then
-- discrete subtype mark!!
Result_Kind := A_Discrete_Subtype_Indication;
elsif Ekind (Entity (Current_Original_Node)) =
E_Enumeration_Literal
then
Result_Kind := An_Enumeration_Literal;
else
Result_Kind := An_Identifier;
end if;
when N_Expanded_Name =>
if Ekind (Entity (Current_Original_Node)) in Discrete_Kind then
-- discrete subtype mark!!
Result_Kind := A_Discrete_Subtype_Indication;
else
-- expression
Result_Kind := A_Selected_Component;
end if;
-- DISCRETE_RANGE ::= ... | RANGE
-- RANGE ::=
-- RANGE_ATTRIBUTE_REFERENCE
-- | SIMPLE_EXPRESSION .. SIMPLE_EXPRESSION
when N_Range =>
-- RANGE ::= ...
-- | SIMPLE_EXPRESSION .. SIMPLE_EXPRESSION
Result_Kind := A_Discrete_Simple_Expression_Range;
when N_Attribute_Reference =>
-- RANGE ::= RANGE_ATTRIBUTE_REFERENCE | ...
-- Sinfo.ads:
-- A range attribute designator is represented
-- in the tree using the normal N_Attribute_Reference
-- node.
-- But if the tree corresponds to the compilable Compilation
-- Unit, the RANGE_ATTRIBUTE_REFERENCE is the only construct
-- which could be in this position --W_R_O_N_G !!! T'Base!!!
if Attribute_Name (Current_Original_Node) = Name_Range then
Result_Kind := A_Discrete_Range_Attribute_Reference;
else
-- attribute denoting a type/subtype or yielding a value:
Result_List (I) := Node_To_Element_New (
Node => Current_Node,
Starting_Element => Starting_Element);
Element_Already_Composed := True;
end if;
-- DISCRETE_CHOICE ::= EXPRESSION | ...
when others =>
-- In the tree corresponding to the compilable Compilation
-- Unit the only possibility in the others choice is the
-- EXPRESSION as the DISCRETE_CHOICE.
Result_List (I) := Node_To_Element_New (
Node => Current_Node,
Starting_Element => Starting_Element);
Element_Already_Composed := True;
end case;
end if;
if not Element_Already_Composed then
Result_List (I) := Node_To_Element_New (
Node => Current_Node,
Internal_Kind => Result_Kind,
Starting_Element => Starting_Element);
end if;
Current_Node := Next (Current_Node);
Current_Original_Node := Original_Node (Current_Node);
end loop;
return Result_List;
end Discrete_Choice_Node_To_Element_List;
----------------------
-- Is_Config_Pragma --
----------------------
function Is_Config_Pragma (N : Node_Id) return Boolean is
begin
return True
and then Nkind (N) = N_Pragma
and then Pragma_Name (N) in
First_Pragma_Name .. Last_Configuration_Pragma_Name;
end Is_Config_Pragma;
-------------------------------
-- Is_GNAT_Attribute_Routine --
-------------------------------
function Is_GNAT_Attribute_Routine (N : Node_Id) return Boolean is
Attribute_Chars : Name_Id;
Result : Boolean := False;
begin
Attribute_Chars := Attribute_Name (N);
if Attribute_Chars = Name_Asm_Input or else
Attribute_Chars = Name_Asm_Output or else
Attribute_Chars = Name_Enum_Rep or else
Attribute_Chars = Name_Enum_Val or else
Attribute_Chars = Name_Fixed_Value or else
Attribute_Chars = Name_Integer_Value or else
Attribute_Chars = Name_Ref
then
Result := True;
end if;
return Result;
end Is_GNAT_Attribute_Routine;
-------------------------------------------
-- Is_Rewritten_Function_Prefix_Notation --
-------------------------------------------
function Is_Rewritten_Function_Prefix_Notation
(N : Node_Id)
return Boolean
is
Result : Boolean := False;
begin
if Nkind (N) = N_Function_Call
and then
Is_Rewrite_Substitution (N)
and then
Nkind (Original_Node (N)) not in N_Op
and then
Present (Parameter_Associations (N))
and then
not Is_Empty_List (Parameter_Associations (N))
and then
Sloc (First (Parameter_Associations (N))) < Sloc (Sinfo.Name (N))
then
Result := True;
end if;
return Result;
end Is_Rewritten_Function_Prefix_Notation;
------------------------------------------------------
-- Is_Rewritten_Impl_Deref_Function_Prefix_Notation --
------------------------------------------------------
function Is_Rewritten_Impl_Deref_Function_Prefix_Notation
(N : Node_Id)
return Boolean
is
Result : Boolean := False;
begin
if Nkind (N) = N_Function_Call
and then
Present (Parameter_Associations (N))
and then
not Is_Empty_List (Parameter_Associations (N))
and then
Sloc (First (Parameter_Associations (N))) < Sloc (Sinfo.Name (N))
then
Result := True;
end if;
return Result;
end Is_Rewritten_Impl_Deref_Function_Prefix_Notation;
-----------------------------------
-- Get_Next_Configuration_Pragma --
-----------------------------------
function Get_Next_Configuration_Pragma (N : Node_Id) return Node_Id is
Result : Node_Id := N;
begin
while not (Is_Config_Pragma (Result) or else
No (Result))
loop
Result := Next (Result);
end loop;
return Result;
end Get_Next_Configuration_Pragma;
----------------------------
-- Is_Not_Duplicated_Decl --
----------------------------
function Is_Not_Duplicated_Decl (Node : Node_Id) return Boolean is
Prev_List_Elem : Node_Id;
begin
-- the idea is to check if the previous list member (and we are
-- sure that Node itself is a list member) to be included
-- in the list is the rewritten tree structure representing
-- just the same Ada construct
--
-- If we change Prev_Non_Pragma to Next_Non_Pragma, then this
-- function will return False for the first, but not for the second
-- of the two duplicated declarations
if not (Nkind (Node) = N_Full_Type_Declaration or else
Nkind (Node) = N_Private_Type_Declaration or else
Nkind (Node) = N_Subtype_Declaration)
then
return True;
-- as far as we know for now, the problem of duplicated
-- declaration exists only for type declarations
end if;
Prev_List_Elem := Prev_Non_Pragma (Node);
while Present (Prev_List_Elem) loop
if Ordinary_Inclusion_Condition (Prev_List_Elem)
and then
(Nkind (Prev_List_Elem) = N_Full_Type_Declaration or else
Nkind (Prev_List_Elem) = N_Subtype_Declaration)
and then
Chars (Defining_Identifier (Prev_List_Elem)) =
Chars (Defining_Identifier (Node))
then
return False;
end if;
Prev_List_Elem := Prev_Non_Pragma (Prev_List_Elem);
end loop;
return True;
end Is_Not_Duplicated_Decl;
---------------------------------
-- Is_Protected_Procedure_Call --
---------------------------------
function Is_Protected_Procedure_Call (N : Node_Id) return Boolean is
Result : Boolean := False;
Tmp_Node : Node_Id;
begin
Tmp_Node := Sinfo.Name (N);
if Nkind (Tmp_Node) = N_Indexed_Component then
-- Call to an entry from an entry family,
Tmp_Node := Prefix (Tmp_Node);
end if;
if Nkind (Tmp_Node) = N_Selected_Component then
Tmp_Node := Selector_Name (Tmp_Node);
end if;
Tmp_Node := Entity (Tmp_Node);
Result := Ekind (Tmp_Node) = E_Procedure;
return Result;
end Is_Protected_Procedure_Call;
------------------
-- Is_Statement --
------------------
function Is_Statement (N : Node_Id) return Boolean is
Arg_Kind : constant Node_Kind := Nkind (N);
begin
return Arg_Kind in N_Statement_Other_Than_Procedure_Call or else
Arg_Kind = N_Procedure_Call_Statement;
end Is_Statement;
------------------------------------------
-- Is_Stub_To_Body_Instanse_Replacement --
------------------------------------------
function Is_Stub_To_Body_Instanse_Replacement
(N : Node_Id)
return Boolean
is
Arg_Kind : constant Node_Kind := Nkind (N);
Result : Boolean := False;
begin
if Arg_Kind in N_Proper_Body and then
Was_Originally_Stub (N)
then
case Arg_Kind is
when N_Subprogram_Body =>
Result := Is_From_Instance (Sinfo.Specification (N));
when N_Package_Body =>
Result := Is_From_Instance (Sinfo.Defining_Unit_Name (N));
when others =>
Result := Is_From_Instance (Sinfo.Defining_Identifier (N));
end case;
end if;
return Result;
end Is_Stub_To_Body_Instanse_Replacement;
---------------------
-- May_Be_Included --
---------------------
function May_Be_Included (Node : Node_Id) return Boolean is
begin
return Ordinary_Inclusion_Condition (Node) and then
Is_Not_Duplicated_Decl (Node);
end May_Be_Included;
-----------------------------------------------
-- N_Abstract_Subprogram_Declaration_Mapping --
-----------------------------------------------
function N_Abstract_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Procedure_Declaration
-- A_Function_Declaration
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Function_Declaration;
else
return A_Procedure_Declaration;
end if;
end N_Abstract_Subprogram_Declaration_Mapping;
----------------------------------
-- N_Accept_Alternative_Mapping --
----------------------------------
function N_Accept_Alternative_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Select_Path
-- An_Or_Path
if No (Prev (Node)) then
return A_Select_Path;
else
return An_Or_Path;
end if;
end N_Accept_Alternative_Mapping;
------------------------------------------
-- N_Access_Function_Definition_Mapping --
------------------------------------------
function N_Access_Function_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Four Internal_Element_Kinds values may be possible:
--
-- An_Access_To_Function
-- An_Access_To_Protected_Function
--
-- A_Formal_Access_To_Function
-- A_Formal_Access_To_Protected_Function
if Nkind (Parent (Node)) = N_Formal_Type_Declaration then
if Protected_Present (Node) then
return A_Formal_Access_To_Protected_Function;
else
return A_Formal_Access_To_Function;
end if;
else
if Protected_Present (Node) then
return An_Access_To_Protected_Function;
else
return An_Access_To_Function;
end if;
end if;
end N_Access_Function_Definition_Mapping;
-------------------------------------------
-- N_Access_Procedure_Definition_Mapping --
-------------------------------------------
function N_Access_Procedure_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Four Internal_Element_Kinds values may be possible:
--
-- An_Access_To_Procedure
-- An_Access_To_Protected_Procedure
--
-- A_Formal_Access_To_Procedure
-- A_Formal_Access_To_Protected_Procedure
if Nkind (Parent (Node)) = N_Formal_Type_Declaration then
if Protected_Present (Node) then
return A_Formal_Access_To_Protected_Procedure;
else
return A_Formal_Access_To_Procedure;
end if;
else
if Protected_Present (Node) then
return An_Access_To_Protected_Procedure;
else
return An_Access_To_Procedure;
end if;
end if;
end N_Access_Procedure_Definition_Mapping;
-- --|A2005 start
---------------------------------
-- N_Access_Definition_Mapping --
---------------------------------
function N_Access_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := Not_An_Element;
Tmp : constant Node_Id :=
Sinfo.Access_To_Subprogram_Definition (Node);
begin
case Nkind (Tmp) is
when N_Empty =>
if Constant_Present (Node) then
Result := An_Anonymous_Access_To_Constant;
else
Result := An_Anonymous_Access_To_Variable;
end if;
when N_Access_Function_Definition =>
if Protected_Present (Tmp) then
Result := An_Anonymous_Access_To_Protected_Function;
else
Result := An_Anonymous_Access_To_Function;
end if;
when N_Access_Procedure_Definition =>
if Protected_Present (Tmp) then
Result := An_Anonymous_Access_To_Protected_Procedure;
else
Result := An_Anonymous_Access_To_Procedure;
end if;
when others =>
pragma Assert (False);
null;
end case;
return Result;
end N_Access_Definition_Mapping;
-- --|A2005 end
-------------------------------------------
-- N_Access_To_Object_Definition_Mapping --
-------------------------------------------
function N_Access_To_Object_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Six Internal_Element_Kinds values may be possible:
--
-- A_Pool_Specific_Access_To_Variable
-- An_Access_To_Variable
-- An_Access_To_Constant
--
-- A_Formal_Pool_Specific_Access_To_Variable
-- A_Formal_Access_To_Variable
-- A_Formal_Access_To_Constant
if Nkind (Parent (Node)) = N_Formal_Type_Declaration then
if All_Present (Node) then
return A_Formal_Access_To_Variable;
elsif Constant_Present (Node) then
return A_Formal_Access_To_Constant;
else
return A_Formal_Pool_Specific_Access_To_Variable;
end if;
else
if All_Present (Node) then
return An_Access_To_Variable;
elsif Constant_Present (Node) then
return An_Access_To_Constant;
else
return A_Pool_Specific_Access_To_Variable;
end if;
end if;
end N_Access_To_Object_Definition_Mapping;
-------------------------
-- N_Aggregate_Mapping --
-------------------------
function N_Aggregate_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Aggregate_Type : Node_Id := Etype (Node);
begin
-- Three Internal_Element_Kinds values may be possible:
-- A_Record_Aggregate
-- A_Positional_Array_Aggregate
-- A_Named_Array_Aggregate
-- the following fragment is a result of the current setting
-- of Etype field in the tree, see open problems #77
-- for multi-dimensional array aggregates, Etype field for
-- inner aggregates is set to Empty!!
if Present (Aggregate_Type) and then
Ekind (Aggregate_Type) in Private_Kind and then
not (Ekind (Aggregate_Type) in Array_Kind or else
Ekind (Aggregate_Type) in Record_Kind)
then
-- we need a full view of the type!
Aggregate_Type := Full_View (Aggregate_Type);
end if;
-- Special case:
if No (Aggregate_Type)
and then
(Nkind (Parent (Node)) = N_Pragma_Argument_Association
or else
Nkind (Parent (Node)) = N_Aspect_Specification)
then
return A_Record_Aggregate;
end if;
if Present (Aggregate_Type) and then
Ekind (Aggregate_Type) in Record_Kind
then
return A_Record_Aggregate;
else
if Present (Expressions (Node)) then
return A_Positional_Array_Aggregate;
else
return A_Named_Array_Aggregate;
end if;
end if;
end N_Aggregate_Mapping;
-------------------------
-- N_Allocator_Mapping --
-------------------------
function N_Allocator_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- An_Allocation_From_Subtype
-- An_Allocation_From_Qualified_Expression
if Nkind (Sinfo.Expression (Node)) = N_Qualified_Expression then
return An_Allocation_From_Qualified_Expression;
else
return An_Allocation_From_Subtype;
end if;
end N_Allocator_Mapping;
-----------------------------------
-- N_Attribute_Reference_Mapping --
-----------------------------------
function N_Attribute_Reference_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Attribute_Chars : constant Name_Id := Attribute_Name (Node);
Context_Kind : constant Node_Kind :=
Nkind (Original_Node (Parent_Node));
begin
-- The following Internal_Element_Kinds values may be possible:
--
-- For range attribute reference:
--
-- A_Discrete_Range_Attribute_Reference_As_Subtype_Definition
-- A_Discrete_Range_Attribute_Reference
-- A_Range_Attribute_Reference
--
-- For attribute reference corresponding to the attributes which are
-- functions
--
-- Adjacent
-- Ceiling
-- Compose
-- Copy_Sign
-- Exponent
-- Floor
-- Fraction
-- Image
-- Input
-- Leading_Part
-- Machine
-- Max
-- Min
-- Model
-- Pos
-- Pred
-- Remainder
-- Round
-- Rounding
-- Scaling
-- Succ
-- Truncation
-- Unbiased_Rounding
-- Val
-- Value
-- Wide_Image
-- Wide_Value
-- |A2005 start
--
-- Ada 2005 attributes that are functions:
--
-- Machine_Rounding
-- Mod
-- Wide_Wide_Image
-- |A2005 end
--
-- plus GNAT-specific attributes:
-- Enum_Rep
-- Fixed_Value
-- Integer_Value
-- Result
--
-- the Element of A_Function_Call Internal_Element_Kinds value should be
-- created, and the determination of the prefix kind should further be
-- done by hand (function Asis_Expressions.Prefix)
--
-- For attribute reference corresponding to the attributes which are
-- procedures
--
-- Output
-- Read
-- Write
--
-- the Element of A_Procedure_Call_Statement kind should be created
--
-- For attributes returning types:
-- Base
-- Class
-- the Element of A_Type_Conversion should be created if the node is
-- rewritten into N_Type_Conversion node. But this is done by the
-- Node_To_Element function (together with setting the Special_Case
-- Element field, which is then taken into account by functions
-- decomposing A_Type_Conversion Element.
if Attribute_Chars = Name_Range then
-- processing the range attribute reference
-- range attribute reference is the part of the RANGE
-- Syntax Cross Reference extraction for RANGE:
--
-- range
-- discrete_range 3.6.1
-- discrete_choice 3.8.1
-- discrete_choice_list 3.8.1
-- array_component_association 4.3.3
-- named_array_aggregate 4.3.3
-- case_statement_alternative 5.4
-- variant 3.8.1
-- index_constraint 3.6.1
-- slice 4.1.2
-- discrete_subtype_definition 3.6
-- constrained_array_definition 3.6
-- entry_declaration 9.5.2
-- entry_index_specification 9.5.2
-- loop_parameter_specification 5.5
-- range_constraint 3.5
-- delta_constraint J.3
-- digits_constraint 3.5.9
-- scalar_constraint 3.2.2
-- relation 4.4
case Context_Kind is -- should be reorganized when complete
when
-- discrete_range
N_Component_Association
| N_Case_Statement_Alternative
| N_Variant
| N_Index_Or_Discriminant_Constraint
| N_Slice
=>
return A_Discrete_Range_Attribute_Reference;
when -- discrete_subtype_definition
N_Constrained_Array_Definition
| N_Entry_Index_Specification
| N_Loop_Parameter_Specification
| N_Entry_Declaration
=>
return A_Discrete_Range_Attribute_Reference_As_Subtype_Definition;
when N_Range_Constraint => -- range_constraint ???
return A_Range_Attribute_Reference;
when N_In -- relation
| N_Not_In
=>
return A_Range_Attribute_Reference;
when others => -- impossible cases:
raise Internal_Implementation_Error;
end case;
elsif -- language-defined attributes which are functions:
Attribute_Chars = Name_Adjacent or else
Attribute_Chars = Name_Ceiling or else
Attribute_Chars = Name_Compose or else
Attribute_Chars = Name_Copy_Sign or else
Attribute_Chars = Name_Exponent or else
Attribute_Chars = Name_Floor or else
Attribute_Chars = Name_Fraction or else
Attribute_Chars = Name_Image or else
Attribute_Chars = Name_Input or else
Attribute_Chars = Name_Leading_Part or else
Attribute_Chars = Name_Machine or else
Attribute_Chars = Name_Max or else
Attribute_Chars = Name_Min or else
Attribute_Chars = Name_Model or else
Attribute_Chars = Name_Pos or else
Attribute_Chars = Name_Pred or else
Attribute_Chars = Name_Remainder or else
Attribute_Chars = Name_Round or else
Attribute_Chars = Name_Rounding or else
Attribute_Chars = Name_Scaling or else
Attribute_Chars = Name_Succ or else
Attribute_Chars = Name_Truncation or else
Attribute_Chars = Name_Unbiased_Rounding or else
Attribute_Chars = Name_Val or else
Attribute_Chars = Name_Value or else
Attribute_Chars = Name_Wide_Image or else
Attribute_Chars = Name_Wide_Value or else
-- |A2005 start
-- Ada 2005 attributes that are functions:
Attribute_Chars = Name_Machine_Rounding or else
Attribute_Chars = Name_Mod or else
Attribute_Chars = Name_Wide_Wide_Image or else
Attribute_Chars = Name_Wide_Wide_Value or else
-- |A2012 start
-- Ada 2012 attributes that are functions:
-- Attribute_Chars = Name_Overlaps_Storage or else (SCz)
-- |A2012 end
-- |A2005 end
-- Implementation Dependent Attributes-Functions:
Attribute_Chars = Name_Asm_Input or else
Attribute_Chars = Name_Asm_Output or else
Attribute_Chars = Name_Enum_Rep or else
Attribute_Chars = Name_Enum_Val or else
Attribute_Chars = Name_Fixed_Value or else
Attribute_Chars = Name_Integer_Value or else
Attribute_Chars = Name_Ref
then
return A_Function_Call;
elsif -- language-defined attributes which are procedures:
Attribute_Chars = Name_Output or else
Attribute_Chars = Name_Read or else
Attribute_Chars = Name_Write
then
return A_Procedure_Call_Statement;
-- language-defined attributes:
elsif Attribute_Chars = Name_Access then
return An_Access_Attribute;
elsif Attribute_Chars = Name_Address then
return An_Address_Attribute;
elsif Attribute_Chars = Name_Aft then
return An_Aft_Attribute;
elsif Attribute_Chars = Name_Alignment then
return An_Alignment_Attribute;
elsif Attribute_Chars = Name_Base then
return A_Base_Attribute;
elsif Attribute_Chars = Name_Bit_Order then
return A_Bit_Order_Attribute;
elsif Attribute_Chars = Name_Body_Version then
return A_Body_Version_Attribute;
elsif Attribute_Chars = Name_Callable then
return A_Callable_Attribute;
elsif Attribute_Chars = Name_Caller then
return A_Caller_Attribute;
elsif Attribute_Chars = Name_Class then
return A_Class_Attribute;
elsif Attribute_Chars = Name_Component_Size then
return A_Component_Size_Attribute;
elsif Attribute_Chars = Name_Constrained then
return A_Constrained_Attribute;
elsif Attribute_Chars = Name_Count then
return A_Count_Attribute;
elsif Attribute_Chars = Name_Definite then
return A_Definite_Attribute;
elsif Attribute_Chars = Name_Delta then
return A_Delta_Attribute;
elsif Attribute_Chars = Name_Denorm then
return A_Denorm_Attribute;
elsif Attribute_Chars = Name_Digits then
return A_Digits_Attribute;
elsif Attribute_Chars = Name_External_Tag then
return An_External_Tag_Attribute;
elsif Attribute_Chars = Name_First then
return A_First_Attribute;
elsif Attribute_Chars = Name_First_Bit then
return A_First_Bit_Attribute;
elsif Attribute_Chars = Name_Fore then
return A_Fore_Attribute;
elsif Attribute_Chars = Name_Identity then
return An_Identity_Attribute;
elsif Attribute_Chars = Name_Last then
return A_Last_Attribute;
elsif Attribute_Chars = Name_Last_Bit then
return A_Last_Bit_Attribute;
elsif Attribute_Chars = Name_Length then
return A_Length_Attribute;
elsif Attribute_Chars = Name_Machine_Emax then
return A_Machine_Emax_Attribute;
elsif Attribute_Chars = Name_Machine_Emin then
return A_Machine_Emin_Attribute;
elsif Attribute_Chars = Name_Machine_Mantissa then
return A_Machine_Mantissa_Attribute;
elsif Attribute_Chars = Name_Machine_Overflows then
return A_Machine_Overflows_Attribute;
elsif Attribute_Chars = Name_Machine_Radix then
return A_Machine_Radix_Attribute;
elsif Attribute_Chars = Name_Machine_Rounds then
return A_Machine_Rounds_Attribute;
elsif Attribute_Chars = Name_Max_Size_In_Storage_Elements then
return A_Max_Size_In_Storage_Elements_Attribute;
elsif Attribute_Chars = Name_Model_Emin then
return A_Model_Emin_Attribute;
elsif Attribute_Chars = Name_Model_Epsilon then
return A_Model_Epsilon_Attribute;
elsif Attribute_Chars = Name_Model_Mantissa then
return A_Model_Mantissa_Attribute;
elsif Attribute_Chars = Name_Model_Small then
return A_Model_Small_Attribute;
elsif Attribute_Chars = Name_Modulus then
return A_Modulus_Attribute;
elsif Attribute_Chars = Name_Partition_ID then
return A_Partition_ID_Attribute;
elsif Attribute_Chars = Name_Position then
return A_Position_Attribute;
elsif Attribute_Chars = Name_Range then -- this alternative
return A_Range_Attribute; -- never works!
elsif Attribute_Chars = Name_Safe_First then
return A_Safe_First_Attribute;
elsif Attribute_Chars = Name_Safe_Last then
return A_Safe_Last_Attribute;
elsif Attribute_Chars = Name_Scale then
return A_Scale_Attribute;
elsif Attribute_Chars = Name_Signed_Zeros then
return A_Signed_Zeros_Attribute;
elsif Attribute_Chars = Name_Size then
return A_Size_Attribute;
elsif Attribute_Chars = Name_Small then
return A_Small_Attribute;
elsif Attribute_Chars = Name_Storage_Pool then
return A_Storage_Pool_Attribute;
elsif Attribute_Chars = Name_Storage_Size then
return A_Storage_Size_Attribute;
elsif Attribute_Chars = Name_Tag then
return A_Tag_Attribute;
elsif Attribute_Chars = Name_Terminated then
return A_Terminated_Attribute;
elsif Attribute_Chars = Name_Unchecked_Access then
return An_Unchecked_Access_Attribute;
elsif Attribute_Chars = Name_Valid then
return A_Valid_Attribute;
elsif Attribute_Chars = Name_Version then
return A_Version_Attribute;
elsif Attribute_Chars = Name_Wide_Width then
return A_Wide_Width_Attribute;
elsif Attribute_Chars = Name_Width then
return A_Width_Attribute;
-- New Ada 2005/2012 attributes:
elsif Attribute_Chars = Name_Priority then
return A_Priority_Attribute;
elsif Attribute_Chars = Name_Stream_Size then
return A_Stream_Size_Attribute;
elsif Attribute_Chars = Name_Wide_Wide_Width then
return A_Wide_Wide_Width_Attribute;
elsif Attribute_Chars = Name_Max_Alignment_For_Allocation then
return A_Max_Alignment_For_Allocation_Attribute;
-- New Ada 2005/2012 attributes:
-- Implementation Dependent Attributes:
elsif Attribute_Chars = Name_Abort_Signal or else
Attribute_Chars = Name_Address_Size or else
Attribute_Chars = Name_Asm_Input or else
Attribute_Chars = Name_Asm_Output or else
Attribute_Chars = Name_AST_Entry or else -- VMS
Attribute_Chars = Name_Bit or else
Attribute_Chars = Name_Bit_Position or else
Attribute_Chars = Name_Code_Address or else
Attribute_Chars = Name_Compiler_Version or else
Attribute_Chars = Name_Default_Bit_Order or else
-- Attribute_Chars = Name_Elab_Subp_Body or else (SCz)
Attribute_Chars = Name_Elaborated or else
Attribute_Chars = Name_Emax or else -- Ada 83
Attribute_Chars = Name_Enabled or else
Attribute_Chars = Name_Enum_Rep or else
Attribute_Chars = Name_Enum_Val or else
Attribute_Chars = Name_Epsilon or else -- Ada 83
Attribute_Chars = Name_Fixed_Value or else
Attribute_Chars = Name_Has_Access_Values or else
Attribute_Chars = Name_Has_Discriminants or else
Attribute_Chars = Name_Img or else
Attribute_Chars = Name_Integer_Value or else
Attribute_Chars = Name_Invalid_Value or else
Attribute_Chars = Name_Large or else -- Ada 83
Attribute_Chars = Name_Machine_Size or else
Attribute_Chars = Name_Mantissa or else -- Ada 83
Attribute_Chars = Name_Maximum_Alignment or else
Attribute_Chars = Name_Mechanism_Code or else
Attribute_Chars = Name_Null_Parameter or else
Attribute_Chars = Name_Object_Size or else
Attribute_Chars = Name_Old or else
Attribute_Chars = Name_Passed_By_Reference or else
Attribute_Chars = Name_Range_Length or else
Attribute_Chars = Name_Ref or else
Attribute_Chars = Name_Result or else
Attribute_Chars = Name_Safe_Emax or else -- Ada 83
Attribute_Chars = Name_Safe_Large or else -- Ada 83
Attribute_Chars = Name_Safe_Small or else -- Ada 83
Attribute_Chars = Name_Storage_Unit or else
-- Attribute_Chars = Name_System_Allocator_Alignment or else (SCz)
Attribute_Chars = Name_Target_Name or else
Attribute_Chars = Name_To_Address or else
Attribute_Chars = Name_Type_Class or else
Attribute_Chars = Name_UET_Address or else
Attribute_Chars = Name_Universal_Literal_String or else
Attribute_Chars = Name_Unrestricted_Access or else
Attribute_Chars = Name_VADS_Size or else
Attribute_Chars = Name_Value_Size or else
Attribute_Chars = Name_Wchar_T_Size or else
Attribute_Chars = Name_Word_Size or else
Attribute_Chars = Name_Elab_Body or else
Attribute_Chars = Name_Elab_Spec
then
return An_Implementation_Defined_Attribute;
else
return An_Unknown_Attribute;
end if;
end N_Attribute_Reference_Mapping;
-------------------------------------
-- N_Component_Association_Mapping --
-------------------------------------
function N_Component_Association_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Special cases first:
case Nkind (Parent (Parent (Node))) is
when N_Enumeration_Representation_Clause =>
return An_Array_Component_Association;
when N_Pragma_Argument_Association |
N_Aspect_Specification =>
return A_Record_Component_Association;
when others =>
null;
end case;
-- Regular case:
if Nkind (Parent (Parent (Node))) = N_Enumeration_Representation_Clause
or else
Ekind (Etype (Parent (Node))) in Array_Kind
then
return An_Array_Component_Association;
else
return A_Record_Component_Association;
end if;
end N_Component_Association_Mapping;
--------------------------------------------
-- N_Constrained_Array_Definition_Mapping --
--------------------------------------------
function N_Constrained_Array_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Constrained_Array_Definition
-- A_Formal_Constrained_Array_Definition
if Nkind (Parent (Node)) = N_Formal_Type_Declaration then
return A_Formal_Constrained_Array_Definition;
else
return A_Constrained_Array_Definition;
end if;
end N_Constrained_Array_Definition_Mapping;
-----------------------------------
-- N_Defining_Identifier_Mapping --
-----------------------------------
function N_Defining_Identifier_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Template_Node : Node_Id := Empty;
begin
-- Several Internal_Element_Kinds values may be possible for automatic
-- Internal Kind Determination:
--
-- A_Defining_Identifier
-- A_Defining_Enumeration_Literal
-- Internal Defining Name kinds, this happens for the extended
-- code of the function instantiation in case if the instance
-- defines an operator symbol - in this case the defining name of
-- the extended function spec and body is represented by
-- N_Defining_Identifier node.
--
-- Some other Internal_Element_Kinds values could be set "by-hand",
-- for example:
--
-- An_Enumeration_Literal_Specification
if Sloc (Node) > Standard_Location and then
Get_Character (Sloc (Node)) = '"'
then
Template_Node := Parent (Parent (Node));
if Pass_Generic_Actual (Template_Node) then
-- This is the case of subprogram renaming that passes an actual
-- for a formal operator function
Template_Node := Corresponding_Formal_Spec (Template_Node);
else
-- This is the case of expanded generic subprogram having a
-- defining operator symbol, it comes as the defining name from
-- the corresponding instance, but is represented by
-- N_Defining_Identifier node in the expanded code. We just
-- go to the defining name from the instance and call
-- N_Defining_Operator_Symbol_Mapping for it
Template_Node := Parent (Template_Node);
if Nkind (Template_Node) = N_Package_Specification then
Template_Node := Parent (Template_Node);
end if;
Template_Node := Next (Template_Node);
if Nkind (Template_Node) = N_Package_Body then
-- skipping the body of wrapper package for extended subprogram
-- body
Template_Node := Next (Template_Node);
end if;
Template_Node := Defining_Unit_Name (Template_Node);
end if;
pragma Assert (Nkind (Template_Node) = N_Defining_Operator_Symbol);
return N_Defining_Operator_Symbol_Mapping (Template_Node);
else
if Nkind (Parent (Node)) = N_Enumeration_Type_Definition then
return A_Defining_Enumeration_Literal;
else
return A_Defining_Identifier;
end if;
end if;
end N_Defining_Identifier_Mapping;
----------------------------------------
-- N_Defining_Operator_Symbol_Mapping --
----------------------------------------
function N_Defining_Operator_Symbol_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Operator_Chars : constant Name_Id := Chars (Node);
Parameter_Number : Nat range 1 .. 2;
-- see the GNAT components Namet.ads and Snames.ads
-- N_Operator_Symbol_Mapping uses just the same approach,
-- (except computing the Parameter_Number value)
-- so if there is any error in it, then both functions contain it
begin
-- The following Internal_Element_Kinds values may be possible:
--
-- A_Defining_And_Operator, -- and
-- A_Defining_Or_Operator, -- or
-- A_Defining_Xor_Operator, -- xor
-- A_Defining_Equal_Operator, -- =
-- A_Defining_Not_Equal_Operator, -- /=
-- A_Defining_Less_Than_Operator, -- <
-- A_Defining_Less_Than_Or_Equal_Operator, -- <=
-- A_Defining_Greater_Than_Operator, -- >
-- A_Defining_Greater_Than_Or_Equal_Operator, -- >=
-- A_Defining_Plus_Operator, -- +
-- A_Defining_Minus_Operator, -- -
-- A_Defining_Concatenate_Operator, -- &
-- A_Defining_Unary_Plus_Operator, -- +
-- A_Defining_Unary_Minus_Operator, -- -
-- A_Defining_Multiply_Operator, -- *
-- A_Defining_Divide_Operator, -- /
-- A_Defining_Mod_Operator, -- mod
-- A_Defining_Rem_Operator, -- rem
-- A_Defining_Exponentiate_Operator, -- **
-- A_Defining_Abs_Operator, -- abs
-- A_Defining_Not_Operator, -- not
if Operator_Chars = Name_Op_And then
return A_Defining_And_Operator;
elsif Operator_Chars = Name_Op_Or then
return A_Defining_Or_Operator;
elsif Operator_Chars = Name_Op_Xor then
return A_Defining_Xor_Operator;
elsif Operator_Chars = Name_Op_Eq then
return A_Defining_Equal_Operator;
elsif Operator_Chars = Name_Op_Ne then
return A_Defining_Not_Equal_Operator;
elsif Operator_Chars = Name_Op_Lt then
return A_Defining_Less_Than_Operator;
elsif Operator_Chars = Name_Op_Le then
return A_Defining_Less_Than_Or_Equal_Operator;
elsif Operator_Chars = Name_Op_Gt then
return A_Defining_Greater_Than_Operator;
elsif Operator_Chars = Name_Op_Ge then
return A_Defining_Greater_Than_Or_Equal_Operator;
elsif Operator_Chars = Name_Op_Concat then
return A_Defining_Concatenate_Operator;
elsif Operator_Chars = Name_Op_Multiply then
return A_Defining_Multiply_Operator;
elsif Operator_Chars = Name_Op_Divide then
return A_Defining_Divide_Operator;
elsif Operator_Chars = Name_Op_Mod then
return A_Defining_Mod_Operator;
elsif Operator_Chars = Name_Op_Rem then
return A_Defining_Rem_Operator;
elsif Operator_Chars = Name_Op_Expon then
return A_Defining_Exponentiate_Operator;
elsif Operator_Chars = Name_Op_Abs then
return A_Defining_Abs_Operator;
elsif Operator_Chars = Name_Op_Not then
return A_Defining_Not_Operator;
else
-- for + and - operator signs binary and unary cases
-- should be distinguished
if Nkind (Parent_Node) = N_Function_Instantiation then
-- we have to compute the number of parameters
-- from the declaration of the corresponding generic
-- function
Parent_Node := Parent (Entity (Sinfo.Name (Parent_Node)));
if Nkind (Parent_Node) = N_Defining_Program_Unit_Name then
Parent_Node := Parent (Parent_Node);
end if;
end if;
Parameter_Number :=
List_Length (Parameter_Specifications (Parent_Node));
if Operator_Chars = Name_Op_Add then
if Parameter_Number = 1 then
return A_Defining_Unary_Plus_Operator;
else
return A_Defining_Plus_Operator;
end if;
else -- Operator_Chars = "-"
if Parameter_Number = 1 then
return A_Defining_Unary_Minus_Operator;
else
return A_Defining_Minus_Operator;
end if;
end if;
end if;
end N_Defining_Operator_Symbol_Mapping;
---------------------------------
-- N_Delay_Alternative_Mapping --
---------------------------------
function N_Delay_Alternative_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Select_Path
-- An_Or_Path
if Is_List_Member (Node) then
-- a delay alternative in a selective accept statement,
-- processing is the same as for N_Accept_Alternative
return N_Accept_Alternative_Mapping (Node);
else
-- a relay alternative in a timed entry call
return An_Or_Path;
end if;
end N_Delay_Alternative_Mapping;
---------------------------------------
-- N_Derived_Type_Definition_Mapping --
---------------------------------------
function N_Derived_Type_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := A_Derived_Type_Definition;
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Derived_Type_Definition
-- A_Derived_Record_Extension_Definition
-- --|A2005 start
-- Plus the following values for Ada 2005:
-- An_Ordinary_Interface
-- A_Limited_Interface
-- A_Task_Interface
-- A_Protected_Interface
-- A_Synchronized_Interface
-- --|A2005 end
-- Implementation revised for Ada 2005
if Interface_Present (Node) then
if Limited_Present (Node) then
Result := A_Limited_Interface;
elsif Task_Present (Node) then
Result := A_Task_Interface;
elsif Protected_Present (Node) then
Result := A_Protected_Interface;
elsif Synchronized_Present (Node) then
Result := A_Synchronized_Interface;
else
Result := An_Ordinary_Interface;
end if;
elsif Present (Record_Extension_Part (Node)) then
Result := A_Derived_Record_Extension_Definition;
end if;
return Result;
-- --|A2005 end
end N_Derived_Type_Definition_Mapping;
-----------------------------
-- N_Expanded_Name_Mapping --
-----------------------------
function N_Expanded_Name_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Context : constant Node_Id := Parent_Node;
Context_Kind : constant Node_Kind := Nkind (Context);
Temp_Node : Node_Id;
begin
-- The following Internal_Element_Kinds values may be possible:
--
-- A_Subtype_Indication
-- A_Discrete_Subtype_Indication_As_Subtype_Definition
-- A_Discrete_Subtype_Indication
-- A_Selected_Component
-- An_Identifier (we use this routine for An_Identifier node as well)
-- A_Function_Call (F in F.X)
-- An_Attribute_Reference
case Context_Kind is
-- special cases should be reorganized when complete ???
when N_Object_Declaration =>
if Node = Object_Definition (Context) then
return A_Subtype_Indication;
else
-- an initializing expression in an object declaration
goto Expr;
end if;
when N_Derived_Type_Definition
| N_Access_To_Object_Definition
=>
-- --|A2005 start
if Is_List_Member (Node) then
-- The node represents an interface name from some interface
-- list
if Nkind (Node) = N_Expanded_Name then
return A_Selected_Component;
else
return An_Identifier;
end if;
else
return A_Subtype_Indication;
end if;
-- --|A2005 end
when N_Constrained_Array_Definition |
N_Entry_Declaration =>
return A_Discrete_Subtype_Indication_As_Subtype_Definition;
when N_Unconstrained_Array_Definition =>
if Is_List_Member (Node) then
-- this for sure means, that node represents one of index
-- subtype definitions
-- CODE SHARING WITH N_IDENTIFIER MAPPING ITEM :-[#]
if Nkind (Node) = N_Expanded_Name then
return A_Selected_Component;
else
return An_Identifier;
end if;
else
-- this is a component definition!
return A_Component_Definition;
end if;
when N_Index_Or_Discriminant_Constraint =>
if Asis_Internal_Element_Kind (Context) =
An_Index_Constraint
then
return A_Discrete_Subtype_Indication;
end if;
when N_Slice =>
-- A.B(C.D) <- Context
-- / \
-- Prefix Discrete_Range
if Node = Sinfo.Discrete_Range (Context) then
return A_Discrete_Subtype_Indication;
end if;
-- when N_??? => should be implemented
when N_Selected_Component =>
-- This corresponds to a special case: F.A, where F is
-- a function call
Temp_Node := Prefix (Context);
if Is_Rewrite_Substitution (Temp_Node) and then
Nkind (Temp_Node) = N_Function_Call and then
Original_Node (Temp_Node) = Node
then
return A_Function_Call;
end if;
when N_Parameter_Specification =>
-- See FA13-008. In case if we have an implicit "/="
-- declaration, and in the corresponding explicit "="
-- declaration parameter type is defined by a 'Class attribute,
-- in the parameter specification of "/=" the front-end uses
-- the reference to the internal type entity node
if Nkind (Node) = N_Identifier
and then
not Comes_From_Source (Node)
and then
Ekind (Entity (Node)) = E_Class_Wide_Type
then
return A_Class_Attribute;
end if;
when others =>
null;
end case;
-- general case, the following if statement is necessary because
-- of sharing of this code between N_Expanded_Name and N_Identifier
-- mapping items.
-- IS THIS CODE SHARING A REALLY GOOD THING???
<<Expr>> -- here we are analyzing the "ordinary" expression
if Nkind (Node) = N_Expanded_Name then
return A_Selected_Component;
elsif Context_Kind /= N_Defining_Program_Unit_Name then
if (Nkind (Node) in N_Has_Entity
or else
Nkind (Node) = N_Attribute_Definition_Clause)
and then
Entity_Present (Node)
and then
Ekind (Entity (Node)) = E_Enumeration_Literal
then
return An_Enumeration_Literal;
else
return An_Identifier;
end if;
else
return An_Identifier;
end if;
end N_Expanded_Name_Mapping;
---------------------------------------
-- N_Formal_Type_Declaration_Mapping --
---------------------------------------
function N_Formal_Type_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- if Nkind (Sinfo.Formal_Type_Definition (Node)) = (SCz)
-- N_Formal_Incomplete_Type_Definition
-- then
-- return A_Formal_Incomplete_Type_Declaration;
-- else
return A_Formal_Type_Declaration;
-- end if;
end N_Formal_Type_Declaration_Mapping;
------------------------------------------
-- N_Formal_Package_Declaration_Mapping --
------------------------------------------
function N_Formal_Package_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Formal_Package_Declaration,
-- A_Formal_Package_Declaration_With_Box
if Box_Present (Node) then
return A_Formal_Package_Declaration_With_Box;
else
return A_Formal_Package_Declaration;
end if;
end N_Formal_Package_Declaration_Mapping;
----------------------------------------------
-- N_Formal_Private_Type_Definition_Mapping --
----------------------------------------------
function N_Formal_Private_Type_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Formal_Private_Type_Definition
-- A_Formal_Tagged_Private_Type_Definition
if Tagged_Present (Node) then
return A_Formal_Tagged_Private_Type_Definition;
else
return A_Formal_Private_Type_Definition;
end if;
end N_Formal_Private_Type_Definition_Mapping;
---------------------------------------------
-- N_Formal_Subprogram_Declaration_Mapping --
---------------------------------------------
function N_Formal_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Formal_Procedure_Declaration
-- A_Formal_Function_Declaration.
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Formal_Function_Declaration;
else
return A_Formal_Procedure_Declaration;
end if;
end N_Formal_Subprogram_Declaration_Mapping;
-----------------------------
-- N_Function_Call_Mapping --
-----------------------------
function N_Function_Call_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Called_Name : Node_Id;
Called_Function : Node_Id := Empty;
Result : Internal_Element_Kinds := A_Function_Call;
begin
-- Three Internal_Element_Kinds values may be possible:
-- A_Function_Call (usual situation)
-- A_Selected_Component
-- An_Enumeration_Literal
-- The last two cases correspond to a reference to an overloaded
-- enumeration literal (either qualified or direct)
if No (Parameter_Associations (Node)) then
Called_Name := Sinfo.Name (Node);
if Nkind (Called_Name) in N_Has_Entity then
Called_Function := Entity (Called_Name);
end if;
if Nkind (Parent (Called_Function)) =
N_Enumeration_Type_Definition
then
if Nkind (Called_Name) = N_Selected_Component or else -- ???
Nkind (Called_Name) = N_Expanded_Name
then
Result := A_Selected_Component;
elsif Nkind (Called_Name) = N_Identifier then
Result := An_Enumeration_Literal;
end if;
end if;
end if;
return Result;
end N_Function_Call_Mapping;
----------------------------------------------
-- N_Generic_Subprogram_Declaration_Mapping --
----------------------------------------------
function N_Generic_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Generic_Procedure_Declaration and A_Generic_Function_Declaration
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Generic_Function_Declaration;
else
return A_Generic_Procedure_Declaration;
end if;
end N_Generic_Subprogram_Declaration_Mapping;
-- |A2005 start
-------------------------------------------
-- N_Incomplete_Type_Declaration_Mapping --
-------------------------------------------
function N_Incomplete_Type_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := An_Incomplete_Type_Declaration;
begin
if Tagged_Present (Node) then
Result := A_Tagged_Incomplete_Type_Declaration;
end if;
return Result;
end N_Incomplete_Type_Declaration_Mapping;
-- |A2005 end
------------------------------------------------
-- N_Index_Or_Discriminant_Constraint_Mapping --
------------------------------------------------
function N_Index_Or_Discriminant_Constraint_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
First_Item : Node_Id;
-- the first element in the list of discrete ranges or discriminant
-- associations, this element is the only one used to determine the kind
-- of the constraint being analyzed
First_Item_Kind : Node_Kind;
Type_Entity : Node_Id;
-- Needed in case when we can not make the decision using the syntax
-- information only. Represents the type or subtype entity to which the
-- constraint is applied
begin
-- Two Internal_Element_Kinds values may be possible:
-- An_Index_Constraint
-- A_Discriminant_Constraint
First_Item := First (Constraints (Node));
First_Item_Kind := Nkind (First_Item);
-- analyzing the syntax structure of First_Item:
if First_Item_Kind = N_Discriminant_Association then
return A_Discriminant_Constraint;
elsif First_Item_Kind = N_Subtype_Indication or else
First_Item_Kind = N_Range
then
return An_Index_Constraint;
elsif First_Item_Kind = N_Attribute_Reference then
-- analyzing the attribute designator:
if Attribute_Name (First_Item) = Name_Range then
return An_Index_Constraint;
else
return A_Discriminant_Constraint;
end if;
elsif not (First_Item_Kind = N_Identifier or else
First_Item_Kind = N_Expanded_Name)
then
-- First_Item is an expression and it could not be interpreted as a
-- subtype_mark from a discrete_subtype_indication, so what we have
-- in this case is:
return A_Discriminant_Constraint;
end if;
-- First_Item is of N_Identifier or N_Expanded_Name kind, and it may be
-- either an expression in index constraint or a subtype mark in a
-- discriminant constraint. In this case it is easier to analyze the
-- type to which the constraint is applied, but not the constraint
-- itself.
Type_Entity := Entity (Sinfo.Subtype_Mark (Parent (Node)));
while Ekind (Type_Entity) in Access_Kind loop
Type_Entity := Directly_Designated_Type (Type_Entity);
end loop;
if Has_Discriminants (Type_Entity) then
return A_Discriminant_Constraint;
else
return An_Index_Constraint;
end if;
end N_Index_Or_Discriminant_Constraint_Mapping;
--------------------------------------
-- N_Iterator_Specification_Mapping --
--------------------------------------
function N_Iterator_Specification_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := A_Generalized_Iterator_Specification;
begin
if Of_Present (Node) then
Result := An_Element_Iterator_Specification;
end if;
return Result;
end N_Iterator_Specification_Mapping;
------------------------------
-- N_Loop_Statement_Mapping --
------------------------------
function N_Loop_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Iteration : Node_Id;
begin
-- Three Internal_Element_Kinds values may be possible:
-- A_Loop_Statement,
-- A_While_Loop_Statement,
-- A_For_Loop_Statement,
Iteration := Iteration_Scheme (Node);
if Present (Iteration) then
if Present (Condition (Iteration)) then
return A_While_Loop_Statement;
else
return A_For_Loop_Statement;
end if;
else
return A_Loop_Statement;
end if;
end N_Loop_Statement_Mapping;
----------------------------------
-- N_Number_Declaration_Mapping --
----------------------------------
function N_Number_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- An_Integer_Number_Declaration
-- A_Real_Number_Declaration
if Ekind (Defining_Identifier (Node)) = E_Named_Integer then
return An_Integer_Number_Declaration;
else
return A_Real_Number_Declaration;
end if;
end N_Number_Declaration_Mapping;
----------------------------------
-- N_Object_Declaration_Mapping --
----------------------------------
function N_Object_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds;
begin
-- Three Internal_Element_Kinds values may be possible:
-- A_Variable_Declaration,
-- A_Constant_Declaration,
-- A_Deferred_Constant_Declaration.
-- |A2005 start
-- A_Return_Variable_Specification
-- A_Return_Constant_Specification
-- |A2005 end
if Nkind (Parent (Node)) = N_Extended_Return_Statement then
if not Constant_Present (Node) then
Result := A_Return_Variable_Specification;
else
Result := A_Return_Constant_Specification;
end if;
elsif not Constant_Present (Node) then
Result := A_Variable_Declaration;
elsif Present (Sinfo.Expression (Node)) then
Result := A_Constant_Declaration;
else
Result := A_Deferred_Constant_Declaration;
end if;
return Result;
end N_Object_Declaration_Mapping;
-------------------------------
-- N_Operator_Symbol_Mapping --
-------------------------------
function N_Operator_Symbol_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Tmp : Node_Id;
Operator_Chars : constant Name_Id := Chars (Node);
Parameter_Number : Nat range 1 .. 2;
-- see the GNAT components Namet.ads and Snames.ads
-- N_Defining_Operator_Symbol_Mapping uses just the same approach,
-- so if there is any error in it, then both functions contain it
begin
-- The following Internal_Element_Kinds values may be possible:
--
-- A_And_Operator, -- and
-- A_Or_Operator, -- or
-- A_Xor_Operator, -- xor
-- A_Equal_Operator, -- =
-- A_Not_Equal_Operator, -- /=
-- A_Less_Than_Operator, -- <
-- A_Less_Than_Or_Equal_Operator, -- <=
-- A_Greater_Than_Operator, -- >
-- A_Greater_Than_Or_Equal_Operator, -- >=
-- A_Plus_Operator, -- +
-- A_Minus_Operator, -- -
-- A_Concatenate_Operator, -- &
-- A_Unary_Plus_Operator, -- +
-- A_Unary_Minus_Operator, -- -
-- A_Multiply_Operator, -- *
-- A_Divide_Operator, -- /
-- A_Mod_Operator, -- mod
-- A_Rem_Operator, -- rem
-- A_Exponentiate_Operator, -- **
-- A_Abs_Operator, -- abs
-- A_Not_Operator, -- not
if Operator_Chars = Name_Op_And then
return An_And_Operator;
elsif Operator_Chars = Name_Op_Or then
return An_Or_Operator;
elsif Operator_Chars = Name_Op_Xor then
return An_Xor_Operator;
elsif Operator_Chars = Name_Op_Eq then
return An_Equal_Operator;
elsif Operator_Chars = Name_Op_Ne then
return A_Not_Equal_Operator;
elsif Operator_Chars = Name_Op_Lt then
return A_Less_Than_Operator;
elsif Operator_Chars = Name_Op_Le then
return A_Less_Than_Or_Equal_Operator;
elsif Operator_Chars = Name_Op_Gt then
return A_Greater_Than_Operator;
elsif Operator_Chars = Name_Op_Ge then
return A_Greater_Than_Or_Equal_Operator;
elsif Operator_Chars = Name_Op_Concat then
return A_Concatenate_Operator;
elsif Operator_Chars = Name_Op_Multiply then
return A_Multiply_Operator;
elsif Operator_Chars = Name_Op_Divide then
return A_Divide_Operator;
elsif Operator_Chars = Name_Op_Mod then
return A_Mod_Operator;
elsif Operator_Chars = Name_Op_Rem then
return A_Rem_Operator;
elsif Operator_Chars = Name_Op_Expon then
return An_Exponentiate_Operator;
elsif Operator_Chars = Name_Op_Abs then
return An_Abs_Operator;
elsif Operator_Chars = Name_Op_Not then
return A_Not_Operator;
else
-- for + and - operator signs binary and unary cases
-- should be distinguished
-- A simple case - we have an entity:
if Entity_Present (Node) then
Tmp := Entity (Node);
if First_Entity (Tmp) = Last_Entity (Tmp) then
Parameter_Number := 1;
else
Parameter_Number := 2;
end if;
else
Parent_Node := Parent (Node);
if Nkind (Parent_Node) = N_Integer_Literal or else
Nkind (Parent_Node) = N_Real_Literal
then
-- Static expression of the form "+"(1, 2) rewritten into
-- a literal value
Parent_Node := Original_Node (Parent_Node);
end if;
-- we have to do this assignment also here, because this
-- function may be called outside Node_To_Element
-- convertors
-- because of the possible tree rewriting, the parent node
-- may be either of N_Function_Call or of N_Op_Xxx type)
-- it can be also of N_Formal_Subprogram_Declaration kind,
-- or even of N_Expanded_Name kind,
while Nkind (Parent_Node) = N_Expanded_Name loop
Parent_Node := Parent (Parent_Node);
if Nkind (Parent_Node) = N_Integer_Literal or else
Nkind (Parent_Node) = N_Real_Literal
then
-- Static expression of the form
-- Prefix_Name."+"(1, 2)
-- rewritten into a literal value
Parent_Node := Original_Node (Parent_Node);
end if;
end loop;
if Nkind (Parent_Node) = N_Op_Plus or else
Nkind (Parent_Node) = N_Op_Minus
then
Parameter_Number := 1;
elsif Nkind (Parent_Node) = N_Op_Add or else
Nkind (Parent_Node) = N_Op_Subtract
then
Parameter_Number := 2;
elsif Nkind (Parent_Node) = N_Function_Call then
Parameter_Number :=
List_Length (Parameter_Associations (Parent_Node));
elsif Nkind (Parent_Node) = N_Subprogram_Renaming_Declaration
or else
Nkind (Parent_Node) in N_Formal_Subprogram_Declaration
then
Parameter_Number := List_Length
(Parameter_Specifications (Specification (Parent_Node)));
elsif Nkind (Parent_Node) = N_Indexed_Component then
Parameter_Number := List_Length
(Sinfo.Expressions (Parent_Node));
elsif Nkind (Parent_Node) = N_Pragma_Argument_Association then
-- this is for pragma inline ("+");
Parameter_Number := 2;
-- this choice is somewhat arbitrary :)
elsif Nkind (Parent_Node) = N_Generic_Association then
Tmp := Defining_Gen_Parameter (Node);
Parameter_Number := List_Length
(Parameter_Specifications (Parent (Tmp)));
else
-- Impossible case
raise Internal_Implementation_Error;
end if;
end if;
if Operator_Chars = Name_Op_Add then
if Parameter_Number = 1 then
return A_Unary_Plus_Operator;
else
return A_Plus_Operator;
end if;
else -- Operator_Chars = "-"
if Parameter_Number = 1 then
return A_Unary_Minus_Operator;
else
return A_Minus_Operator;
end if;
end if;
end if;
end N_Operator_Symbol_Mapping;
----------------------
-- N_Pragma_Mapping --
----------------------
function N_Pragma_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Pragma_Chars : constant Name_Id := Pragma_Name (Node);
begin
-- Language-Defined Pragmas --
if Pragma_Chars = Name_All_Calls_Remote then
return An_All_Calls_Remote_Pragma; -- I.2.3(6)
elsif Pragma_Chars = Name_Asynchronous then
return An_Asynchronous_Pragma; -- I.4.1(3)
elsif Pragma_Chars = Name_Atomic then
return An_Atomic_Pragma; -- G.5(3)
elsif Pragma_Chars = Name_Atomic_Components then
return An_Atomic_Components_Pragma; -- G.5(3)
elsif Pragma_Chars = Name_Attach_Handler then
return An_Attach_Handler_Pragma; -- G.3.1(3)
elsif Pragma_Chars = Name_Controlled then
return A_Controlled_Pragma; -- 13.11.3(3), B(12)
elsif Pragma_Chars = Name_Convention then
return A_Convention_Pragma; -- B(16), M.1(5)
elsif Pragma_Chars = Name_Discard_Names then
return A_Discard_Names_Pragma; -- C.5(2)
elsif Pragma_Chars = Name_Elaborate then
return An_Elaborate_Pragma; -- 10.2.1(20)
elsif Pragma_Chars = Name_Elaborate_All then
return An_Elaborate_All_Pragma; -- 10.2.1(19), B(8)
elsif Pragma_Chars = Name_Elaborate_Body then
return An_Elaborate_Body_Pragma; -- 10.2.1(21), B(9)
elsif Pragma_Chars = Name_Export then
return An_Export_Pragma; -- B(15), M.1(5)
elsif Pragma_Chars = Name_Import then
return An_Import_Pragma; -- B(14), M.1(5)
elsif Pragma_Chars = Name_Inline then
return An_Inline_Pragma; -- 6.3.2(4), B(5)
elsif Pragma_Chars = Name_Inspection_Point then
return An_Inspection_Point_Pragma; -- L.2.2(2)
elsif Pragma_Chars = Name_Interrupt_Handler then
return An_Interrupt_Handler_Pragma; -- G.3.1(2)
elsif Pragma_Chars = Name_Interrupt_Priority then
return An_Interrupt_Priority_Pragma; -- H.1(4)
elsif Pragma_Chars = Name_Linker_Options then
return A_Linker_Options_Pragma; -- B.1(8)
elsif Pragma_Chars = Snames.Name_List then
return A_List_Pragma; -- 2.8(18), B(2)
elsif Pragma_Chars = Name_Locking_Policy then
return A_Locking_Policy_Pragma; -- H.3(3)
elsif Pragma_Chars = Name_Normalize_Scalars then
return A_Normalize_Scalars_Pragma; -- L.1.1(2)
elsif Pragma_Chars = Name_Optimize then
return An_Optimize_Pragma; -- 2.8(18), B(4)
elsif Pragma_Chars = Name_Pack then
return A_Pack_Pragma; -- 13.2(2), B(11)
elsif Pragma_Chars = Name_Page then
return A_Page_Pragma; -- 2.8(18), B(3)
elsif Pragma_Chars = Name_Preelaborate then
return A_Preelaborate_Pragma; -- 10.2.1(3), B(6)
elsif Pragma_Chars = Name_Priority then
return A_Priority_Pragma; -- H.1(3)
elsif Pragma_Chars = Name_Pure then
return A_Pure_Pragma; -- 10.2.1(13), B(7)
elsif Pragma_Chars = Name_Queuing_Policy then
return A_Queuing_Policy_Pragma; -- H.4(3)
elsif Pragma_Chars = Name_Remote_Call_Interface then
return A_Remote_Call_Interface_Pragma; -- I.2.3(4)
elsif Pragma_Chars = Name_Remote_Types then
return A_Remote_Types_Pragma; -- I.2.2(4)
elsif Pragma_Chars = Name_Restrictions then
return A_Restrictions_Pragma; -- 13.12(2), B(13)
elsif Pragma_Chars = Name_Reviewable then
return A_Reviewable_Pragma; -- L.2.1(2)
elsif Pragma_Chars = Name_Shared_Passive then
return A_Shared_Passive_Pragma; -- I.2.1(4)
elsif Pragma_Chars = Name_Storage_Size then
-- the same name entry as for 'Storage_Size attribute!
return A_Storage_Size_Pragma; -- 13.3(62)
elsif Pragma_Chars = Name_Suppress then
return A_Suppress_Pragma; -- 11.5(4), B(10)
elsif Pragma_Chars = Name_Task_Dispatching_Policy then
return A_Task_Dispatching_Policy_Pragma; -- H.2.2(2)
elsif Pragma_Chars = Name_Volatile then
return A_Volatile_Pragma; -- G.5(3)
elsif Pragma_Chars = Name_Volatile_Components then
return A_Volatile_Components_Pragma; -- G.5(3)
-- --|A2005 start
-- New Ada 2005 pragmas. To be alphabetically ordered later
elsif Pragma_Chars = Name_Assert then
return An_Assert_Pragma;
elsif Pragma_Chars = Name_Assertion_Policy then
return An_Assertion_Policy_Pragma;
elsif Pragma_Chars = Name_Detect_Blocking then
return A_Detect_Blocking_Pragma;
elsif Pragma_Chars = Name_No_Return then
return A_No_Return_Pragma;
-- A_Partition_Elaboration_Policy_Pragma - not implemented yet!
elsif Pragma_Chars = Name_Preelaborable_Initialization then
return A_Preelaborable_Initialization_Pragma;
elsif Pragma_Chars = Name_Priority_Specific_Dispatching then
return A_Priority_Specific_Dispatching_Pragma;
elsif Pragma_Chars = Name_Profile then
return A_Profile_Pragma;
elsif Pragma_Chars = Name_Relative_Deadline then
return A_Relative_Deadline_Pragma;
elsif Pragma_Chars = Name_Unchecked_Union then
return An_Unchecked_Union_Pragma;
elsif Pragma_Chars = Name_Unsuppress then
return An_Unsuppress_Pragma;
-- --|A2005 end
-- --|A2012 start
-- New Ada 2012 pragmas. To be alphabetically ordered later
elsif Pragma_Chars = Name_Default_Storage_Pool then
return A_Default_Storage_Pool_Pragma;
-- elsif Pragma_Chars = Name_Dispatching_Domain then SCz
-- return A_Dispatching_Domain_Pragma;
elsif Pragma_Chars = Name_CPU then
return A_CPU_Pragma;
elsif Pragma_Chars = Name_Independent then
return An_Independent_Pragma;
elsif Pragma_Chars = Name_Independent_Components then
return A_Independent_Components_Pragma;
-- To be continued...
-- --|A2012 end
-- Implementation(GNAT)-Defined Pragmas --
elsif Pragma_Chars in First_Pragma_Name .. Last_Pragma_Name then
-- We have already checked for all the standard pragma names, so
-- all the rest known as pragma name should be GNAT-specific pragmas.
return An_Implementation_Defined_Pragma; -- Vendor Appendix M
else
return An_Unknown_Pragma; -- Unknown to the compiler.
end if;
end N_Pragma_Mapping;
----------------------------------------
-- N_Procedure_Call_Statement_Mapping --
----------------------------------------
function N_Procedure_Call_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Parent_N : Node_Id := Parent (Parent (Node));
Result : Internal_Element_Kinds := A_Procedure_Call_Statement;
begin
-- The only special case we have to process is a procedure call that is
-- an argument of a pragma Debug. To satisfy the Ada syntax, we have to
-- classify it as A_Function_Call (see G330-002).
if Nkind (Parent_N) = N_Block_Statement
and then
not Comes_From_Source (Parent_N)
then
Parent_N := Parent (Parent_N);
if Nkind (Parent_N) = N_If_Statement
and then
Nkind (Original_Node (Parent_N)) = N_Pragma
and then
Pragma_Name (Original_Node (Parent_N)) = Name_Debug
then
Result := A_Function_Call;
end if;
end if;
return Result;
end N_Procedure_Call_Statement_Mapping;
-------------------------------------
-- N_Quantified_Expression_Mapping --
-------------------------------------
function N_Quantified_Expression_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := A_For_Some_Quantified_Expression;
begin
if All_Present (Node) then
Result := A_For_All_Quantified_Expression;
end if;
return Result;
end N_Quantified_Expression_Mapping;
--------------------------------
-- N_Range_Constraint_Mapping --
--------------------------------
function N_Range_Constraint_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Range_Attribute_Reference
-- A_Simple_Expression_Range
if Nkind (Original_Node (Range_Expression (Node))) = N_Range then
return A_Simple_Expression_Range;
else
return A_Range_Attribute_Reference;
end if;
end N_Range_Constraint_Mapping;
---------------------
-- N_Range_Mapping --
---------------------
function N_Range_Mapping (Node : Node_Id) return Internal_Element_Kinds is
Context_Kind : constant Node_Kind := Nkind (Original_Node (Parent_Node));
begin
-- The following Internal_Element_Kinds values may be possible:
-- A_Discrete_Simple_Expression_Range_As_Subtype_Definition
-- A_Discrete_Simple_Expression_Range
-- ???
-- Other values should be added during constructing the
-- full implementation
case Context_Kind is
when N_Constrained_Array_Definition
| N_Entry_Declaration =>
return A_Discrete_Simple_Expression_Range_As_Subtype_Definition;
when N_Index_Or_Discriminant_Constraint |
N_Slice |
N_Case_Statement_Alternative |
N_Component_Association
=>
return A_Discrete_Simple_Expression_Range;
when N_In |
N_Not_In =>
return A_Simple_Expression_Range;
when others => -- not implemented cases (???)
Not_Implemented_Mapping (Nkind (Node));
end case;
end N_Range_Mapping;
---------------------------------
-- N_Record_Definition_Mapping --
---------------------------------
function N_Record_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := A_Record_Type_Definition;
Is_Formal : constant Boolean :=
Nkind (Original_Node (Parent (Node))) = N_Formal_Type_Declaration;
begin
-- Two Internal_Element_Kinds values may be possible (Ada 95):
-- A_Record_Type_Definition
-- A_Tagged_Record_Type_Definition
-- --|A2005 start
-- Plus the following values for Ada 2005:
--
-- An_Ordinary_Interface
-- A_Limited_Interface
-- A_Task_Interface
-- A_Protected_Interface
-- A_Synchronized_Interface
--
-- A_Formal_Ordinary_Interface
-- A_Formal_Limited_Interface
-- A_Formal_Task_Interface
-- A_Formal_Protected_Interface
-- A_Formal_Synchronized_Interface
-- --|A2005 end
-- Implementation revised for Ada 2005
if Interface_Present (Node) then
if Limited_Present (Node) then
if Is_Formal then
Result := A_Formal_Limited_Interface;
else
Result := A_Limited_Interface;
end if;
elsif Task_Present (Node) then
if Is_Formal then
Result := A_Formal_Task_Interface;
else
Result := A_Task_Interface;
end if;
elsif Protected_Present (Node) then
if Is_Formal then
Result := A_Formal_Protected_Interface;
else
Result := A_Protected_Interface;
end if;
elsif Synchronized_Present (Node) then
if Is_Formal then
Result := A_Formal_Synchronized_Interface;
else
Result := A_Synchronized_Interface;
end if;
else
if Is_Formal then
Result := A_Formal_Ordinary_Interface;
else
Result := An_Ordinary_Interface;
end if;
end if;
elsif Tagged_Present (Node) then
Result := A_Tagged_Record_Type_Definition;
end if;
return Result;
-- --|A2005 end
end N_Record_Definition_Mapping;
---------------------------------
-- N_Requeue_Statement_Mapping --
---------------------------------
function N_Requeue_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Requeue_Statement
-- A_Requeue_Statement_With_Abort
if Abort_Present (Node) then
return A_Requeue_Statement_With_Abort;
else
return A_Requeue_Statement;
end if;
end N_Requeue_Statement_Mapping;
-------------------------------
-- N_Subprogram_Body_Mapping --
-------------------------------
function N_Subprogram_Body_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Procedure_Body_Declaration and A_Function_Body_Declaration
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Function_Body_Declaration;
else
return A_Procedure_Body_Declaration;
end if;
end N_Subprogram_Body_Mapping;
------------------------------------
-- N_Subprogram_Body_Stub_Mapping --
------------------------------------
function N_Subprogram_Body_Stub_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Procedure_Body_Stub and A_Function_Body_Stub,
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Function_Body_Stub;
else
return A_Procedure_Body_Stub;
end if;
end N_Subprogram_Body_Stub_Mapping;
--------------------------------------
-- N_Subprogram_Declaration_Mapping --
--------------------------------------
function N_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Procedure_Declaration
-- A_Function_Declaration
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Function_Declaration;
-- --|A2005 start
elsif Null_Present (Specification (Node)) then
return A_Null_Procedure_Declaration;
-- --|A2005 end
else
return A_Procedure_Declaration;
end if;
end N_Subprogram_Declaration_Mapping;
-----------------------------------------------
-- N_Subprogram_Renaming_Declaration_Mapping --
-----------------------------------------------
function N_Subprogram_Renaming_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Procedure_Renaming_Declaration and A_Function_Renaming_Declaration
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Function_Renaming_Declaration;
else
return A_Procedure_Renaming_Declaration;
end if;
end N_Subprogram_Renaming_Declaration_Mapping;
----------------------------------
-- N_Subtype_Indication_Mapping --
----------------------------------
function N_Subtype_Indication_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- The following Internal_Element_Kinds values may be possible:
-- A_Discrete_Subtype_Indication_As_Subtype_Definition
-- A_Discrete_Subtype_Indication
-- A_Subtype_Indication
case Nkind (Parent_Node) is
when N_Constrained_Array_Definition =>
if Is_List_Member (Node) then
return A_Discrete_Subtype_Indication_As_Subtype_Definition;
end if;
when N_Entry_Declaration =>
return A_Discrete_Subtype_Indication_As_Subtype_Definition;
when N_Index_Or_Discriminant_Constraint |
N_Slice =>
return A_Discrete_Subtype_Indication;
when others =>
null;
end case;
return A_Subtype_Indication;
end N_Subtype_Indication_Mapping;
-------------------------------
-- N_Use_Type_Clause_Mapping --
-------------------------------
function N_Use_Type_Clause_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
if All_Present (Node) then
return A_Use_All_Type_Clause;
else
return A_Use_Type_Clause;
end if;
end N_Use_Type_Clause_Mapping;
----------------------
-- N_To_E_List_New --
----------------------
function N_To_E_List_New
(List : List_Id;
Include_Pragmas : Boolean := False;
Starting_Element : Asis.Element := Asis.Nil_Element;
Node_Knd : Node_Kind := N_Empty;
Internal_Kind : Internal_Element_Kinds := Not_An_Element;
Special_Case : Special_Cases := Not_A_Special_Case;
Norm_Case : Normalization_Cases := Is_Not_Normalized;
In_Unit : Asis.Compilation_Unit := Asis.Nil_Compilation_Unit)
return Asis.Element_List
is
begin
Set_Element_List
(List,
Include_Pragmas,
Starting_Element,
Node_Knd,
Internal_Kind,
Special_Case,
Norm_Case,
In_Unit);
return Asis.Association_List
(Internal_Asis_Element_Table.Table
(1 .. Internal_Asis_Element_Table.Last));
end N_To_E_List_New;
----------------------------------------------
-- N_Unconstrained_Array_Definition_Mapping --
----------------------------------------------
function N_Unconstrained_Array_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- An_Unconstrained_Array_Definition
-- A_Formal_Unconstrained_Array_Definition
if Nkind (Parent (Node)) = N_Formal_Type_Declaration then
return A_Formal_Unconstrained_Array_Definition;
else
return An_Unconstrained_Array_Definition;
end if;
end N_Unconstrained_Array_Definition_Mapping;
----------------
-- No_Mapping --
----------------
procedure No_Mapping (Node : Node_Id) is
begin
-- This function should never be called!
raise Internal_Implementation_Error;
end No_Mapping;
-------------------------
-- Node_To_Element_New --
-------------------------
function Node_To_Element_New
(Node : Node_Id;
Node_Field_1 : Node_Id := Empty;
Node_Field_2 : Node_Id := Empty;
Starting_Element : Asis.Element := Asis.Nil_Element;
Internal_Kind : Internal_Element_Kinds := Not_An_Element;
Spec_Case : Special_Cases := Not_A_Special_Case;
Norm_Case : Normalization_Cases := Is_Not_Normalized;
Considering_Parent_Count : Boolean := True;
Using_Original_Node : Boolean := True;
Inherited : Boolean := False;
In_Unit : Asis.Compilation_Unit :=
Asis.Nil_Compilation_Unit)
return Asis.Element
is
R_Node : Node_Id;
Res_Node : Node_Id;
Res_Node_Field_1 : Node_Id := Empty;
Res_Node_Field_2 : Node_Id := Empty;
Res_Internal_Kind : Internal_Element_Kinds := Internal_Kind;
Res_Enclosing_Unit : Asis.Compilation_Unit;
Res_Is_Part_Of_Implicit : Boolean := False;
Res_Is_Part_Of_Inherited : Boolean := False;
Res_Is_Part_Of_Instance : Boolean := False;
Res_Spec_Case : Special_Cases := Spec_Case;
Res_Char_Code : Char_Code := 0;
Res_Parenth_Count : Nat := 0;
begin
-- first, check if Node is not Empty and return Nil_Element otherwise:
if No (Node) then
return Nil_Element;
end if;
if Using_Original_Node
and then
Is_Rewrite_Substitution (Node)
and then
not Is_Rewritten_Function_Prefix_Notation (Node)
then
-- Note that for a function call in Object.Operation notation we do
-- not use the original node at all, because the original tree
-- structure is not properly decorated and analyzed, but the
-- rewritten subtree contains all we need
Res_Node := Original_Node (Node);
if Is_Rewrite_Substitution (Res_Node) then
Res_Node := Original_Node (Res_Node);
end if;
else
Res_Node := Node;
end if;
-- setting the global Parent_Node needed for computing the kind of
-- the returned Element
Parent_Node := Parent (Node);
if not Is_Nil (Starting_Element) then
-- We need this to define the enclosing unit for the new Element
Res_Spec_Case := Special_Case (Starting_Element);
end if;
-- setting result's enclosing unit:
if Exists (In_Unit) then
-- if In_Unit is set, we take information about the result's
-- enclosing unit from it, unless we have to create a configuration
-- pragma or component thereof.
if Spec_Case = Configuration_File_Pragma then
Res_Enclosing_Unit := Get_Configuration_CU (In_Unit);
else
Res_Enclosing_Unit := In_Unit;
end if;
elsif not Is_Nil (Starting_Element) then
-- if Starting_Element is set, but In_Unit is not, we take
-- information about the result's enclosing unit from
-- Starting_Element
Res_Enclosing_Unit := Encl_Unit (Starting_Element);
else
-- we can be here only if both Starting_Element and In_Unit are
-- nor set. This is definitely an error.
raise Internal_Implementation_Error;
end if;
-- if Starting_Element is set, we "transfer" everything what is
-- possible from it to the result:
if not Is_Nil (Starting_Element) then
if Nkind (Res_Node) = N_Null_Statement
and then
not (Comes_From_Source (Res_Node))
then
-- Implicit NULL statement'floating' labels are attached to
Res_Is_Part_Of_Implicit := True;
elsif Nkind (Res_Node) = N_Label then
-- Needed in case of 'floating' labels
Res_Is_Part_Of_Implicit := False;
else
Res_Is_Part_Of_Implicit := Is_From_Implicit (Starting_Element);
end if;
Res_Is_Part_Of_Inherited := Is_From_Inherited (Starting_Element);
Res_Is_Part_Of_Instance := Is_From_Instance (Starting_Element);
-- Res_Spec_Case is already set!
if Present (Node_Field_1_Value (Starting_Element)) then
Res_Node_Field_1 := Node_Field_1_Value (Starting_Element);
pragma Assert (Get_Current_Tree = Encl_Tree (Starting_Element));
-- We can not use Asis.Set_Get.Node_Field_1 here, because it
-- might reset the tree.
end if;
if Present (Node_Field_2_Value (Starting_Element)) then
Res_Node_Field_2 := Node_Field_2_Value (Starting_Element);
pragma Assert (Get_Current_Tree = Encl_Tree (Starting_Element));
-- We can not use Asis.Set_Get.Node_Field_2 here, because it
-- might reset the tree.
end if;
if Internal_Kind = A_Defining_Character_Literal or else
Internal_Kind = An_Enumeration_Literal_Specification
then
-- We keep Character_Code unless the result is type definition
-- (it that case keeping Character_Code would make Is_Equal test
-- not work properly
Res_Char_Code := Character_Code (Starting_Element);
end if;
if Res_Spec_Case in Expanded_Spec then
-- We have to reset Res_Spec_Case from
-- Expanded_Package_Instantiation or
-- Expanded_Subprogram_Instantiation to Not_A_Special_Case;
-- because only (the whole) expanded generic declarations can have
-- the value of Special_Case from Expanded_Spec
Res_Spec_Case := Not_A_Special_Case;
end if;
elsif Res_Spec_Case in Expanded_Spec then
Res_Is_Part_Of_Implicit := False;
else
if Is_From_Instance (Original_Node (Node)) or else
Is_Name_Of_Expanded_Subprogram (Res_Node) or else
Part_Of_Pass_Generic_Actual (Original_Node (Node)) or else
Is_Stub_To_Body_Instanse_Replacement (Node) or else
Spec_Case = Expanded_Package_Instantiation or else
Spec_Case = Expanded_Subprogram_Instantiation
then
Res_Is_Part_Of_Instance := True;
end if;
if Inherited then
Res_Is_Part_Of_Inherited := True;
Res_Is_Part_Of_Implicit := True;
end if;
if not Comes_From_Source (Res_Node)
and then
(not Part_Of_Pass_Generic_Actual (Res_Node)
or else
Norm_Case = Is_Normalized_Defaulted_For_Box)
and then
not Is_Name_Of_Expanded_Subprogram (Res_Node)
then
Res_Is_Part_Of_Implicit := True;
end if;
end if;
-- This patch below is really terrible!!! requires revising!!!
-- ???
if Spec_Case = Expanded_Package_Instantiation or else
Spec_Case = Expanded_Subprogram_Instantiation
then
Res_Is_Part_Of_Instance := True;
end if;
-- if Spec_Case is set explicitly, we should set (or reset)
-- Res_Spec_Case from it
if Spec_Case /= Not_A_Special_Case then
Res_Spec_Case := Spec_Case;
end if;
-- computing the kind of the result and correcting Special_Case,
-- if needed
if Res_Internal_Kind = Not_An_Element then
-- Res_Internal_Kind is initialized by the value of the
-- Internal_Kind parameter. If this value differs from
-- Not_An_Element, we simply does not change it
if Considering_Parent_Count and then
(Parenth_Count (Res_Node, Node) > 0
or else
Requires_Parentheses (Res_Node))
then
-- special processing for A_Parenthesized_Expression
Res_Internal_Kind := A_Parenthesized_Expression;
if Parenth_Count (Res_Node, Node) > 0 then
Res_Parenth_Count := Parenth_Count (Res_Node, Node);
if Requires_Parentheses (Res_Node) then
Res_Parenth_Count := Res_Parenth_Count + 1;
end if;
else
-- (conditional expression)
Res_Parenth_Count := 1;
end if;
else
-- from Sinfo (spec, rev. 1.334):
---------------------------------
-- 9.5.3 Entry Call Statement --
---------------------------------
-- ENTRY_CALL_STATEMENT ::= entry_NAME [ACTUAL_PARAMETER_PART];
-- The parser may generate a procedure call for this construct. The
-- semantic pass must correct this misidentification where needed.
if Res_Node /= Node and then
((Nkind (Res_Node) = N_Procedure_Call_Statement and then
Nkind (Node) = N_Entry_Call_Statement and then
not Is_Protected_Procedure_Call (Node))
or else
(Nkind (Res_Node) = N_Explicit_Dereference and then
Nkind (Node) = N_Function_Call))
then
Res_Node := Node; -- ???
-- There is no need to keep the original structure in this
-- case, it is definitely wrong
if Nkind (Node) = N_Entry_Call_Statement then
Res_Internal_Kind := An_Entry_Call_Statement;
else
Res_Internal_Kind := A_Function_Call;
end if;
else
if (Nkind (Node) = N_Integer_Literal or else
Nkind (Node) = N_Real_Literal)
and then
((not Is_Rewrite_Substitution (Node))
or else
Nkind (Original_Node (Node)) = N_Identifier)
and then
Comes_From_Source (Node) = False
and then
Is_Static_Expression (Node)
and then
Present (Original_Entity (Node))
then
-- See BB10-002: The special case of named numbers rewritten
-- into numeric literals.
Res_Spec_Case := Rewritten_Named_Number;
Res_Internal_Kind := An_Identifier;
else
Res_Internal_Kind := Asis_Internal_Element_Kind (Res_Node);
end if;
end if;
end if;
end if;
-- and now we have to check if the Element to be returned is from the
-- Standard package, and if it is, we have to correct Res_Spec_Case:
if Res_Spec_Case = Not_A_Special_Case and then
Sloc (Res_Node) <= Standard_Location
then
if Nkind (Node) = N_Defining_Character_Literal then
Res_Spec_Case := Stand_Char_Literal;
else
Res_Spec_Case := Explicit_From_Standard;
end if;
end if;
if Res_Spec_Case = Explicit_From_Standard or else
Res_Spec_Case = Stand_Char_Literal
then
Res_Is_Part_Of_Implicit := False;
end if;
-- ??? This assignment is not necessary and has been
-- introduced to workaround a problem with the sgi n32 compiler
R_Node := Node;
if Nkind (Node) = N_Function_Call and then
(Res_Internal_Kind = A_Selected_Component or else
Res_Internal_Kind = An_Enumeration_Literal)
then
-- a reference to an overloaded enumeration literal represented as a
-- function call, we have to go one step down:
R_Node := Sinfo.Name (Node);
Res_Node := R_Node;
else
R_Node := Node;
end if;
if Present (Node_Field_1) then
Res_Node_Field_1 := Node_Field_1;
end if;
if Present (Node_Field_2) then
Res_Node_Field_2 := Node_Field_2;
end if;
if Res_Spec_Case = From_Limited_View then
Res_Is_Part_Of_Implicit := True;
end if;
return Set_Element (
Node => Res_Node,
R_Node => R_Node,
Node_Field_1 => Res_Node_Field_1,
Node_Field_2 => Res_Node_Field_2,
Encl_Unit => Res_Enclosing_Unit,
Int_Kind => Res_Internal_Kind,
Implicit => Res_Is_Part_Of_Implicit,
Inherited => Res_Is_Part_Of_Inherited,
Instance => Res_Is_Part_Of_Instance,
Spec_Case => Res_Spec_Case,
Norm_Case => Norm_Case,
Par_Count => Res_Parenth_Count,
Character_Code => Res_Char_Code);
end Node_To_Element_New;
--------------------
-- Normalize_Name --
--------------------
procedure Normalize_Name (Capitalized : Boolean := False) is
begin
if Namet.Name_Len = 0 then
return;
end if;
Namet.Name_Buffer (1) := To_Upper (Namet.Name_Buffer (1));
for I in 1 .. Namet.Name_Len - 1 loop
if Capitalized or else
Namet.Name_Buffer (I) = '_'
then
Namet.Name_Buffer (I + 1) := To_Upper (Namet.Name_Buffer (I + 1));
end if;
end loop;
end Normalize_Name;
-----------------------------
-- Normalized_Namet_String --
-----------------------------
function Normalized_Namet_String (Node : Node_Id) return String is
Capitalize : Boolean := False;
begin
Namet.Get_Name_String (Chars (Node));
if Node = Standard_ASCII or else
Node in SE (S_LC_A) .. SE (S_LC_Z) or else
Node in SE (S_NUL) .. SE (S_US) or else
Node = SE (S_DEL)
then
Capitalize := True;
end if;
Normalize_Name (Capitalize);
return Namet.Name_Buffer (1 .. Namet.Name_Len);
end Normalized_Namet_String;
-----------------------------
-- Not_Implemented_Mapping --
-----------------------------
function Not_Implemented_Mapping
(Node : Node_Id)
return Internal_Element_Kinds is
begin
Not_Implemented_Yet (Diagnosis =>
"AST Node -> Asis.Element mapping for the "
& Node_Kind'Image (Nkind (Node))
& " Node Kind value has not been implemented yet");
return Not_An_Element; -- to make the code syntactically correct;
end Not_Implemented_Mapping;
procedure Not_Implemented_Mapping (Source_Node_Kind : Node_Kind) is
begin
Not_Implemented_Yet (Diagnosis =>
"AST Node -> Asis.Element mapping for the "
& Node_Kind'Image (Source_Node_Kind)
& " Node Kind value has not been implemented yet");
end Not_Implemented_Mapping;
----------------------------------
-- Ordinary_Inclusion_Condition --
----------------------------------
function Ordinary_Inclusion_Condition (Node : Node_Id) return Boolean is
O_Node : constant Node_Id := Original_Node (Node);
Arg_Kind : constant Node_Kind := Nkind (Node);
Result : Boolean := True;
begin
if Is_Rewrite_Insertion (Node) or else
May_Be_Included_Switch (Nkind (Node)) = False or else
(Nkind (Node) = N_With_Clause
and then
Implicit_With (Node)) or else
(Nkind (Node) = N_Entry_Call_Statement
and then
Node = O_Node)
then
Result := False;
elsif not Comes_From_Source (O_Node) then
if Arg_Kind = N_Null_Statement then
-- We have to include implicit null statements 'floating' labels
-- are attached to
if not (No (Next (Node))
and then
Present (Prev (Node))
and then
Nkind (Prev (Node)) = N_Label
and then
Comes_From_Source (Prev (Node)))
then
Result := False;
end if;
elsif Arg_Kind = N_Object_Renaming_Declaration then
-- For FB02-008
if (Nkind (Sinfo.Name (Node)) = N_Identifier
and then
Is_Internal_Name (Chars (Sinfo.Name (Node))))
or else
(Nkind (Sinfo.Subtype_Mark (Node)) = N_Identifier
and then
Is_Internal_Name (Chars (Sinfo.Subtype_Mark (Node))))
then
Result := False;
end if;
elsif not ((Arg_Kind = N_Object_Declaration
and then
not Is_Internal_Name (Chars (Defining_Identifier (O_Node))))
or else
Arg_Kind = N_Component_Declaration
or else
Arg_Kind = N_Discriminant_Specification
or else
Arg_Kind = N_Parameter_Specification
or else
Arg_Kind = N_Component_Association
or else
((Arg_Kind = N_Integer_Literal
or else
Arg_Kind = N_Real_Literal)
and then
Is_Static_Expression (Node))
-- This condition describes the special case of a named
-- number rewritten into a literal node, see BB10-002
or else
Sloc (Node) <= Standard_Location
or else
Is_Rewritten_Function_Prefix_Notation (Parent (Node))
or else
Pass_Generic_Actual (Node))
then
Result := False;
end if;
end if;
return Result;
end Ordinary_Inclusion_Condition;
-------------------
-- Parenth_Count --
-------------------
function Parenth_Count
(N : Node_Id;
Original_N : Node_Id)
return Nat
is
Result : Nat := Paren_Count (N);
begin
if Result > 0 and then
Nkind (Original_Node (Parent (Original_N))) = N_Qualified_Expression
then
Result := Result - 1;
end if;
return Result;
end Parenth_Count;
--------------------------
-- Requires_Parentheses --
--------------------------
function Requires_Parentheses
(N : Node_Id)
return Boolean
is
Left_Par_Sloc : Source_Ptr;
Result : Boolean := False;
begin
if Nkind (N) = N_Conditional_Expression
or else
Nkind (N) = N_Case_Expression
or else
Nkind (N) = N_Quantified_Expression
then
Result := True;
-- And now - cases when the expression does not require parentheses:
if Nkind (Parent (N)) = N_Qualified_Expression
or else
Nkind (Parent (N)) = N_Type_Conversion
or else
(Is_List_Member (N)
and then
List_Length (List_Containing (N)) = 1)
then
-- There is a corner case here:
-- P ((if A then B else C));
Left_Par_Sloc := Sloc (N);
Left_Par_Sloc := Search_Prev_Word (Left_Par_Sloc);
pragma Assert (Get_Character (Left_Par_Sloc) = '(');
Left_Par_Sloc := Search_Prev_Word (Left_Par_Sloc);
if Get_Character (Left_Par_Sloc) /= '(' then
Result := False;
end if;
end if;
end if;
-- if Nkind (N) = N_Conditional_Expression
-- or else
-- Nkind (N) = N_Case_Expression
-- or else
-- Nkind (N) = N_Quantified_Expression
-- then
-- Left_Par_Sloc := Sloc (N);
-- Left_Par_Sloc := Search_Prev_Word (Left_Par_Sloc);
-- Result := Get_Character (Left_Par_Sloc) = '(';
-- end if;
-- if Result then
-- -- We have to check if this '(' belongs to some other construct:
-- Left_Par_Sloc := Search_Prev_Word (Left_Par_Sloc);
-- if Get_Character (Left_Par_Sloc) /= '(' then
-- case Nkind (Parent (N)) is
-- when N_Qualified_Expression |
-- N_Type_Conversion =>
-- Result := False;
-- when N_Function_Call |
-- N_Indexed_Component |
-- N_Procedure_Call_Statement |
-- N_Entry_Call_Statement =>
-- -- ??? Is this list complete???
-- if Get_Character (Left_Par_Sloc) /= ',' then
-- Result := False;
-- end if;
-- when others =>
-- null;
-- end case;
-- end if;
-- end if;
return Result;
end Requires_Parentheses;
-----------------------------------------
-- Set_Concurrent_Inherited_Components --
-----------------------------------------
procedure Set_Concurrent_Inherited_Components
(Type_Def : Asis.Element;
Include_Discs : Boolean := True)
is
Type_Entity : Entity_Id;
Next_Comp_Node : Node_Id;
begin
Asis_Element_Table.Init;
Type_Entity := Defining_Identifier (Parent (R_Node (Type_Def)));
if Present (First_Entity (Type_Entity)) then
if Include_Discs then
Next_Comp_Node := First_Entity (Type_Entity);
while Ekind (Next_Comp_Node) = E_Discriminant loop
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Parent (Next_Comp_Node),
Starting_Element => Type_Def));
Set_Node_Field_2
(Asis_Element_Table.Table (Asis_Element_Table.Last),
Next_Comp_Node);
-- This is needed to unify the processing of inherited
-- discriminants in Asis.Declarations.Names
Next_Comp_Node := Next_Entity (Next_Comp_Node);
end loop;
end if;
-- To set all the non-discriminant components, we have to go to the
-- definition of the root concurrent type and to traverse it to
-- grab all this components, because the (non-discrimiinant)
-- entities attached to the entity of the derived concurrent type
-- are artificial entities created for further tree expansion
while Type_Entity /= Etype (Type_Entity) loop
Type_Entity := Etype (Type_Entity);
end loop;
Type_Entity := Parent (Type_Entity);
if Nkind (Type_Entity) = N_Task_Type_Declaration then
Type_Entity := Task_Definition (Type_Entity);
else
Type_Entity := Protected_Definition (Type_Entity);
end if;
Next_Comp_Node :=
First_Non_Pragma (Visible_Declarations (Type_Entity));
while Present (Next_Comp_Node) loop
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Next_Comp_Node,
Starting_Element => Type_Def));
Next_Comp_Node := Next_Non_Pragma (Next_Comp_Node);
end loop;
if Present (Private_Declarations (Type_Entity)) then
Next_Comp_Node :=
First_Non_Pragma (Private_Declarations (Type_Entity));
while Present (Next_Comp_Node) loop
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Next_Comp_Node,
Starting_Element => Type_Def));
Next_Comp_Node := Next_Non_Pragma (Next_Comp_Node);
end loop;
end if;
end if;
end Set_Concurrent_Inherited_Components;
----------------------
-- Set_Element_List --
----------------------
-- At the moment, the implementation is just a copy from N_To_E_List_New
-- with changes related to building the result list in Element Table
procedure Set_Element_List
(List : List_Id;
Include_Pragmas : Boolean := False;
Starting_Element : Asis.Element := Asis.Nil_Element;
Node_Knd : Node_Kind := N_Empty;
Internal_Kind : Internal_Element_Kinds := Not_An_Element;
Special_Case : Special_Cases := Not_A_Special_Case;
Norm_Case : Normalization_Cases := Is_Not_Normalized;
In_Unit : Asis.Compilation_Unit := Asis.Nil_Compilation_Unit;
Append : Boolean := False)
is
List_El : Node_Id;
List_El_Kind : Node_Kind;
function First_List_Element (List : List_Id) return Node_Id;
-- returns the first element of List, taking into account
-- the value of Include_Pragmas
function Next_List_Element (Node : Node_Id) return Node_Id;
-- returns the first element of List, taking into account
-- the value of Include_Pragmas
procedure Skip_Pragmas (N : in out Node_Id);
-- Supposes that Is_List_Member (N). If N is of N_Pragma kind and if
-- Include_Pragmas is set OFF, moves N to the next element of the same
-- list that is not of N_Pragma kinds or set it to Empty if there is no
-- such node. We can not just use Nlists.First_Non_Pragma and
-- Nlists.Next_Non_Pragma, because they also skip N_Null_Statement
-- nodes.
------------------------
-- First_List_Element --
------------------------
function First_List_Element (List : List_Id) return Node_Id is
Result : Node_Id;
begin
Result := First (List);
Skip_Pragmas (Result);
if Is_Rewrite_Substitution (Result)
and then
Nkind (Result) = N_Loop_Statement
and then
Nkind (Original_Node (Result)) = N_Goto_Statement
then
-- This is the case when infinite loop implemented as
--
-- <<Target>> ...
-- ...
-- goto Target;
--
-- Is rewritten into N_Loop_Statement
if not Is_Empty_List (Statements (Result)) then
Result := First (Statements (Result));
end if;
end if;
return Result;
end First_List_Element;
-----------------------
-- Next_List_Element --
-----------------------
function Next_List_Element (Node : Node_Id) return Node_Id is
Tmp : Node_Id;
Result : Node_Id;
begin
Result := Next (Node);
Skip_Pragmas (Result);
if Is_Rewrite_Substitution (Result)
and then
Nkind (Result) = N_Loop_Statement
and then
Nkind (Original_Node (Result)) = N_Goto_Statement
then
-- This is the case when infinite loop implemented as
--
-- <<Target>> ...
-- ...
-- goto Target;
--
-- Is rewritten into N_Loop_Statement
if not Is_Empty_List (Statements (Result)) then
Result := First (Statements (Result));
end if;
end if;
if No (Result) then
Tmp := Parent (Node);
if Is_Rewrite_Substitution (Tmp)
and then
Nkind (Tmp) = N_Loop_Statement
and then
Nkind (Original_Node (Tmp)) = N_Goto_Statement
then
-- We have just finished traversing of the artificial loop
-- statement created for goto, so it's tome to
-- return this goto itself. Note, that we are returning the
-- rewritten N_Loop_Statement to keep list and parent
-- references
Result := Tmp;
end if;
end if;
return Result;
end Next_List_Element;
------------------
-- Skip_Pragmas --
------------------
procedure Skip_Pragmas (N : in out Node_Id) is
begin
if not Include_Pragmas then
while Present (N)
and then
Nkind (Original_Node (N)) = N_Pragma
loop
N := Next (N);
end loop;
end if;
end Skip_Pragmas;
begin
if not Append then
Internal_Asis_Element_Table.Init;
end if;
if No (List) or else Is_Empty_List (List) then
return;
end if;
List_El := First_List_Element (List);
while Present (List_El) loop
if Debug_Flag_L then
Write_Node (N => List_El,
Prefix => "Set_Element_List debug info-> ");
Write_Str ("May_Be_Included is ");
Write_Str (Boolean'Image (May_Be_Included (List_El)));
Write_Eol;
Write_Eol;
end if;
List_El_Kind := Nkind (List_El);
if May_Be_Included (List_El) and then
not ((Node_Knd /= N_Empty) and then (List_El_Kind /= Node_Knd))
then
Internal_Asis_Element_Table.Append
(Node_To_Element_New
(Starting_Element => Starting_Element,
Node => List_El,
Internal_Kind => Internal_Kind,
Spec_Case => Special_Case,
Norm_Case => Norm_Case,
In_Unit => In_Unit));
if List_El_Kind = N_Object_Declaration or else
List_El_Kind = N_Number_Declaration or else
List_El_Kind = N_Discriminant_Specification or else
List_El_Kind = N_Component_Declaration or else
List_El_Kind = N_Parameter_Specification or else
List_El_Kind = N_Exception_Declaration or else
List_El_Kind = N_Formal_Object_Declaration or else
List_El_Kind = N_With_Clause
then
Skip_Normalized_Declarations (List_El);
end if;
end if;
List_El := Next_List_Element (List_El);
end loop;
end Set_Element_List;
---------------------------------
-- Set_Inherited_Discriminants --
---------------------------------
procedure Set_Inherited_Discriminants (Type_Def : Asis.Element) is
Next_Discr_Elmt : Elmt_Id;
Next_Elem_Node : Node_Id;
begin
Next_Elem_Node := Defining_Identifier (Parent (R_Node (Type_Def)));
if Present (Stored_Constraint (Next_Elem_Node)) then
Asis_Element_Table.Init;
Next_Discr_Elmt := First_Elmt (Stored_Constraint (Next_Elem_Node));
while Present (Next_Discr_Elmt) loop
Next_Elem_Node := Parent (Entity (Node (Next_Discr_Elmt)));
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Next_Elem_Node,
Internal_Kind => A_Discriminant_Specification,
Starting_Element => Type_Def));
Next_Discr_Elmt := Next_Elmt (Next_Discr_Elmt);
end loop;
end if;
end Set_Inherited_Discriminants;
------------------------------
-- Set_Inherited_Components --
------------------------------
procedure Set_Inherited_Components
(Type_Def : Asis.Element;
Include_Discs : Boolean := True)
is
Next_Comp_Node : Node_Id;
function Is_Implicit_Component (E : Entity_Id) return Boolean;
-- Checks if E is an entity representing implicit inherited
-- component
function Is_Implicit_Component (E : Entity_Id) return Boolean is
Result : Boolean := False;
begin
if Ekind (E) = E_Component then
Result :=
(E /= Original_Record_Component (E)) or else
not Comes_From_Source (Parent (E));
elsif Ekind (E) = E_Discriminant and then Include_Discs then
Result := not Is_Completely_Hidden (E);
end if;
return Result;
end Is_Implicit_Component;
begin
Asis_Element_Table.Init;
Next_Comp_Node := Defining_Identifier (Parent (R_Node (Type_Def)));
if Ekind (Next_Comp_Node) = E_Record_Subtype then
-- For subtypes we may have components depending on discriminants
-- skipped in case of static discriminant constraints
Next_Comp_Node := Etype (Next_Comp_Node);
end if;
if Present (First_Entity (Next_Comp_Node)) then
Next_Comp_Node := First_Entity (Next_Comp_Node);
while Present (Next_Comp_Node) loop
if Is_Implicit_Component (Next_Comp_Node) then
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Parent (Next_Comp_Node),
Starting_Element => Type_Def));
Set_Node_Field_2
(Asis_Element_Table.Table (Asis_Element_Table.Last),
Next_Comp_Node);
Set_From_Implicit
(Asis_Element_Table.Table (Asis_Element_Table.Last), True);
Set_From_Inherited
(Asis_Element_Table.Table (Asis_Element_Table.Last), True);
end if;
Next_Comp_Node := Next_Entity (Next_Comp_Node);
end loop;
end if;
end Set_Inherited_Components;
----------------------------
-- Set_Inherited_Literals --
----------------------------
procedure Set_Inherited_Literals (Type_Def : Asis.Element) is
Next_Literal_Node : Node_Id;
Res_Etype : Entity_Id;
Encl_Type : constant Node_Id := Parent (R_Node (Type_Def));
begin
Asis_Element_Table.Init;
Next_Literal_Node := Defining_Identifier (Parent (R_Node (Type_Def)));
if Present (First_Literal (Next_Literal_Node)) then
Next_Literal_Node := First_Literal (Next_Literal_Node);
Res_Etype := Etype (Next_Literal_Node);
while Present (Next_Literal_Node) and then
Etype (Next_Literal_Node) = Res_Etype
loop
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Next_Literal_Node,
Internal_Kind => An_Enumeration_Literal_Specification,
Starting_Element => Type_Def));
Set_Node_Field_1
(Asis_Element_Table.Table (Asis_Element_Table.Last),
Encl_Type);
Set_From_Implicit
(Asis_Element_Table.Table (Asis_Element_Table.Last), True);
Set_From_Inherited
(Asis_Element_Table.Table (Asis_Element_Table.Last), True);
Next_Literal_Node := Next_Entity (Next_Literal_Node);
end loop;
else
Not_Implemented_Yet
(Diagnosis =>
"Asis.Definitions.Implicit_Inherited_Declarations "
& "(derived from Standard character type)");
end if;
end Set_Inherited_Literals;
----------------------------------
-- Skip_Normalized_Declarations --
----------------------------------
procedure Skip_Normalized_Declarations (Node : in out Node_Id) is
Arg_Kind : constant Node_Kind := Nkind (Node);
begin
loop
if Arg_Kind = N_Object_Declaration or else
Arg_Kind = N_Number_Declaration or else
Arg_Kind = N_Discriminant_Specification or else
Arg_Kind = N_Component_Declaration or else
Arg_Kind = N_Parameter_Specification or else
Arg_Kind = N_Exception_Declaration or else
Arg_Kind = N_Formal_Object_Declaration
then
if More_Ids (Node) then
Node := Next (Node);
while Nkind (Node) /= Arg_Kind loop
-- some implicit subtype declarations may be inserted by
-- the compiler in between the normalized declarations, so:
Node := Next (Node);
end loop;
else
return;
end if;
else
-- Arg_Kind = N_With_Clause.
-- Note that we should skip implicit clauses that can be added by
-- front-end.
if Comes_From_Source (Node) and then Last_Name (Node) then
return;
else
Node := Next (Node);
end if;
end if;
end loop;
end Skip_Normalized_Declarations;
-------------------------------
-- Subprogram_Attribute_Kind --
-------------------------------
function Subprogram_Attribute_Kind
(Node : Node_Id)
return Internal_Element_Kinds
is
Attribute_Chars : Name_Id;
begin
Attribute_Chars := Attribute_Name (Node);
-- language-defined attributes which are functions:
if Attribute_Chars = Name_Adjacent then
return An_Adjacent_Attribute;
elsif Attribute_Chars = Name_Ceiling then
return A_Ceiling_Attribute;
elsif Attribute_Chars = Name_Compose then
return A_Compose_Attribute;
elsif Attribute_Chars = Name_Copy_Sign then
return A_Copy_Sign_Attribute;
elsif Attribute_Chars = Name_Exponent then
return An_Exponent_Attribute;
elsif Attribute_Chars = Name_Floor then
return A_Floor_Attribute;
elsif Attribute_Chars = Name_Fraction then
return A_Fraction_Attribute;
elsif Attribute_Chars = Name_Image then
return An_Image_Attribute;
elsif Attribute_Chars = Name_Input then
return An_Input_Attribute;
elsif Attribute_Chars = Name_Leading_Part then
return A_Leading_Part_Attribute;
elsif Attribute_Chars = Name_Machine then
return A_Machine_Attribute;
elsif Attribute_Chars = Name_Max then
return A_Max_Attribute;
elsif Attribute_Chars = Name_Min then
return A_Min_Attribute;
elsif Attribute_Chars = Name_Model then
return A_Model_Attribute;
elsif Attribute_Chars = Name_Pos then
return A_Pos_Attribute;
elsif Attribute_Chars = Name_Pred then
return A_Pred_Attribute;
elsif Attribute_Chars = Name_Remainder then
return A_Remainder_Attribute;
elsif Attribute_Chars = Name_Round then
return A_Round_Attribute;
elsif Attribute_Chars = Name_Rounding then
return A_Rounding_Attribute;
elsif Attribute_Chars = Name_Scaling then
return A_Scaling_Attribute;
elsif Attribute_Chars = Name_Succ then
return A_Succ_Attribute;
elsif Attribute_Chars = Name_Truncation then
return A_Truncation_Attribute;
elsif Attribute_Chars = Name_Unbiased_Rounding then
return An_Unbiased_Rounding_Attribute;
elsif Attribute_Chars = Name_Val then
return A_Val_Attribute;
elsif Attribute_Chars = Name_Value then
return A_Value_Attribute;
elsif Attribute_Chars = Name_Wide_Image then
return A_Wide_Image_Attribute;
elsif Attribute_Chars = Name_Wide_Value then
return A_Wide_Value_Attribute;
-- |A2005 start
-- Ada 2005 attributes that are functions:
elsif Attribute_Chars = Name_Machine_Rounding then
return A_Machine_Rounding_Attribute;
elsif Attribute_Chars = Name_Mod then
return A_Mod_Attribute;
elsif Attribute_Chars = Name_Wide_Wide_Image then
return A_Wide_Wide_Image_Attribute;
elsif Attribute_Chars = Name_Wide_Wide_Value then
return A_Wide_Wide_Value_Attribute;
-- |A2005 end
-- |A2012 start
-- Ada 2012 attributes that are functions:
-- elsif Attribute_Chars = Name_Overlaps_Storage then (SCz)
-- return An_Overlaps_Storage_Attribute;
-- |A2012 end
-- language-defined attributes which are procedures:
elsif Attribute_Chars = Name_Output then
return An_Output_Attribute;
elsif Attribute_Chars = Name_Read then
return A_Read_Attribute;
elsif Attribute_Chars = Name_Write then
return A_Write_Attribute;
-- Implementation Dependent Attributes-Functions --
elsif Attribute_Chars = Name_Asm_Input or else
Attribute_Chars = Name_Asm_Output or else
Attribute_Chars = Name_Enum_Rep or else
Attribute_Chars = Name_Enum_Val or else
Attribute_Chars = Name_Fixed_Value or else
Attribute_Chars = Name_Integer_Value or else
Attribute_Chars = Name_Ref
then
return An_Implementation_Defined_Attribute;
else
return An_Unknown_Attribute;
end if;
end Subprogram_Attribute_Kind;
-----------------
-- Ureal_Image --
-----------------
function Ureal_Image (N : Node_Id) return String is
Result : String (1 .. 256);
Res_Len : Natural range 0 .. 256 := 0;
-- bad solution!!! ASIS needs a general-purpose String buffer
-- somewhere!!! ???
Real : constant Ureal := Realval (N);
Nom : constant Uint := Norm_Num (Real);
Den : constant Uint := Norm_Den (Real);
Dot_Outputed : Boolean := False;
begin
if UR_Is_Negative (Real) then
Res_Len := Res_Len + 1;
Result (Res_Len) := '(';
Res_Len := Res_Len + 1;
Result (Res_Len) := '-';
end if;
UI_Image (Nom, Decimal);
for I in 1 .. UI_Image_Length loop
if UI_Image_Buffer (I) = 'E' then
Res_Len := Res_Len + 1;
Result (Res_Len) := '.';
Res_Len := Res_Len + 1;
Result (Res_Len) := '0';
Res_Len := Res_Len + 1;
Result (Res_Len) := 'E';
Dot_Outputed := True;
else
Res_Len := Res_Len + 1;
Result (Res_Len) := UI_Image_Buffer (I);
end if;
end loop;
if not Dot_Outputed then
Res_Len := Res_Len + 1;
Result (Res_Len) := '.';
Res_Len := Res_Len + 1;
Result (Res_Len) := '0';
end if;
Dot_Outputed := False;
Res_Len := Res_Len + 1;
Result (Res_Len) := '/';
UI_Image (Den, Decimal);
for I in 1 .. UI_Image_Length loop
if UI_Image_Buffer (I) = 'E' then
Res_Len := Res_Len + 1;
Result (Res_Len) := '.';
Res_Len := Res_Len + 1;
Result (Res_Len) := '0';
Res_Len := Res_Len + 1;
Result (Res_Len) := 'E';
Dot_Outputed := True;
else
Res_Len := Res_Len + 1;
Result (Res_Len) := UI_Image_Buffer (I);
end if;
end loop;
if not Dot_Outputed then
Res_Len := Res_Len + 1;
Result (Res_Len) := '.';
Res_Len := Res_Len + 1;
Result (Res_Len) := '0';
end if;
if UR_Is_Negative (Real) then
Res_Len := Res_Len + 1;
Result (Res_Len) := ')';
end if;
return Result (1 .. Res_Len);
end Ureal_Image;
end A4G.Mapping;
| true | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . M A P P I N G --
-- --
-- B o d y --
-- --
-- Copyright (C) 1995-2012, Free Software Foundation, Inc. --
-- --
-- ASIS-for-GNAT is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore --
-- (http://www.adPI:EMAIL:<EMAIL>END_PI.com). --
-- --
------------------------------------------------------------------------------
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Asis; use Asis;
with Asis.Compilation_Units; use Asis.Compilation_Units;
with Asis.Elements; use Asis.Elements;
with Asis.Set_Get; use Asis.Set_Get;
with A4G.A_Debug; use A4G.A_Debug;
with A4G.A_Output; use A4G.A_Output;
with A4G.A_Sem; use A4G.A_Sem;
with A4G.A_Sinput; use A4G.A_Sinput;
with A4G.Asis_Tables; use A4G.Asis_Tables;
with A4G.Contt; use A4G.Contt;
with A4G.Norm; use A4G.Norm;
with A4G.Vcheck; use A4G.Vcheck;
with Atree; use Atree;
with Einfo; use Einfo;
with Elists; use Elists;
with Namet; use Namet;
with Nlists; use Nlists;
with Output; use Output;
with Snames; use Snames;
with Stand; use Stand;
with Uintp; use Uintp;
with Urealp; use Urealp;
package body A4G.Mapping is
-------------------------------------------
-- Tree nodes onto ASIS Elements Mapping --
-------------------------------------------
-- The kernel of the mapping from tree nodes onto ASIS Elements is
-- determining the ASIS kind of the Element which should be built on top
-- of a given node. We are computing the Element position in the internal
-- flat classification, that is, the corresponding value of
-- Internal_Element_Kinds (which is further referred simply as Element
-- kind in this unit).
--
-- Mapping of tree nodes onto Element kinds is implemented as two-level
-- switching based on look-up tables. Both look-up tables are one-dimension
-- arrays indexed by Node_Kind type).
--
-- The first table has Internal_Element_Kinds as its component type. It
-- defines the mapping of Node_Kind values onto Internal_Element_Kinds
-- values as pairs index_value -> component_value, the semantics of this
-- mapping depends on the component value in the following way:
--
-- Component value First switch mapping semantics
--
-- A_Xxx, where A_Xxx corresponds - Element which should be based on
-- to some position in the original any node having the corresponding
-- ASIS element classification Node_Kind will always be of A_Xxx
-- hierarchy (such as An_Identifier) ASIS kind, no more computation
-- of Element kind is needed
--
-- Non_Trivial_Mapping - Elements which can be built on
-- nodes having the corresponding
-- Node_Kind may have different ASIS
-- kinds, therefore a special function
-- computing the ASIS kind should be
-- used, this function is defined by
-- the second look-up table
--
-- No_Mapping - no ASIS Element kind corresponds to
-- nodes of the corresponding
-- Node_Kind in the framework of the
-- given node-to-Element mapping
--
-- Not_Implemented_Mapping - this value was used during the
-- development phase and now it is
-- kept as the value for 'others'
-- choice in the initialization
-- aggregate just in case if a new
-- value appear in Node_Kind type
--
-- No_Mapping does not mean, that for a given Node_Kind value no Element
-- can be created at all, it means, that automatic Element kind
-- determination is impossible for these nodes because of any reason.
--
-- Both No_Mapping and Not_Implemented_Mapping mapping items, when chosen.
-- resulted in raising the ASIS_Failed exception. The reason because of
-- which we keep Not_Implemented_Mapping value after finishing the
-- development stage is to catch possible changes in Node_Kind definition.
-- No_Mapping means that for sure there is no mapping for a given Node_Kind
-- value, and Not_Implemented_Mapping means that processing of the given
-- Node_Kind value is missed in the existing code.
--
-- The second look-up table defines functions to be used to compute
-- Element kind for those Node_Kind values for which the first table
-- defines Non_Trivial_Mapping. All these functions are supposed to be
-- called for nodes of the Node_Kind from the corresponding mapping item
-- defined by the second table, it is erroneous to call them for other
-- nodes.
--
-- The structure, documentation and naming policy for look-up tables
-- implementing note-to-Element mapping are based on the GNAT Sinfo
-- package, and, in particular, on the Sinfo.Node_Kind type definition.
-- Rather old version of the spec of Sinfo is used, so some deviations
-- with the latest version may be possible
------------------------------------------------------
-- Tree nodes lists onto ASIS Element lists Mapping --
------------------------------------------------------
-- ASIS Element lists are built from tree node lists: when constructing an
-- ASIS Element_List value, the corresponding routine goes trough the
-- corresponding tree node list, checks which nodes should be used as a
-- basis for ASIS Elements to be placed in the result Element_List, and
-- which should not, and then calls node-to-Element conversion function
-- for the selected nodes. Therefore, two main components of node list to
-- Element list mapping are filters for the nodes in the argument node
-- list and node-to-Element mapping
-----------------------
-- Local subprograms --
-----------------------
procedure Normalize_Name (Capitalized : Boolean := False);
-- This procedure "normalizes" a name stored in Namet.Name_Buffer by
-- capitalizing its firs letter and all the letters following underscores
-- (if any). If Capitalized is set ON, all the letters are converted to
-- upper case, this is used for some defining names from Standard (such as
-- ASCII)
function Is_Protected_Procedure_Call (N : Node_Id) return Boolean;
-- In case if N is of N_Entry_Call_Statement, it checks if this is a call
-- to a protected subprogram (if it is, the corresponding ASIS Element
-- should be classified as A_Procedure_Call_Statement, but not as
-- An_Entry_Call_Statement
function Is_Stub_To_Body_Instanse_Replacement
(N : Node_Id)
return Boolean;
-- Checks if the node corresponds to the body which replaces the body stub
-- within the instance. The reason why we need this is that Sloc
-- field is not set to point into the instance copy if the source for
-- such node, so the ordinary Is_From_Instance check does not work
-- for this node (see 8930-001)
function Is_Config_Pragma (N : Node_Id) return Boolean;
-- Checks if N represents a configuration pragma
function Requires_Parentheses
(N : Node_Id)
return Boolean;
-- Checks if N represents a conditional or quantified expression in the
-- context that requires the expression to be in parentheses. The problem
-- is that in this case Parent_Count is 0. This function is supposed to be
-- called if Parent_Count (N) = 0
--------------------------------------------------------------
-- Subprograms for the second Note-to-Element Look-Up Table --
--------------------------------------------------------------
procedure No_Mapping (Node : Node_Id);
function Not_Implemented_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
procedure Not_Implemented_Mapping (Source_Node_Kind : Node_Kind);
-- These three subprograms raise ASIS_Failed with the appropriate
-- Diagnosis string
pragma No_Return (Not_Implemented_Mapping);
pragma No_Return (No_Mapping);
-- Individual mapping components:
function N_Pragma_Mapping (Node : Node_Id) return Internal_Element_Kinds;
function N_Defining_Identifier_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Defining_Operator_Symbol_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Expanded_Name_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Identifier_Mapping
(Node : Node_Id)
return Internal_Element_Kinds renames N_Expanded_Name_Mapping;
function N_Attribute_Reference_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Function_Call_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Range_Mapping (Node : Node_Id) return Internal_Element_Kinds;
function N_Allocator_Mapping (Node : Node_Id) return Internal_Element_Kinds;
function N_Aggregate_Mapping (Node : Node_Id) return Internal_Element_Kinds;
-- |A2005 start
function N_Incomplete_Type_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
-- |A2005 end
function N_Subtype_Indication_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
-- |A2012 start
function N_Formal_Type_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Iterator_Specification_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Quantified_Expression_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
-- |A2012 end
function N_Object_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Access_Function_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Access_Procedure_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Subprogram_Body_Stub_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Subprogram_Body_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Generic_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Constrained_Array_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Unconstrained_Array_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Subprogram_Renaming_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Loop_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Requeue_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Abstract_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Accept_Alternative_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
-- --|A2005 start
function N_Access_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
-- --|A2005 end
function N_Access_To_Object_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Component_Association_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Derived_Type_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Delay_Alternative_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Formal_Package_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Formal_Private_Type_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Formal_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Index_Or_Discriminant_Constraint_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Number_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Procedure_Call_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Range_Constraint_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Record_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Use_Type_Clause_Mapping
(Node : Node_Id)
return Internal_Element_Kinds;
function N_Terminate_Alternative_Mapping
(Node : Node_Id)
return Internal_Element_Kinds renames N_Accept_Alternative_Mapping;
-----------------------------------------
-- Node lists to Element lists filters --
-----------------------------------------
function May_Be_Included (Node : Node_Id) return Boolean;
-- Top-level filter for selecting nodes from a node list to be used to
-- create ASIS Elements which are members of some ASIS Element List.
function Ordinary_Inclusion_Condition (Node : Node_Id) return Boolean;
-- Defines the general condition for a separate node list member to be
-- used to construct an Element to be returned by some ASIS query. This
-- function does not make the final decision, because the node may be
-- duplicated, and this is checked in the May_Be_Included function
procedure Skip_Normalized_Declarations (Node : in out Node_Id);
-- This procedure is applied in case when the compiler normalizes a
-- multi-identifier declaration (or multi-name with clause) in a set of
-- equivalent one-identifier (one-name) declarations (clauses). It is
-- intended to be called for Node representing the first declaration
-- (clause) in this normalized sequence, and it resets its parameter
-- to point to the last declaration (clause) in this sequence
-----------------------------------------
-- Node-to-Element First Look-Up Table --
-----------------------------------------
Node_To_Element_Kind_Mapping_First_Switch :
constant array (Node_Kind) of Internal_Element_Kinds := (
N_Unused_At_Start => No_Mapping,
N_At_Clause => An_At_Clause,
N_Component_Clause => A_Component_Clause,
N_Enumeration_Representation_Clause => An_Enumeration_Representation_Clause,
N_Mod_Clause => No_Mapping,
N_Record_Representation_Clause => A_Record_Representation_Clause,
N_Attribute_Definition_Clause => An_Attribute_Definition_Clause,
N_Empty => No_Mapping,
N_Error => No_Mapping,
N_Pragma => Non_Trivial_Mapping,
N_Pragma_Argument_Association => A_Pragma_Argument_Association,
N_Defining_Character_Literal => A_Defining_Character_Literal,
N_Defining_Identifier => Non_Trivial_Mapping,
N_Defining_Operator_Symbol => Non_Trivial_Mapping,
N_Expanded_Name => Non_Trivial_Mapping,
N_Identifier => Non_Trivial_Mapping,
N_Character_Literal => A_Character_Literal,
N_Operator_Symbol => Non_Trivial_Mapping,
N_Op_Add => A_Function_Call,
N_Op_And => A_Function_Call,
N_And_Then => An_And_Then_Short_Circuit,
N_Op_Concat => A_Function_Call,
N_Op_Divide => A_Function_Call,
N_Op_Eq => A_Function_Call,
N_Op_Expon => A_Function_Call,
N_Op_Ge => A_Function_Call,
N_Op_Gt => A_Function_Call,
-- N_In => Non_Trivial_Mapping,
N_In => An_In_Membership_Test,
N_Op_Le => A_Function_Call,
N_Op_Lt => A_Function_Call,
N_Op_Mod => A_Function_Call,
N_Op_Multiply => A_Function_Call,
N_Op_Ne => A_Function_Call,
-- N_Not_In => Non_Trivial_Mapping,
N_Not_In => A_Not_In_Membership_Test,
N_Op_Or => A_Function_Call,
N_Or_Else => An_Or_Else_Short_Circuit,
N_Op_Rem => A_Function_Call,
N_Op_Subtract => A_Function_Call,
N_Op_Xor => A_Function_Call,
N_Op_Abs => A_Function_Call,
N_Op_Minus => A_Function_Call,
N_Op_Not => A_Function_Call,
N_Op_Plus => A_Function_Call,
N_Attribute_Reference => Non_Trivial_Mapping,
N_Conditional_Expression => An_If_Expression,
N_Explicit_Dereference => An_Explicit_Dereference,
N_Function_Call => Non_Trivial_Mapping,
N_Indexed_Component => An_Indexed_Component,
N_Integer_Literal => An_Integer_Literal,
N_Null => A_Null_Literal,
N_Procedure_Call_Statement => Non_Trivial_Mapping,
N_Qualified_Expression => A_Qualified_Expression,
N_Quantified_Expression => Non_Trivial_Mapping,
N_Raise_Constraint_Error => No_Mapping,
N_Range => Non_Trivial_Mapping,
N_Real_Literal => A_Real_Literal,
N_Selected_Component => A_Selected_Component,
N_Type_Conversion => A_Type_Conversion,
N_Allocator => Non_Trivial_Mapping,
N_Case_Expression => A_Case_Expression, -- ASIS 2012
N_Aggregate => Non_Trivial_Mapping,
N_Extension_Aggregate => An_Extension_Aggregate,
N_Slice => A_Slice,
N_String_Literal => A_String_Literal,
N_Subtype_Indication => Non_Trivial_Mapping,
N_Component_Declaration => A_Component_Declaration,
N_Entry_Body => An_Entry_Body_Declaration,
N_Entry_Declaration => An_Entry_Declaration,
-- N_Expression_Function => An_Expression_Function_Declaration, (SCz)
N_Entry_Index_Specification => An_Entry_Index_Specification,
N_Formal_Object_Declaration => A_Formal_Object_Declaration,
N_Formal_Type_Declaration => Non_Trivial_Mapping,
N_Freeze_Entity => No_Mapping,
N_Full_Type_Declaration => An_Ordinary_Type_Declaration,
-- --|A2005 start
-- N_Incomplete_Type_Declaration => An_Incomplete_Type_Declaration,
N_Incomplete_Type_Declaration => Non_Trivial_Mapping,
-- --|A2005 end
-- --|A2012 start
N_Iterator_Specification => Non_Trivial_Mapping,
-- --|A2012 end
N_Loop_Parameter_Specification => A_Loop_Parameter_Specification,
N_Object_Declaration => Non_Trivial_Mapping,
N_Private_Extension_Declaration => A_Private_Extension_Declaration,
N_Private_Type_Declaration => A_Private_Type_Declaration,
N_Subtype_Declaration => A_Subtype_Declaration,
N_Protected_Type_Declaration => A_Protected_Type_Declaration,
N_Accept_Statement => An_Accept_Statement,
N_Function_Specification => No_Mapping,
N_Procedure_Specification => No_Mapping,
N_Access_Function_Definition => Non_Trivial_Mapping,
N_Access_Procedure_Definition => Non_Trivial_Mapping,
N_Task_Type_Declaration => A_Task_Type_Declaration,
N_Package_Body_Stub => A_Package_Body_Stub,
N_Protected_Body_Stub => A_Protected_Body_Stub,
N_Subprogram_Body_Stub => Non_Trivial_Mapping,
N_Task_Body_Stub => A_Task_Body_Stub,
N_Function_Instantiation => A_Function_Instantiation,
N_Package_Instantiation => A_Package_Instantiation,
N_Procedure_Instantiation => A_Procedure_Instantiation,
N_Package_Body => A_Package_Body_Declaration,
N_Subprogram_Body => Non_Trivial_Mapping,
N_Implicit_Label_Declaration => No_Mapping,
N_Package_Declaration => A_Package_Declaration,
N_Single_Task_Declaration => A_Single_Task_Declaration,
N_Subprogram_Declaration => Non_Trivial_Mapping,
N_Task_Body => A_Task_Body_Declaration,
N_Use_Package_Clause => A_Use_Package_Clause,
N_Generic_Package_Declaration => A_Generic_Package_Declaration,
N_Generic_Subprogram_Declaration => Non_Trivial_Mapping,
N_Constrained_Array_Definition => Non_Trivial_Mapping,
N_Unconstrained_Array_Definition => Non_Trivial_Mapping,
N_Exception_Renaming_Declaration => An_Exception_Renaming_Declaration,
N_Object_Renaming_Declaration => An_Object_Renaming_Declaration,
N_Package_Renaming_Declaration => A_Package_Renaming_Declaration,
N_Subprogram_Renaming_Declaration => Non_Trivial_Mapping,
N_Generic_Function_Renaming_Declaration =>
A_Generic_Function_Renaming_Declaration,
N_Generic_Package_Renaming_Declaration =>
A_Generic_Package_Renaming_Declaration,
N_Generic_Procedure_Renaming_Declaration =>
A_Generic_Procedure_Renaming_Declaration,
N_Abort_Statement => An_Abort_Statement,
N_Assignment_Statement => An_Assignment_Statement,
N_Block_Statement => A_Block_Statement,
N_Case_Statement => A_Case_Statement,
N_Code_Statement => A_Code_Statement,
N_Delay_Relative_Statement => A_Delay_Relative_Statement,
N_Delay_Until_Statement => A_Delay_Until_Statement,
N_Entry_Call_Statement => An_Entry_Call_Statement,
N_Exit_Statement => An_Exit_Statement,
N_Free_Statement => No_Mapping,
N_Goto_Statement => A_Goto_Statement,
N_If_Statement => An_If_Statement,
N_Loop_Statement => Non_Trivial_Mapping,
N_Null_Statement => A_Null_Statement,
N_Raise_Statement => A_Raise_Statement,
N_Requeue_Statement => Non_Trivial_Mapping,
N_Return_Statement => A_Return_Statement,
N_Extended_Return_Statement => An_Extended_Return_Statement,
N_Abortable_Part => A_Then_Abort_Path,
N_Abstract_Subprogram_Declaration => Non_Trivial_Mapping,
N_Accept_Alternative => Non_Trivial_Mapping,
-- --|A2005 start
N_Access_Definition => Non_Trivial_Mapping,
-- --|A2005 end
N_Access_To_Object_Definition => Non_Trivial_Mapping,
-- --|A2012 start
N_Aspect_Specification => An_Aspect_Specification,
N_Case_Expression_Alternative => A_Case_Expression_Path,
-- --|A2012 end
N_Asynchronous_Select => An_Asynchronous_Select_Statement,
N_Case_Statement_Alternative => A_Case_Path,
N_Compilation_Unit => No_Mapping,
N_Component_Association => Non_Trivial_Mapping,
N_Component_Definition => A_Component_Definition,
N_Conditional_Entry_Call => A_Conditional_Entry_Call_Statement,
N_Derived_Type_Definition => Non_Trivial_Mapping,
N_Decimal_Fixed_Point_Definition => A_Decimal_Fixed_Point_Definition,
N_Defining_Program_Unit_Name => A_Defining_Expanded_Name,
N_Delay_Alternative => Non_Trivial_Mapping,
N_Delta_Constraint => A_Delta_Constraint,
N_Digits_Constraint => A_Digits_Constraint,
N_Discriminant_Association => A_Discriminant_Association,
N_Discriminant_Specification => A_Discriminant_Specification,
N_Elsif_Part => An_Elsif_Path,
N_Enumeration_Type_Definition => An_Enumeration_Type_Definition,
N_Entry_Call_Alternative => A_Select_Path,
N_Exception_Declaration => An_Exception_Declaration,
N_Exception_Handler => An_Exception_Handler,
N_Floating_Point_Definition => A_Floating_Point_Definition,
N_Formal_Decimal_Fixed_Point_Definition =>
A_Formal_Decimal_Fixed_Point_Definition,
N_Formal_Derived_Type_Definition => A_Formal_Derived_Type_Definition,
N_Formal_Discrete_Type_Definition => A_Formal_Discrete_Type_Definition,
N_Formal_Floating_Point_Definition => A_Formal_Floating_Point_Definition,
N_Formal_Modular_Type_Definition => A_Formal_Modular_Type_Definition,
N_Formal_Ordinary_Fixed_Point_Definition =>
A_Formal_Ordinary_Fixed_Point_Definition,
N_Formal_Package_Declaration => Non_Trivial_Mapping,
N_Formal_Private_Type_Definition => Non_Trivial_Mapping,
N_Formal_Signed_Integer_Type_Definition =>
A_Formal_Signed_Integer_Type_Definition,
N_Formal_Subprogram_Declaration => Non_Trivial_Mapping,
N_Generic_Association => A_Generic_Association,
N_Index_Or_Discriminant_Constraint => Non_Trivial_Mapping,
N_Label => No_Mapping,
N_Modular_Type_Definition => A_Modular_Type_Definition,
N_Number_Declaration => Non_Trivial_Mapping,
N_Ordinary_Fixed_Point_Definition => An_Ordinary_Fixed_Point_Definition,
N_Others_Choice => An_Others_Choice,
N_Package_Specification => No_Mapping,
N_Parameter_Association => A_Parameter_Association,
N_Parameter_Specification => A_Parameter_Specification,
N_Protected_Body => A_Protected_Body_Declaration,
N_Protected_Definition => A_Protected_Definition,
N_Range_Constraint => Non_Trivial_Mapping,
N_Real_Range_Specification => A_Simple_Expression_Range,
N_Record_Definition => Non_Trivial_Mapping,
N_Selective_Accept => A_Selective_Accept_Statement,
N_Signed_Integer_Type_Definition => A_Signed_Integer_Type_Definition,
N_Single_Protected_Declaration => A_Single_Protected_Declaration,
N_Subunit => No_Mapping,
N_Task_Definition => A_Task_Definition,
N_Terminate_Alternative => Non_Trivial_Mapping,
N_Timed_Entry_Call => A_Timed_Entry_Call_Statement,
N_Triggering_Alternative => A_Select_Path,
N_Use_Type_Clause => Non_Trivial_Mapping,
N_Variant => A_Variant,
N_Variant_Part => A_Variant_Part,
N_With_Clause => A_With_Clause,
N_Unused_At_End => No_Mapping,
others => Not_Implemented_Mapping);
------------------------------------------
-- Node-to-Element Second Look-Up Table --
------------------------------------------
type Mapping_Item is access function (Node : Node_Id)
return Internal_Element_Kinds;
Node_To_Element_Kind_Mapping_Second_Switch :
constant array (Node_Kind) of Mapping_Item := (
N_Pragma => N_Pragma_Mapping'Access,
N_Defining_Identifier => N_Defining_Identifier_Mapping'Access,
N_Defining_Operator_Symbol => N_Defining_Operator_Symbol_Mapping'Access,
N_Expanded_Name => N_Expanded_Name_Mapping'Access,
N_Identifier => N_Identifier_Mapping'Access,
N_Operator_Symbol => N_Operator_Symbol_Mapping'Access,
N_Attribute_Reference => N_Attribute_Reference_Mapping'Access,
N_Function_Call => N_Function_Call_Mapping'Access,
N_Quantified_Expression => N_Quantified_Expression_Mapping'Access,
N_Range => N_Range_Mapping'Access,
N_Allocator => N_Allocator_Mapping'Access,
N_Aggregate => N_Aggregate_Mapping'Access,
N_Subtype_Indication => N_Subtype_Indication_Mapping'Access,
-- --|A2012 start
N_Formal_Type_Declaration => N_Formal_Type_Declaration_Mapping'Access,
-- --|A2012 end
-- --|A2005 start
-- N_Incomplete_Type_Declaration => An_Incomplete_Type_Declaration,
N_Incomplete_Type_Declaration =>
N_Incomplete_Type_Declaration_Mapping'Access,
-- --|A2005 end
-- --|A2012 start
N_Iterator_Specification => N_Iterator_Specification_Mapping'Access,
-- --|A2012 end
N_Object_Declaration => N_Object_Declaration_Mapping'Access,
N_Access_Function_Definition =>
N_Access_Function_Definition_Mapping'Access,
N_Access_Procedure_Definition =>
N_Access_Procedure_Definition_Mapping'Access,
N_Subprogram_Body_Stub => N_Subprogram_Body_Stub_Mapping'Access,
N_Subprogram_Body => N_Subprogram_Body_Mapping'Access,
N_Subprogram_Declaration => N_Subprogram_Declaration_Mapping'Access,
N_Generic_Subprogram_Declaration =>
N_Generic_Subprogram_Declaration_Mapping'Access,
N_Constrained_Array_Definition =>
N_Constrained_Array_Definition_Mapping'Access,
N_Unconstrained_Array_Definition =>
N_Unconstrained_Array_Definition_Mapping'Access,
N_Subprogram_Renaming_Declaration =>
N_Subprogram_Renaming_Declaration_Mapping'Access,
N_Loop_Statement => N_Loop_Statement_Mapping'Access,
N_Requeue_Statement => N_Requeue_Statement_Mapping'Access,
N_Abstract_Subprogram_Declaration =>
N_Abstract_Subprogram_Declaration_Mapping'Access,
N_Accept_Alternative => N_Accept_Alternative_Mapping'Access,
-- --|A2005 start
N_Access_Definition => N_Access_Definition_Mapping'Access,
-- --|A2005 end
N_Access_To_Object_Definition =>
N_Access_To_Object_Definition_Mapping'Access,
N_Component_Association => N_Component_Association_Mapping'Access,
N_Derived_Type_Definition => N_Derived_Type_Definition_Mapping'Access,
N_Delay_Alternative => N_Delay_Alternative_Mapping'Access,
N_Formal_Package_Declaration =>
N_Formal_Package_Declaration_Mapping'Access,
N_Formal_Private_Type_Definition =>
N_Formal_Private_Type_Definition_Mapping'Access,
N_Formal_Subprogram_Declaration =>
N_Formal_Subprogram_Declaration_Mapping'Access,
N_Index_Or_Discriminant_Constraint =>
N_Index_Or_Discriminant_Constraint_Mapping'Access,
N_Number_Declaration => N_Number_Declaration_Mapping'Access,
N_Range_Constraint => N_Range_Constraint_Mapping'Access,
N_Record_Definition => N_Record_Definition_Mapping'Access,
N_Terminate_Alternative => N_Terminate_Alternative_Mapping'Access,
N_Use_Type_Clause => N_Use_Type_Clause_Mapping'Access,
N_Procedure_Call_Statement => N_Procedure_Call_Statement_Mapping'Access,
others => Not_Implemented_Mapping'Access);
----------------------------------------------------
-- Node List to Element List Filter Look-Up Table --
----------------------------------------------------
-- The following look-up table defines the first, very rough filter for
-- selecting node list elements to be used as a basis for ASIS Element
-- list components: it defines which Node_Kind values could never be used
-- for creating Elements in Element List (for them False is set in the
-- table)
May_Be_Included_Switch : constant array (Node_Kind) of Boolean := (
N_Unused_At_Start => False,
N_Freeze_Entity => False,
N_Implicit_Label_Declaration => False,
N_Label => False,
others => True);
--------------------------------
-- Asis_Internal_Element_Kind --
--------------------------------
function Asis_Internal_Element_Kind
(Node : Node_Id)
return Internal_Element_Kinds
is
Mapping_Case : Internal_Element_Kinds;
Source_Node_Kind : Node_Kind;
begin -- two-level switching only!
Source_Node_Kind := Nkind (Node);
Mapping_Case := Node_To_Element_Kind_Mapping_First_Switch
(Source_Node_Kind);
case Mapping_Case is
when Non_Trivial_Mapping =>
return Node_To_Element_Kind_Mapping_Second_Switch
(Source_Node_Kind) (Node);
when Not_Implemented_Mapping =>
Not_Implemented_Mapping (Source_Node_Kind);
when No_Mapping =>
No_Mapping (Node);
when others => -- all trivial cases!
return Mapping_Case;
end case;
end Asis_Internal_Element_Kind;
--------------------------------------
-- Defining_Id_List_From_Normalized --
--------------------------------------
function Defining_Id_List_From_Normalized
(N : Node_Id;
From_Declaration : Asis.Element)
return Asis.Defining_Name_List
is
Res_Max_Len : constant Natural :=
Natural (List_Length (List_Containing (N)));
-- to avoid two loops through the list of declarations/specifications,
-- we use the rough estimation of the length of the result
-- Defining_Name_List - it cannot contain more elements that the
-- number of nodes in the tree node list containing (normalized)
-- declarations
Res_Act_Len : Natural := 1;
-- the actual number of defining identifiers in the normalized
-- declaration
Result_List : Defining_Name_List (1 .. Res_Max_Len);
Decl_Node : Node_Id := N;
Decl_Nkind : constant Node_Kind := Nkind (Decl_Node);
Def_Id_Node : Node_Id;
begin
Def_Id_Node := Defining_Identifier (Decl_Node);
Result_List (Res_Act_Len) :=
Node_To_Element_New (Node => Def_Id_Node,
Starting_Element => From_Declaration,
Internal_Kind => A_Defining_Identifier);
while More_Ids (Decl_Node) loop
Decl_Node := Next (Decl_Node);
while Nkind (Decl_Node) /= Decl_Nkind loop
-- some implicit subtype declarations may be inserted by
-- the compiler in between the normalized declarations, so:
Decl_Node := Next (Decl_Node);
end loop;
Def_Id_Node := Defining_Identifier (Decl_Node);
Res_Act_Len := Res_Act_Len + 1;
Result_List (Res_Act_Len) :=
Node_To_Element_New (Node => Def_Id_Node,
Starting_Element => From_Declaration,
Internal_Kind => A_Defining_Identifier);
end loop;
return Result_List (1 .. Res_Act_Len);
end Defining_Id_List_From_Normalized;
------------------------------------------
-- Discrete_Choice_Node_To_Element_List --
------------------------------------------
function Discrete_Choice_Node_To_Element_List
(Choice_List : List_Id;
Starting_Element : Asis.Element)
return Asis.Element_List
is
Result_List : Asis.Element_List
(1 .. ASIS_Integer (List_Length (Choice_List)));
-- List_Length (Choice_List) cannot be 0 for the DISCRETE_CHOICE_LIST!
Current_Node : Node_Id;
Current_Original_Node : Node_Id;
Element_Already_Composed : Boolean;
Result_Kind : Internal_Element_Kinds;
begin
Current_Node := First (Choice_List);
-- first list element to process cannot be Empty!
Current_Original_Node := Original_Node (Current_Node);
for I in 1 .. ASIS_Integer (List_Length (Choice_List)) loop
Element_Already_Composed := False;
if Paren_Count (Current_Original_Node) > 0 then
-- Corner but legal case of discrete choice like
--
-- when (1) =>
--
-- or
--
-- When (A.B.C) =>
Result_Kind := Not_An_Element;
else
case Nkind (Current_Original_Node) is
-- DISCRETE_CHOICE_LIST ::= DISCRETE_CHOICE {| DISCRETE_CHOICE}
-- DISCRETE_CHOICE ::= EXPRESSION | DISCRETE_RANGE | others
when N_Others_Choice => -- DISCRETE_CHOICE ::= ... | others
Result_Kind := An_Others_Choice;
-- DISCRETE_CHOICE ::= ... | DISCRETE_RANGE | ...
-- DISCRETE_RANGE ::= discrete_SUBTYPE_INDICATION | RANGE
when N_Subtype_Indication =>
-- DISCRETE_RANGE ::= discrete_SUBTYPE_INDICATION | ...
--
-- The problem is that GNAT reduces the subtype_indication
-- having NO constraint directly to subtype_mark
-- (-> N_Identifier, N_Expanded_Name). May be, it is a
-- pathological case, but it can also be represented by
-- ...'Base construction (-> N_Attribute_Reference)
Result_Kind := A_Discrete_Subtype_Indication;
when N_Identifier =>
if Ekind (Entity (Current_Original_Node)) in Discrete_Kind then
-- discrete subtype mark!!
Result_Kind := A_Discrete_Subtype_Indication;
elsif Ekind (Entity (Current_Original_Node)) =
E_Enumeration_Literal
then
Result_Kind := An_Enumeration_Literal;
else
Result_Kind := An_Identifier;
end if;
when N_Expanded_Name =>
if Ekind (Entity (Current_Original_Node)) in Discrete_Kind then
-- discrete subtype mark!!
Result_Kind := A_Discrete_Subtype_Indication;
else
-- expression
Result_Kind := A_Selected_Component;
end if;
-- DISCRETE_RANGE ::= ... | RANGE
-- RANGE ::=
-- RANGE_ATTRIBUTE_REFERENCE
-- | SIMPLE_EXPRESSION .. SIMPLE_EXPRESSION
when N_Range =>
-- RANGE ::= ...
-- | SIMPLE_EXPRESSION .. SIMPLE_EXPRESSION
Result_Kind := A_Discrete_Simple_Expression_Range;
when N_Attribute_Reference =>
-- RANGE ::= RANGE_ATTRIBUTE_REFERENCE | ...
-- Sinfo.ads:
-- A range attribute designator is represented
-- in the tree using the normal N_Attribute_Reference
-- node.
-- But if the tree corresponds to the compilable Compilation
-- Unit, the RANGE_ATTRIBUTE_REFERENCE is the only construct
-- which could be in this position --W_R_O_N_G !!! T'Base!!!
if Attribute_Name (Current_Original_Node) = Name_Range then
Result_Kind := A_Discrete_Range_Attribute_Reference;
else
-- attribute denoting a type/subtype or yielding a value:
Result_List (I) := Node_To_Element_New (
Node => Current_Node,
Starting_Element => Starting_Element);
Element_Already_Composed := True;
end if;
-- DISCRETE_CHOICE ::= EXPRESSION | ...
when others =>
-- In the tree corresponding to the compilable Compilation
-- Unit the only possibility in the others choice is the
-- EXPRESSION as the DISCRETE_CHOICE.
Result_List (I) := Node_To_Element_New (
Node => Current_Node,
Starting_Element => Starting_Element);
Element_Already_Composed := True;
end case;
end if;
if not Element_Already_Composed then
Result_List (I) := Node_To_Element_New (
Node => Current_Node,
Internal_Kind => Result_Kind,
Starting_Element => Starting_Element);
end if;
Current_Node := Next (Current_Node);
Current_Original_Node := Original_Node (Current_Node);
end loop;
return Result_List;
end Discrete_Choice_Node_To_Element_List;
----------------------
-- Is_Config_Pragma --
----------------------
function Is_Config_Pragma (N : Node_Id) return Boolean is
begin
return True
and then Nkind (N) = N_Pragma
and then Pragma_Name (N) in
First_Pragma_Name .. Last_Configuration_Pragma_Name;
end Is_Config_Pragma;
-------------------------------
-- Is_GNAT_Attribute_Routine --
-------------------------------
function Is_GNAT_Attribute_Routine (N : Node_Id) return Boolean is
Attribute_Chars : Name_Id;
Result : Boolean := False;
begin
Attribute_Chars := Attribute_Name (N);
if Attribute_Chars = Name_Asm_Input or else
Attribute_Chars = Name_Asm_Output or else
Attribute_Chars = Name_Enum_Rep or else
Attribute_Chars = Name_Enum_Val or else
Attribute_Chars = Name_Fixed_Value or else
Attribute_Chars = Name_Integer_Value or else
Attribute_Chars = Name_Ref
then
Result := True;
end if;
return Result;
end Is_GNAT_Attribute_Routine;
-------------------------------------------
-- Is_Rewritten_Function_Prefix_Notation --
-------------------------------------------
function Is_Rewritten_Function_Prefix_Notation
(N : Node_Id)
return Boolean
is
Result : Boolean := False;
begin
if Nkind (N) = N_Function_Call
and then
Is_Rewrite_Substitution (N)
and then
Nkind (Original_Node (N)) not in N_Op
and then
Present (Parameter_Associations (N))
and then
not Is_Empty_List (Parameter_Associations (N))
and then
Sloc (First (Parameter_Associations (N))) < Sloc (Sinfo.Name (N))
then
Result := True;
end if;
return Result;
end Is_Rewritten_Function_Prefix_Notation;
------------------------------------------------------
-- Is_Rewritten_Impl_Deref_Function_Prefix_Notation --
------------------------------------------------------
function Is_Rewritten_Impl_Deref_Function_Prefix_Notation
(N : Node_Id)
return Boolean
is
Result : Boolean := False;
begin
if Nkind (N) = N_Function_Call
and then
Present (Parameter_Associations (N))
and then
not Is_Empty_List (Parameter_Associations (N))
and then
Sloc (First (Parameter_Associations (N))) < Sloc (Sinfo.Name (N))
then
Result := True;
end if;
return Result;
end Is_Rewritten_Impl_Deref_Function_Prefix_Notation;
-----------------------------------
-- Get_Next_Configuration_Pragma --
-----------------------------------
function Get_Next_Configuration_Pragma (N : Node_Id) return Node_Id is
Result : Node_Id := N;
begin
while not (Is_Config_Pragma (Result) or else
No (Result))
loop
Result := Next (Result);
end loop;
return Result;
end Get_Next_Configuration_Pragma;
----------------------------
-- Is_Not_Duplicated_Decl --
----------------------------
function Is_Not_Duplicated_Decl (Node : Node_Id) return Boolean is
Prev_List_Elem : Node_Id;
begin
-- the idea is to check if the previous list member (and we are
-- sure that Node itself is a list member) to be included
-- in the list is the rewritten tree structure representing
-- just the same Ada construct
--
-- If we change Prev_Non_Pragma to Next_Non_Pragma, then this
-- function will return False for the first, but not for the second
-- of the two duplicated declarations
if not (Nkind (Node) = N_Full_Type_Declaration or else
Nkind (Node) = N_Private_Type_Declaration or else
Nkind (Node) = N_Subtype_Declaration)
then
return True;
-- as far as we know for now, the problem of duplicated
-- declaration exists only for type declarations
end if;
Prev_List_Elem := Prev_Non_Pragma (Node);
while Present (Prev_List_Elem) loop
if Ordinary_Inclusion_Condition (Prev_List_Elem)
and then
(Nkind (Prev_List_Elem) = N_Full_Type_Declaration or else
Nkind (Prev_List_Elem) = N_Subtype_Declaration)
and then
Chars (Defining_Identifier (Prev_List_Elem)) =
Chars (Defining_Identifier (Node))
then
return False;
end if;
Prev_List_Elem := Prev_Non_Pragma (Prev_List_Elem);
end loop;
return True;
end Is_Not_Duplicated_Decl;
---------------------------------
-- Is_Protected_Procedure_Call --
---------------------------------
function Is_Protected_Procedure_Call (N : Node_Id) return Boolean is
Result : Boolean := False;
Tmp_Node : Node_Id;
begin
Tmp_Node := Sinfo.Name (N);
if Nkind (Tmp_Node) = N_Indexed_Component then
-- Call to an entry from an entry family,
Tmp_Node := Prefix (Tmp_Node);
end if;
if Nkind (Tmp_Node) = N_Selected_Component then
Tmp_Node := Selector_Name (Tmp_Node);
end if;
Tmp_Node := Entity (Tmp_Node);
Result := Ekind (Tmp_Node) = E_Procedure;
return Result;
end Is_Protected_Procedure_Call;
------------------
-- Is_Statement --
------------------
function Is_Statement (N : Node_Id) return Boolean is
Arg_Kind : constant Node_Kind := Nkind (N);
begin
return Arg_Kind in N_Statement_Other_Than_Procedure_Call or else
Arg_Kind = N_Procedure_Call_Statement;
end Is_Statement;
------------------------------------------
-- Is_Stub_To_Body_Instanse_Replacement --
------------------------------------------
function Is_Stub_To_Body_Instanse_Replacement
(N : Node_Id)
return Boolean
is
Arg_Kind : constant Node_Kind := Nkind (N);
Result : Boolean := False;
begin
if Arg_Kind in N_Proper_Body and then
Was_Originally_Stub (N)
then
case Arg_Kind is
when N_Subprogram_Body =>
Result := Is_From_Instance (Sinfo.Specification (N));
when N_Package_Body =>
Result := Is_From_Instance (Sinfo.Defining_Unit_Name (N));
when others =>
Result := Is_From_Instance (Sinfo.Defining_Identifier (N));
end case;
end if;
return Result;
end Is_Stub_To_Body_Instanse_Replacement;
---------------------
-- May_Be_Included --
---------------------
function May_Be_Included (Node : Node_Id) return Boolean is
begin
return Ordinary_Inclusion_Condition (Node) and then
Is_Not_Duplicated_Decl (Node);
end May_Be_Included;
-----------------------------------------------
-- N_Abstract_Subprogram_Declaration_Mapping --
-----------------------------------------------
function N_Abstract_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Procedure_Declaration
-- A_Function_Declaration
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Function_Declaration;
else
return A_Procedure_Declaration;
end if;
end N_Abstract_Subprogram_Declaration_Mapping;
----------------------------------
-- N_Accept_Alternative_Mapping --
----------------------------------
function N_Accept_Alternative_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Select_Path
-- An_Or_Path
if No (Prev (Node)) then
return A_Select_Path;
else
return An_Or_Path;
end if;
end N_Accept_Alternative_Mapping;
------------------------------------------
-- N_Access_Function_Definition_Mapping --
------------------------------------------
function N_Access_Function_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Four Internal_Element_Kinds values may be possible:
--
-- An_Access_To_Function
-- An_Access_To_Protected_Function
--
-- A_Formal_Access_To_Function
-- A_Formal_Access_To_Protected_Function
if Nkind (Parent (Node)) = N_Formal_Type_Declaration then
if Protected_Present (Node) then
return A_Formal_Access_To_Protected_Function;
else
return A_Formal_Access_To_Function;
end if;
else
if Protected_Present (Node) then
return An_Access_To_Protected_Function;
else
return An_Access_To_Function;
end if;
end if;
end N_Access_Function_Definition_Mapping;
-------------------------------------------
-- N_Access_Procedure_Definition_Mapping --
-------------------------------------------
function N_Access_Procedure_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Four Internal_Element_Kinds values may be possible:
--
-- An_Access_To_Procedure
-- An_Access_To_Protected_Procedure
--
-- A_Formal_Access_To_Procedure
-- A_Formal_Access_To_Protected_Procedure
if Nkind (Parent (Node)) = N_Formal_Type_Declaration then
if Protected_Present (Node) then
return A_Formal_Access_To_Protected_Procedure;
else
return A_Formal_Access_To_Procedure;
end if;
else
if Protected_Present (Node) then
return An_Access_To_Protected_Procedure;
else
return An_Access_To_Procedure;
end if;
end if;
end N_Access_Procedure_Definition_Mapping;
-- --|A2005 start
---------------------------------
-- N_Access_Definition_Mapping --
---------------------------------
function N_Access_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := Not_An_Element;
Tmp : constant Node_Id :=
Sinfo.Access_To_Subprogram_Definition (Node);
begin
case Nkind (Tmp) is
when N_Empty =>
if Constant_Present (Node) then
Result := An_Anonymous_Access_To_Constant;
else
Result := An_Anonymous_Access_To_Variable;
end if;
when N_Access_Function_Definition =>
if Protected_Present (Tmp) then
Result := An_Anonymous_Access_To_Protected_Function;
else
Result := An_Anonymous_Access_To_Function;
end if;
when N_Access_Procedure_Definition =>
if Protected_Present (Tmp) then
Result := An_Anonymous_Access_To_Protected_Procedure;
else
Result := An_Anonymous_Access_To_Procedure;
end if;
when others =>
pragma Assert (False);
null;
end case;
return Result;
end N_Access_Definition_Mapping;
-- --|A2005 end
-------------------------------------------
-- N_Access_To_Object_Definition_Mapping --
-------------------------------------------
function N_Access_To_Object_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Six Internal_Element_Kinds values may be possible:
--
-- A_Pool_Specific_Access_To_Variable
-- An_Access_To_Variable
-- An_Access_To_Constant
--
-- A_Formal_Pool_Specific_Access_To_Variable
-- A_Formal_Access_To_Variable
-- A_Formal_Access_To_Constant
if Nkind (Parent (Node)) = N_Formal_Type_Declaration then
if All_Present (Node) then
return A_Formal_Access_To_Variable;
elsif Constant_Present (Node) then
return A_Formal_Access_To_Constant;
else
return A_Formal_Pool_Specific_Access_To_Variable;
end if;
else
if All_Present (Node) then
return An_Access_To_Variable;
elsif Constant_Present (Node) then
return An_Access_To_Constant;
else
return A_Pool_Specific_Access_To_Variable;
end if;
end if;
end N_Access_To_Object_Definition_Mapping;
-------------------------
-- N_Aggregate_Mapping --
-------------------------
function N_Aggregate_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Aggregate_Type : Node_Id := Etype (Node);
begin
-- Three Internal_Element_Kinds values may be possible:
-- A_Record_Aggregate
-- A_Positional_Array_Aggregate
-- A_Named_Array_Aggregate
-- the following fragment is a result of the current setting
-- of Etype field in the tree, see open problems #77
-- for multi-dimensional array aggregates, Etype field for
-- inner aggregates is set to Empty!!
if Present (Aggregate_Type) and then
Ekind (Aggregate_Type) in Private_Kind and then
not (Ekind (Aggregate_Type) in Array_Kind or else
Ekind (Aggregate_Type) in Record_Kind)
then
-- we need a full view of the type!
Aggregate_Type := Full_View (Aggregate_Type);
end if;
-- Special case:
if No (Aggregate_Type)
and then
(Nkind (Parent (Node)) = N_Pragma_Argument_Association
or else
Nkind (Parent (Node)) = N_Aspect_Specification)
then
return A_Record_Aggregate;
end if;
if Present (Aggregate_Type) and then
Ekind (Aggregate_Type) in Record_Kind
then
return A_Record_Aggregate;
else
if Present (Expressions (Node)) then
return A_Positional_Array_Aggregate;
else
return A_Named_Array_Aggregate;
end if;
end if;
end N_Aggregate_Mapping;
-------------------------
-- N_Allocator_Mapping --
-------------------------
function N_Allocator_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- An_Allocation_From_Subtype
-- An_Allocation_From_Qualified_Expression
if Nkind (Sinfo.Expression (Node)) = N_Qualified_Expression then
return An_Allocation_From_Qualified_Expression;
else
return An_Allocation_From_Subtype;
end if;
end N_Allocator_Mapping;
-----------------------------------
-- N_Attribute_Reference_Mapping --
-----------------------------------
function N_Attribute_Reference_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Attribute_Chars : constant Name_Id := Attribute_Name (Node);
Context_Kind : constant Node_Kind :=
Nkind (Original_Node (Parent_Node));
begin
-- The following Internal_Element_Kinds values may be possible:
--
-- For range attribute reference:
--
-- A_Discrete_Range_Attribute_Reference_As_Subtype_Definition
-- A_Discrete_Range_Attribute_Reference
-- A_Range_Attribute_Reference
--
-- For attribute reference corresponding to the attributes which are
-- functions
--
-- Adjacent
-- Ceiling
-- Compose
-- Copy_Sign
-- Exponent
-- Floor
-- Fraction
-- Image
-- Input
-- Leading_Part
-- Machine
-- Max
-- Min
-- Model
-- Pos
-- Pred
-- Remainder
-- Round
-- Rounding
-- Scaling
-- Succ
-- Truncation
-- Unbiased_Rounding
-- Val
-- Value
-- Wide_Image
-- Wide_Value
-- |A2005 start
--
-- Ada 2005 attributes that are functions:
--
-- Machine_Rounding
-- Mod
-- Wide_Wide_Image
-- |A2005 end
--
-- plus GNAT-specific attributes:
-- Enum_Rep
-- Fixed_Value
-- Integer_Value
-- Result
--
-- the Element of A_Function_Call Internal_Element_Kinds value should be
-- created, and the determination of the prefix kind should further be
-- done by hand (function Asis_Expressions.Prefix)
--
-- For attribute reference corresponding to the attributes which are
-- procedures
--
-- Output
-- Read
-- Write
--
-- the Element of A_Procedure_Call_Statement kind should be created
--
-- For attributes returning types:
-- Base
-- Class
-- the Element of A_Type_Conversion should be created if the node is
-- rewritten into N_Type_Conversion node. But this is done by the
-- Node_To_Element function (together with setting the Special_Case
-- Element field, which is then taken into account by functions
-- decomposing A_Type_Conversion Element.
if Attribute_Chars = Name_Range then
-- processing the range attribute reference
-- range attribute reference is the part of the RANGE
-- Syntax Cross Reference extraction for RANGE:
--
-- range
-- discrete_range 3.6.1
-- discrete_choice 3.8.1
-- discrete_choice_list 3.8.1
-- array_component_association 4.3.3
-- named_array_aggregate 4.3.3
-- case_statement_alternative 5.4
-- variant 3.8.1
-- index_constraint 3.6.1
-- slice 4.1.2
-- discrete_subtype_definition 3.6
-- constrained_array_definition 3.6
-- entry_declaration 9.5.2
-- entry_index_specification 9.5.2
-- loop_parameter_specification 5.5
-- range_constraint 3.5
-- delta_constraint J.3
-- digits_constraint 3.5.9
-- scalar_constraint 3.2.2
-- relation 4.4
case Context_Kind is -- should be reorganized when complete
when
-- discrete_range
N_Component_Association
| N_Case_Statement_Alternative
| N_Variant
| N_Index_Or_Discriminant_Constraint
| N_Slice
=>
return A_Discrete_Range_Attribute_Reference;
when -- discrete_subtype_definition
N_Constrained_Array_Definition
| N_Entry_Index_Specification
| N_Loop_Parameter_Specification
| N_Entry_Declaration
=>
return A_Discrete_Range_Attribute_Reference_As_Subtype_Definition;
when N_Range_Constraint => -- range_constraint ???
return A_Range_Attribute_Reference;
when N_In -- relation
| N_Not_In
=>
return A_Range_Attribute_Reference;
when others => -- impossible cases:
raise Internal_Implementation_Error;
end case;
elsif -- language-defined attributes which are functions:
Attribute_Chars = Name_Adjacent or else
Attribute_Chars = Name_Ceiling or else
Attribute_Chars = Name_Compose or else
Attribute_Chars = Name_Copy_Sign or else
Attribute_Chars = Name_Exponent or else
Attribute_Chars = Name_Floor or else
Attribute_Chars = Name_Fraction or else
Attribute_Chars = Name_Image or else
Attribute_Chars = Name_Input or else
Attribute_Chars = Name_Leading_Part or else
Attribute_Chars = Name_Machine or else
Attribute_Chars = Name_Max or else
Attribute_Chars = Name_Min or else
Attribute_Chars = Name_Model or else
Attribute_Chars = Name_Pos or else
Attribute_Chars = Name_Pred or else
Attribute_Chars = Name_Remainder or else
Attribute_Chars = Name_Round or else
Attribute_Chars = Name_Rounding or else
Attribute_Chars = Name_Scaling or else
Attribute_Chars = Name_Succ or else
Attribute_Chars = Name_Truncation or else
Attribute_Chars = Name_Unbiased_Rounding or else
Attribute_Chars = Name_Val or else
Attribute_Chars = Name_Value or else
Attribute_Chars = Name_Wide_Image or else
Attribute_Chars = Name_Wide_Value or else
-- |A2005 start
-- Ada 2005 attributes that are functions:
Attribute_Chars = Name_Machine_Rounding or else
Attribute_Chars = Name_Mod or else
Attribute_Chars = Name_Wide_Wide_Image or else
Attribute_Chars = Name_Wide_Wide_Value or else
-- |A2012 start
-- Ada 2012 attributes that are functions:
-- Attribute_Chars = Name_Overlaps_Storage or else (SCz)
-- |A2012 end
-- |A2005 end
-- Implementation Dependent Attributes-Functions:
Attribute_Chars = Name_Asm_Input or else
Attribute_Chars = Name_Asm_Output or else
Attribute_Chars = Name_Enum_Rep or else
Attribute_Chars = Name_Enum_Val or else
Attribute_Chars = Name_Fixed_Value or else
Attribute_Chars = Name_Integer_Value or else
Attribute_Chars = Name_Ref
then
return A_Function_Call;
elsif -- language-defined attributes which are procedures:
Attribute_Chars = Name_Output or else
Attribute_Chars = Name_Read or else
Attribute_Chars = Name_Write
then
return A_Procedure_Call_Statement;
-- language-defined attributes:
elsif Attribute_Chars = Name_Access then
return An_Access_Attribute;
elsif Attribute_Chars = Name_Address then
return An_Address_Attribute;
elsif Attribute_Chars = Name_Aft then
return An_Aft_Attribute;
elsif Attribute_Chars = Name_Alignment then
return An_Alignment_Attribute;
elsif Attribute_Chars = Name_Base then
return A_Base_Attribute;
elsif Attribute_Chars = Name_Bit_Order then
return A_Bit_Order_Attribute;
elsif Attribute_Chars = Name_Body_Version then
return A_Body_Version_Attribute;
elsif Attribute_Chars = Name_Callable then
return A_Callable_Attribute;
elsif Attribute_Chars = Name_Caller then
return A_Caller_Attribute;
elsif Attribute_Chars = Name_Class then
return A_Class_Attribute;
elsif Attribute_Chars = Name_Component_Size then
return A_Component_Size_Attribute;
elsif Attribute_Chars = Name_Constrained then
return A_Constrained_Attribute;
elsif Attribute_Chars = Name_Count then
return A_Count_Attribute;
elsif Attribute_Chars = Name_Definite then
return A_Definite_Attribute;
elsif Attribute_Chars = Name_Delta then
return A_Delta_Attribute;
elsif Attribute_Chars = Name_Denorm then
return A_Denorm_Attribute;
elsif Attribute_Chars = Name_Digits then
return A_Digits_Attribute;
elsif Attribute_Chars = Name_External_Tag then
return An_External_Tag_Attribute;
elsif Attribute_Chars = Name_First then
return A_First_Attribute;
elsif Attribute_Chars = Name_First_Bit then
return A_First_Bit_Attribute;
elsif Attribute_Chars = Name_Fore then
return A_Fore_Attribute;
elsif Attribute_Chars = Name_Identity then
return An_Identity_Attribute;
elsif Attribute_Chars = Name_Last then
return A_Last_Attribute;
elsif Attribute_Chars = Name_Last_Bit then
return A_Last_Bit_Attribute;
elsif Attribute_Chars = Name_Length then
return A_Length_Attribute;
elsif Attribute_Chars = Name_Machine_Emax then
return A_Machine_Emax_Attribute;
elsif Attribute_Chars = Name_Machine_Emin then
return A_Machine_Emin_Attribute;
elsif Attribute_Chars = Name_Machine_Mantissa then
return A_Machine_Mantissa_Attribute;
elsif Attribute_Chars = Name_Machine_Overflows then
return A_Machine_Overflows_Attribute;
elsif Attribute_Chars = Name_Machine_Radix then
return A_Machine_Radix_Attribute;
elsif Attribute_Chars = Name_Machine_Rounds then
return A_Machine_Rounds_Attribute;
elsif Attribute_Chars = Name_Max_Size_In_Storage_Elements then
return A_Max_Size_In_Storage_Elements_Attribute;
elsif Attribute_Chars = Name_Model_Emin then
return A_Model_Emin_Attribute;
elsif Attribute_Chars = Name_Model_Epsilon then
return A_Model_Epsilon_Attribute;
elsif Attribute_Chars = Name_Model_Mantissa then
return A_Model_Mantissa_Attribute;
elsif Attribute_Chars = Name_Model_Small then
return A_Model_Small_Attribute;
elsif Attribute_Chars = Name_Modulus then
return A_Modulus_Attribute;
elsif Attribute_Chars = Name_Partition_ID then
return A_Partition_ID_Attribute;
elsif Attribute_Chars = Name_Position then
return A_Position_Attribute;
elsif Attribute_Chars = Name_Range then -- this alternative
return A_Range_Attribute; -- never works!
elsif Attribute_Chars = Name_Safe_First then
return A_Safe_First_Attribute;
elsif Attribute_Chars = Name_Safe_Last then
return A_Safe_Last_Attribute;
elsif Attribute_Chars = Name_Scale then
return A_Scale_Attribute;
elsif Attribute_Chars = Name_Signed_Zeros then
return A_Signed_Zeros_Attribute;
elsif Attribute_Chars = Name_Size then
return A_Size_Attribute;
elsif Attribute_Chars = Name_Small then
return A_Small_Attribute;
elsif Attribute_Chars = Name_Storage_Pool then
return A_Storage_Pool_Attribute;
elsif Attribute_Chars = Name_Storage_Size then
return A_Storage_Size_Attribute;
elsif Attribute_Chars = Name_Tag then
return A_Tag_Attribute;
elsif Attribute_Chars = Name_Terminated then
return A_Terminated_Attribute;
elsif Attribute_Chars = Name_Unchecked_Access then
return An_Unchecked_Access_Attribute;
elsif Attribute_Chars = Name_Valid then
return A_Valid_Attribute;
elsif Attribute_Chars = Name_Version then
return A_Version_Attribute;
elsif Attribute_Chars = Name_Wide_Width then
return A_Wide_Width_Attribute;
elsif Attribute_Chars = Name_Width then
return A_Width_Attribute;
-- New Ada 2005/2012 attributes:
elsif Attribute_Chars = Name_Priority then
return A_Priority_Attribute;
elsif Attribute_Chars = Name_Stream_Size then
return A_Stream_Size_Attribute;
elsif Attribute_Chars = Name_Wide_Wide_Width then
return A_Wide_Wide_Width_Attribute;
elsif Attribute_Chars = Name_Max_Alignment_For_Allocation then
return A_Max_Alignment_For_Allocation_Attribute;
-- New Ada 2005/2012 attributes:
-- Implementation Dependent Attributes:
elsif Attribute_Chars = Name_Abort_Signal or else
Attribute_Chars = Name_Address_Size or else
Attribute_Chars = Name_Asm_Input or else
Attribute_Chars = Name_Asm_Output or else
Attribute_Chars = Name_AST_Entry or else -- VMS
Attribute_Chars = Name_Bit or else
Attribute_Chars = Name_Bit_Position or else
Attribute_Chars = Name_Code_Address or else
Attribute_Chars = Name_Compiler_Version or else
Attribute_Chars = Name_Default_Bit_Order or else
-- Attribute_Chars = Name_Elab_Subp_Body or else (SCz)
Attribute_Chars = Name_Elaborated or else
Attribute_Chars = Name_Emax or else -- Ada 83
Attribute_Chars = Name_Enabled or else
Attribute_Chars = Name_Enum_Rep or else
Attribute_Chars = Name_Enum_Val or else
Attribute_Chars = Name_Epsilon or else -- Ada 83
Attribute_Chars = Name_Fixed_Value or else
Attribute_Chars = Name_Has_Access_Values or else
Attribute_Chars = Name_Has_Discriminants or else
Attribute_Chars = Name_Img or else
Attribute_Chars = Name_Integer_Value or else
Attribute_Chars = Name_Invalid_Value or else
Attribute_Chars = Name_Large or else -- Ada 83
Attribute_Chars = Name_Machine_Size or else
Attribute_Chars = Name_Mantissa or else -- Ada 83
Attribute_Chars = Name_Maximum_Alignment or else
Attribute_Chars = Name_Mechanism_Code or else
Attribute_Chars = Name_Null_Parameter or else
Attribute_Chars = Name_Object_Size or else
Attribute_Chars = Name_Old or else
Attribute_Chars = Name_Passed_By_Reference or else
Attribute_Chars = Name_Range_Length or else
Attribute_Chars = Name_Ref or else
Attribute_Chars = Name_Result or else
Attribute_Chars = Name_Safe_Emax or else -- Ada 83
Attribute_Chars = Name_Safe_Large or else -- Ada 83
Attribute_Chars = Name_Safe_Small or else -- Ada 83
Attribute_Chars = Name_Storage_Unit or else
-- Attribute_Chars = Name_System_Allocator_Alignment or else (SCz)
Attribute_Chars = Name_Target_Name or else
Attribute_Chars = Name_To_Address or else
Attribute_Chars = Name_Type_Class or else
Attribute_Chars = Name_UET_Address or else
Attribute_Chars = Name_Universal_Literal_String or else
Attribute_Chars = Name_Unrestricted_Access or else
Attribute_Chars = Name_VADS_Size or else
Attribute_Chars = Name_Value_Size or else
Attribute_Chars = Name_Wchar_T_Size or else
Attribute_Chars = Name_Word_Size or else
Attribute_Chars = Name_Elab_Body or else
Attribute_Chars = Name_Elab_Spec
then
return An_Implementation_Defined_Attribute;
else
return An_Unknown_Attribute;
end if;
end N_Attribute_Reference_Mapping;
-------------------------------------
-- N_Component_Association_Mapping --
-------------------------------------
function N_Component_Association_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Special cases first:
case Nkind (Parent (Parent (Node))) is
when N_Enumeration_Representation_Clause =>
return An_Array_Component_Association;
when N_Pragma_Argument_Association |
N_Aspect_Specification =>
return A_Record_Component_Association;
when others =>
null;
end case;
-- Regular case:
if Nkind (Parent (Parent (Node))) = N_Enumeration_Representation_Clause
or else
Ekind (Etype (Parent (Node))) in Array_Kind
then
return An_Array_Component_Association;
else
return A_Record_Component_Association;
end if;
end N_Component_Association_Mapping;
--------------------------------------------
-- N_Constrained_Array_Definition_Mapping --
--------------------------------------------
function N_Constrained_Array_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Constrained_Array_Definition
-- A_Formal_Constrained_Array_Definition
if Nkind (Parent (Node)) = N_Formal_Type_Declaration then
return A_Formal_Constrained_Array_Definition;
else
return A_Constrained_Array_Definition;
end if;
end N_Constrained_Array_Definition_Mapping;
-----------------------------------
-- N_Defining_Identifier_Mapping --
-----------------------------------
function N_Defining_Identifier_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Template_Node : Node_Id := Empty;
begin
-- Several Internal_Element_Kinds values may be possible for automatic
-- Internal Kind Determination:
--
-- A_Defining_Identifier
-- A_Defining_Enumeration_Literal
-- Internal Defining Name kinds, this happens for the extended
-- code of the function instantiation in case if the instance
-- defines an operator symbol - in this case the defining name of
-- the extended function spec and body is represented by
-- N_Defining_Identifier node.
--
-- Some other Internal_Element_Kinds values could be set "by-hand",
-- for example:
--
-- An_Enumeration_Literal_Specification
if Sloc (Node) > Standard_Location and then
Get_Character (Sloc (Node)) = '"'
then
Template_Node := Parent (Parent (Node));
if Pass_Generic_Actual (Template_Node) then
-- This is the case of subprogram renaming that passes an actual
-- for a formal operator function
Template_Node := Corresponding_Formal_Spec (Template_Node);
else
-- This is the case of expanded generic subprogram having a
-- defining operator symbol, it comes as the defining name from
-- the corresponding instance, but is represented by
-- N_Defining_Identifier node in the expanded code. We just
-- go to the defining name from the instance and call
-- N_Defining_Operator_Symbol_Mapping for it
Template_Node := Parent (Template_Node);
if Nkind (Template_Node) = N_Package_Specification then
Template_Node := Parent (Template_Node);
end if;
Template_Node := Next (Template_Node);
if Nkind (Template_Node) = N_Package_Body then
-- skipping the body of wrapper package for extended subprogram
-- body
Template_Node := Next (Template_Node);
end if;
Template_Node := Defining_Unit_Name (Template_Node);
end if;
pragma Assert (Nkind (Template_Node) = N_Defining_Operator_Symbol);
return N_Defining_Operator_Symbol_Mapping (Template_Node);
else
if Nkind (Parent (Node)) = N_Enumeration_Type_Definition then
return A_Defining_Enumeration_Literal;
else
return A_Defining_Identifier;
end if;
end if;
end N_Defining_Identifier_Mapping;
----------------------------------------
-- N_Defining_Operator_Symbol_Mapping --
----------------------------------------
function N_Defining_Operator_Symbol_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Operator_Chars : constant Name_Id := Chars (Node);
Parameter_Number : Nat range 1 .. 2;
-- see the GNAT components Namet.ads and Snames.ads
-- N_Operator_Symbol_Mapping uses just the same approach,
-- (except computing the Parameter_Number value)
-- so if there is any error in it, then both functions contain it
begin
-- The following Internal_Element_Kinds values may be possible:
--
-- A_Defining_And_Operator, -- and
-- A_Defining_Or_Operator, -- or
-- A_Defining_Xor_Operator, -- xor
-- A_Defining_Equal_Operator, -- =
-- A_Defining_Not_Equal_Operator, -- /=
-- A_Defining_Less_Than_Operator, -- <
-- A_Defining_Less_Than_Or_Equal_Operator, -- <=
-- A_Defining_Greater_Than_Operator, -- >
-- A_Defining_Greater_Than_Or_Equal_Operator, -- >=
-- A_Defining_Plus_Operator, -- +
-- A_Defining_Minus_Operator, -- -
-- A_Defining_Concatenate_Operator, -- &
-- A_Defining_Unary_Plus_Operator, -- +
-- A_Defining_Unary_Minus_Operator, -- -
-- A_Defining_Multiply_Operator, -- *
-- A_Defining_Divide_Operator, -- /
-- A_Defining_Mod_Operator, -- mod
-- A_Defining_Rem_Operator, -- rem
-- A_Defining_Exponentiate_Operator, -- **
-- A_Defining_Abs_Operator, -- abs
-- A_Defining_Not_Operator, -- not
if Operator_Chars = Name_Op_And then
return A_Defining_And_Operator;
elsif Operator_Chars = Name_Op_Or then
return A_Defining_Or_Operator;
elsif Operator_Chars = Name_Op_Xor then
return A_Defining_Xor_Operator;
elsif Operator_Chars = Name_Op_Eq then
return A_Defining_Equal_Operator;
elsif Operator_Chars = Name_Op_Ne then
return A_Defining_Not_Equal_Operator;
elsif Operator_Chars = Name_Op_Lt then
return A_Defining_Less_Than_Operator;
elsif Operator_Chars = Name_Op_Le then
return A_Defining_Less_Than_Or_Equal_Operator;
elsif Operator_Chars = Name_Op_Gt then
return A_Defining_Greater_Than_Operator;
elsif Operator_Chars = Name_Op_Ge then
return A_Defining_Greater_Than_Or_Equal_Operator;
elsif Operator_Chars = Name_Op_Concat then
return A_Defining_Concatenate_Operator;
elsif Operator_Chars = Name_Op_Multiply then
return A_Defining_Multiply_Operator;
elsif Operator_Chars = Name_Op_Divide then
return A_Defining_Divide_Operator;
elsif Operator_Chars = Name_Op_Mod then
return A_Defining_Mod_Operator;
elsif Operator_Chars = Name_Op_Rem then
return A_Defining_Rem_Operator;
elsif Operator_Chars = Name_Op_Expon then
return A_Defining_Exponentiate_Operator;
elsif Operator_Chars = Name_Op_Abs then
return A_Defining_Abs_Operator;
elsif Operator_Chars = Name_Op_Not then
return A_Defining_Not_Operator;
else
-- for + and - operator signs binary and unary cases
-- should be distinguished
if Nkind (Parent_Node) = N_Function_Instantiation then
-- we have to compute the number of parameters
-- from the declaration of the corresponding generic
-- function
Parent_Node := Parent (Entity (Sinfo.Name (Parent_Node)));
if Nkind (Parent_Node) = N_Defining_Program_Unit_Name then
Parent_Node := Parent (Parent_Node);
end if;
end if;
Parameter_Number :=
List_Length (Parameter_Specifications (Parent_Node));
if Operator_Chars = Name_Op_Add then
if Parameter_Number = 1 then
return A_Defining_Unary_Plus_Operator;
else
return A_Defining_Plus_Operator;
end if;
else -- Operator_Chars = "-"
if Parameter_Number = 1 then
return A_Defining_Unary_Minus_Operator;
else
return A_Defining_Minus_Operator;
end if;
end if;
end if;
end N_Defining_Operator_Symbol_Mapping;
---------------------------------
-- N_Delay_Alternative_Mapping --
---------------------------------
function N_Delay_Alternative_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Select_Path
-- An_Or_Path
if Is_List_Member (Node) then
-- a delay alternative in a selective accept statement,
-- processing is the same as for N_Accept_Alternative
return N_Accept_Alternative_Mapping (Node);
else
-- a relay alternative in a timed entry call
return An_Or_Path;
end if;
end N_Delay_Alternative_Mapping;
---------------------------------------
-- N_Derived_Type_Definition_Mapping --
---------------------------------------
function N_Derived_Type_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := A_Derived_Type_Definition;
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Derived_Type_Definition
-- A_Derived_Record_Extension_Definition
-- --|A2005 start
-- Plus the following values for Ada 2005:
-- An_Ordinary_Interface
-- A_Limited_Interface
-- A_Task_Interface
-- A_Protected_Interface
-- A_Synchronized_Interface
-- --|A2005 end
-- Implementation revised for Ada 2005
if Interface_Present (Node) then
if Limited_Present (Node) then
Result := A_Limited_Interface;
elsif Task_Present (Node) then
Result := A_Task_Interface;
elsif Protected_Present (Node) then
Result := A_Protected_Interface;
elsif Synchronized_Present (Node) then
Result := A_Synchronized_Interface;
else
Result := An_Ordinary_Interface;
end if;
elsif Present (Record_Extension_Part (Node)) then
Result := A_Derived_Record_Extension_Definition;
end if;
return Result;
-- --|A2005 end
end N_Derived_Type_Definition_Mapping;
-----------------------------
-- N_Expanded_Name_Mapping --
-----------------------------
function N_Expanded_Name_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Context : constant Node_Id := Parent_Node;
Context_Kind : constant Node_Kind := Nkind (Context);
Temp_Node : Node_Id;
begin
-- The following Internal_Element_Kinds values may be possible:
--
-- A_Subtype_Indication
-- A_Discrete_Subtype_Indication_As_Subtype_Definition
-- A_Discrete_Subtype_Indication
-- A_Selected_Component
-- An_Identifier (we use this routine for An_Identifier node as well)
-- A_Function_Call (F in F.X)
-- An_Attribute_Reference
case Context_Kind is
-- special cases should be reorganized when complete ???
when N_Object_Declaration =>
if Node = Object_Definition (Context) then
return A_Subtype_Indication;
else
-- an initializing expression in an object declaration
goto Expr;
end if;
when N_Derived_Type_Definition
| N_Access_To_Object_Definition
=>
-- --|A2005 start
if Is_List_Member (Node) then
-- The node represents an interface name from some interface
-- list
if Nkind (Node) = N_Expanded_Name then
return A_Selected_Component;
else
return An_Identifier;
end if;
else
return A_Subtype_Indication;
end if;
-- --|A2005 end
when N_Constrained_Array_Definition |
N_Entry_Declaration =>
return A_Discrete_Subtype_Indication_As_Subtype_Definition;
when N_Unconstrained_Array_Definition =>
if Is_List_Member (Node) then
-- this for sure means, that node represents one of index
-- subtype definitions
-- CODE SHARING WITH N_IDENTIFIER MAPPING ITEM :-[#]
if Nkind (Node) = N_Expanded_Name then
return A_Selected_Component;
else
return An_Identifier;
end if;
else
-- this is a component definition!
return A_Component_Definition;
end if;
when N_Index_Or_Discriminant_Constraint =>
if Asis_Internal_Element_Kind (Context) =
An_Index_Constraint
then
return A_Discrete_Subtype_Indication;
end if;
when N_Slice =>
-- A.B(C.D) <- Context
-- / \
-- Prefix Discrete_Range
if Node = Sinfo.Discrete_Range (Context) then
return A_Discrete_Subtype_Indication;
end if;
-- when N_??? => should be implemented
when N_Selected_Component =>
-- This corresponds to a special case: F.A, where F is
-- a function call
Temp_Node := Prefix (Context);
if Is_Rewrite_Substitution (Temp_Node) and then
Nkind (Temp_Node) = N_Function_Call and then
Original_Node (Temp_Node) = Node
then
return A_Function_Call;
end if;
when N_Parameter_Specification =>
-- See FA13-008. In case if we have an implicit "/="
-- declaration, and in the corresponding explicit "="
-- declaration parameter type is defined by a 'Class attribute,
-- in the parameter specification of "/=" the front-end uses
-- the reference to the internal type entity node
if Nkind (Node) = N_Identifier
and then
not Comes_From_Source (Node)
and then
Ekind (Entity (Node)) = E_Class_Wide_Type
then
return A_Class_Attribute;
end if;
when others =>
null;
end case;
-- general case, the following if statement is necessary because
-- of sharing of this code between N_Expanded_Name and N_Identifier
-- mapping items.
-- IS THIS CODE SHARING A REALLY GOOD THING???
<<Expr>> -- here we are analyzing the "ordinary" expression
if Nkind (Node) = N_Expanded_Name then
return A_Selected_Component;
elsif Context_Kind /= N_Defining_Program_Unit_Name then
if (Nkind (Node) in N_Has_Entity
or else
Nkind (Node) = N_Attribute_Definition_Clause)
and then
Entity_Present (Node)
and then
Ekind (Entity (Node)) = E_Enumeration_Literal
then
return An_Enumeration_Literal;
else
return An_Identifier;
end if;
else
return An_Identifier;
end if;
end N_Expanded_Name_Mapping;
---------------------------------------
-- N_Formal_Type_Declaration_Mapping --
---------------------------------------
function N_Formal_Type_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- if Nkind (Sinfo.Formal_Type_Definition (Node)) = (SCz)
-- N_Formal_Incomplete_Type_Definition
-- then
-- return A_Formal_Incomplete_Type_Declaration;
-- else
return A_Formal_Type_Declaration;
-- end if;
end N_Formal_Type_Declaration_Mapping;
------------------------------------------
-- N_Formal_Package_Declaration_Mapping --
------------------------------------------
function N_Formal_Package_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Formal_Package_Declaration,
-- A_Formal_Package_Declaration_With_Box
if Box_Present (Node) then
return A_Formal_Package_Declaration_With_Box;
else
return A_Formal_Package_Declaration;
end if;
end N_Formal_Package_Declaration_Mapping;
----------------------------------------------
-- N_Formal_Private_Type_Definition_Mapping --
----------------------------------------------
function N_Formal_Private_Type_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Formal_Private_Type_Definition
-- A_Formal_Tagged_Private_Type_Definition
if Tagged_Present (Node) then
return A_Formal_Tagged_Private_Type_Definition;
else
return A_Formal_Private_Type_Definition;
end if;
end N_Formal_Private_Type_Definition_Mapping;
---------------------------------------------
-- N_Formal_Subprogram_Declaration_Mapping --
---------------------------------------------
function N_Formal_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Formal_Procedure_Declaration
-- A_Formal_Function_Declaration.
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Formal_Function_Declaration;
else
return A_Formal_Procedure_Declaration;
end if;
end N_Formal_Subprogram_Declaration_Mapping;
-----------------------------
-- N_Function_Call_Mapping --
-----------------------------
function N_Function_Call_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Called_Name : Node_Id;
Called_Function : Node_Id := Empty;
Result : Internal_Element_Kinds := A_Function_Call;
begin
-- Three Internal_Element_Kinds values may be possible:
-- A_Function_Call (usual situation)
-- A_Selected_Component
-- An_Enumeration_Literal
-- The last two cases correspond to a reference to an overloaded
-- enumeration literal (either qualified or direct)
if No (Parameter_Associations (Node)) then
Called_Name := Sinfo.Name (Node);
if Nkind (Called_Name) in N_Has_Entity then
Called_Function := Entity (Called_Name);
end if;
if Nkind (Parent (Called_Function)) =
N_Enumeration_Type_Definition
then
if Nkind (Called_Name) = N_Selected_Component or else -- ???
Nkind (Called_Name) = N_Expanded_Name
then
Result := A_Selected_Component;
elsif Nkind (Called_Name) = N_Identifier then
Result := An_Enumeration_Literal;
end if;
end if;
end if;
return Result;
end N_Function_Call_Mapping;
----------------------------------------------
-- N_Generic_Subprogram_Declaration_Mapping --
----------------------------------------------
function N_Generic_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Generic_Procedure_Declaration and A_Generic_Function_Declaration
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Generic_Function_Declaration;
else
return A_Generic_Procedure_Declaration;
end if;
end N_Generic_Subprogram_Declaration_Mapping;
-- |A2005 start
-------------------------------------------
-- N_Incomplete_Type_Declaration_Mapping --
-------------------------------------------
function N_Incomplete_Type_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := An_Incomplete_Type_Declaration;
begin
if Tagged_Present (Node) then
Result := A_Tagged_Incomplete_Type_Declaration;
end if;
return Result;
end N_Incomplete_Type_Declaration_Mapping;
-- |A2005 end
------------------------------------------------
-- N_Index_Or_Discriminant_Constraint_Mapping --
------------------------------------------------
function N_Index_Or_Discriminant_Constraint_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
First_Item : Node_Id;
-- the first element in the list of discrete ranges or discriminant
-- associations, this element is the only one used to determine the kind
-- of the constraint being analyzed
First_Item_Kind : Node_Kind;
Type_Entity : Node_Id;
-- Needed in case when we can not make the decision using the syntax
-- information only. Represents the type or subtype entity to which the
-- constraint is applied
begin
-- Two Internal_Element_Kinds values may be possible:
-- An_Index_Constraint
-- A_Discriminant_Constraint
First_Item := First (Constraints (Node));
First_Item_Kind := Nkind (First_Item);
-- analyzing the syntax structure of First_Item:
if First_Item_Kind = N_Discriminant_Association then
return A_Discriminant_Constraint;
elsif First_Item_Kind = N_Subtype_Indication or else
First_Item_Kind = N_Range
then
return An_Index_Constraint;
elsif First_Item_Kind = N_Attribute_Reference then
-- analyzing the attribute designator:
if Attribute_Name (First_Item) = Name_Range then
return An_Index_Constraint;
else
return A_Discriminant_Constraint;
end if;
elsif not (First_Item_Kind = N_Identifier or else
First_Item_Kind = N_Expanded_Name)
then
-- First_Item is an expression and it could not be interpreted as a
-- subtype_mark from a discrete_subtype_indication, so what we have
-- in this case is:
return A_Discriminant_Constraint;
end if;
-- First_Item is of N_Identifier or N_Expanded_Name kind, and it may be
-- either an expression in index constraint or a subtype mark in a
-- discriminant constraint. In this case it is easier to analyze the
-- type to which the constraint is applied, but not the constraint
-- itself.
Type_Entity := Entity (Sinfo.Subtype_Mark (Parent (Node)));
while Ekind (Type_Entity) in Access_Kind loop
Type_Entity := Directly_Designated_Type (Type_Entity);
end loop;
if Has_Discriminants (Type_Entity) then
return A_Discriminant_Constraint;
else
return An_Index_Constraint;
end if;
end N_Index_Or_Discriminant_Constraint_Mapping;
--------------------------------------
-- N_Iterator_Specification_Mapping --
--------------------------------------
function N_Iterator_Specification_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := A_Generalized_Iterator_Specification;
begin
if Of_Present (Node) then
Result := An_Element_Iterator_Specification;
end if;
return Result;
end N_Iterator_Specification_Mapping;
------------------------------
-- N_Loop_Statement_Mapping --
------------------------------
function N_Loop_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Iteration : Node_Id;
begin
-- Three Internal_Element_Kinds values may be possible:
-- A_Loop_Statement,
-- A_While_Loop_Statement,
-- A_For_Loop_Statement,
Iteration := Iteration_Scheme (Node);
if Present (Iteration) then
if Present (Condition (Iteration)) then
return A_While_Loop_Statement;
else
return A_For_Loop_Statement;
end if;
else
return A_Loop_Statement;
end if;
end N_Loop_Statement_Mapping;
----------------------------------
-- N_Number_Declaration_Mapping --
----------------------------------
function N_Number_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- An_Integer_Number_Declaration
-- A_Real_Number_Declaration
if Ekind (Defining_Identifier (Node)) = E_Named_Integer then
return An_Integer_Number_Declaration;
else
return A_Real_Number_Declaration;
end if;
end N_Number_Declaration_Mapping;
----------------------------------
-- N_Object_Declaration_Mapping --
----------------------------------
function N_Object_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds;
begin
-- Three Internal_Element_Kinds values may be possible:
-- A_Variable_Declaration,
-- A_Constant_Declaration,
-- A_Deferred_Constant_Declaration.
-- |A2005 start
-- A_Return_Variable_Specification
-- A_Return_Constant_Specification
-- |A2005 end
if Nkind (Parent (Node)) = N_Extended_Return_Statement then
if not Constant_Present (Node) then
Result := A_Return_Variable_Specification;
else
Result := A_Return_Constant_Specification;
end if;
elsif not Constant_Present (Node) then
Result := A_Variable_Declaration;
elsif Present (Sinfo.Expression (Node)) then
Result := A_Constant_Declaration;
else
Result := A_Deferred_Constant_Declaration;
end if;
return Result;
end N_Object_Declaration_Mapping;
-------------------------------
-- N_Operator_Symbol_Mapping --
-------------------------------
function N_Operator_Symbol_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Tmp : Node_Id;
Operator_Chars : constant Name_Id := Chars (Node);
Parameter_Number : Nat range 1 .. 2;
-- see the GNAT components Namet.ads and Snames.ads
-- N_Defining_Operator_Symbol_Mapping uses just the same approach,
-- so if there is any error in it, then both functions contain it
begin
-- The following Internal_Element_Kinds values may be possible:
--
-- A_And_Operator, -- and
-- A_Or_Operator, -- or
-- A_Xor_Operator, -- xor
-- A_Equal_Operator, -- =
-- A_Not_Equal_Operator, -- /=
-- A_Less_Than_Operator, -- <
-- A_Less_Than_Or_Equal_Operator, -- <=
-- A_Greater_Than_Operator, -- >
-- A_Greater_Than_Or_Equal_Operator, -- >=
-- A_Plus_Operator, -- +
-- A_Minus_Operator, -- -
-- A_Concatenate_Operator, -- &
-- A_Unary_Plus_Operator, -- +
-- A_Unary_Minus_Operator, -- -
-- A_Multiply_Operator, -- *
-- A_Divide_Operator, -- /
-- A_Mod_Operator, -- mod
-- A_Rem_Operator, -- rem
-- A_Exponentiate_Operator, -- **
-- A_Abs_Operator, -- abs
-- A_Not_Operator, -- not
if Operator_Chars = Name_Op_And then
return An_And_Operator;
elsif Operator_Chars = Name_Op_Or then
return An_Or_Operator;
elsif Operator_Chars = Name_Op_Xor then
return An_Xor_Operator;
elsif Operator_Chars = Name_Op_Eq then
return An_Equal_Operator;
elsif Operator_Chars = Name_Op_Ne then
return A_Not_Equal_Operator;
elsif Operator_Chars = Name_Op_Lt then
return A_Less_Than_Operator;
elsif Operator_Chars = Name_Op_Le then
return A_Less_Than_Or_Equal_Operator;
elsif Operator_Chars = Name_Op_Gt then
return A_Greater_Than_Operator;
elsif Operator_Chars = Name_Op_Ge then
return A_Greater_Than_Or_Equal_Operator;
elsif Operator_Chars = Name_Op_Concat then
return A_Concatenate_Operator;
elsif Operator_Chars = Name_Op_Multiply then
return A_Multiply_Operator;
elsif Operator_Chars = Name_Op_Divide then
return A_Divide_Operator;
elsif Operator_Chars = Name_Op_Mod then
return A_Mod_Operator;
elsif Operator_Chars = Name_Op_Rem then
return A_Rem_Operator;
elsif Operator_Chars = Name_Op_Expon then
return An_Exponentiate_Operator;
elsif Operator_Chars = Name_Op_Abs then
return An_Abs_Operator;
elsif Operator_Chars = Name_Op_Not then
return A_Not_Operator;
else
-- for + and - operator signs binary and unary cases
-- should be distinguished
-- A simple case - we have an entity:
if Entity_Present (Node) then
Tmp := Entity (Node);
if First_Entity (Tmp) = Last_Entity (Tmp) then
Parameter_Number := 1;
else
Parameter_Number := 2;
end if;
else
Parent_Node := Parent (Node);
if Nkind (Parent_Node) = N_Integer_Literal or else
Nkind (Parent_Node) = N_Real_Literal
then
-- Static expression of the form "+"(1, 2) rewritten into
-- a literal value
Parent_Node := Original_Node (Parent_Node);
end if;
-- we have to do this assignment also here, because this
-- function may be called outside Node_To_Element
-- convertors
-- because of the possible tree rewriting, the parent node
-- may be either of N_Function_Call or of N_Op_Xxx type)
-- it can be also of N_Formal_Subprogram_Declaration kind,
-- or even of N_Expanded_Name kind,
while Nkind (Parent_Node) = N_Expanded_Name loop
Parent_Node := Parent (Parent_Node);
if Nkind (Parent_Node) = N_Integer_Literal or else
Nkind (Parent_Node) = N_Real_Literal
then
-- Static expression of the form
-- Prefix_Name."+"(1, 2)
-- rewritten into a literal value
Parent_Node := Original_Node (Parent_Node);
end if;
end loop;
if Nkind (Parent_Node) = N_Op_Plus or else
Nkind (Parent_Node) = N_Op_Minus
then
Parameter_Number := 1;
elsif Nkind (Parent_Node) = N_Op_Add or else
Nkind (Parent_Node) = N_Op_Subtract
then
Parameter_Number := 2;
elsif Nkind (Parent_Node) = N_Function_Call then
Parameter_Number :=
List_Length (Parameter_Associations (Parent_Node));
elsif Nkind (Parent_Node) = N_Subprogram_Renaming_Declaration
or else
Nkind (Parent_Node) in N_Formal_Subprogram_Declaration
then
Parameter_Number := List_Length
(Parameter_Specifications (Specification (Parent_Node)));
elsif Nkind (Parent_Node) = N_Indexed_Component then
Parameter_Number := List_Length
(Sinfo.Expressions (Parent_Node));
elsif Nkind (Parent_Node) = N_Pragma_Argument_Association then
-- this is for pragma inline ("+");
Parameter_Number := 2;
-- this choice is somewhat arbitrary :)
elsif Nkind (Parent_Node) = N_Generic_Association then
Tmp := Defining_Gen_Parameter (Node);
Parameter_Number := List_Length
(Parameter_Specifications (Parent (Tmp)));
else
-- Impossible case
raise Internal_Implementation_Error;
end if;
end if;
if Operator_Chars = Name_Op_Add then
if Parameter_Number = 1 then
return A_Unary_Plus_Operator;
else
return A_Plus_Operator;
end if;
else -- Operator_Chars = "-"
if Parameter_Number = 1 then
return A_Unary_Minus_Operator;
else
return A_Minus_Operator;
end if;
end if;
end if;
end N_Operator_Symbol_Mapping;
----------------------
-- N_Pragma_Mapping --
----------------------
function N_Pragma_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Pragma_Chars : constant Name_Id := Pragma_Name (Node);
begin
-- Language-Defined Pragmas --
if Pragma_Chars = Name_All_Calls_Remote then
return An_All_Calls_Remote_Pragma; -- I.2.3(6)
elsif Pragma_Chars = Name_Asynchronous then
return An_Asynchronous_Pragma; -- I.4.1(3)
elsif Pragma_Chars = Name_Atomic then
return An_Atomic_Pragma; -- G.5(3)
elsif Pragma_Chars = Name_Atomic_Components then
return An_Atomic_Components_Pragma; -- G.5(3)
elsif Pragma_Chars = Name_Attach_Handler then
return An_Attach_Handler_Pragma; -- G.3.1(3)
elsif Pragma_Chars = Name_Controlled then
return A_Controlled_Pragma; -- 13.11.3(3), B(12)
elsif Pragma_Chars = Name_Convention then
return A_Convention_Pragma; -- B(16), M.1(5)
elsif Pragma_Chars = Name_Discard_Names then
return A_Discard_Names_Pragma; -- C.5(2)
elsif Pragma_Chars = Name_Elaborate then
return An_Elaborate_Pragma; -- 10.2.1(20)
elsif Pragma_Chars = Name_Elaborate_All then
return An_Elaborate_All_Pragma; -- 10.2.1(19), B(8)
elsif Pragma_Chars = Name_Elaborate_Body then
return An_Elaborate_Body_Pragma; -- 10.2.1(21), B(9)
elsif Pragma_Chars = Name_Export then
return An_Export_Pragma; -- B(15), M.1(5)
elsif Pragma_Chars = Name_Import then
return An_Import_Pragma; -- B(14), M.1(5)
elsif Pragma_Chars = Name_Inline then
return An_Inline_Pragma; -- 6.3.2(4), B(5)
elsif Pragma_Chars = Name_Inspection_Point then
return An_Inspection_Point_Pragma; -- L.2.2(2)
elsif Pragma_Chars = Name_Interrupt_Handler then
return An_Interrupt_Handler_Pragma; -- G.3.1(2)
elsif Pragma_Chars = Name_Interrupt_Priority then
return An_Interrupt_Priority_Pragma; -- H.1(4)
elsif Pragma_Chars = Name_Linker_Options then
return A_Linker_Options_Pragma; -- B.1(8)
elsif Pragma_Chars = Snames.Name_List then
return A_List_Pragma; -- 2.8(18), B(2)
elsif Pragma_Chars = Name_Locking_Policy then
return A_Locking_Policy_Pragma; -- H.3(3)
elsif Pragma_Chars = Name_Normalize_Scalars then
return A_Normalize_Scalars_Pragma; -- L.1.1(2)
elsif Pragma_Chars = Name_Optimize then
return An_Optimize_Pragma; -- 2.8(18), B(4)
elsif Pragma_Chars = Name_Pack then
return A_Pack_Pragma; -- 13.2(2), B(11)
elsif Pragma_Chars = Name_Page then
return A_Page_Pragma; -- 2.8(18), B(3)
elsif Pragma_Chars = Name_Preelaborate then
return A_Preelaborate_Pragma; -- 10.2.1(3), B(6)
elsif Pragma_Chars = Name_Priority then
return A_Priority_Pragma; -- H.1(3)
elsif Pragma_Chars = Name_Pure then
return A_Pure_Pragma; -- 10.2.1(13), B(7)
elsif Pragma_Chars = Name_Queuing_Policy then
return A_Queuing_Policy_Pragma; -- H.4(3)
elsif Pragma_Chars = Name_Remote_Call_Interface then
return A_Remote_Call_Interface_Pragma; -- I.2.3(4)
elsif Pragma_Chars = Name_Remote_Types then
return A_Remote_Types_Pragma; -- I.2.2(4)
elsif Pragma_Chars = Name_Restrictions then
return A_Restrictions_Pragma; -- 13.12(2), B(13)
elsif Pragma_Chars = Name_Reviewable then
return A_Reviewable_Pragma; -- L.2.1(2)
elsif Pragma_Chars = Name_Shared_Passive then
return A_Shared_Passive_Pragma; -- I.2.1(4)
elsif Pragma_Chars = Name_Storage_Size then
-- the same name entry as for 'Storage_Size attribute!
return A_Storage_Size_Pragma; -- 13.3(62)
elsif Pragma_Chars = Name_Suppress then
return A_Suppress_Pragma; -- 11.5(4), B(10)
elsif Pragma_Chars = Name_Task_Dispatching_Policy then
return A_Task_Dispatching_Policy_Pragma; -- H.2.2(2)
elsif Pragma_Chars = Name_Volatile then
return A_Volatile_Pragma; -- G.5(3)
elsif Pragma_Chars = Name_Volatile_Components then
return A_Volatile_Components_Pragma; -- G.5(3)
-- --|A2005 start
-- New Ada 2005 pragmas. To be alphabetically ordered later
elsif Pragma_Chars = Name_Assert then
return An_Assert_Pragma;
elsif Pragma_Chars = Name_Assertion_Policy then
return An_Assertion_Policy_Pragma;
elsif Pragma_Chars = Name_Detect_Blocking then
return A_Detect_Blocking_Pragma;
elsif Pragma_Chars = Name_No_Return then
return A_No_Return_Pragma;
-- A_Partition_Elaboration_Policy_Pragma - not implemented yet!
elsif Pragma_Chars = Name_Preelaborable_Initialization then
return A_Preelaborable_Initialization_Pragma;
elsif Pragma_Chars = Name_Priority_Specific_Dispatching then
return A_Priority_Specific_Dispatching_Pragma;
elsif Pragma_Chars = Name_Profile then
return A_Profile_Pragma;
elsif Pragma_Chars = Name_Relative_Deadline then
return A_Relative_Deadline_Pragma;
elsif Pragma_Chars = Name_Unchecked_Union then
return An_Unchecked_Union_Pragma;
elsif Pragma_Chars = Name_Unsuppress then
return An_Unsuppress_Pragma;
-- --|A2005 end
-- --|A2012 start
-- New Ada 2012 pragmas. To be alphabetically ordered later
elsif Pragma_Chars = Name_Default_Storage_Pool then
return A_Default_Storage_Pool_Pragma;
-- elsif Pragma_Chars = Name_Dispatching_Domain then SCz
-- return A_Dispatching_Domain_Pragma;
elsif Pragma_Chars = Name_CPU then
return A_CPU_Pragma;
elsif Pragma_Chars = Name_Independent then
return An_Independent_Pragma;
elsif Pragma_Chars = Name_Independent_Components then
return A_Independent_Components_Pragma;
-- To be continued...
-- --|A2012 end
-- Implementation(GNAT)-Defined Pragmas --
elsif Pragma_Chars in First_Pragma_Name .. Last_Pragma_Name then
-- We have already checked for all the standard pragma names, so
-- all the rest known as pragma name should be GNAT-specific pragmas.
return An_Implementation_Defined_Pragma; -- Vendor Appendix M
else
return An_Unknown_Pragma; -- Unknown to the compiler.
end if;
end N_Pragma_Mapping;
----------------------------------------
-- N_Procedure_Call_Statement_Mapping --
----------------------------------------
function N_Procedure_Call_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Parent_N : Node_Id := Parent (Parent (Node));
Result : Internal_Element_Kinds := A_Procedure_Call_Statement;
begin
-- The only special case we have to process is a procedure call that is
-- an argument of a pragma Debug. To satisfy the Ada syntax, we have to
-- classify it as A_Function_Call (see G330-002).
if Nkind (Parent_N) = N_Block_Statement
and then
not Comes_From_Source (Parent_N)
then
Parent_N := Parent (Parent_N);
if Nkind (Parent_N) = N_If_Statement
and then
Nkind (Original_Node (Parent_N)) = N_Pragma
and then
Pragma_Name (Original_Node (Parent_N)) = Name_Debug
then
Result := A_Function_Call;
end if;
end if;
return Result;
end N_Procedure_Call_Statement_Mapping;
-------------------------------------
-- N_Quantified_Expression_Mapping --
-------------------------------------
function N_Quantified_Expression_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := A_For_Some_Quantified_Expression;
begin
if All_Present (Node) then
Result := A_For_All_Quantified_Expression;
end if;
return Result;
end N_Quantified_Expression_Mapping;
--------------------------------
-- N_Range_Constraint_Mapping --
--------------------------------
function N_Range_Constraint_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Range_Attribute_Reference
-- A_Simple_Expression_Range
if Nkind (Original_Node (Range_Expression (Node))) = N_Range then
return A_Simple_Expression_Range;
else
return A_Range_Attribute_Reference;
end if;
end N_Range_Constraint_Mapping;
---------------------
-- N_Range_Mapping --
---------------------
function N_Range_Mapping (Node : Node_Id) return Internal_Element_Kinds is
Context_Kind : constant Node_Kind := Nkind (Original_Node (Parent_Node));
begin
-- The following Internal_Element_Kinds values may be possible:
-- A_Discrete_Simple_Expression_Range_As_Subtype_Definition
-- A_Discrete_Simple_Expression_Range
-- ???
-- Other values should be added during constructing the
-- full implementation
case Context_Kind is
when N_Constrained_Array_Definition
| N_Entry_Declaration =>
return A_Discrete_Simple_Expression_Range_As_Subtype_Definition;
when N_Index_Or_Discriminant_Constraint |
N_Slice |
N_Case_Statement_Alternative |
N_Component_Association
=>
return A_Discrete_Simple_Expression_Range;
when N_In |
N_Not_In =>
return A_Simple_Expression_Range;
when others => -- not implemented cases (???)
Not_Implemented_Mapping (Nkind (Node));
end case;
end N_Range_Mapping;
---------------------------------
-- N_Record_Definition_Mapping --
---------------------------------
function N_Record_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
Result : Internal_Element_Kinds := A_Record_Type_Definition;
Is_Formal : constant Boolean :=
Nkind (Original_Node (Parent (Node))) = N_Formal_Type_Declaration;
begin
-- Two Internal_Element_Kinds values may be possible (Ada 95):
-- A_Record_Type_Definition
-- A_Tagged_Record_Type_Definition
-- --|A2005 start
-- Plus the following values for Ada 2005:
--
-- An_Ordinary_Interface
-- A_Limited_Interface
-- A_Task_Interface
-- A_Protected_Interface
-- A_Synchronized_Interface
--
-- A_Formal_Ordinary_Interface
-- A_Formal_Limited_Interface
-- A_Formal_Task_Interface
-- A_Formal_Protected_Interface
-- A_Formal_Synchronized_Interface
-- --|A2005 end
-- Implementation revised for Ada 2005
if Interface_Present (Node) then
if Limited_Present (Node) then
if Is_Formal then
Result := A_Formal_Limited_Interface;
else
Result := A_Limited_Interface;
end if;
elsif Task_Present (Node) then
if Is_Formal then
Result := A_Formal_Task_Interface;
else
Result := A_Task_Interface;
end if;
elsif Protected_Present (Node) then
if Is_Formal then
Result := A_Formal_Protected_Interface;
else
Result := A_Protected_Interface;
end if;
elsif Synchronized_Present (Node) then
if Is_Formal then
Result := A_Formal_Synchronized_Interface;
else
Result := A_Synchronized_Interface;
end if;
else
if Is_Formal then
Result := A_Formal_Ordinary_Interface;
else
Result := An_Ordinary_Interface;
end if;
end if;
elsif Tagged_Present (Node) then
Result := A_Tagged_Record_Type_Definition;
end if;
return Result;
-- --|A2005 end
end N_Record_Definition_Mapping;
---------------------------------
-- N_Requeue_Statement_Mapping --
---------------------------------
function N_Requeue_Statement_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Requeue_Statement
-- A_Requeue_Statement_With_Abort
if Abort_Present (Node) then
return A_Requeue_Statement_With_Abort;
else
return A_Requeue_Statement;
end if;
end N_Requeue_Statement_Mapping;
-------------------------------
-- N_Subprogram_Body_Mapping --
-------------------------------
function N_Subprogram_Body_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Procedure_Body_Declaration and A_Function_Body_Declaration
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Function_Body_Declaration;
else
return A_Procedure_Body_Declaration;
end if;
end N_Subprogram_Body_Mapping;
------------------------------------
-- N_Subprogram_Body_Stub_Mapping --
------------------------------------
function N_Subprogram_Body_Stub_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Procedure_Body_Stub and A_Function_Body_Stub,
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Function_Body_Stub;
else
return A_Procedure_Body_Stub;
end if;
end N_Subprogram_Body_Stub_Mapping;
--------------------------------------
-- N_Subprogram_Declaration_Mapping --
--------------------------------------
function N_Subprogram_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Procedure_Declaration
-- A_Function_Declaration
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Function_Declaration;
-- --|A2005 start
elsif Null_Present (Specification (Node)) then
return A_Null_Procedure_Declaration;
-- --|A2005 end
else
return A_Procedure_Declaration;
end if;
end N_Subprogram_Declaration_Mapping;
-----------------------------------------------
-- N_Subprogram_Renaming_Declaration_Mapping --
-----------------------------------------------
function N_Subprogram_Renaming_Declaration_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- A_Procedure_Renaming_Declaration and A_Function_Renaming_Declaration
if Nkind (Specification (Node)) = N_Function_Specification then
return A_Function_Renaming_Declaration;
else
return A_Procedure_Renaming_Declaration;
end if;
end N_Subprogram_Renaming_Declaration_Mapping;
----------------------------------
-- N_Subtype_Indication_Mapping --
----------------------------------
function N_Subtype_Indication_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- The following Internal_Element_Kinds values may be possible:
-- A_Discrete_Subtype_Indication_As_Subtype_Definition
-- A_Discrete_Subtype_Indication
-- A_Subtype_Indication
case Nkind (Parent_Node) is
when N_Constrained_Array_Definition =>
if Is_List_Member (Node) then
return A_Discrete_Subtype_Indication_As_Subtype_Definition;
end if;
when N_Entry_Declaration =>
return A_Discrete_Subtype_Indication_As_Subtype_Definition;
when N_Index_Or_Discriminant_Constraint |
N_Slice =>
return A_Discrete_Subtype_Indication;
when others =>
null;
end case;
return A_Subtype_Indication;
end N_Subtype_Indication_Mapping;
-------------------------------
-- N_Use_Type_Clause_Mapping --
-------------------------------
function N_Use_Type_Clause_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
if All_Present (Node) then
return A_Use_All_Type_Clause;
else
return A_Use_Type_Clause;
end if;
end N_Use_Type_Clause_Mapping;
----------------------
-- N_To_E_List_New --
----------------------
function N_To_E_List_New
(List : List_Id;
Include_Pragmas : Boolean := False;
Starting_Element : Asis.Element := Asis.Nil_Element;
Node_Knd : Node_Kind := N_Empty;
Internal_Kind : Internal_Element_Kinds := Not_An_Element;
Special_Case : Special_Cases := Not_A_Special_Case;
Norm_Case : Normalization_Cases := Is_Not_Normalized;
In_Unit : Asis.Compilation_Unit := Asis.Nil_Compilation_Unit)
return Asis.Element_List
is
begin
Set_Element_List
(List,
Include_Pragmas,
Starting_Element,
Node_Knd,
Internal_Kind,
Special_Case,
Norm_Case,
In_Unit);
return Asis.Association_List
(Internal_Asis_Element_Table.Table
(1 .. Internal_Asis_Element_Table.Last));
end N_To_E_List_New;
----------------------------------------------
-- N_Unconstrained_Array_Definition_Mapping --
----------------------------------------------
function N_Unconstrained_Array_Definition_Mapping
(Node : Node_Id)
return Internal_Element_Kinds
is
begin
-- Two Internal_Element_Kinds values may be possible:
-- An_Unconstrained_Array_Definition
-- A_Formal_Unconstrained_Array_Definition
if Nkind (Parent (Node)) = N_Formal_Type_Declaration then
return A_Formal_Unconstrained_Array_Definition;
else
return An_Unconstrained_Array_Definition;
end if;
end N_Unconstrained_Array_Definition_Mapping;
----------------
-- No_Mapping --
----------------
procedure No_Mapping (Node : Node_Id) is
begin
-- This function should never be called!
raise Internal_Implementation_Error;
end No_Mapping;
-------------------------
-- Node_To_Element_New --
-------------------------
function Node_To_Element_New
(Node : Node_Id;
Node_Field_1 : Node_Id := Empty;
Node_Field_2 : Node_Id := Empty;
Starting_Element : Asis.Element := Asis.Nil_Element;
Internal_Kind : Internal_Element_Kinds := Not_An_Element;
Spec_Case : Special_Cases := Not_A_Special_Case;
Norm_Case : Normalization_Cases := Is_Not_Normalized;
Considering_Parent_Count : Boolean := True;
Using_Original_Node : Boolean := True;
Inherited : Boolean := False;
In_Unit : Asis.Compilation_Unit :=
Asis.Nil_Compilation_Unit)
return Asis.Element
is
R_Node : Node_Id;
Res_Node : Node_Id;
Res_Node_Field_1 : Node_Id := Empty;
Res_Node_Field_2 : Node_Id := Empty;
Res_Internal_Kind : Internal_Element_Kinds := Internal_Kind;
Res_Enclosing_Unit : Asis.Compilation_Unit;
Res_Is_Part_Of_Implicit : Boolean := False;
Res_Is_Part_Of_Inherited : Boolean := False;
Res_Is_Part_Of_Instance : Boolean := False;
Res_Spec_Case : Special_Cases := Spec_Case;
Res_Char_Code : Char_Code := 0;
Res_Parenth_Count : Nat := 0;
begin
-- first, check if Node is not Empty and return Nil_Element otherwise:
if No (Node) then
return Nil_Element;
end if;
if Using_Original_Node
and then
Is_Rewrite_Substitution (Node)
and then
not Is_Rewritten_Function_Prefix_Notation (Node)
then
-- Note that for a function call in Object.Operation notation we do
-- not use the original node at all, because the original tree
-- structure is not properly decorated and analyzed, but the
-- rewritten subtree contains all we need
Res_Node := Original_Node (Node);
if Is_Rewrite_Substitution (Res_Node) then
Res_Node := Original_Node (Res_Node);
end if;
else
Res_Node := Node;
end if;
-- setting the global Parent_Node needed for computing the kind of
-- the returned Element
Parent_Node := Parent (Node);
if not Is_Nil (Starting_Element) then
-- We need this to define the enclosing unit for the new Element
Res_Spec_Case := Special_Case (Starting_Element);
end if;
-- setting result's enclosing unit:
if Exists (In_Unit) then
-- if In_Unit is set, we take information about the result's
-- enclosing unit from it, unless we have to create a configuration
-- pragma or component thereof.
if Spec_Case = Configuration_File_Pragma then
Res_Enclosing_Unit := Get_Configuration_CU (In_Unit);
else
Res_Enclosing_Unit := In_Unit;
end if;
elsif not Is_Nil (Starting_Element) then
-- if Starting_Element is set, but In_Unit is not, we take
-- information about the result's enclosing unit from
-- Starting_Element
Res_Enclosing_Unit := Encl_Unit (Starting_Element);
else
-- we can be here only if both Starting_Element and In_Unit are
-- nor set. This is definitely an error.
raise Internal_Implementation_Error;
end if;
-- if Starting_Element is set, we "transfer" everything what is
-- possible from it to the result:
if not Is_Nil (Starting_Element) then
if Nkind (Res_Node) = N_Null_Statement
and then
not (Comes_From_Source (Res_Node))
then
-- Implicit NULL statement'floating' labels are attached to
Res_Is_Part_Of_Implicit := True;
elsif Nkind (Res_Node) = N_Label then
-- Needed in case of 'floating' labels
Res_Is_Part_Of_Implicit := False;
else
Res_Is_Part_Of_Implicit := Is_From_Implicit (Starting_Element);
end if;
Res_Is_Part_Of_Inherited := Is_From_Inherited (Starting_Element);
Res_Is_Part_Of_Instance := Is_From_Instance (Starting_Element);
-- Res_Spec_Case is already set!
if Present (Node_Field_1_Value (Starting_Element)) then
Res_Node_Field_1 := Node_Field_1_Value (Starting_Element);
pragma Assert (Get_Current_Tree = Encl_Tree (Starting_Element));
-- We can not use Asis.Set_Get.Node_Field_1 here, because it
-- might reset the tree.
end if;
if Present (Node_Field_2_Value (Starting_Element)) then
Res_Node_Field_2 := Node_Field_2_Value (Starting_Element);
pragma Assert (Get_Current_Tree = Encl_Tree (Starting_Element));
-- We can not use Asis.Set_Get.Node_Field_2 here, because it
-- might reset the tree.
end if;
if Internal_Kind = A_Defining_Character_Literal or else
Internal_Kind = An_Enumeration_Literal_Specification
then
-- We keep Character_Code unless the result is type definition
-- (it that case keeping Character_Code would make Is_Equal test
-- not work properly
Res_Char_Code := Character_Code (Starting_Element);
end if;
if Res_Spec_Case in Expanded_Spec then
-- We have to reset Res_Spec_Case from
-- Expanded_Package_Instantiation or
-- Expanded_Subprogram_Instantiation to Not_A_Special_Case;
-- because only (the whole) expanded generic declarations can have
-- the value of Special_Case from Expanded_Spec
Res_Spec_Case := Not_A_Special_Case;
end if;
elsif Res_Spec_Case in Expanded_Spec then
Res_Is_Part_Of_Implicit := False;
else
if Is_From_Instance (Original_Node (Node)) or else
Is_Name_Of_Expanded_Subprogram (Res_Node) or else
Part_Of_Pass_Generic_Actual (Original_Node (Node)) or else
Is_Stub_To_Body_Instanse_Replacement (Node) or else
Spec_Case = Expanded_Package_Instantiation or else
Spec_Case = Expanded_Subprogram_Instantiation
then
Res_Is_Part_Of_Instance := True;
end if;
if Inherited then
Res_Is_Part_Of_Inherited := True;
Res_Is_Part_Of_Implicit := True;
end if;
if not Comes_From_Source (Res_Node)
and then
(not Part_Of_Pass_Generic_Actual (Res_Node)
or else
Norm_Case = Is_Normalized_Defaulted_For_Box)
and then
not Is_Name_Of_Expanded_Subprogram (Res_Node)
then
Res_Is_Part_Of_Implicit := True;
end if;
end if;
-- This patch below is really terrible!!! requires revising!!!
-- ???
if Spec_Case = Expanded_Package_Instantiation or else
Spec_Case = Expanded_Subprogram_Instantiation
then
Res_Is_Part_Of_Instance := True;
end if;
-- if Spec_Case is set explicitly, we should set (or reset)
-- Res_Spec_Case from it
if Spec_Case /= Not_A_Special_Case then
Res_Spec_Case := Spec_Case;
end if;
-- computing the kind of the result and correcting Special_Case,
-- if needed
if Res_Internal_Kind = Not_An_Element then
-- Res_Internal_Kind is initialized by the value of the
-- Internal_Kind parameter. If this value differs from
-- Not_An_Element, we simply does not change it
if Considering_Parent_Count and then
(Parenth_Count (Res_Node, Node) > 0
or else
Requires_Parentheses (Res_Node))
then
-- special processing for A_Parenthesized_Expression
Res_Internal_Kind := A_Parenthesized_Expression;
if Parenth_Count (Res_Node, Node) > 0 then
Res_Parenth_Count := Parenth_Count (Res_Node, Node);
if Requires_Parentheses (Res_Node) then
Res_Parenth_Count := Res_Parenth_Count + 1;
end if;
else
-- (conditional expression)
Res_Parenth_Count := 1;
end if;
else
-- from Sinfo (spec, rev. 1.334):
---------------------------------
-- 9.5.3 Entry Call Statement --
---------------------------------
-- ENTRY_CALL_STATEMENT ::= entry_NAME [ACTUAL_PARAMETER_PART];
-- The parser may generate a procedure call for this construct. The
-- semantic pass must correct this misidentification where needed.
if Res_Node /= Node and then
((Nkind (Res_Node) = N_Procedure_Call_Statement and then
Nkind (Node) = N_Entry_Call_Statement and then
not Is_Protected_Procedure_Call (Node))
or else
(Nkind (Res_Node) = N_Explicit_Dereference and then
Nkind (Node) = N_Function_Call))
then
Res_Node := Node; -- ???
-- There is no need to keep the original structure in this
-- case, it is definitely wrong
if Nkind (Node) = N_Entry_Call_Statement then
Res_Internal_Kind := An_Entry_Call_Statement;
else
Res_Internal_Kind := A_Function_Call;
end if;
else
if (Nkind (Node) = N_Integer_Literal or else
Nkind (Node) = N_Real_Literal)
and then
((not Is_Rewrite_Substitution (Node))
or else
Nkind (Original_Node (Node)) = N_Identifier)
and then
Comes_From_Source (Node) = False
and then
Is_Static_Expression (Node)
and then
Present (Original_Entity (Node))
then
-- See BB10-002: The special case of named numbers rewritten
-- into numeric literals.
Res_Spec_Case := Rewritten_Named_Number;
Res_Internal_Kind := An_Identifier;
else
Res_Internal_Kind := Asis_Internal_Element_Kind (Res_Node);
end if;
end if;
end if;
end if;
-- and now we have to check if the Element to be returned is from the
-- Standard package, and if it is, we have to correct Res_Spec_Case:
if Res_Spec_Case = Not_A_Special_Case and then
Sloc (Res_Node) <= Standard_Location
then
if Nkind (Node) = N_Defining_Character_Literal then
Res_Spec_Case := Stand_Char_Literal;
else
Res_Spec_Case := Explicit_From_Standard;
end if;
end if;
if Res_Spec_Case = Explicit_From_Standard or else
Res_Spec_Case = Stand_Char_Literal
then
Res_Is_Part_Of_Implicit := False;
end if;
-- ??? This assignment is not necessary and has been
-- introduced to workaround a problem with the sgi n32 compiler
R_Node := Node;
if Nkind (Node) = N_Function_Call and then
(Res_Internal_Kind = A_Selected_Component or else
Res_Internal_Kind = An_Enumeration_Literal)
then
-- a reference to an overloaded enumeration literal represented as a
-- function call, we have to go one step down:
R_Node := Sinfo.Name (Node);
Res_Node := R_Node;
else
R_Node := Node;
end if;
if Present (Node_Field_1) then
Res_Node_Field_1 := Node_Field_1;
end if;
if Present (Node_Field_2) then
Res_Node_Field_2 := Node_Field_2;
end if;
if Res_Spec_Case = From_Limited_View then
Res_Is_Part_Of_Implicit := True;
end if;
return Set_Element (
Node => Res_Node,
R_Node => R_Node,
Node_Field_1 => Res_Node_Field_1,
Node_Field_2 => Res_Node_Field_2,
Encl_Unit => Res_Enclosing_Unit,
Int_Kind => Res_Internal_Kind,
Implicit => Res_Is_Part_Of_Implicit,
Inherited => Res_Is_Part_Of_Inherited,
Instance => Res_Is_Part_Of_Instance,
Spec_Case => Res_Spec_Case,
Norm_Case => Norm_Case,
Par_Count => Res_Parenth_Count,
Character_Code => Res_Char_Code);
end Node_To_Element_New;
--------------------
-- Normalize_Name --
--------------------
procedure Normalize_Name (Capitalized : Boolean := False) is
begin
if Namet.Name_Len = 0 then
return;
end if;
Namet.Name_Buffer (1) := To_Upper (Namet.Name_Buffer (1));
for I in 1 .. Namet.Name_Len - 1 loop
if Capitalized or else
Namet.Name_Buffer (I) = '_'
then
Namet.Name_Buffer (I + 1) := To_Upper (Namet.Name_Buffer (I + 1));
end if;
end loop;
end Normalize_Name;
-----------------------------
-- Normalized_Namet_String --
-----------------------------
function Normalized_Namet_String (Node : Node_Id) return String is
Capitalize : Boolean := False;
begin
Namet.Get_Name_String (Chars (Node));
if Node = Standard_ASCII or else
Node in SE (S_LC_A) .. SE (S_LC_Z) or else
Node in SE (S_NUL) .. SE (S_US) or else
Node = SE (S_DEL)
then
Capitalize := True;
end if;
Normalize_Name (Capitalize);
return Namet.Name_Buffer (1 .. Namet.Name_Len);
end Normalized_Namet_String;
-----------------------------
-- Not_Implemented_Mapping --
-----------------------------
function Not_Implemented_Mapping
(Node : Node_Id)
return Internal_Element_Kinds is
begin
Not_Implemented_Yet (Diagnosis =>
"AST Node -> Asis.Element mapping for the "
& Node_Kind'Image (Nkind (Node))
& " Node Kind value has not been implemented yet");
return Not_An_Element; -- to make the code syntactically correct;
end Not_Implemented_Mapping;
procedure Not_Implemented_Mapping (Source_Node_Kind : Node_Kind) is
begin
Not_Implemented_Yet (Diagnosis =>
"AST Node -> Asis.Element mapping for the "
& Node_Kind'Image (Source_Node_Kind)
& " Node Kind value has not been implemented yet");
end Not_Implemented_Mapping;
----------------------------------
-- Ordinary_Inclusion_Condition --
----------------------------------
function Ordinary_Inclusion_Condition (Node : Node_Id) return Boolean is
O_Node : constant Node_Id := Original_Node (Node);
Arg_Kind : constant Node_Kind := Nkind (Node);
Result : Boolean := True;
begin
if Is_Rewrite_Insertion (Node) or else
May_Be_Included_Switch (Nkind (Node)) = False or else
(Nkind (Node) = N_With_Clause
and then
Implicit_With (Node)) or else
(Nkind (Node) = N_Entry_Call_Statement
and then
Node = O_Node)
then
Result := False;
elsif not Comes_From_Source (O_Node) then
if Arg_Kind = N_Null_Statement then
-- We have to include implicit null statements 'floating' labels
-- are attached to
if not (No (Next (Node))
and then
Present (Prev (Node))
and then
Nkind (Prev (Node)) = N_Label
and then
Comes_From_Source (Prev (Node)))
then
Result := False;
end if;
elsif Arg_Kind = N_Object_Renaming_Declaration then
-- For FB02-008
if (Nkind (Sinfo.Name (Node)) = N_Identifier
and then
Is_Internal_Name (Chars (Sinfo.Name (Node))))
or else
(Nkind (Sinfo.Subtype_Mark (Node)) = N_Identifier
and then
Is_Internal_Name (Chars (Sinfo.Subtype_Mark (Node))))
then
Result := False;
end if;
elsif not ((Arg_Kind = N_Object_Declaration
and then
not Is_Internal_Name (Chars (Defining_Identifier (O_Node))))
or else
Arg_Kind = N_Component_Declaration
or else
Arg_Kind = N_Discriminant_Specification
or else
Arg_Kind = N_Parameter_Specification
or else
Arg_Kind = N_Component_Association
or else
((Arg_Kind = N_Integer_Literal
or else
Arg_Kind = N_Real_Literal)
and then
Is_Static_Expression (Node))
-- This condition describes the special case of a named
-- number rewritten into a literal node, see BB10-002
or else
Sloc (Node) <= Standard_Location
or else
Is_Rewritten_Function_Prefix_Notation (Parent (Node))
or else
Pass_Generic_Actual (Node))
then
Result := False;
end if;
end if;
return Result;
end Ordinary_Inclusion_Condition;
-------------------
-- Parenth_Count --
-------------------
function Parenth_Count
(N : Node_Id;
Original_N : Node_Id)
return Nat
is
Result : Nat := Paren_Count (N);
begin
if Result > 0 and then
Nkind (Original_Node (Parent (Original_N))) = N_Qualified_Expression
then
Result := Result - 1;
end if;
return Result;
end Parenth_Count;
--------------------------
-- Requires_Parentheses --
--------------------------
function Requires_Parentheses
(N : Node_Id)
return Boolean
is
Left_Par_Sloc : Source_Ptr;
Result : Boolean := False;
begin
if Nkind (N) = N_Conditional_Expression
or else
Nkind (N) = N_Case_Expression
or else
Nkind (N) = N_Quantified_Expression
then
Result := True;
-- And now - cases when the expression does not require parentheses:
if Nkind (Parent (N)) = N_Qualified_Expression
or else
Nkind (Parent (N)) = N_Type_Conversion
or else
(Is_List_Member (N)
and then
List_Length (List_Containing (N)) = 1)
then
-- There is a corner case here:
-- P ((if A then B else C));
Left_Par_Sloc := Sloc (N);
Left_Par_Sloc := Search_Prev_Word (Left_Par_Sloc);
pragma Assert (Get_Character (Left_Par_Sloc) = '(');
Left_Par_Sloc := Search_Prev_Word (Left_Par_Sloc);
if Get_Character (Left_Par_Sloc) /= '(' then
Result := False;
end if;
end if;
end if;
-- if Nkind (N) = N_Conditional_Expression
-- or else
-- Nkind (N) = N_Case_Expression
-- or else
-- Nkind (N) = N_Quantified_Expression
-- then
-- Left_Par_Sloc := Sloc (N);
-- Left_Par_Sloc := Search_Prev_Word (Left_Par_Sloc);
-- Result := Get_Character (Left_Par_Sloc) = '(';
-- end if;
-- if Result then
-- -- We have to check if this '(' belongs to some other construct:
-- Left_Par_Sloc := Search_Prev_Word (Left_Par_Sloc);
-- if Get_Character (Left_Par_Sloc) /= '(' then
-- case Nkind (Parent (N)) is
-- when N_Qualified_Expression |
-- N_Type_Conversion =>
-- Result := False;
-- when N_Function_Call |
-- N_Indexed_Component |
-- N_Procedure_Call_Statement |
-- N_Entry_Call_Statement =>
-- -- ??? Is this list complete???
-- if Get_Character (Left_Par_Sloc) /= ',' then
-- Result := False;
-- end if;
-- when others =>
-- null;
-- end case;
-- end if;
-- end if;
return Result;
end Requires_Parentheses;
-----------------------------------------
-- Set_Concurrent_Inherited_Components --
-----------------------------------------
procedure Set_Concurrent_Inherited_Components
(Type_Def : Asis.Element;
Include_Discs : Boolean := True)
is
Type_Entity : Entity_Id;
Next_Comp_Node : Node_Id;
begin
Asis_Element_Table.Init;
Type_Entity := Defining_Identifier (Parent (R_Node (Type_Def)));
if Present (First_Entity (Type_Entity)) then
if Include_Discs then
Next_Comp_Node := First_Entity (Type_Entity);
while Ekind (Next_Comp_Node) = E_Discriminant loop
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Parent (Next_Comp_Node),
Starting_Element => Type_Def));
Set_Node_Field_2
(Asis_Element_Table.Table (Asis_Element_Table.Last),
Next_Comp_Node);
-- This is needed to unify the processing of inherited
-- discriminants in Asis.Declarations.Names
Next_Comp_Node := Next_Entity (Next_Comp_Node);
end loop;
end if;
-- To set all the non-discriminant components, we have to go to the
-- definition of the root concurrent type and to traverse it to
-- grab all this components, because the (non-discrimiinant)
-- entities attached to the entity of the derived concurrent type
-- are artificial entities created for further tree expansion
while Type_Entity /= Etype (Type_Entity) loop
Type_Entity := Etype (Type_Entity);
end loop;
Type_Entity := Parent (Type_Entity);
if Nkind (Type_Entity) = N_Task_Type_Declaration then
Type_Entity := Task_Definition (Type_Entity);
else
Type_Entity := Protected_Definition (Type_Entity);
end if;
Next_Comp_Node :=
First_Non_Pragma (Visible_Declarations (Type_Entity));
while Present (Next_Comp_Node) loop
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Next_Comp_Node,
Starting_Element => Type_Def));
Next_Comp_Node := Next_Non_Pragma (Next_Comp_Node);
end loop;
if Present (Private_Declarations (Type_Entity)) then
Next_Comp_Node :=
First_Non_Pragma (Private_Declarations (Type_Entity));
while Present (Next_Comp_Node) loop
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Next_Comp_Node,
Starting_Element => Type_Def));
Next_Comp_Node := Next_Non_Pragma (Next_Comp_Node);
end loop;
end if;
end if;
end Set_Concurrent_Inherited_Components;
----------------------
-- Set_Element_List --
----------------------
-- At the moment, the implementation is just a copy from N_To_E_List_New
-- with changes related to building the result list in Element Table
procedure Set_Element_List
(List : List_Id;
Include_Pragmas : Boolean := False;
Starting_Element : Asis.Element := Asis.Nil_Element;
Node_Knd : Node_Kind := N_Empty;
Internal_Kind : Internal_Element_Kinds := Not_An_Element;
Special_Case : Special_Cases := Not_A_Special_Case;
Norm_Case : Normalization_Cases := Is_Not_Normalized;
In_Unit : Asis.Compilation_Unit := Asis.Nil_Compilation_Unit;
Append : Boolean := False)
is
List_El : Node_Id;
List_El_Kind : Node_Kind;
function First_List_Element (List : List_Id) return Node_Id;
-- returns the first element of List, taking into account
-- the value of Include_Pragmas
function Next_List_Element (Node : Node_Id) return Node_Id;
-- returns the first element of List, taking into account
-- the value of Include_Pragmas
procedure Skip_Pragmas (N : in out Node_Id);
-- Supposes that Is_List_Member (N). If N is of N_Pragma kind and if
-- Include_Pragmas is set OFF, moves N to the next element of the same
-- list that is not of N_Pragma kinds or set it to Empty if there is no
-- such node. We can not just use Nlists.First_Non_Pragma and
-- Nlists.Next_Non_Pragma, because they also skip N_Null_Statement
-- nodes.
------------------------
-- First_List_Element --
------------------------
function First_List_Element (List : List_Id) return Node_Id is
Result : Node_Id;
begin
Result := First (List);
Skip_Pragmas (Result);
if Is_Rewrite_Substitution (Result)
and then
Nkind (Result) = N_Loop_Statement
and then
Nkind (Original_Node (Result)) = N_Goto_Statement
then
-- This is the case when infinite loop implemented as
--
-- <<Target>> ...
-- ...
-- goto Target;
--
-- Is rewritten into N_Loop_Statement
if not Is_Empty_List (Statements (Result)) then
Result := First (Statements (Result));
end if;
end if;
return Result;
end First_List_Element;
-----------------------
-- Next_List_Element --
-----------------------
function Next_List_Element (Node : Node_Id) return Node_Id is
Tmp : Node_Id;
Result : Node_Id;
begin
Result := Next (Node);
Skip_Pragmas (Result);
if Is_Rewrite_Substitution (Result)
and then
Nkind (Result) = N_Loop_Statement
and then
Nkind (Original_Node (Result)) = N_Goto_Statement
then
-- This is the case when infinite loop implemented as
--
-- <<Target>> ...
-- ...
-- goto Target;
--
-- Is rewritten into N_Loop_Statement
if not Is_Empty_List (Statements (Result)) then
Result := First (Statements (Result));
end if;
end if;
if No (Result) then
Tmp := Parent (Node);
if Is_Rewrite_Substitution (Tmp)
and then
Nkind (Tmp) = N_Loop_Statement
and then
Nkind (Original_Node (Tmp)) = N_Goto_Statement
then
-- We have just finished traversing of the artificial loop
-- statement created for goto, so it's tome to
-- return this goto itself. Note, that we are returning the
-- rewritten N_Loop_Statement to keep list and parent
-- references
Result := Tmp;
end if;
end if;
return Result;
end Next_List_Element;
------------------
-- Skip_Pragmas --
------------------
procedure Skip_Pragmas (N : in out Node_Id) is
begin
if not Include_Pragmas then
while Present (N)
and then
Nkind (Original_Node (N)) = N_Pragma
loop
N := Next (N);
end loop;
end if;
end Skip_Pragmas;
begin
if not Append then
Internal_Asis_Element_Table.Init;
end if;
if No (List) or else Is_Empty_List (List) then
return;
end if;
List_El := First_List_Element (List);
while Present (List_El) loop
if Debug_Flag_L then
Write_Node (N => List_El,
Prefix => "Set_Element_List debug info-> ");
Write_Str ("May_Be_Included is ");
Write_Str (Boolean'Image (May_Be_Included (List_El)));
Write_Eol;
Write_Eol;
end if;
List_El_Kind := Nkind (List_El);
if May_Be_Included (List_El) and then
not ((Node_Knd /= N_Empty) and then (List_El_Kind /= Node_Knd))
then
Internal_Asis_Element_Table.Append
(Node_To_Element_New
(Starting_Element => Starting_Element,
Node => List_El,
Internal_Kind => Internal_Kind,
Spec_Case => Special_Case,
Norm_Case => Norm_Case,
In_Unit => In_Unit));
if List_El_Kind = N_Object_Declaration or else
List_El_Kind = N_Number_Declaration or else
List_El_Kind = N_Discriminant_Specification or else
List_El_Kind = N_Component_Declaration or else
List_El_Kind = N_Parameter_Specification or else
List_El_Kind = N_Exception_Declaration or else
List_El_Kind = N_Formal_Object_Declaration or else
List_El_Kind = N_With_Clause
then
Skip_Normalized_Declarations (List_El);
end if;
end if;
List_El := Next_List_Element (List_El);
end loop;
end Set_Element_List;
---------------------------------
-- Set_Inherited_Discriminants --
---------------------------------
procedure Set_Inherited_Discriminants (Type_Def : Asis.Element) is
Next_Discr_Elmt : Elmt_Id;
Next_Elem_Node : Node_Id;
begin
Next_Elem_Node := Defining_Identifier (Parent (R_Node (Type_Def)));
if Present (Stored_Constraint (Next_Elem_Node)) then
Asis_Element_Table.Init;
Next_Discr_Elmt := First_Elmt (Stored_Constraint (Next_Elem_Node));
while Present (Next_Discr_Elmt) loop
Next_Elem_Node := Parent (Entity (Node (Next_Discr_Elmt)));
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Next_Elem_Node,
Internal_Kind => A_Discriminant_Specification,
Starting_Element => Type_Def));
Next_Discr_Elmt := Next_Elmt (Next_Discr_Elmt);
end loop;
end if;
end Set_Inherited_Discriminants;
------------------------------
-- Set_Inherited_Components --
------------------------------
procedure Set_Inherited_Components
(Type_Def : Asis.Element;
Include_Discs : Boolean := True)
is
Next_Comp_Node : Node_Id;
function Is_Implicit_Component (E : Entity_Id) return Boolean;
-- Checks if E is an entity representing implicit inherited
-- component
function Is_Implicit_Component (E : Entity_Id) return Boolean is
Result : Boolean := False;
begin
if Ekind (E) = E_Component then
Result :=
(E /= Original_Record_Component (E)) or else
not Comes_From_Source (Parent (E));
elsif Ekind (E) = E_Discriminant and then Include_Discs then
Result := not Is_Completely_Hidden (E);
end if;
return Result;
end Is_Implicit_Component;
begin
Asis_Element_Table.Init;
Next_Comp_Node := Defining_Identifier (Parent (R_Node (Type_Def)));
if Ekind (Next_Comp_Node) = E_Record_Subtype then
-- For subtypes we may have components depending on discriminants
-- skipped in case of static discriminant constraints
Next_Comp_Node := Etype (Next_Comp_Node);
end if;
if Present (First_Entity (Next_Comp_Node)) then
Next_Comp_Node := First_Entity (Next_Comp_Node);
while Present (Next_Comp_Node) loop
if Is_Implicit_Component (Next_Comp_Node) then
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Parent (Next_Comp_Node),
Starting_Element => Type_Def));
Set_Node_Field_2
(Asis_Element_Table.Table (Asis_Element_Table.Last),
Next_Comp_Node);
Set_From_Implicit
(Asis_Element_Table.Table (Asis_Element_Table.Last), True);
Set_From_Inherited
(Asis_Element_Table.Table (Asis_Element_Table.Last), True);
end if;
Next_Comp_Node := Next_Entity (Next_Comp_Node);
end loop;
end if;
end Set_Inherited_Components;
----------------------------
-- Set_Inherited_Literals --
----------------------------
procedure Set_Inherited_Literals (Type_Def : Asis.Element) is
Next_Literal_Node : Node_Id;
Res_Etype : Entity_Id;
Encl_Type : constant Node_Id := Parent (R_Node (Type_Def));
begin
Asis_Element_Table.Init;
Next_Literal_Node := Defining_Identifier (Parent (R_Node (Type_Def)));
if Present (First_Literal (Next_Literal_Node)) then
Next_Literal_Node := First_Literal (Next_Literal_Node);
Res_Etype := Etype (Next_Literal_Node);
while Present (Next_Literal_Node) and then
Etype (Next_Literal_Node) = Res_Etype
loop
Asis_Element_Table.Append
(Node_To_Element_New
(Node => Next_Literal_Node,
Internal_Kind => An_Enumeration_Literal_Specification,
Starting_Element => Type_Def));
Set_Node_Field_1
(Asis_Element_Table.Table (Asis_Element_Table.Last),
Encl_Type);
Set_From_Implicit
(Asis_Element_Table.Table (Asis_Element_Table.Last), True);
Set_From_Inherited
(Asis_Element_Table.Table (Asis_Element_Table.Last), True);
Next_Literal_Node := Next_Entity (Next_Literal_Node);
end loop;
else
Not_Implemented_Yet
(Diagnosis =>
"Asis.Definitions.Implicit_Inherited_Declarations "
& "(derived from Standard character type)");
end if;
end Set_Inherited_Literals;
----------------------------------
-- Skip_Normalized_Declarations --
----------------------------------
procedure Skip_Normalized_Declarations (Node : in out Node_Id) is
Arg_Kind : constant Node_Kind := Nkind (Node);
begin
loop
if Arg_Kind = N_Object_Declaration or else
Arg_Kind = N_Number_Declaration or else
Arg_Kind = N_Discriminant_Specification or else
Arg_Kind = N_Component_Declaration or else
Arg_Kind = N_Parameter_Specification or else
Arg_Kind = N_Exception_Declaration or else
Arg_Kind = N_Formal_Object_Declaration
then
if More_Ids (Node) then
Node := Next (Node);
while Nkind (Node) /= Arg_Kind loop
-- some implicit subtype declarations may be inserted by
-- the compiler in between the normalized declarations, so:
Node := Next (Node);
end loop;
else
return;
end if;
else
-- Arg_Kind = N_With_Clause.
-- Note that we should skip implicit clauses that can be added by
-- front-end.
if Comes_From_Source (Node) and then Last_Name (Node) then
return;
else
Node := Next (Node);
end if;
end if;
end loop;
end Skip_Normalized_Declarations;
-------------------------------
-- Subprogram_Attribute_Kind --
-------------------------------
function Subprogram_Attribute_Kind
(Node : Node_Id)
return Internal_Element_Kinds
is
Attribute_Chars : Name_Id;
begin
Attribute_Chars := Attribute_Name (Node);
-- language-defined attributes which are functions:
if Attribute_Chars = Name_Adjacent then
return An_Adjacent_Attribute;
elsif Attribute_Chars = Name_Ceiling then
return A_Ceiling_Attribute;
elsif Attribute_Chars = Name_Compose then
return A_Compose_Attribute;
elsif Attribute_Chars = Name_Copy_Sign then
return A_Copy_Sign_Attribute;
elsif Attribute_Chars = Name_Exponent then
return An_Exponent_Attribute;
elsif Attribute_Chars = Name_Floor then
return A_Floor_Attribute;
elsif Attribute_Chars = Name_Fraction then
return A_Fraction_Attribute;
elsif Attribute_Chars = Name_Image then
return An_Image_Attribute;
elsif Attribute_Chars = Name_Input then
return An_Input_Attribute;
elsif Attribute_Chars = Name_Leading_Part then
return A_Leading_Part_Attribute;
elsif Attribute_Chars = Name_Machine then
return A_Machine_Attribute;
elsif Attribute_Chars = Name_Max then
return A_Max_Attribute;
elsif Attribute_Chars = Name_Min then
return A_Min_Attribute;
elsif Attribute_Chars = Name_Model then
return A_Model_Attribute;
elsif Attribute_Chars = Name_Pos then
return A_Pos_Attribute;
elsif Attribute_Chars = Name_Pred then
return A_Pred_Attribute;
elsif Attribute_Chars = Name_Remainder then
return A_Remainder_Attribute;
elsif Attribute_Chars = Name_Round then
return A_Round_Attribute;
elsif Attribute_Chars = Name_Rounding then
return A_Rounding_Attribute;
elsif Attribute_Chars = Name_Scaling then
return A_Scaling_Attribute;
elsif Attribute_Chars = Name_Succ then
return A_Succ_Attribute;
elsif Attribute_Chars = Name_Truncation then
return A_Truncation_Attribute;
elsif Attribute_Chars = Name_Unbiased_Rounding then
return An_Unbiased_Rounding_Attribute;
elsif Attribute_Chars = Name_Val then
return A_Val_Attribute;
elsif Attribute_Chars = Name_Value then
return A_Value_Attribute;
elsif Attribute_Chars = Name_Wide_Image then
return A_Wide_Image_Attribute;
elsif Attribute_Chars = Name_Wide_Value then
return A_Wide_Value_Attribute;
-- |A2005 start
-- Ada 2005 attributes that are functions:
elsif Attribute_Chars = Name_Machine_Rounding then
return A_Machine_Rounding_Attribute;
elsif Attribute_Chars = Name_Mod then
return A_Mod_Attribute;
elsif Attribute_Chars = Name_Wide_Wide_Image then
return A_Wide_Wide_Image_Attribute;
elsif Attribute_Chars = Name_Wide_Wide_Value then
return A_Wide_Wide_Value_Attribute;
-- |A2005 end
-- |A2012 start
-- Ada 2012 attributes that are functions:
-- elsif Attribute_Chars = Name_Overlaps_Storage then (SCz)
-- return An_Overlaps_Storage_Attribute;
-- |A2012 end
-- language-defined attributes which are procedures:
elsif Attribute_Chars = Name_Output then
return An_Output_Attribute;
elsif Attribute_Chars = Name_Read then
return A_Read_Attribute;
elsif Attribute_Chars = Name_Write then
return A_Write_Attribute;
-- Implementation Dependent Attributes-Functions --
elsif Attribute_Chars = Name_Asm_Input or else
Attribute_Chars = Name_Asm_Output or else
Attribute_Chars = Name_Enum_Rep or else
Attribute_Chars = Name_Enum_Val or else
Attribute_Chars = Name_Fixed_Value or else
Attribute_Chars = Name_Integer_Value or else
Attribute_Chars = Name_Ref
then
return An_Implementation_Defined_Attribute;
else
return An_Unknown_Attribute;
end if;
end Subprogram_Attribute_Kind;
-----------------
-- Ureal_Image --
-----------------
function Ureal_Image (N : Node_Id) return String is
Result : String (1 .. 256);
Res_Len : Natural range 0 .. 256 := 0;
-- bad solution!!! ASIS needs a general-purpose String buffer
-- somewhere!!! ???
Real : constant Ureal := Realval (N);
Nom : constant Uint := Norm_Num (Real);
Den : constant Uint := Norm_Den (Real);
Dot_Outputed : Boolean := False;
begin
if UR_Is_Negative (Real) then
Res_Len := Res_Len + 1;
Result (Res_Len) := '(';
Res_Len := Res_Len + 1;
Result (Res_Len) := '-';
end if;
UI_Image (Nom, Decimal);
for I in 1 .. UI_Image_Length loop
if UI_Image_Buffer (I) = 'E' then
Res_Len := Res_Len + 1;
Result (Res_Len) := '.';
Res_Len := Res_Len + 1;
Result (Res_Len) := '0';
Res_Len := Res_Len + 1;
Result (Res_Len) := 'E';
Dot_Outputed := True;
else
Res_Len := Res_Len + 1;
Result (Res_Len) := UI_Image_Buffer (I);
end if;
end loop;
if not Dot_Outputed then
Res_Len := Res_Len + 1;
Result (Res_Len) := '.';
Res_Len := Res_Len + 1;
Result (Res_Len) := '0';
end if;
Dot_Outputed := False;
Res_Len := Res_Len + 1;
Result (Res_Len) := '/';
UI_Image (Den, Decimal);
for I in 1 .. UI_Image_Length loop
if UI_Image_Buffer (I) = 'E' then
Res_Len := Res_Len + 1;
Result (Res_Len) := '.';
Res_Len := Res_Len + 1;
Result (Res_Len) := '0';
Res_Len := Res_Len + 1;
Result (Res_Len) := 'E';
Dot_Outputed := True;
else
Res_Len := Res_Len + 1;
Result (Res_Len) := UI_Image_Buffer (I);
end if;
end loop;
if not Dot_Outputed then
Res_Len := Res_Len + 1;
Result (Res_Len) := '.';
Res_Len := Res_Len + 1;
Result (Res_Len) := '0';
end if;
if UR_Is_Negative (Real) then
Res_Len := Res_Len + 1;
Result (Res_Len) := ')';
end if;
return Result (1 .. Res_Len);
end Ureal_Image;
end A4G.Mapping;
|
[
{
"context": "lected\n-- at compile-time.\n\n-- Copyright (c) 2015, James Humphry - see LICENSE file for details\n\ngeneric\npackage S",
"end": 235,
"score": 0.9998735189437866,
"start": 222,
"tag": "NAME",
"value": "James Humphry"
}
] | src/siphash-entropy.ads | jhumphry/SPARK_SipHash | 5 | -- SipHash.Entropy
-- A child package that attempts to set the key from an entropy source on the
-- system. There are various different implementations of this that are selected
-- at compile-time.
-- Copyright (c) 2015, James Humphry - see LICENSE file for details
generic
package SipHash.Entropy
with SPARK_Mode => On
is
Entropy_Unavailable : exception;
-- This function indicates whether the program has been compiled with the
-- possibility to set the SipHash key from system entropy. Note that even
-- if this returns true it is still possible for Set_Key_From_System_Entropy
-- to fail, for example if there is an IO error or the system declines to
-- provide enough entropy.
function System_Entropy_Source return Boolean;
-- This procedure will set the SipHash key from a system entropy source,
-- unless System_Entropy_Source is False or the system returns insufficient
-- data, in which case it will raise No_Entropy_Available.
procedure Set_Key_From_System_Entropy
with Global => (Output => Initial_Hash_State);
-- This procedure will set the SipHash key from a system entropy source,
-- returning a boolean to indicate if it was successful. Failure can be
-- caused by having no entropy source compiled into the library, or by an
-- inability to retrieve sufficient data from the system.
-- It would be nice to make this a function, but functions with side effects
-- are not permitted by SPARK.
procedure Set_Key_From_System_Entropy (Success : out Boolean)
with Global => (Output => Initial_Hash_State);
end SipHash.Entropy;
| 621 | -- SipHash.Entropy
-- A child package that attempts to set the key from an entropy source on the
-- system. There are various different implementations of this that are selected
-- at compile-time.
-- Copyright (c) 2015, <NAME> - see LICENSE file for details
generic
package SipHash.Entropy
with SPARK_Mode => On
is
Entropy_Unavailable : exception;
-- This function indicates whether the program has been compiled with the
-- possibility to set the SipHash key from system entropy. Note that even
-- if this returns true it is still possible for Set_Key_From_System_Entropy
-- to fail, for example if there is an IO error or the system declines to
-- provide enough entropy.
function System_Entropy_Source return Boolean;
-- This procedure will set the SipHash key from a system entropy source,
-- unless System_Entropy_Source is False or the system returns insufficient
-- data, in which case it will raise No_Entropy_Available.
procedure Set_Key_From_System_Entropy
with Global => (Output => Initial_Hash_State);
-- This procedure will set the SipHash key from a system entropy source,
-- returning a boolean to indicate if it was successful. Failure can be
-- caused by having no entropy source compiled into the library, or by an
-- inability to retrieve sufficient data from the system.
-- It would be nice to make this a function, but functions with side effects
-- are not permitted by SPARK.
procedure Set_Key_From_System_Entropy (Success : out Boolean)
with Global => (Output => Initial_Hash_State);
end SipHash.Entropy;
| true | -- SipHash.Entropy
-- A child package that attempts to set the key from an entropy source on the
-- system. There are various different implementations of this that are selected
-- at compile-time.
-- Copyright (c) 2015, PI:NAME:<NAME>END_PI - see LICENSE file for details
generic
package SipHash.Entropy
with SPARK_Mode => On
is
Entropy_Unavailable : exception;
-- This function indicates whether the program has been compiled with the
-- possibility to set the SipHash key from system entropy. Note that even
-- if this returns true it is still possible for Set_Key_From_System_Entropy
-- to fail, for example if there is an IO error or the system declines to
-- provide enough entropy.
function System_Entropy_Source return Boolean;
-- This procedure will set the SipHash key from a system entropy source,
-- unless System_Entropy_Source is False or the system returns insufficient
-- data, in which case it will raise No_Entropy_Available.
procedure Set_Key_From_System_Entropy
with Global => (Output => Initial_Hash_State);
-- This procedure will set the SipHash key from a system entropy source,
-- returning a boolean to indicate if it was successful. Failure can be
-- caused by having no entropy source compiled into the library, or by an
-- inability to retrieve sufficient data from the system.
-- It would be nice to make this a function, but functions with side effects
-- are not permitted by SPARK.
procedure Set_Key_From_System_Entropy (Success : out Boolean)
with Global => (Output => Initial_Hash_State);
end SipHash.Entropy;
|
[
{
"context": "----------\n-- Fichier : foret.ads\n-- Auteur : MOUDDENE Hamza & CAZES Noa\n-- Objectif : Spécification du modul",
"end": 135,
"score": 0.9998748898506165,
"start": 121,
"tag": "NAME",
"value": "MOUDDENE Hamza"
},
{
"context": "chier : foret.ads\n-- Auteur : MOUDDENE Hamza & CAZES Noa\n-- Objectif : Spécification du module Foret\n-- ",
"end": 147,
"score": 0.9998800158500671,
"start": 138,
"tag": "NAME",
"value": "CAZES Noa"
}
] | 1A/S5/PIM/projet/src/foret.ads | MOUDDENEHamza/ENSEEIHT | 4 | --------------------------------------------------------------------------------
-- Fichier : foret.ads
-- Auteur : MOUDDENE Hamza & CAZES Noa
-- Objectif : Spécification du module Foret
-- Crée : Jeudi Déc 12 2019
--------------------------------------------------------------------------------
with Ensemble;
with Arbre_Genealogique; use Arbre_Genealogique;
package Foret is
-- Type du package Foret qui est privé.
type Forest is private;
ABSENT_TREE_EXCEPTION : Exception; -- Arbre inexistant.
----------------------------------Constuctor--------------------------------
-- Nom : Initialize_Forest
-- Sémantique : Initialiser Forest. Forest est vide.
-- Paramètres :
-- F -- Forest que l'on va initialiser.
procedure Initialize_Forest (F : out Forest);
-- Nom : Add_To_Forest
-- Sémantique : Ajouter un Arbre dans la Forest.
-- Paramètres :
-- F -- Forest que l'on va initialiser.
-- Ab -- L'arbre qu'on va ajouter
procedure Add_To_Forest (F : in out Forest; Ab : in T_ABG);
----------------------------------------------------------------------------
-- Nom : Is_Empty_Forest
-- Sémantique : Vérifier si une foret donnée est vide.
-- Type_De_Retour : Boolean True si la foret est vide, sinon False.
-- Paramètre :
-- F : La foret qu'on va parcourir.
function Is_Empty_Forest (F : in Forest) return Boolean;
-- Nom : Is_Present_Forest
-- Sémantique : Vérifier si un arbre est dans la foret.
-- Type_De_Retour : Boolean True si un arbre est dans la foret, sinon False.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- ID : identifiant unique d'un individu dans la foret.
function Is_Present_Forest (F : in Forest; ID : Integer) return Boolean;
-- Nom : Find_Tree
-- Sémantique : Trouver un ID dans la foret.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- ID : L'ID d'une racine d'arbre dans la foret.
procedure Find_Tree (F : in Forest; Ab : out T_ABG; ID : in Integer);
-- Nom : Update_Forest
-- Sémantique : Mettre à jour la foret.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- Old_Ab : L'arbre avant la modification.
-- New_Ab : L'arbre après la modification.
procedure Update_Forest (F : in Forest; Old_Ab, New_Ab : in T_ABG);
-- Nom : Remove_Tree
-- Sémantique : Supprimer un arbre de la foret.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- Old_Ab : L'arbre avant la modification.
-- New_Ab : L'arbre après la modification.
procedure Remove_Tree (F : in out Forest; Ab : in T_ABG);
-- Nom : Get_Set_Cohabitant
-- Sémantique : Ajouter un concubain à un individu donné.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- Ab : L'arbre d'un individu dans la foret.
procedure Get_Set_Cohabitant (F : in out Forest; ID, Child_ID : in Integer);
-- Nom : Get_Set_Half_Brother
-- Sémantique : Obtenir l'ensemble des demis frères et demie-soeur d'un individu donné.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- ID : identifiant unique d'un individu dans la foret.
procedure Get_Set_Half_Brother (F : in Forest; ID, Father_ID, Mother_ID : in Integer);
-- Nom : Destruct_Forest
-- Sémantique : Détruire Forest. Forest est vide.
-- Paramètres :
-- F -- Forest que l'on va détruire.
procedure Destruct_Forest (F : in out Forest);
private
-- Instancier Ensemble avec T_Element comme T_ABG.
package Ens is
New Ensemble (T_Element => T_ABG);
use Ens;
-- Déclaration du type forest comme une liste chainée.
type Forest is new T_Ensemble;
end Foret;
| 21883 | --------------------------------------------------------------------------------
-- Fichier : foret.ads
-- Auteur : <NAME> & <NAME>
-- Objectif : Spécification du module Foret
-- Crée : Jeudi Déc 12 2019
--------------------------------------------------------------------------------
with Ensemble;
with Arbre_Genealogique; use Arbre_Genealogique;
package Foret is
-- Type du package Foret qui est privé.
type Forest is private;
ABSENT_TREE_EXCEPTION : Exception; -- Arbre inexistant.
----------------------------------Constuctor--------------------------------
-- Nom : Initialize_Forest
-- Sémantique : Initialiser Forest. Forest est vide.
-- Paramètres :
-- F -- Forest que l'on va initialiser.
procedure Initialize_Forest (F : out Forest);
-- Nom : Add_To_Forest
-- Sémantique : Ajouter un Arbre dans la Forest.
-- Paramètres :
-- F -- Forest que l'on va initialiser.
-- Ab -- L'arbre qu'on va ajouter
procedure Add_To_Forest (F : in out Forest; Ab : in T_ABG);
----------------------------------------------------------------------------
-- Nom : Is_Empty_Forest
-- Sémantique : Vérifier si une foret donnée est vide.
-- Type_De_Retour : Boolean True si la foret est vide, sinon False.
-- Paramètre :
-- F : La foret qu'on va parcourir.
function Is_Empty_Forest (F : in Forest) return Boolean;
-- Nom : Is_Present_Forest
-- Sémantique : Vérifier si un arbre est dans la foret.
-- Type_De_Retour : Boolean True si un arbre est dans la foret, sinon False.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- ID : identifiant unique d'un individu dans la foret.
function Is_Present_Forest (F : in Forest; ID : Integer) return Boolean;
-- Nom : Find_Tree
-- Sémantique : Trouver un ID dans la foret.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- ID : L'ID d'une racine d'arbre dans la foret.
procedure Find_Tree (F : in Forest; Ab : out T_ABG; ID : in Integer);
-- Nom : Update_Forest
-- Sémantique : Mettre à jour la foret.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- Old_Ab : L'arbre avant la modification.
-- New_Ab : L'arbre après la modification.
procedure Update_Forest (F : in Forest; Old_Ab, New_Ab : in T_ABG);
-- Nom : Remove_Tree
-- Sémantique : Supprimer un arbre de la foret.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- Old_Ab : L'arbre avant la modification.
-- New_Ab : L'arbre après la modification.
procedure Remove_Tree (F : in out Forest; Ab : in T_ABG);
-- Nom : Get_Set_Cohabitant
-- Sémantique : Ajouter un concubain à un individu donné.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- Ab : L'arbre d'un individu dans la foret.
procedure Get_Set_Cohabitant (F : in out Forest; ID, Child_ID : in Integer);
-- Nom : Get_Set_Half_Brother
-- Sémantique : Obtenir l'ensemble des demis frères et demie-soeur d'un individu donné.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- ID : identifiant unique d'un individu dans la foret.
procedure Get_Set_Half_Brother (F : in Forest; ID, Father_ID, Mother_ID : in Integer);
-- Nom : Destruct_Forest
-- Sémantique : Détruire Forest. Forest est vide.
-- Paramètres :
-- F -- Forest que l'on va détruire.
procedure Destruct_Forest (F : in out Forest);
private
-- Instancier Ensemble avec T_Element comme T_ABG.
package Ens is
New Ensemble (T_Element => T_ABG);
use Ens;
-- Déclaration du type forest comme une liste chainée.
type Forest is new T_Ensemble;
end Foret;
| true | --------------------------------------------------------------------------------
-- Fichier : foret.ads
-- Auteur : PI:NAME:<NAME>END_PI & PI:NAME:<NAME>END_PI
-- Objectif : Spécification du module Foret
-- Crée : Jeudi Déc 12 2019
--------------------------------------------------------------------------------
with Ensemble;
with Arbre_Genealogique; use Arbre_Genealogique;
package Foret is
-- Type du package Foret qui est privé.
type Forest is private;
ABSENT_TREE_EXCEPTION : Exception; -- Arbre inexistant.
----------------------------------Constuctor--------------------------------
-- Nom : Initialize_Forest
-- Sémantique : Initialiser Forest. Forest est vide.
-- Paramètres :
-- F -- Forest que l'on va initialiser.
procedure Initialize_Forest (F : out Forest);
-- Nom : Add_To_Forest
-- Sémantique : Ajouter un Arbre dans la Forest.
-- Paramètres :
-- F -- Forest que l'on va initialiser.
-- Ab -- L'arbre qu'on va ajouter
procedure Add_To_Forest (F : in out Forest; Ab : in T_ABG);
----------------------------------------------------------------------------
-- Nom : Is_Empty_Forest
-- Sémantique : Vérifier si une foret donnée est vide.
-- Type_De_Retour : Boolean True si la foret est vide, sinon False.
-- Paramètre :
-- F : La foret qu'on va parcourir.
function Is_Empty_Forest (F : in Forest) return Boolean;
-- Nom : Is_Present_Forest
-- Sémantique : Vérifier si un arbre est dans la foret.
-- Type_De_Retour : Boolean True si un arbre est dans la foret, sinon False.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- ID : identifiant unique d'un individu dans la foret.
function Is_Present_Forest (F : in Forest; ID : Integer) return Boolean;
-- Nom : Find_Tree
-- Sémantique : Trouver un ID dans la foret.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- ID : L'ID d'une racine d'arbre dans la foret.
procedure Find_Tree (F : in Forest; Ab : out T_ABG; ID : in Integer);
-- Nom : Update_Forest
-- Sémantique : Mettre à jour la foret.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- Old_Ab : L'arbre avant la modification.
-- New_Ab : L'arbre après la modification.
procedure Update_Forest (F : in Forest; Old_Ab, New_Ab : in T_ABG);
-- Nom : Remove_Tree
-- Sémantique : Supprimer un arbre de la foret.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- Old_Ab : L'arbre avant la modification.
-- New_Ab : L'arbre après la modification.
procedure Remove_Tree (F : in out Forest; Ab : in T_ABG);
-- Nom : Get_Set_Cohabitant
-- Sémantique : Ajouter un concubain à un individu donné.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- Ab : L'arbre d'un individu dans la foret.
procedure Get_Set_Cohabitant (F : in out Forest; ID, Child_ID : in Integer);
-- Nom : Get_Set_Half_Brother
-- Sémantique : Obtenir l'ensemble des demis frères et demie-soeur d'un individu donné.
-- Paramètre :
-- F : La foret qu'on va parcourir.
-- ID : identifiant unique d'un individu dans la foret.
procedure Get_Set_Half_Brother (F : in Forest; ID, Father_ID, Mother_ID : in Integer);
-- Nom : Destruct_Forest
-- Sémantique : Détruire Forest. Forest est vide.
-- Paramètres :
-- F -- Forest que l'on va détruire.
procedure Destruct_Forest (F : in out Forest);
private
-- Instancier Ensemble avec T_Element comme T_ABG.
package Ens is
New Ensemble (T_Element => T_ABG);
use Ens;
-- Déclaration du type forest comme une liste chainée.
type Forest is new T_Ensemble;
end Foret;
|
[
{
"context": "es:\n--\t\t\t- \n\t\n--\tNotes:\n--\t\t\t-\n\t\t\t \n--\t2019/04/10, Maya Posch\n\n\n\nwith Ada.Command_Line;\nwith Ada.Text_IO;\nuse A",
"end": 175,
"score": 0.9998721480369568,
"start": 165,
"tag": "NAME",
"value": "Maya Posch"
}
] | ada/src/sarge.adb | martinmoene/Sarge | 69 | -- sarge.adb - Implementation file for the Sarge command line argument parser project.
-- Revision 0
-- Features:
-- -
-- Notes:
-- -
-- 2019/04/10, Maya Posch
with Ada.Command_Line;
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Strings.Unbounded.Text_IO;
use Ada.Strings.Unbounded.Text_IO;
package body Sarge is
--- SET ARGUMENT ---
procedure setArgument(arg_short: in Unbounded_String; arg_long: in Unbounded_String; desc: in Unbounded_String; hasVal: in boolean) is
arg: aliased Argument := (arg_short => arg_short, arg_long => arg_long, description => desc, hasValue => hasVal, value => +"", parsed => False);
begin
args.append(arg);
-- Set up links.
if length(arg_short) > 0 then
argNames.include(arg_short, args.Last_Index);
end if;
if length(arg_long) > 0 then
argNames.include(arg_long, args.Last_Index);
end if;
end setArgument;
--- SET DESCRIPTION ---
procedure setDescription(desc: in Unbounded_String) is
begin
description := desc;
end setDescription;
--- SET USAGE ---
procedure setUsage(usage: in Unbounded_String) is
begin
usageStr := usage;
end setUsage;
--- PARSE ARGUMENTS ---
function parseArguments return boolean is
flag_it: argNames_map.Cursor;
expectValue: boolean := False;
arg: Unbounded_String;
short_arg: Unbounded_String;
begin
--
execName := +Ada.Command_Line.command_name;
for arg_i in 1..Ada.Command_Line.argument_count loop
arg := +Ada.Command_Line.Argument(arg_i);
-- Each flag will start with a '-' character. Multiple flags can be joined together in
-- the same string if they're the short form flag type (one character per flag).
if expectValue = True then
-- Copy value.
args.Reference(argNames_map.Element(flag_it)).value := arg;
expectValue := False;
elsif Ada.Strings.Unbounded.Slice(arg, 1, 1) = "-" then
-- Parse flag.
-- First check for the long form.
if Ada.Strings.Unbounded.Slice(arg, 1, 2) = "--" then
-- Long form of the flag.
-- First delete the preceding dashes.
arg := Ada.Strings.Unbounded.Delete(arg, 1, 2);
if not argNames.contains(arg) then
-- Flag wasn't found. Abort.
Ada.Strings.Unbounded.Text_IO.put_line("Long flag " & arg & " wasn't found");
return False;
end if;
-- Mark as found.
flag_it := argNames.find(arg);
args(argNames_map.Element(flag_it)).parsed := True;
flagCounter := flagCounter + 1;
if args(argNames_map.Element(flag_it)).hasValue = True then
expectValue := True;
end if;
else
-- Parse short form flag. Parse all of them sequentially. Only the last one
-- is allowed to have an additional value following it.
-- First delete the preceding dash.
arg := Ada.Strings.Unbounded.Delete(arg, 1, 1);
for i in 1 .. Ada.Strings.Unbounded.Length(arg) loop
Ada.Strings.Unbounded.Append(short_arg, Ada.Strings.Unbounded.Element(arg, i));
if argNames_map.Contains(argNames, short_arg) /= True then
-- Flag wasn't found. Abort.
put_line("Short flag " & short_arg & " wasn't found.");
return False;
end if;
flag_it := argNames.find(short_arg);
-- Mark as found.
args(argNames_map.Element(flag_it)).parsed := True;
flagCounter := flagCounter + 1;
if args(argNames_map.Element(flag_it)).hasValue = True then
if i /= (Ada.Strings.Unbounded.Length(arg)) then
-- Flag isn't at end, thus cannot have value.
put_line("Flag " & short_arg & " needs to be followed by a value string.");
return False;
else
expectValue := True;
end if;
end if;
Ada.Strings.Unbounded.Delete(short_arg, 1, 1);
end loop;
end if;
else
-- Add to text argument vector.
textArguments.append(arg);
end if;
end loop;
parsed := True;
return True;
end parseArguments;
--- GET FLAG ---
function getFlag(arg_flag: in Unbounded_String; arg_value: out Unbounded_String) return boolean is
flag_it: argNames_map.Cursor;
use argNames_map;
begin
if parsed /= True then
return False;
end if;
flag_it := argNames.find(arg_flag);
if flag_it = argNames_map.No_Element then
return False;
elsif args(argNames_map.Element(flag_it)).parsed /= True then
return False;
end if;
if args(argNames_map.Element(flag_it)).hasValue = True then
arg_value := args(argNames_map.Element(flag_it)).value;
end if;
return True;
end getFlag;
--- EXISTS ---
function exists(arg_flag: in Unbounded_String) return boolean is
flag_it: argNames_map.Cursor;
use argNames_map;
begin
if parsed /= True then
return False;
end if;
flag_it := argNames.find(arg_flag);
if flag_it = argNames_map.No_Element then
return False;
elsif args(argNames_map.Element(flag_it)).parsed /= True then
return False;
end if;
return True;
end exists;
--- GET TEXT ARGUMENT ---
function getTextArgument(index: in Integer; value: out Unbounded_String) return boolean is
begin
if index < Integer(tArgVector.length(textArguments)) then
value := textArguments(index);
return True;
end if;
return False;
end getTextArgument;
--- PRINT HELP ---
procedure printHelp is
count: Integer := 1;
spaceCnt: Integer;
begin
put_line("");
put_line(description);
put_line("Usage:");
put_line(usageStr);
put_line("");
put_line("Options:");
-- Determine whitespace needed between arg_long and description.
for flag in args.Iterate loop
if Integer(Ada.Strings.Unbounded.length(args(flag).arg_long)) > count then
count := Integer(Ada.Strings.Unbounded.length(args(flag).arg_long));
end if;
end loop;
count := count + 3; -- Number of actual spaces between the longest arg_long and description.
-- Print out the options.
for opt in args.Iterate loop
--spaceStr := Unbound_String(count - Ada.Strings.Unbounded.length(args(opt).arg_long)
spaceCnt := (count - Integer(Ada.Strings.Unbounded.length(args(opt).arg_long)));
if Ada.Strings.Unbounded.length(args(opt).arg_short) < 1 then
Ada.Strings.Unbounded.Text_IO.put_line(" " & args(opt).arg_short
& "--" & args(opt).arg_long
& spaceCnt * " " & args(opt).description);
else
Ada.Strings.Unbounded.Text_IO.put_line("-" & args(opt).arg_short
& ", --" & args(opt).arg_long
& spaceCnt * " " & args(opt).description);
end if;
end loop;
end printHelp;
--- FLAG COUNT ---
function flagCount return integer is
begin
return flagCounter;
end flagCount;
--- EXECUTABLE NAME ---
function executableName return Unbounded_String is
begin
return execName;
end executableName;
end Sarge;
| 19012 | -- sarge.adb - Implementation file for the Sarge command line argument parser project.
-- Revision 0
-- Features:
-- -
-- Notes:
-- -
-- 2019/04/10, <NAME>
with Ada.Command_Line;
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Strings.Unbounded.Text_IO;
use Ada.Strings.Unbounded.Text_IO;
package body Sarge is
--- SET ARGUMENT ---
procedure setArgument(arg_short: in Unbounded_String; arg_long: in Unbounded_String; desc: in Unbounded_String; hasVal: in boolean) is
arg: aliased Argument := (arg_short => arg_short, arg_long => arg_long, description => desc, hasValue => hasVal, value => +"", parsed => False);
begin
args.append(arg);
-- Set up links.
if length(arg_short) > 0 then
argNames.include(arg_short, args.Last_Index);
end if;
if length(arg_long) > 0 then
argNames.include(arg_long, args.Last_Index);
end if;
end setArgument;
--- SET DESCRIPTION ---
procedure setDescription(desc: in Unbounded_String) is
begin
description := desc;
end setDescription;
--- SET USAGE ---
procedure setUsage(usage: in Unbounded_String) is
begin
usageStr := usage;
end setUsage;
--- PARSE ARGUMENTS ---
function parseArguments return boolean is
flag_it: argNames_map.Cursor;
expectValue: boolean := False;
arg: Unbounded_String;
short_arg: Unbounded_String;
begin
--
execName := +Ada.Command_Line.command_name;
for arg_i in 1..Ada.Command_Line.argument_count loop
arg := +Ada.Command_Line.Argument(arg_i);
-- Each flag will start with a '-' character. Multiple flags can be joined together in
-- the same string if they're the short form flag type (one character per flag).
if expectValue = True then
-- Copy value.
args.Reference(argNames_map.Element(flag_it)).value := arg;
expectValue := False;
elsif Ada.Strings.Unbounded.Slice(arg, 1, 1) = "-" then
-- Parse flag.
-- First check for the long form.
if Ada.Strings.Unbounded.Slice(arg, 1, 2) = "--" then
-- Long form of the flag.
-- First delete the preceding dashes.
arg := Ada.Strings.Unbounded.Delete(arg, 1, 2);
if not argNames.contains(arg) then
-- Flag wasn't found. Abort.
Ada.Strings.Unbounded.Text_IO.put_line("Long flag " & arg & " wasn't found");
return False;
end if;
-- Mark as found.
flag_it := argNames.find(arg);
args(argNames_map.Element(flag_it)).parsed := True;
flagCounter := flagCounter + 1;
if args(argNames_map.Element(flag_it)).hasValue = True then
expectValue := True;
end if;
else
-- Parse short form flag. Parse all of them sequentially. Only the last one
-- is allowed to have an additional value following it.
-- First delete the preceding dash.
arg := Ada.Strings.Unbounded.Delete(arg, 1, 1);
for i in 1 .. Ada.Strings.Unbounded.Length(arg) loop
Ada.Strings.Unbounded.Append(short_arg, Ada.Strings.Unbounded.Element(arg, i));
if argNames_map.Contains(argNames, short_arg) /= True then
-- Flag wasn't found. Abort.
put_line("Short flag " & short_arg & " wasn't found.");
return False;
end if;
flag_it := argNames.find(short_arg);
-- Mark as found.
args(argNames_map.Element(flag_it)).parsed := True;
flagCounter := flagCounter + 1;
if args(argNames_map.Element(flag_it)).hasValue = True then
if i /= (Ada.Strings.Unbounded.Length(arg)) then
-- Flag isn't at end, thus cannot have value.
put_line("Flag " & short_arg & " needs to be followed by a value string.");
return False;
else
expectValue := True;
end if;
end if;
Ada.Strings.Unbounded.Delete(short_arg, 1, 1);
end loop;
end if;
else
-- Add to text argument vector.
textArguments.append(arg);
end if;
end loop;
parsed := True;
return True;
end parseArguments;
--- GET FLAG ---
function getFlag(arg_flag: in Unbounded_String; arg_value: out Unbounded_String) return boolean is
flag_it: argNames_map.Cursor;
use argNames_map;
begin
if parsed /= True then
return False;
end if;
flag_it := argNames.find(arg_flag);
if flag_it = argNames_map.No_Element then
return False;
elsif args(argNames_map.Element(flag_it)).parsed /= True then
return False;
end if;
if args(argNames_map.Element(flag_it)).hasValue = True then
arg_value := args(argNames_map.Element(flag_it)).value;
end if;
return True;
end getFlag;
--- EXISTS ---
function exists(arg_flag: in Unbounded_String) return boolean is
flag_it: argNames_map.Cursor;
use argNames_map;
begin
if parsed /= True then
return False;
end if;
flag_it := argNames.find(arg_flag);
if flag_it = argNames_map.No_Element then
return False;
elsif args(argNames_map.Element(flag_it)).parsed /= True then
return False;
end if;
return True;
end exists;
--- GET TEXT ARGUMENT ---
function getTextArgument(index: in Integer; value: out Unbounded_String) return boolean is
begin
if index < Integer(tArgVector.length(textArguments)) then
value := textArguments(index);
return True;
end if;
return False;
end getTextArgument;
--- PRINT HELP ---
procedure printHelp is
count: Integer := 1;
spaceCnt: Integer;
begin
put_line("");
put_line(description);
put_line("Usage:");
put_line(usageStr);
put_line("");
put_line("Options:");
-- Determine whitespace needed between arg_long and description.
for flag in args.Iterate loop
if Integer(Ada.Strings.Unbounded.length(args(flag).arg_long)) > count then
count := Integer(Ada.Strings.Unbounded.length(args(flag).arg_long));
end if;
end loop;
count := count + 3; -- Number of actual spaces between the longest arg_long and description.
-- Print out the options.
for opt in args.Iterate loop
--spaceStr := Unbound_String(count - Ada.Strings.Unbounded.length(args(opt).arg_long)
spaceCnt := (count - Integer(Ada.Strings.Unbounded.length(args(opt).arg_long)));
if Ada.Strings.Unbounded.length(args(opt).arg_short) < 1 then
Ada.Strings.Unbounded.Text_IO.put_line(" " & args(opt).arg_short
& "--" & args(opt).arg_long
& spaceCnt * " " & args(opt).description);
else
Ada.Strings.Unbounded.Text_IO.put_line("-" & args(opt).arg_short
& ", --" & args(opt).arg_long
& spaceCnt * " " & args(opt).description);
end if;
end loop;
end printHelp;
--- FLAG COUNT ---
function flagCount return integer is
begin
return flagCounter;
end flagCount;
--- EXECUTABLE NAME ---
function executableName return Unbounded_String is
begin
return execName;
end executableName;
end Sarge;
| true | -- sarge.adb - Implementation file for the Sarge command line argument parser project.
-- Revision 0
-- Features:
-- -
-- Notes:
-- -
-- 2019/04/10, PI:NAME:<NAME>END_PI
with Ada.Command_Line;
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Strings.Unbounded.Text_IO;
use Ada.Strings.Unbounded.Text_IO;
package body Sarge is
--- SET ARGUMENT ---
procedure setArgument(arg_short: in Unbounded_String; arg_long: in Unbounded_String; desc: in Unbounded_String; hasVal: in boolean) is
arg: aliased Argument := (arg_short => arg_short, arg_long => arg_long, description => desc, hasValue => hasVal, value => +"", parsed => False);
begin
args.append(arg);
-- Set up links.
if length(arg_short) > 0 then
argNames.include(arg_short, args.Last_Index);
end if;
if length(arg_long) > 0 then
argNames.include(arg_long, args.Last_Index);
end if;
end setArgument;
--- SET DESCRIPTION ---
procedure setDescription(desc: in Unbounded_String) is
begin
description := desc;
end setDescription;
--- SET USAGE ---
procedure setUsage(usage: in Unbounded_String) is
begin
usageStr := usage;
end setUsage;
--- PARSE ARGUMENTS ---
function parseArguments return boolean is
flag_it: argNames_map.Cursor;
expectValue: boolean := False;
arg: Unbounded_String;
short_arg: Unbounded_String;
begin
--
execName := +Ada.Command_Line.command_name;
for arg_i in 1..Ada.Command_Line.argument_count loop
arg := +Ada.Command_Line.Argument(arg_i);
-- Each flag will start with a '-' character. Multiple flags can be joined together in
-- the same string if they're the short form flag type (one character per flag).
if expectValue = True then
-- Copy value.
args.Reference(argNames_map.Element(flag_it)).value := arg;
expectValue := False;
elsif Ada.Strings.Unbounded.Slice(arg, 1, 1) = "-" then
-- Parse flag.
-- First check for the long form.
if Ada.Strings.Unbounded.Slice(arg, 1, 2) = "--" then
-- Long form of the flag.
-- First delete the preceding dashes.
arg := Ada.Strings.Unbounded.Delete(arg, 1, 2);
if not argNames.contains(arg) then
-- Flag wasn't found. Abort.
Ada.Strings.Unbounded.Text_IO.put_line("Long flag " & arg & " wasn't found");
return False;
end if;
-- Mark as found.
flag_it := argNames.find(arg);
args(argNames_map.Element(flag_it)).parsed := True;
flagCounter := flagCounter + 1;
if args(argNames_map.Element(flag_it)).hasValue = True then
expectValue := True;
end if;
else
-- Parse short form flag. Parse all of them sequentially. Only the last one
-- is allowed to have an additional value following it.
-- First delete the preceding dash.
arg := Ada.Strings.Unbounded.Delete(arg, 1, 1);
for i in 1 .. Ada.Strings.Unbounded.Length(arg) loop
Ada.Strings.Unbounded.Append(short_arg, Ada.Strings.Unbounded.Element(arg, i));
if argNames_map.Contains(argNames, short_arg) /= True then
-- Flag wasn't found. Abort.
put_line("Short flag " & short_arg & " wasn't found.");
return False;
end if;
flag_it := argNames.find(short_arg);
-- Mark as found.
args(argNames_map.Element(flag_it)).parsed := True;
flagCounter := flagCounter + 1;
if args(argNames_map.Element(flag_it)).hasValue = True then
if i /= (Ada.Strings.Unbounded.Length(arg)) then
-- Flag isn't at end, thus cannot have value.
put_line("Flag " & short_arg & " needs to be followed by a value string.");
return False;
else
expectValue := True;
end if;
end if;
Ada.Strings.Unbounded.Delete(short_arg, 1, 1);
end loop;
end if;
else
-- Add to text argument vector.
textArguments.append(arg);
end if;
end loop;
parsed := True;
return True;
end parseArguments;
--- GET FLAG ---
function getFlag(arg_flag: in Unbounded_String; arg_value: out Unbounded_String) return boolean is
flag_it: argNames_map.Cursor;
use argNames_map;
begin
if parsed /= True then
return False;
end if;
flag_it := argNames.find(arg_flag);
if flag_it = argNames_map.No_Element then
return False;
elsif args(argNames_map.Element(flag_it)).parsed /= True then
return False;
end if;
if args(argNames_map.Element(flag_it)).hasValue = True then
arg_value := args(argNames_map.Element(flag_it)).value;
end if;
return True;
end getFlag;
--- EXISTS ---
function exists(arg_flag: in Unbounded_String) return boolean is
flag_it: argNames_map.Cursor;
use argNames_map;
begin
if parsed /= True then
return False;
end if;
flag_it := argNames.find(arg_flag);
if flag_it = argNames_map.No_Element then
return False;
elsif args(argNames_map.Element(flag_it)).parsed /= True then
return False;
end if;
return True;
end exists;
--- GET TEXT ARGUMENT ---
function getTextArgument(index: in Integer; value: out Unbounded_String) return boolean is
begin
if index < Integer(tArgVector.length(textArguments)) then
value := textArguments(index);
return True;
end if;
return False;
end getTextArgument;
--- PRINT HELP ---
procedure printHelp is
count: Integer := 1;
spaceCnt: Integer;
begin
put_line("");
put_line(description);
put_line("Usage:");
put_line(usageStr);
put_line("");
put_line("Options:");
-- Determine whitespace needed between arg_long and description.
for flag in args.Iterate loop
if Integer(Ada.Strings.Unbounded.length(args(flag).arg_long)) > count then
count := Integer(Ada.Strings.Unbounded.length(args(flag).arg_long));
end if;
end loop;
count := count + 3; -- Number of actual spaces between the longest arg_long and description.
-- Print out the options.
for opt in args.Iterate loop
--spaceStr := Unbound_String(count - Ada.Strings.Unbounded.length(args(opt).arg_long)
spaceCnt := (count - Integer(Ada.Strings.Unbounded.length(args(opt).arg_long)));
if Ada.Strings.Unbounded.length(args(opt).arg_short) < 1 then
Ada.Strings.Unbounded.Text_IO.put_line(" " & args(opt).arg_short
& "--" & args(opt).arg_long
& spaceCnt * " " & args(opt).description);
else
Ada.Strings.Unbounded.Text_IO.put_line("-" & args(opt).arg_short
& ", --" & args(opt).arg_long
& spaceCnt * " " & args(opt).description);
end if;
end loop;
end printHelp;
--- FLAG COUNT ---
function flagCount return integer is
begin
return flagCounter;
end flagCount;
--- EXECUTABLE NAME ---
function executableName return Unbounded_String is
begin
return execName;
end executableName;
end Sarge;
|
[
{
"context": "ad))\n -- GStreamer\n -- * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>\n -- * 200",
"end": 9117,
"score": 0.9998767971992493,
"start": 9102,
"tag": "NAME",
"value": "Erik Walthinsen"
},
{
"context": "r\n -- * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>\n -- * 2000 Wim Taymans <wim.",
"end": 9136,
"score": 0.9999340772628784,
"start": 9119,
"tag": "EMAIL",
"value": "omega@cse.ogi.edu"
},
{
"context": "<omega@cse.ogi.edu>\n -- * 2000 Wim Taymans <wim.taymans@chello.be>\n -- *\n -- * gstpad.h: H",
"end": 9180,
"score": 0.9998705387115479,
"start": 9169,
"tag": "NAME",
"value": "Wim Taymans"
},
{
"context": ".edu>\n -- * 2000 Wim Taymans <wim.taymans@chello.be>\n -- *\n -- * gstpad.h: Header for GstPad object",
"end": 9203,
"score": 0.9999361038208008,
"start": 9182,
"tag": "EMAIL",
"value": "wim.taymans@chello.be"
}
] | src/gen/gstreamer-gst_low_level-gstreamer_0_10_gst_gstpad_h.ads | persan/A-gst | 1 | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
with glib.Values;
with System;
with System;
-- with GStreamer.GST_Low_Level.glib_2_0_glib_gquark_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_glist_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h;
-- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_deprecated_gthread_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttask_h;
-- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstminiobject_h;
with glib;
-- with GStreamer.GST_Low_Level.libxml2_libxml_tree_h;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h is
-- unsupported macro: GST_TYPE_PAD (gst_pad_get_type ())
-- arg-macro: function GST_IS_PAD (obj)
-- return G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD);
-- arg-macro: function GST_IS_PAD_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD);
-- arg-macro: function GST_PAD (obj)
-- return G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD, GstPad);
-- arg-macro: function GST_PAD_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD, GstPadClass);
-- arg-macro: function GST_PAD_CAST (obj)
-- return (GstPad*)(obj);
-- arg-macro: function GST_PAD_LINK_FAILED (ret)
-- return (ret) < GST_PAD_LINK_OK;
-- arg-macro: function GST_PAD_LINK_SUCCESSFUL (ret)
-- return (ret) >= GST_PAD_LINK_OK;
-- arg-macro: function GST_FLOW_IS_FATAL (ret)
-- return (ret) <= GST_FLOW_UNEXPECTED;
-- arg-macro: function GST_FLOW_IS_SUCCESS (ret)
-- return (ret) >= GST_FLOW_OK;
-- unsupported macro: GST_PAD_LINK_CHECK_DEFAULT ((GstPadLinkCheck) (GST_PAD_LINK_CHECK_HIERARCHY | GST_PAD_LINK_CHECK_CAPS))
-- arg-macro: function GST_PAD_MODE_ACTIVATE (mode)
-- return (mode) /= GST_ACTIVATE_NONE;
-- arg-macro: function GST_PAD_NAME (pad)
-- return GST_OBJECT_NAME(pad);
-- arg-macro: function GST_PAD_PARENT (pad)
-- return GST_ELEMENT_CAST(GST_OBJECT_PARENT(pad));
-- arg-macro: function GST_PAD_ELEMENT_PRIVATE (pad)
-- return GST_PAD_CAST(pad).element_private;
-- arg-macro: function GST_PAD_PAD_TEMPLATE (pad)
-- return GST_PAD_CAST(pad).padtemplate;
-- arg-macro: function GST_PAD_DIRECTION (pad)
-- return GST_PAD_CAST(pad).direction;
-- arg-macro: function GST_PAD_TASK (pad)
-- return GST_PAD_CAST(pad).task;
-- arg-macro: function GST_PAD_ACTIVATE_MODE (pad)
-- return GST_PAD_CAST(pad).mode;
-- arg-macro: function GST_PAD_ACTIVATEFUNC (pad)
-- return GST_PAD_CAST(pad).activatefunc;
-- arg-macro: function GST_PAD_ACTIVATEPUSHFUNC (pad)
-- return GST_PAD_CAST(pad).activatepushfunc;
-- arg-macro: function GST_PAD_ACTIVATEPULLFUNC (pad)
-- return GST_PAD_CAST(pad).activatepullfunc;
-- arg-macro: function GST_PAD_CHAINFUNC (pad)
-- return GST_PAD_CAST(pad).chainfunc;
-- arg-macro: function GST_PAD_CHECKGETRANGEFUNC (pad)
-- return GST_PAD_CAST(pad).checkgetrangefunc;
-- arg-macro: function GST_PAD_GETRANGEFUNC (pad)
-- return GST_PAD_CAST(pad).getrangefunc;
-- arg-macro: function GST_PAD_EVENTFUNC (pad)
-- return GST_PAD_CAST(pad).eventfunc;
-- arg-macro: function GST_PAD_QUERYTYPEFUNC (pad)
-- return GST_PAD_CAST(pad).querytypefunc;
-- arg-macro: function GST_PAD_QUERYFUNC (pad)
-- return GST_PAD_CAST(pad).queryfunc;
-- arg-macro: function GST_PAD_INTLINKFUNC (pad)
-- return GST_PAD_CAST(pad).intlinkfunc;
-- arg-macro: function GST_PAD_ITERINTLINKFUNC (pad)
-- return GST_PAD_CAST(pad).iterintlinkfunc;
-- arg-macro: function GST_PAD_PEER (pad)
-- return GST_PAD_CAST(pad).peer;
-- arg-macro: function GST_PAD_LINKFUNC (pad)
-- return GST_PAD_CAST(pad).linkfunc;
-- arg-macro: function GST_PAD_UNLINKFUNC (pad)
-- return GST_PAD_CAST(pad).unlinkfunc;
-- arg-macro: function GST_PAD_CAPS (pad)
-- return GST_PAD_CAST(pad).caps;
-- arg-macro: function GST_PAD_GETCAPSFUNC (pad)
-- return GST_PAD_CAST(pad).getcapsfunc;
-- arg-macro: function GST_PAD_SETCAPSFUNC (pad)
-- return GST_PAD_CAST(pad).setcapsfunc;
-- arg-macro: function GST_PAD_ACCEPTCAPSFUNC (pad)
-- return GST_PAD_CAST(pad).acceptcapsfunc;
-- arg-macro: function GST_PAD_FIXATECAPSFUNC (pad)
-- return GST_PAD_CAST(pad).fixatecapsfunc;
-- arg-macro: function GST_PAD_BUFFERALLOCFUNC (pad)
-- return GST_PAD_CAST(pad).bufferallocfunc;
-- arg-macro: function GST_PAD_DO_BUFFER_SIGNALS (pad)
-- return GST_PAD_CAST(pad).do_buffer_signals;
-- arg-macro: function GST_PAD_DO_EVENT_SIGNALS (pad)
-- return GST_PAD_CAST(pad).do_event_signals;
-- arg-macro: function GST_PAD_IS_LINKED (pad)
-- return GST_PAD_PEER(pad) /= NULL;
-- arg-macro: function GST_PAD_IS_BLOCKED (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKED);
-- arg-macro: function GST_PAD_IS_BLOCKING (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKING);
-- arg-macro: function GST_PAD_IS_FLUSHING (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLUSHING);
-- arg-macro: function GST_PAD_IS_IN_GETCAPS (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_GETCAPS);
-- arg-macro: function GST_PAD_IS_IN_SETCAPS (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_SETCAPS);
-- arg-macro: function GST_PAD_IS_SRC (pad)
-- return GST_PAD_DIRECTION(pad) = GST_PAD_SRC;
-- arg-macro: function GST_PAD_IS_SINK (pad)
-- return GST_PAD_DIRECTION(pad) = GST_PAD_SINK;
-- arg-macro: function GST_PAD_SET_FLUSHING (pad)
-- return GST_OBJECT_FLAG_SET (pad, GST_PAD_FLUSHING);
-- arg-macro: function GST_PAD_UNSET_FLUSHING (pad)
-- return GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLUSHING);
-- arg-macro: function GST_PAD_GET_STREAM_LOCK (pad)
-- return GST_PAD_CAST(pad).stream_rec_lock;
-- arg-macro: function GST_PAD_STREAM_LOCK (pad)
-- return g_static_rec_mutex_lock(GST_PAD_GET_STREAM_LOCK(pad));
-- arg-macro: function GST_PAD_STREAM_LOCK_FULL (pad, t)
-- return g_static_rec_mutex_lock_full(GST_PAD_GET_STREAM_LOCK(pad), t);
-- arg-macro: function GST_PAD_STREAM_TRYLOCK (pad)
-- return g_static_rec_mutex_trylock(GST_PAD_GET_STREAM_LOCK(pad));
-- arg-macro: function GST_PAD_STREAM_UNLOCK (pad)
-- return g_static_rec_mutex_unlock(GST_PAD_GET_STREAM_LOCK(pad));
-- arg-macro: function GST_PAD_STREAM_UNLOCK_FULL (pad)
-- return g_static_rec_mutex_unlock_full(GST_PAD_GET_STREAM_LOCK(pad));
-- arg-macro: function GST_PAD_GET_PREROLL_LOCK (pad)
-- return GST_PAD_CAST(pad).preroll_lock;
-- arg-macro: function GST_PAD_PREROLL_LOCK (pad)
-- return g_mutex_lock(GST_PAD_GET_PREROLL_LOCK(pad));
-- arg-macro: function GST_PAD_PREROLL_TRYLOCK (pad)
-- return g_mutex_trylock(GST_PAD_GET_PREROLL_LOCK(pad));
-- arg-macro: function GST_PAD_PREROLL_UNLOCK (pad)
-- return g_mutex_unlock(GST_PAD_GET_PREROLL_LOCK(pad));
-- arg-macro: function GST_PAD_GET_PREROLL_COND (pad)
-- return GST_PAD_CAST(pad).preroll_cond;
-- arg-macro: procedure GST_PAD_PREROLL_WAIT (pad)
-- g_cond_wait (GST_PAD_GET_PREROLL_COND (pad), GST_PAD_GET_PREROLL_LOCK (pad))
-- arg-macro: procedure GST_PAD_PREROLL_TIMED_WAIT (pad, timeval)
-- g_cond_timed_wait (GST_PAD_GET_PREROLL_COND (pad), GST_PAD_GET_PREROLL_LOCK (pad), timeval)
-- arg-macro: procedure GST_PAD_PREROLL_SIGNAL (pad)
-- g_cond_signal (GST_PAD_GET_PREROLL_COND (pad));
-- arg-macro: procedure GST_PAD_PREROLL_BROADCAST (pad)
-- g_cond_broadcast (GST_PAD_GET_PREROLL_COND (pad));
-- arg-macro: function GST_PAD_BLOCK_GET_COND (pad)
-- return GST_PAD_CAST(pad).block_cond;
-- arg-macro: function GST_PAD_BLOCK_WAIT (pad)
-- return g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_OBJECT_GET_LOCK (pad));
-- arg-macro: function GST_PAD_BLOCK_SIGNAL (pad)
-- return g_cond_signal(GST_PAD_BLOCK_GET_COND (pad));
-- arg-macro: function GST_PAD_BLOCK_BROADCAST (pad)
-- return g_cond_broadcast(GST_PAD_BLOCK_GET_COND (pad));
-- arg-macro: procedure gst_pad_get_name (pad)
-- gst_object_get_name (GST_OBJECT_CAST (pad))
-- arg-macro: procedure gst_pad_get_parent (pad)
-- gst_object_get_parent (GST_OBJECT_CAST (pad))
-- GStreamer
-- * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
-- * 2000 Wim Taymans <wim.taymans@chello.be>
-- *
-- * gstpad.h: Header for GstPad object
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
-- * Pad base class
--
type GstPad;
type anon_200;
type anon_201 is record
block_callback_called : aliased GLIB.gboolean; -- gst/gstpad.h:739
priv : System.Address; -- gst/gstpad.h:740
end record;
pragma Convention (C_Pass_By_Copy, anon_201);
type u_GstPad_u_gst_reserved_array is array (0 .. 1) of System.Address;
type anon_200 (discr : unsigned := 0) is record
case discr is
when 0 =>
ABI : aliased anon_201; -- gst/gstpad.h:741
when others =>
u_gst_reserved : u_GstPad_u_gst_reserved_array; -- gst/gstpad.h:742
end case;
end record;
pragma Convention (C_Pass_By_Copy, anon_200);
pragma Unchecked_Union (anon_200);--subtype GstPad is u_GstPad; -- gst/gstpad.h:50
-- skipped empty struct u_GstPadPrivate
-- skipped empty struct GstPadPrivate
type GstPadClass;
type u_GstPadClass_u_gst_reserved_array is array (0 .. 3) of System.Address;
--subtype GstPadClass is u_GstPadClass; -- gst/gstpad.h:52
--*
-- * GstPadLinkReturn:
-- * @GST_PAD_LINK_OK : link succeeded
-- * @GST_PAD_LINK_WRONG_HIERARCHY: pads have no common grandparent
-- * @GST_PAD_LINK_WAS_LINKED : pad was already linked
-- * @GST_PAD_LINK_WRONG_DIRECTION: pads have wrong direction
-- * @GST_PAD_LINK_NOFORMAT : pads do not have common format
-- * @GST_PAD_LINK_NOSCHED : pads cannot cooperate in scheduling
-- * @GST_PAD_LINK_REFUSED : refused for some reason
-- *
-- * Result values from gst_pad_link and friends.
--
subtype GstPadLinkReturn is int;
GST_PAD_LINK_OK : constant GstPadLinkReturn := 0;
GST_PAD_LINK_WRONG_HIERARCHY : constant GstPadLinkReturn := -1;
GST_PAD_LINK_WAS_LINKED : constant GstPadLinkReturn := -2;
GST_PAD_LINK_WRONG_DIRECTION : constant GstPadLinkReturn := -3;
GST_PAD_LINK_NOFORMAT : constant GstPadLinkReturn := -4;
GST_PAD_LINK_NOSCHED : constant GstPadLinkReturn := -5;
GST_PAD_LINK_REFUSED : constant GstPadLinkReturn := -6; -- gst/gstpad.h:74
--*
-- * GST_PAD_LINK_FAILED:
-- * @ret: the #GstPadLinkReturn value
-- *
-- * Macro to test if the given #GstPadLinkReturn value indicates a failed
-- * link step.
--
--*
-- * GST_PAD_LINK_SUCCESSFUL:
-- * @ret: the #GstPadLinkReturn value
-- *
-- * Macro to test if the given #GstPadLinkReturn value indicates a successful
-- * link step.
--
--*
-- * GstFlowReturn:
-- * @GST_FLOW_RESEND: Resend buffer, possibly with new caps (not
-- * sent yet) (unused/unimplemented).
-- * @GST_FLOW_OK: Data passing was ok.
-- * @GST_FLOW_NOT_LINKED: Pad is not linked.
-- * @GST_FLOW_WRONG_STATE: Pad is in wrong state.
-- * @GST_FLOW_UNEXPECTED: Did not expect anything, like after EOS.
-- * @GST_FLOW_NOT_NEGOTIATED: Pad is not negotiated.
-- * @GST_FLOW_ERROR: Some (fatal) error occured. Element generating
-- * this error should post an error message with more
-- * details.
-- * @GST_FLOW_NOT_SUPPORTED: This operation is not supported.
-- * @GST_FLOW_CUSTOM_SUCCESS: Elements can use values starting from
-- * this (and higher) to define custom success
-- * codes. Since 0.10.7.
-- * @GST_FLOW_CUSTOM_SUCCESS_1: Pre-defined custom success code (define your
-- * custom success code to this to avoid compiler
-- * warnings). Since 0.10.29.
-- * @GST_FLOW_CUSTOM_SUCCESS_2: Pre-defined custom success code. Since 0.10.29.
-- * @GST_FLOW_CUSTOM_ERROR: Elements can use values starting from
-- * this (and lower) to define custom error codes.
-- * Since 0.10.7.
-- * @GST_FLOW_CUSTOM_ERROR_1: Pre-defined custom error code (define your
-- * custom error code to this to avoid compiler
-- * warnings). Since 0.10.29.
-- * @GST_FLOW_CUSTOM_ERROR_2: Pre-defined custom error code. Since 0.10.29.
-- *
-- * The result of passing data to a pad.
-- *
-- * Note that the custom return values should not be exposed outside of the
-- * element scope and are available since 0.10.7.
--
-- FIXME 0.11: remove custom flow returns
-- custom success starts here
-- core predefined
-- expected failures
-- error cases
-- custom error starts here
subtype GstFlowReturn is int;
GST_FLOW_CUSTOM_SUCCESS_2 : constant GstFlowReturn := 102;
GST_FLOW_CUSTOM_SUCCESS_1 : constant GstFlowReturn := 101;
GST_FLOW_CUSTOM_SUCCESS : constant GstFlowReturn := 100;
GST_FLOW_RESEND : constant GstFlowReturn := 1;
GST_FLOW_OK : constant GstFlowReturn := 0;
GST_FLOW_NOT_LINKED : constant GstFlowReturn := -1;
GST_FLOW_WRONG_STATE : constant GstFlowReturn := -2;
GST_FLOW_UNEXPECTED : constant GstFlowReturn := -3;
GST_FLOW_NOT_NEGOTIATED : constant GstFlowReturn := -4;
GST_FLOW_ERROR : constant GstFlowReturn := -5;
GST_FLOW_NOT_SUPPORTED : constant GstFlowReturn := -6;
GST_FLOW_CUSTOM_ERROR : constant GstFlowReturn := -100;
GST_FLOW_CUSTOM_ERROR_1 : constant GstFlowReturn := -101;
GST_FLOW_CUSTOM_ERROR_2 : constant GstFlowReturn := -102; -- gst/gstpad.h:150
--*
-- * GST_FLOW_IS_FATAL:
-- * @ret: a #GstFlowReturn value
-- *
-- * Macro to test if the given #GstFlowReturn value indicates a fatal
-- * error. This macro is mainly used in elements driving the pipeline to decide
-- * whether an error message should be posted on the bus. Note that such
-- * elements may also need to post an error message in the #GST_FLOW_NOT_LINKED
-- * case which is not caught by this macro.
-- *
-- * Deprecated: This macro is badly named and can't be used in any real
-- * scenarios without additional checks.
--
--*
-- * GST_FLOW_IS_SUCCESS:
-- * @ret: a #GstFlowReturn value
-- *
-- * Macro to test if the given #GstFlowReturn value indicates a
-- * successful result
-- * This macro is mainly used in elements to decide if the processing
-- * of a buffer was successful.
-- *
-- * Since: 0.10.7
-- *
-- * Deprecated: This macro is badly named and can't be used in any real
-- * scenarios without additional checks.
--
function gst_flow_get_name (ret : GstFlowReturn) return access GLIB.gchar; -- gst/gstpad.h:187
pragma Import (C, gst_flow_get_name, "gst_flow_get_name");
function gst_flow_to_quark (ret : GstFlowReturn) return Glib.GQuark; -- gst/gstpad.h:188
pragma Import (C, gst_flow_to_quark, "gst_flow_to_quark");
--*
-- * GstPadLinkCheck:
-- * @GST_PAD_LINK_CHECK_NOTHING: Don't check hierarchy or caps compatibility.
-- * @GST_PAD_LINK_CHECK_HIERARCHY: Check the pads have same parents/grandparents.
-- * Could be omitted if it is already known that the two elements that own the
-- * pads are in the same bin.
-- * @GST_PAD_LINK_CHECK_TEMPLATE_CAPS: Check if the pads are compatible by using
-- * their template caps. This is much faster than @GST_PAD_LINK_CHECK_CAPS, but
-- * would be unsafe e.g. if one pad has %GST_CAPS_ANY.
-- * @GST_PAD_LINK_CHECK_CAPS: Check if the pads are compatible by comparing the
-- * caps returned by gst_pad_get_caps().
-- *
-- * The amount of checking to be done when linking pads. @GST_PAD_LINK_CHECK_CAPS
-- * and @GST_PAD_LINK_CHECK_TEMPLATE_CAPS are mutually exclusive. If both are
-- * specified, expensive but safe @GST_PAD_LINK_CHECK_CAPS are performed.
-- *
-- * <warning><para>
-- * Only disable some of the checks if you are 100% certain you know the link
-- * will not fail because of hierarchy/caps compatibility failures. If uncertain,
-- * use the default checks (%GST_PAD_LINK_CHECK_DEFAULT) or the regular methods
-- * for linking the pads.
-- * </para></warning>
-- *
-- * Since: 0.10.30
--
subtype GstPadLinkCheck is unsigned;
GST_PAD_LINK_CHECK_NOTHING : constant GstPadLinkCheck := 0;
GST_PAD_LINK_CHECK_HIERARCHY : constant GstPadLinkCheck := 1;
GST_PAD_LINK_CHECK_TEMPLATE_CAPS : constant GstPadLinkCheck := 2;
GST_PAD_LINK_CHECK_CAPS : constant GstPadLinkCheck := 4; -- gst/gstpad.h:221
--*
-- * GST_PAD_LINK_CHECK_DEFAULT:
-- *
-- * The default checks done when linking pads (i.e. the ones used by
-- * gst_pad_link()).
-- *
-- * Since: 0.10.30
--
--*
-- * GstActivateMode:
-- * @GST_ACTIVATE_NONE: Pad will not handle dataflow
-- * @GST_ACTIVATE_PUSH: Pad handles dataflow in downstream push mode
-- * @GST_ACTIVATE_PULL: Pad handles dataflow in upstream pull mode
-- *
-- * The status of a GstPad. After activating a pad, which usually happens when the
-- * parent element goes from READY to PAUSED, the GstActivateMode defines if the
-- * pad operates in push or pull mode.
--
type GstActivateMode is
(GST_ACTIVATE_NONE,
GST_ACTIVATE_PUSH,
GST_ACTIVATE_PULL);
pragma Convention (C, GstActivateMode); -- gst/gstpad.h:247
--*
-- * GST_PAD_MODE_ACTIVATE:
-- * @mode: a #GstActivateMode
-- *
-- * Macro to test if the given #GstActivateMode value indicates that datapassing
-- * is possible or not.
--
-- pad states
--*
-- * GstPadActivateFunction:
-- * @pad: a #GstPad
-- *
-- * This function is called when the pad is activated during the element
-- * READY to PAUSED state change. By default this function will call the
-- * activate function that puts the pad in push mode but elements can
-- * override this function to activate the pad in pull mode if they wish.
-- *
-- * Returns: TRUE if the pad could be activated.
--
type GstPadActivateFunction is access function (arg1 : access GstPad) return GLIB.gboolean;
pragma Convention (C, GstPadActivateFunction); -- gst/gstpad.h:270
--*
-- * GstPadActivateModeFunction:
-- * @pad: a #GstPad
-- * @active: activate or deactivate the pad.
-- *
-- * The prototype of the push and pull activate functions.
-- *
-- * Returns: TRUE if the pad could be activated or deactivated.
--
type GstPadActivateModeFunction is access function (arg1 : access GstPad; arg2 : GLIB.gboolean) return GLIB.gboolean;
pragma Convention (C, GstPadActivateModeFunction); -- gst/gstpad.h:280
-- data passing
--*
-- * GstPadChainFunction:
-- * @pad: the sink #GstPad that performed the chain.
-- * @buffer: the #GstBuffer that is chained, not %NULL.
-- *
-- * A function that will be called on sinkpads when chaining buffers.
-- * The function typically processes the data contained in the buffer and
-- * either consumes the data or passes it on to the internally linked pad(s).
-- *
-- * The implementer of this function receives a refcount to @buffer and should
-- * gst_buffer_unref() when the buffer is no longer needed.
-- *
-- * When a chain function detects an error in the data stream, it must post an
-- * error on the bus and return an appropriate #GstFlowReturn value.
-- *
-- * Returns: #GST_FLOW_OK for success
--
type GstPadChainFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GstFlowReturn;
pragma Convention (C, GstPadChainFunction); -- gst/gstpad.h:301
--*
-- * GstPadChainListFunction:
-- * @pad: the sink #GstPad that performed the chain.
-- * @list: the #GstBufferList that is chained, not %NULL.
-- *
-- * A function that will be called on sinkpads when chaining buffer lists.
-- * The function typically processes the data contained in the buffer list and
-- * either consumes the data or passes it on to the internally linked pad(s).
-- *
-- * The implementer of this function receives a refcount to @list and
-- * should gst_buffer_list_unref() when the list is no longer needed.
-- *
-- * When a chainlist function detects an error in the data stream, it must
-- * post an error on the bus and return an appropriate #GstFlowReturn value.
-- *
-- * Returns: #GST_FLOW_OK for success
--
type GstPadChainListFunction is access function (arg1 : access GstPad; arg2 : System.Address) return GstFlowReturn;
pragma Convention (C, GstPadChainListFunction); -- gst/gstpad.h:320
--*
-- * GstPadGetRangeFunction:
-- * @pad: the src #GstPad to perform the getrange on.
-- * @offset: the offset of the range
-- * @length: the length of the range
-- * @buffer: a memory location to hold the result buffer, cannot be NULL.
-- *
-- * This function will be called on source pads when a peer element
-- * request a buffer at the specified @offset and @length. If this function
-- * returns #GST_FLOW_OK, the result buffer will be stored in @buffer. The
-- * contents of @buffer is invalid for any other return value.
-- *
-- * This function is installed on a source pad with
-- * gst_pad_set_getrange_function() and can only be called on source pads after
-- * they are successfully activated with gst_pad_activate_pull().
-- *
-- * @offset and @length are always given in byte units. @offset must normally be a value
-- * between 0 and the length in bytes of the data available on @pad. The
-- * length (duration in bytes) can be retrieved with a #GST_QUERY_DURATION or with a
-- * #GST_QUERY_SEEKING.
-- *
-- * Any @offset larger or equal than the length will make the function return
-- * #GST_FLOW_UNEXPECTED, which corresponds to EOS. In this case @buffer does not
-- * contain a valid buffer.
-- *
-- * The buffer size of @buffer will only be smaller than @length when @offset is
-- * near the end of the stream. In all other cases, the size of @buffer must be
-- * exactly the requested size.
-- *
-- * It is allowed to call this function with a 0 @length and valid @offset, in
-- * which case @buffer will contain a 0-sized buffer and the function returns
-- * #GST_FLOW_OK.
-- *
-- * When this function is called with a -1 @offset, the sequentially next buffer
-- * of length @length in the stream is returned.
-- *
-- * When this function is called with a -1 @length, a buffer with a default
-- * optimal length is returned in @buffer. The length might depend on the value
-- * of @offset.
-- *
-- * Returns: #GST_FLOW_OK for success and a valid buffer in @buffer. Any other
-- * return value leaves @buffer undefined.
--
type GstPadGetRangeFunction is access function
(arg1 : access GstPad;
arg2 : GLIB.guint64;
arg3 : GLIB.guint;
arg4 : System.Address) return GstFlowReturn;
pragma Convention (C, GstPadGetRangeFunction); -- gst/gstpad.h:365
--*
-- * GstPadEventFunction:
-- * @pad: the #GstPad to handle the event.
-- * @event: the #GstEvent to handle.
-- *
-- * Function signature to handle an event for the pad.
-- *
-- * Returns: TRUE if the pad could handle the event.
--
type GstPadEventFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean;
pragma Convention (C, GstPadEventFunction); -- gst/gstpad.h:377
-- FIXME: 0.11: deprecate me, check range should use seeking query
--*
-- * GstPadCheckGetRangeFunction:
-- * @pad: a #GstPad
-- *
-- * Check if @pad can be activated in pull mode.
-- *
-- * This function will be deprecated after 0.10; use the seeking query to check
-- * if a pad can support random access.
-- *
-- * Returns: TRUE if the pad can operate in pull mode.
--
type GstPadCheckGetRangeFunction is access function (arg1 : access GstPad) return GLIB.gboolean;
pragma Convention (C, GstPadCheckGetRangeFunction); -- gst/gstpad.h:392
-- internal links
--*
-- * GstPadIntLinkFunction:
-- * @pad: The #GstPad to query.
-- *
-- * The signature of the internal pad link function.
-- *
-- * Returns: (element-type Gst.Pad) (transfer container): a newly allocated #GList of pads that are linked to the given pad on
-- * the inside of the parent element.
-- *
-- * The caller must call g_list_free() on it after use.
-- *
-- * Deprecated: use the threadsafe #GstPadIterIntLinkFunction instead.
--
type GstPadIntLinkFunction is access function (arg1 : access GstPad) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList;
pragma Convention (C, GstPadIntLinkFunction); -- gst/gstpad.h:409
--*
-- * GstPadIterIntLinkFunction:
-- * @pad: The #GstPad to query.
-- *
-- * The signature of the internal pad link iterator function.
-- *
-- * Returns: a new #GstIterator that will iterate over all pads that are
-- * linked to the given pad on the inside of the parent element.
-- *
-- * the caller must call gst_iterator_free() after usage.
-- *
-- * Since 0.10.21
--
type GstPadIterIntLinkFunction is access function (arg1 : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator;
pragma Convention (C, GstPadIterIntLinkFunction); -- gst/gstpad.h:426
-- generic query function
--*
-- * GstPadQueryTypeFunction:
-- * @pad: a #GstPad to query
-- *
-- * The signature of the query types function.
-- *
-- * Returns: a constant array of query types
--
type GstPadQueryTypeFunction is access function (arg1 : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQueryType;
pragma Convention (C, GstPadQueryTypeFunction); -- gst/gstpad.h:437
--*
-- * GstPadQueryFunction:
-- * @pad: the #GstPad to query.
-- * @query: the #GstQuery object to execute
-- *
-- * The signature of the query function.
-- *
-- * Returns: TRUE if the query could be performed.
--
type GstPadQueryFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean;
pragma Convention (C, GstPadQueryFunction); -- gst/gstpad.h:448
-- linking
--*
-- * GstPadLinkFunction
-- * @pad: the #GstPad that is linked.
-- * @peer: the peer #GstPad of the link
-- *
-- * Function signature to handle a new link on the pad.
-- *
-- * Returns: the result of the link with the specified peer.
--
type GstPadLinkFunction is access function (arg1 : access GstPad; arg2 : access GstPad) return GstPadLinkReturn;
pragma Convention (C, GstPadLinkFunction); -- gst/gstpad.h:461
--*
-- * GstPadUnlinkFunction
-- * @pad: the #GstPad that is linked.
-- *
-- * Function signature to handle a unlinking the pad prom its peer.
--
type GstPadUnlinkFunction is access procedure (arg1 : access GstPad);
pragma Convention (C, GstPadUnlinkFunction); -- gst/gstpad.h:468
-- caps nego
--*
-- * GstPadGetCapsFunction:
-- * @pad: the #GstPad to get the capabilities of.
-- *
-- * Returns a copy of the capabilities of the specified pad. By default this
-- * function will return the pad template capabilities, but can optionally
-- * be overridden by elements.
-- *
-- * Returns: a newly allocated copy #GstCaps of the pad.
--
type GstPadGetCapsFunction is access function (arg1 : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
pragma Convention (C, GstPadGetCapsFunction); -- gst/gstpad.h:482
--*
-- * GstPadSetCapsFunction:
-- * @pad: the #GstPad to set the capabilities of.
-- * @caps: the #GstCaps to set
-- *
-- * Set @caps on @pad. By default this function updates the caps of the
-- * pad but the function can be overriden by elements to perform extra
-- * actions or verifications.
-- *
-- * Returns: TRUE if the caps could be set on the pad.
--
type GstPadSetCapsFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean;
pragma Convention (C, GstPadSetCapsFunction); -- gst/gstpad.h:495
--*
-- * GstPadAcceptCapsFunction:
-- * @pad: the #GstPad to check
-- * @caps: the #GstCaps to check
-- *
-- * Check if @pad can accept @caps. By default this function will see if @caps
-- * intersect with the result from gst_pad_get_caps() by can be overridden to
-- * perform extra checks.
-- *
-- * Returns: TRUE if the caps can be accepted by the pad.
--
type GstPadAcceptCapsFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean;
pragma Convention (C, GstPadAcceptCapsFunction); -- gst/gstpad.h:507
--*
-- * GstPadFixateCapsFunction:
-- * @pad: a #GstPad
-- * @caps: the #GstCaps to fixate
-- *
-- * Given possibly unfixed caps @caps, let @pad use its default preferred
-- * format to make a fixed caps. @caps should be writable. By default this
-- * function will pick the first value of any ranges or lists in the caps but
-- * elements can override this function to perform other behaviour.
--
type GstPadFixateCapsFunction is access procedure (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps);
pragma Convention (C, GstPadFixateCapsFunction); -- gst/gstpad.h:518
--*
-- * GstPadBufferAllocFunction:
-- * @pad: a sink #GstPad
-- * @offset: the desired offset of the buffer
-- * @size: the desired size of the buffer
-- * @caps: the desired caps of the buffer
-- * @buf: pointer to hold the allocated buffer.
-- *
-- * Ask the sinkpad @pad to allocate a buffer with @offset, @size and @caps.
-- * The result will be stored in @buf.
-- *
-- * The purpose of this function is to allocate a buffer that is optimal to
-- * be processed by @pad. The function is mostly overridden by elements that can
-- * provide a hardware buffer in order to avoid additional memcpy operations.
-- *
-- * The function can return a buffer that has caps different from the requested
-- * @caps, in which case the upstream element requests a format change to this
-- * new caps.
-- * If a format change was requested, the returned buffer will be one to hold
-- * the data of said new caps, so its size might be different from the requested
-- * @size.
-- *
-- * When this function returns anything else than #GST_FLOW_OK, the buffer allocation
-- * failed and @buf does not contain valid data. If the function returns #GST_FLOW_OK and
-- * the @buf is NULL, a #GstBuffer will be created with @caps, @offset and @size.
-- *
-- * By default this function returns a new buffer of @size and with @caps containing
-- * purely malloced data. The buffer should be freed with gst_buffer_unref()
-- * after usage.
-- *
-- * Returns: #GST_FLOW_OK if @buf contains a valid buffer, any other return
-- * value means @buf does not hold a valid buffer.
--
type GstPadBufferAllocFunction is access function
(arg1 : access GstPad;
arg2 : GLIB.guint64;
arg3 : GLIB.guint;
arg4 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
arg5 : System.Address) return GstFlowReturn;
pragma Convention (C, GstPadBufferAllocFunction); -- gst/gstpad.h:552
-- misc
--*
-- * GstPadDispatcherFunction:
-- * @pad: the #GstPad that is dispatched.
-- * @data: the gpointer to optional user data.
-- *
-- * A dispatcher function is called for all internally linked pads, see
-- * gst_pad_dispatcher().
-- *
-- * Returns: TRUE if the dispatching procedure has to be stopped.
--
type GstPadDispatcherFunction is access function (arg1 : access GstPad; arg2 : System.Address) return GLIB.gboolean;
pragma Convention (C, GstPadDispatcherFunction); -- gst/gstpad.h:566
--*
-- * GstPadBlockCallback:
-- * @pad: the #GstPad that is blockend or unblocked.
-- * @blocked: blocking state for the pad
-- * @user_data: the gpointer to optional user data.
-- *
-- * Callback used by gst_pad_set_blocked_async(). Gets called when the blocking
-- * operation succeeds.
--
type GstPadBlockCallback is access procedure
(arg1 : access GstPad;
arg2 : GLIB.gboolean;
arg3 : System.Address);
pragma Convention (C, GstPadBlockCallback); -- gst/gstpad.h:577
--*
-- * GstPadDirection:
-- * @GST_PAD_UNKNOWN: direction is unknown.
-- * @GST_PAD_SRC: the pad is a source pad.
-- * @GST_PAD_SINK: the pad is a sink pad.
-- *
-- * The direction of a pad.
--
type GstPadDirection is
(GST_PAD_UNKNOWN,
GST_PAD_SRC,
GST_PAD_SINK);
pragma Convention (C, GstPadDirection); -- gst/gstpad.h:591
--*
-- * GstPadFlags:
-- * @GST_PAD_BLOCKED: is dataflow on a pad blocked
-- * @GST_PAD_FLUSHING: is pad refusing buffers
-- * @GST_PAD_IN_GETCAPS: GstPadGetCapsFunction() is running now
-- * @GST_PAD_IN_SETCAPS: GstPadSetCapsFunction() is running now
-- * @GST_PAD_BLOCKING: is pad currently blocking on a buffer or event
-- * @GST_PAD_FLAG_LAST: offset to define more flags
-- *
-- * Pad state flags
--
-- padding
type GstPadFlags is new unsigned;
GST_PAD_BLOCKED : constant GstPadFlags := 16;
GST_PAD_FLUSHING : constant GstPadFlags := 32;
GST_PAD_IN_GETCAPS : constant GstPadFlags := 64;
GST_PAD_IN_SETCAPS : constant GstPadFlags := 128;
GST_PAD_BLOCKING : constant GstPadFlags := 256;
GST_PAD_FLAG_LAST : constant GstPadFlags := 4096; -- gst/gstpad.h:612
-- FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h)
-- subtype GstPadTemplate is GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate -- gst/gstpad.h:615
--*
-- * GstPad:
-- * @element_private: private data owned by the parent element
-- * @padtemplate: padtemplate for this pad
-- * @direction: the direction of the pad, cannot change after creating
-- * the pad.
-- * @stream_rec_lock: recursive stream lock of the pad, used to protect
-- * the data used in streaming.
-- * @task: task for this pad if the pad is actively driving dataflow.
-- * @preroll_lock: lock used when prerolling
-- * @preroll_cond: conf to signal preroll
-- * @block_cond: conditional to signal pad block
-- * @block_callback: callback for the pad block if any
-- * @block_data: user data for @block_callback
-- * @caps: the current caps of the pad
-- * @getcapsfunc: function to get caps of the pad
-- * @setcapsfunc: function to set caps on the pad
-- * @acceptcapsfunc: function to check if pad can accept caps
-- * @fixatecapsfunc: function to fixate caps
-- * @activatefunc: pad activation function
-- * @activatepushfunc: function to activate/deactivate pad in push mode
-- * @activatepullfunc: function to activate/deactivate pad in pull mode
-- * @linkfunc: function called when pad is linked
-- * @unlinkfunc: function called when pad is unlinked
-- * @peer: the pad this pad is linked to
-- * @sched_private: private storage for the scheduler
-- * @chainfunc: function to chain buffer to pad
-- * @checkgetrangefunc: function to check if pad can operate in pull mode
-- * @getrangefunc: function to get a range of data from a pad
-- * @eventfunc: function to send an event to a pad
-- * @mode: current activation mode of the pad
-- * @querytypefunc: get list of supported queries
-- * @queryfunc: perform a query on the pad
-- * @intlinkfunc: get the internal links of this pad
-- * @bufferallocfunc: function to allocate a buffer for this pad
-- * @do_buffer_signals: counter counting installed buffer signals
-- * @do_event_signals: counter counting installed event signals
-- * @iterintlinkfunc: get the internal links iterator of this pad
-- * @block_destroy_data: notify function for gst_pad_set_blocked_async_full()
-- *
-- * The #GstPad structure. Use the functions to update the variables.
--
type GstPad is record
object : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObject; -- gst/gstpad.h:660
element_private : System.Address; -- gst/gstpad.h:663
padtemplate : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; -- gst/gstpad.h:665
direction : aliased GstPadDirection; -- gst/gstpad.h:667
stream_rec_lock : access GStreamer.GST_Low_Level.glib_2_0_glib_deprecated_gthread_h.GStaticRecMutex; -- gst/gstpad.h:671
c_task : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttask_h.GstTask; -- gst/gstpad.h:672
preroll_lock : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GMutex; -- gst/gstpad.h:674
preroll_cond : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GCond; -- gst/gstpad.h:675
block_cond : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GCond; -- gst/gstpad.h:679
block_callback : GstPadBlockCallback; -- gst/gstpad.h:680
block_data : System.Address; -- gst/gstpad.h:681
caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:684
getcapsfunc : GstPadGetCapsFunction; -- gst/gstpad.h:685
setcapsfunc : GstPadSetCapsFunction; -- gst/gstpad.h:686
acceptcapsfunc : GstPadAcceptCapsFunction; -- gst/gstpad.h:687
fixatecapsfunc : GstPadFixateCapsFunction; -- gst/gstpad.h:688
activatefunc : GstPadActivateFunction; -- gst/gstpad.h:690
activatepushfunc : GstPadActivateModeFunction; -- gst/gstpad.h:691
activatepullfunc : GstPadActivateModeFunction; -- gst/gstpad.h:692
linkfunc : GstPadLinkFunction; -- gst/gstpad.h:695
unlinkfunc : GstPadUnlinkFunction; -- gst/gstpad.h:696
peer : access GstPad; -- gst/gstpad.h:697
sched_private : System.Address; -- gst/gstpad.h:699
chainfunc : GstPadChainFunction; -- gst/gstpad.h:702
checkgetrangefunc : GstPadCheckGetRangeFunction; -- gst/gstpad.h:703
getrangefunc : GstPadGetRangeFunction; -- gst/gstpad.h:704
eventfunc : GstPadEventFunction; -- gst/gstpad.h:705
mode : aliased GstActivateMode; -- gst/gstpad.h:707
querytypefunc : GstPadQueryTypeFunction; -- gst/gstpad.h:710
queryfunc : GstPadQueryFunction; -- gst/gstpad.h:711
intlinkfunc : GstPadIntLinkFunction; -- gst/gstpad.h:715
bufferallocfunc : GstPadBufferAllocFunction; -- gst/gstpad.h:722
do_buffer_signals : aliased GLIB.gint; -- gst/gstpad.h:726
do_event_signals : aliased GLIB.gint; -- gst/gstpad.h:727
iterintlinkfunc : GstPadIterIntLinkFunction; -- gst/gstpad.h:731
block_destroy_data : GStreamer.GST_Low_Level.glib_2_0_glib_gtypes_h.GDestroyNotify; -- gst/gstpad.h:734
abidata : aliased anon_200; -- gst/gstpad.h:743
end record;
pragma Convention (C_Pass_By_Copy, GstPad); -- gst/gstpad.h:659
--< public >
--< public >
-- with STREAM_LOCK
-- streaming rec_lock
--< public >
-- with PREROLL_LOCK
--< public >
-- with LOCK
-- block cond, mutex is from the object
-- the pad capabilities
-- pad link
-- data transport functions
-- generic query method
-- internal links
-- whether to emit signals for have-data. counts number
-- * of handlers attached.
-- ABI added
-- iterate internal links
-- free block_data
--< private >
type GstPadClass is record
parent_class : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObjectClass; -- gst/gstpad.h:747
linked : access procedure (arg1 : access GstPad; arg2 : access GstPad); -- gst/gstpad.h:750
unlinked : access procedure (arg1 : access GstPad; arg2 : access GstPad); -- gst/gstpad.h:751
request_link : access procedure (arg1 : access GstPad); -- gst/gstpad.h:752
have_data : access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstminiobject_h.GstMiniObject) return GLIB.gboolean; -- gst/gstpad.h:753
u_gst_reserved : u_GstPadClass_u_gst_reserved_array; -- gst/gstpad.h:756
end record;
pragma Convention (C_Pass_By_Copy, GstPadClass); -- gst/gstpad.h:746
-- signal callbacks
--< private >
--**** helper macros ****
-- GstPad
--*
-- * GST_PAD_CAPS:
-- * @pad: a #GstPad.
-- *
-- * The caps for this pad.
--
--*
-- * GST_PAD_GET_STREAM_LOCK:
-- * @pad: a #GstPad
-- *
-- * Get the stream lock of @pad. The stream lock is protecting the
-- * resources used in the data processing functions of @pad.
--
--*
-- * GST_PAD_STREAM_LOCK:
-- * @pad: a #GstPad
-- *
-- * Lock the stream lock of @pad.
--
--*
-- * GST_PAD_STREAM_LOCK_FULL:
-- * @pad: a #GstPad
-- * @t: the number of times to recursively lock
-- *
-- * Lock the stream lock of @pad @t times.
--
--*
-- * GST_PAD_STREAM_TRYLOCK:
-- * @pad: a #GstPad
-- *
-- * Try to Lock the stream lock of the pad, return TRUE if the lock could be
-- * taken.
--
--*
-- * GST_PAD_STREAM_UNLOCK:
-- * @pad: a #GstPad
-- *
-- * Unlock the stream lock of @pad.
--
--*
-- * GST_PAD_STREAM_UNLOCK_FULL:
-- * @pad: a #GstPad
-- *
-- * Fully unlock the recursive stream lock of @pad, return the number of times
-- * @pad was locked.
--
-- FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h)
function gst_pad_get_type return GLIB.GType; -- gst/gstpad.h:885
pragma Import (C, gst_pad_get_type, "gst_pad_get_type");
-- creating pads
function gst_pad_new (name : access GLIB.gchar; direction : GstPadDirection) return access GstPad; -- gst/gstpad.h:888
pragma Import (C, gst_pad_new, "gst_pad_new");
function gst_pad_new_from_template (templ : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; name : access GLIB.gchar) return access GstPad; -- gst/gstpad.h:889
pragma Import (C, gst_pad_new_from_template, "gst_pad_new_from_template");
function gst_pad_new_from_static_template (templ : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstStaticPadTemplate; name : access GLIB.gchar) return access GstPad; -- gst/gstpad.h:890
pragma Import (C, gst_pad_new_from_static_template, "gst_pad_new_from_static_template");
--*
-- * gst_pad_get_name:
-- * @pad: the pad to get the name from
-- *
-- * Get a copy of the name of the pad. g_free() after usage.
-- *
-- * MT safe.
--
--*
-- * gst_pad_get_parent:
-- * @pad: the pad to get the parent of
-- *
-- * Get the parent of @pad. This function increases the refcount
-- * of the parent object so you should gst_object_unref() it after usage.
-- * Can return NULL if the pad did not have a parent.
-- *
-- * MT safe.
--
function gst_pad_get_direction (pad : access GstPad) return GstPadDirection; -- gst/gstpad.h:914
pragma Import (C, gst_pad_get_direction, "gst_pad_get_direction");
function gst_pad_set_active (pad : access GstPad; active : GLIB.gboolean) return GLIB.gboolean; -- gst/gstpad.h:916
pragma Import (C, gst_pad_set_active, "gst_pad_set_active");
function gst_pad_is_active (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:917
pragma Import (C, gst_pad_is_active, "gst_pad_is_active");
function gst_pad_activate_pull (pad : access GstPad; active : GLIB.gboolean) return GLIB.gboolean; -- gst/gstpad.h:918
pragma Import (C, gst_pad_activate_pull, "gst_pad_activate_pull");
function gst_pad_activate_push (pad : access GstPad; active : GLIB.gboolean) return GLIB.gboolean; -- gst/gstpad.h:919
pragma Import (C, gst_pad_activate_push, "gst_pad_activate_push");
function gst_pad_set_blocked (pad : access GstPad; blocked : GLIB.gboolean) return GLIB.gboolean; -- gst/gstpad.h:921
pragma Import (C, gst_pad_set_blocked, "gst_pad_set_blocked");
function gst_pad_set_blocked_async
(pad : access GstPad;
blocked : GLIB.gboolean;
callback : GstPadBlockCallback;
user_data : System.Address) return GLIB.gboolean; -- gst/gstpad.h:922
pragma Import (C, gst_pad_set_blocked_async, "gst_pad_set_blocked_async");
function gst_pad_set_blocked_async_full
(pad : access GstPad;
blocked : GLIB.gboolean;
callback : GstPadBlockCallback;
user_data : System.Address;
destroy_data : GStreamer.GST_Low_Level.glib_2_0_glib_gtypes_h.GDestroyNotify) return GLIB.gboolean; -- gst/gstpad.h:924
pragma Import (C, gst_pad_set_blocked_async_full, "gst_pad_set_blocked_async_full");
function gst_pad_is_blocked (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:927
pragma Import (C, gst_pad_is_blocked, "gst_pad_is_blocked");
function gst_pad_is_blocking (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:928
pragma Import (C, gst_pad_is_blocking, "gst_pad_is_blocking");
procedure gst_pad_set_element_private (pad : access GstPad; priv : System.Address); -- gst/gstpad.h:930
pragma Import (C, gst_pad_set_element_private, "gst_pad_set_element_private");
function gst_pad_get_element_private (pad : access GstPad) return System.Address; -- gst/gstpad.h:931
pragma Import (C, gst_pad_get_element_private, "gst_pad_get_element_private");
function gst_pad_get_pad_template (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; -- gst/gstpad.h:933
pragma Import (C, gst_pad_get_pad_template, "gst_pad_get_pad_template");
procedure gst_pad_set_bufferalloc_function (pad : access GstPad; bufalloc : GstPadBufferAllocFunction); -- gst/gstpad.h:935
pragma Import (C, gst_pad_set_bufferalloc_function, "gst_pad_set_bufferalloc_function");
function gst_pad_alloc_buffer
(pad : access GstPad;
offset : GLIB.guint64;
size : GLIB.gint;
caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
buf : System.Address) return GstFlowReturn; -- gst/gstpad.h:936
pragma Import (C, gst_pad_alloc_buffer, "gst_pad_alloc_buffer");
function gst_pad_alloc_buffer_and_set_caps
(pad : access GstPad;
offset : GLIB.guint64;
size : GLIB.gint;
caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
buf : System.Address) return GstFlowReturn; -- gst/gstpad.h:938
pragma Import (C, gst_pad_alloc_buffer_and_set_caps, "gst_pad_alloc_buffer_and_set_caps");
-- data passing setup functions
procedure gst_pad_set_activate_function (pad : access GstPad; activate : GstPadActivateFunction); -- gst/gstpad.h:942
pragma Import (C, gst_pad_set_activate_function, "gst_pad_set_activate_function");
procedure gst_pad_set_activatepull_function (pad : access GstPad; activatepull : GstPadActivateModeFunction); -- gst/gstpad.h:943
pragma Import (C, gst_pad_set_activatepull_function, "gst_pad_set_activatepull_function");
procedure gst_pad_set_activatepush_function (pad : access GstPad; activatepush : GstPadActivateModeFunction); -- gst/gstpad.h:944
pragma Import (C, gst_pad_set_activatepush_function, "gst_pad_set_activatepush_function");
procedure gst_pad_set_chain_function (pad : access GstPad; chain : GstPadChainFunction); -- gst/gstpad.h:945
pragma Import (C, gst_pad_set_chain_function, "gst_pad_set_chain_function");
procedure gst_pad_set_chain_list_function (pad : access GstPad; chainlist : GstPadChainListFunction); -- gst/gstpad.h:946
pragma Import (C, gst_pad_set_chain_list_function, "gst_pad_set_chain_list_function");
procedure gst_pad_set_getrange_function (pad : access GstPad; get : GstPadGetRangeFunction); -- gst/gstpad.h:947
pragma Import (C, gst_pad_set_getrange_function, "gst_pad_set_getrange_function");
procedure gst_pad_set_checkgetrange_function (pad : access GstPad; check : GstPadCheckGetRangeFunction); -- gst/gstpad.h:948
pragma Import (C, gst_pad_set_checkgetrange_function, "gst_pad_set_checkgetrange_function");
procedure gst_pad_set_event_function (pad : access GstPad; event : GstPadEventFunction); -- gst/gstpad.h:949
pragma Import (C, gst_pad_set_event_function, "gst_pad_set_event_function");
-- pad links
procedure gst_pad_set_link_function (pad : access GstPad; link : GstPadLinkFunction); -- gst/gstpad.h:952
pragma Import (C, gst_pad_set_link_function, "gst_pad_set_link_function");
procedure gst_pad_set_unlink_function (pad : access GstPad; unlink : GstPadUnlinkFunction); -- gst/gstpad.h:953
pragma Import (C, gst_pad_set_unlink_function, "gst_pad_set_unlink_function");
function gst_pad_can_link (srcpad : access GstPad; sinkpad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:955
pragma Import (C, gst_pad_can_link, "gst_pad_can_link");
function gst_pad_link (srcpad : access GstPad; sinkpad : access GstPad) return GstPadLinkReturn; -- gst/gstpad.h:956
pragma Import (C, gst_pad_link, "gst_pad_link");
function gst_pad_link_full
(srcpad : access GstPad;
sinkpad : access GstPad;
flags : GstPadLinkCheck) return GstPadLinkReturn; -- gst/gstpad.h:957
pragma Import (C, gst_pad_link_full, "gst_pad_link_full");
function gst_pad_unlink (srcpad : access GstPad; sinkpad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:958
pragma Import (C, gst_pad_unlink, "gst_pad_unlink");
function gst_pad_is_linked (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:959
pragma Import (C, gst_pad_is_linked, "gst_pad_is_linked");
function gst_pad_get_peer (pad : access GstPad) return access GstPad; -- gst/gstpad.h:961
pragma Import (C, gst_pad_get_peer, "gst_pad_get_peer");
-- capsnego functions
procedure gst_pad_set_getcaps_function (pad : access GstPad; getcaps : GstPadGetCapsFunction); -- gst/gstpad.h:964
pragma Import (C, gst_pad_set_getcaps_function, "gst_pad_set_getcaps_function");
procedure gst_pad_set_acceptcaps_function (pad : access GstPad; acceptcaps : GstPadAcceptCapsFunction); -- gst/gstpad.h:965
pragma Import (C, gst_pad_set_acceptcaps_function, "gst_pad_set_acceptcaps_function");
procedure gst_pad_set_fixatecaps_function (pad : access GstPad; fixatecaps : GstPadFixateCapsFunction); -- gst/gstpad.h:966
pragma Import (C, gst_pad_set_fixatecaps_function, "gst_pad_set_fixatecaps_function");
procedure gst_pad_set_setcaps_function (pad : access GstPad; setcaps : GstPadSetCapsFunction); -- gst/gstpad.h:967
pragma Import (C, gst_pad_set_setcaps_function, "gst_pad_set_setcaps_function");
function gst_pad_get_pad_template_caps (pad : access GstPad) return access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:969
pragma Import (C, gst_pad_get_pad_template_caps, "gst_pad_get_pad_template_caps");
-- capsnego function for linked/unlinked pads
function gst_pad_get_caps_reffed (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:972
pragma Import (C, gst_pad_get_caps_reffed, "gst_pad_get_caps_reffed");
function gst_pad_get_caps (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:973
pragma Import (C, gst_pad_get_caps, "gst_pad_get_caps");
procedure gst_pad_fixate_caps (pad : access GstPad; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps); -- gst/gstpad.h:974
pragma Import (C, gst_pad_fixate_caps, "gst_pad_fixate_caps");
function gst_pad_accept_caps (pad : access GstPad; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean; -- gst/gstpad.h:975
pragma Import (C, gst_pad_accept_caps, "gst_pad_accept_caps");
function gst_pad_set_caps (pad : access GstPad; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean; -- gst/gstpad.h:976
pragma Import (C, gst_pad_set_caps, "gst_pad_set_caps");
function gst_pad_peer_get_caps_reffed (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:978
pragma Import (C, gst_pad_peer_get_caps_reffed, "gst_pad_peer_get_caps_reffed");
function gst_pad_peer_get_caps (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:979
pragma Import (C, gst_pad_peer_get_caps, "gst_pad_peer_get_caps");
function gst_pad_peer_accept_caps (pad : access GstPad; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean; -- gst/gstpad.h:980
pragma Import (C, gst_pad_peer_accept_caps, "gst_pad_peer_accept_caps");
-- capsnego for linked pads
function gst_pad_get_allowed_caps (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:983
pragma Import (C, gst_pad_get_allowed_caps, "gst_pad_get_allowed_caps");
function gst_pad_get_negotiated_caps (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:984
pragma Import (C, gst_pad_get_negotiated_caps, "gst_pad_get_negotiated_caps");
-- data passing functions to peer
function gst_pad_push (pad : access GstPad; buffer : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GstFlowReturn; -- gst/gstpad.h:987
pragma Import (C, gst_pad_push, "gst_pad_push");
function gst_pad_push_list (pad : access GstPad; list : System.Address) return GstFlowReturn; -- gst/gstpad.h:988
pragma Import (C, gst_pad_push_list, "gst_pad_push_list");
function gst_pad_check_pull_range (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:989
pragma Import (C, gst_pad_check_pull_range, "gst_pad_check_pull_range");
function gst_pad_pull_range
(pad : access GstPad;
offset : GLIB.guint64;
size : GLIB.guint;
buffer : System.Address) return GstFlowReturn; -- gst/gstpad.h:990
pragma Import (C, gst_pad_pull_range, "gst_pad_pull_range");
function gst_pad_push_event (pad : access GstPad; event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/gstpad.h:992
pragma Import (C, gst_pad_push_event, "gst_pad_push_event");
function gst_pad_event_default (pad : access GstPad; event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/gstpad.h:993
pragma Import (C, gst_pad_event_default, "gst_pad_event_default");
-- data passing functions on pad
function gst_pad_chain (pad : access GstPad; buffer : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GstFlowReturn; -- gst/gstpad.h:996
pragma Import (C, gst_pad_chain, "gst_pad_chain");
function gst_pad_chain_list (pad : access GstPad; list : System.Address) return GstFlowReturn; -- gst/gstpad.h:997
pragma Import (C, gst_pad_chain_list, "gst_pad_chain_list");
function gst_pad_get_range
(pad : access GstPad;
offset : GLIB.guint64;
size : GLIB.guint;
buffer : System.Address) return GstFlowReturn; -- gst/gstpad.h:998
pragma Import (C, gst_pad_get_range, "gst_pad_get_range");
function gst_pad_send_event (pad : access GstPad; event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/gstpad.h:1000
pragma Import (C, gst_pad_send_event, "gst_pad_send_event");
-- pad tasks
function gst_pad_start_task
(pad : access GstPad;
func : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttask_h.GstTaskFunction;
data : System.Address) return GLIB.gboolean; -- gst/gstpad.h:1003
pragma Import (C, gst_pad_start_task, "gst_pad_start_task");
function gst_pad_pause_task (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:1005
pragma Import (C, gst_pad_pause_task, "gst_pad_pause_task");
function gst_pad_stop_task (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:1006
pragma Import (C, gst_pad_stop_task, "gst_pad_stop_task");
-- internal links
procedure gst_pad_set_internal_link_function (pad : access GstPad; intlink : GstPadIntLinkFunction); -- gst/gstpad.h:1010
pragma Import (C, gst_pad_set_internal_link_function, "gst_pad_set_internal_link_function");
function gst_pad_get_internal_links (pad : access GstPad) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstpad.h:1011
pragma Import (C, gst_pad_get_internal_links, "gst_pad_get_internal_links");
function gst_pad_get_internal_links_default (pad : access GstPad) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstpad.h:1012
pragma Import (C, gst_pad_get_internal_links_default, "gst_pad_get_internal_links_default");
procedure gst_pad_set_iterate_internal_links_function (pad : access GstPad; iterintlink : GstPadIterIntLinkFunction); -- gst/gstpad.h:1015
pragma Import (C, gst_pad_set_iterate_internal_links_function, "gst_pad_set_iterate_internal_links_function");
function gst_pad_iterate_internal_links (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator; -- gst/gstpad.h:1017
pragma Import (C, gst_pad_iterate_internal_links, "gst_pad_iterate_internal_links");
function gst_pad_iterate_internal_links_default (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator; -- gst/gstpad.h:1018
pragma Import (C, gst_pad_iterate_internal_links_default, "gst_pad_iterate_internal_links_default");
-- generic query function
procedure gst_pad_set_query_type_function (pad : access GstPad; type_func : GstPadQueryTypeFunction); -- gst/gstpad.h:1022
pragma Import (C, gst_pad_set_query_type_function, "gst_pad_set_query_type_function");
function gst_pad_get_query_types (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQueryType; -- gst/gstpad.h:1023
pragma Import (C, gst_pad_get_query_types, "gst_pad_get_query_types");
function gst_pad_get_query_types_default (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQueryType; -- gst/gstpad.h:1024
pragma Import (C, gst_pad_get_query_types_default, "gst_pad_get_query_types_default");
function gst_pad_query (pad : access GstPad; query : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/gstpad.h:1026
pragma Import (C, gst_pad_query, "gst_pad_query");
function gst_pad_peer_query (pad : access GstPad; query : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/gstpad.h:1027
pragma Import (C, gst_pad_peer_query, "gst_pad_peer_query");
procedure gst_pad_set_query_function (pad : access GstPad; query : GstPadQueryFunction); -- gst/gstpad.h:1028
pragma Import (C, gst_pad_set_query_function, "gst_pad_set_query_function");
function gst_pad_query_default (pad : access GstPad; query : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/gstpad.h:1029
pragma Import (C, gst_pad_query_default, "gst_pad_query_default");
-- misc helper functions
function gst_pad_dispatcher
(pad : access GstPad;
dispatch : GstPadDispatcherFunction;
data : System.Address) return GLIB.gboolean; -- gst/gstpad.h:1032
pragma Import (C, gst_pad_dispatcher, "gst_pad_dispatcher");
procedure gst_pad_load_and_link (self : GStreamer.GST_Low_Level.libxml2_libxml_tree_h.xmlNodePtr; parent : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObject); -- gst/gstpad.h:1036
pragma Import (C, gst_pad_load_and_link, "gst_pad_load_and_link");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h;
| 26568 | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
with glib.Values;
with System;
with System;
-- with GStreamer.GST_Low_Level.glib_2_0_glib_gquark_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_glist_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h;
-- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_deprecated_gthread_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttask_h;
-- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstminiobject_h;
with glib;
-- with GStreamer.GST_Low_Level.libxml2_libxml_tree_h;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h is
-- unsupported macro: GST_TYPE_PAD (gst_pad_get_type ())
-- arg-macro: function GST_IS_PAD (obj)
-- return G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD);
-- arg-macro: function GST_IS_PAD_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD);
-- arg-macro: function GST_PAD (obj)
-- return G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD, GstPad);
-- arg-macro: function GST_PAD_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD, GstPadClass);
-- arg-macro: function GST_PAD_CAST (obj)
-- return (GstPad*)(obj);
-- arg-macro: function GST_PAD_LINK_FAILED (ret)
-- return (ret) < GST_PAD_LINK_OK;
-- arg-macro: function GST_PAD_LINK_SUCCESSFUL (ret)
-- return (ret) >= GST_PAD_LINK_OK;
-- arg-macro: function GST_FLOW_IS_FATAL (ret)
-- return (ret) <= GST_FLOW_UNEXPECTED;
-- arg-macro: function GST_FLOW_IS_SUCCESS (ret)
-- return (ret) >= GST_FLOW_OK;
-- unsupported macro: GST_PAD_LINK_CHECK_DEFAULT ((GstPadLinkCheck) (GST_PAD_LINK_CHECK_HIERARCHY | GST_PAD_LINK_CHECK_CAPS))
-- arg-macro: function GST_PAD_MODE_ACTIVATE (mode)
-- return (mode) /= GST_ACTIVATE_NONE;
-- arg-macro: function GST_PAD_NAME (pad)
-- return GST_OBJECT_NAME(pad);
-- arg-macro: function GST_PAD_PARENT (pad)
-- return GST_ELEMENT_CAST(GST_OBJECT_PARENT(pad));
-- arg-macro: function GST_PAD_ELEMENT_PRIVATE (pad)
-- return GST_PAD_CAST(pad).element_private;
-- arg-macro: function GST_PAD_PAD_TEMPLATE (pad)
-- return GST_PAD_CAST(pad).padtemplate;
-- arg-macro: function GST_PAD_DIRECTION (pad)
-- return GST_PAD_CAST(pad).direction;
-- arg-macro: function GST_PAD_TASK (pad)
-- return GST_PAD_CAST(pad).task;
-- arg-macro: function GST_PAD_ACTIVATE_MODE (pad)
-- return GST_PAD_CAST(pad).mode;
-- arg-macro: function GST_PAD_ACTIVATEFUNC (pad)
-- return GST_PAD_CAST(pad).activatefunc;
-- arg-macro: function GST_PAD_ACTIVATEPUSHFUNC (pad)
-- return GST_PAD_CAST(pad).activatepushfunc;
-- arg-macro: function GST_PAD_ACTIVATEPULLFUNC (pad)
-- return GST_PAD_CAST(pad).activatepullfunc;
-- arg-macro: function GST_PAD_CHAINFUNC (pad)
-- return GST_PAD_CAST(pad).chainfunc;
-- arg-macro: function GST_PAD_CHECKGETRANGEFUNC (pad)
-- return GST_PAD_CAST(pad).checkgetrangefunc;
-- arg-macro: function GST_PAD_GETRANGEFUNC (pad)
-- return GST_PAD_CAST(pad).getrangefunc;
-- arg-macro: function GST_PAD_EVENTFUNC (pad)
-- return GST_PAD_CAST(pad).eventfunc;
-- arg-macro: function GST_PAD_QUERYTYPEFUNC (pad)
-- return GST_PAD_CAST(pad).querytypefunc;
-- arg-macro: function GST_PAD_QUERYFUNC (pad)
-- return GST_PAD_CAST(pad).queryfunc;
-- arg-macro: function GST_PAD_INTLINKFUNC (pad)
-- return GST_PAD_CAST(pad).intlinkfunc;
-- arg-macro: function GST_PAD_ITERINTLINKFUNC (pad)
-- return GST_PAD_CAST(pad).iterintlinkfunc;
-- arg-macro: function GST_PAD_PEER (pad)
-- return GST_PAD_CAST(pad).peer;
-- arg-macro: function GST_PAD_LINKFUNC (pad)
-- return GST_PAD_CAST(pad).linkfunc;
-- arg-macro: function GST_PAD_UNLINKFUNC (pad)
-- return GST_PAD_CAST(pad).unlinkfunc;
-- arg-macro: function GST_PAD_CAPS (pad)
-- return GST_PAD_CAST(pad).caps;
-- arg-macro: function GST_PAD_GETCAPSFUNC (pad)
-- return GST_PAD_CAST(pad).getcapsfunc;
-- arg-macro: function GST_PAD_SETCAPSFUNC (pad)
-- return GST_PAD_CAST(pad).setcapsfunc;
-- arg-macro: function GST_PAD_ACCEPTCAPSFUNC (pad)
-- return GST_PAD_CAST(pad).acceptcapsfunc;
-- arg-macro: function GST_PAD_FIXATECAPSFUNC (pad)
-- return GST_PAD_CAST(pad).fixatecapsfunc;
-- arg-macro: function GST_PAD_BUFFERALLOCFUNC (pad)
-- return GST_PAD_CAST(pad).bufferallocfunc;
-- arg-macro: function GST_PAD_DO_BUFFER_SIGNALS (pad)
-- return GST_PAD_CAST(pad).do_buffer_signals;
-- arg-macro: function GST_PAD_DO_EVENT_SIGNALS (pad)
-- return GST_PAD_CAST(pad).do_event_signals;
-- arg-macro: function GST_PAD_IS_LINKED (pad)
-- return GST_PAD_PEER(pad) /= NULL;
-- arg-macro: function GST_PAD_IS_BLOCKED (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKED);
-- arg-macro: function GST_PAD_IS_BLOCKING (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKING);
-- arg-macro: function GST_PAD_IS_FLUSHING (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLUSHING);
-- arg-macro: function GST_PAD_IS_IN_GETCAPS (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_GETCAPS);
-- arg-macro: function GST_PAD_IS_IN_SETCAPS (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_SETCAPS);
-- arg-macro: function GST_PAD_IS_SRC (pad)
-- return GST_PAD_DIRECTION(pad) = GST_PAD_SRC;
-- arg-macro: function GST_PAD_IS_SINK (pad)
-- return GST_PAD_DIRECTION(pad) = GST_PAD_SINK;
-- arg-macro: function GST_PAD_SET_FLUSHING (pad)
-- return GST_OBJECT_FLAG_SET (pad, GST_PAD_FLUSHING);
-- arg-macro: function GST_PAD_UNSET_FLUSHING (pad)
-- return GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLUSHING);
-- arg-macro: function GST_PAD_GET_STREAM_LOCK (pad)
-- return GST_PAD_CAST(pad).stream_rec_lock;
-- arg-macro: function GST_PAD_STREAM_LOCK (pad)
-- return g_static_rec_mutex_lock(GST_PAD_GET_STREAM_LOCK(pad));
-- arg-macro: function GST_PAD_STREAM_LOCK_FULL (pad, t)
-- return g_static_rec_mutex_lock_full(GST_PAD_GET_STREAM_LOCK(pad), t);
-- arg-macro: function GST_PAD_STREAM_TRYLOCK (pad)
-- return g_static_rec_mutex_trylock(GST_PAD_GET_STREAM_LOCK(pad));
-- arg-macro: function GST_PAD_STREAM_UNLOCK (pad)
-- return g_static_rec_mutex_unlock(GST_PAD_GET_STREAM_LOCK(pad));
-- arg-macro: function GST_PAD_STREAM_UNLOCK_FULL (pad)
-- return g_static_rec_mutex_unlock_full(GST_PAD_GET_STREAM_LOCK(pad));
-- arg-macro: function GST_PAD_GET_PREROLL_LOCK (pad)
-- return GST_PAD_CAST(pad).preroll_lock;
-- arg-macro: function GST_PAD_PREROLL_LOCK (pad)
-- return g_mutex_lock(GST_PAD_GET_PREROLL_LOCK(pad));
-- arg-macro: function GST_PAD_PREROLL_TRYLOCK (pad)
-- return g_mutex_trylock(GST_PAD_GET_PREROLL_LOCK(pad));
-- arg-macro: function GST_PAD_PREROLL_UNLOCK (pad)
-- return g_mutex_unlock(GST_PAD_GET_PREROLL_LOCK(pad));
-- arg-macro: function GST_PAD_GET_PREROLL_COND (pad)
-- return GST_PAD_CAST(pad).preroll_cond;
-- arg-macro: procedure GST_PAD_PREROLL_WAIT (pad)
-- g_cond_wait (GST_PAD_GET_PREROLL_COND (pad), GST_PAD_GET_PREROLL_LOCK (pad))
-- arg-macro: procedure GST_PAD_PREROLL_TIMED_WAIT (pad, timeval)
-- g_cond_timed_wait (GST_PAD_GET_PREROLL_COND (pad), GST_PAD_GET_PREROLL_LOCK (pad), timeval)
-- arg-macro: procedure GST_PAD_PREROLL_SIGNAL (pad)
-- g_cond_signal (GST_PAD_GET_PREROLL_COND (pad));
-- arg-macro: procedure GST_PAD_PREROLL_BROADCAST (pad)
-- g_cond_broadcast (GST_PAD_GET_PREROLL_COND (pad));
-- arg-macro: function GST_PAD_BLOCK_GET_COND (pad)
-- return GST_PAD_CAST(pad).block_cond;
-- arg-macro: function GST_PAD_BLOCK_WAIT (pad)
-- return g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_OBJECT_GET_LOCK (pad));
-- arg-macro: function GST_PAD_BLOCK_SIGNAL (pad)
-- return g_cond_signal(GST_PAD_BLOCK_GET_COND (pad));
-- arg-macro: function GST_PAD_BLOCK_BROADCAST (pad)
-- return g_cond_broadcast(GST_PAD_BLOCK_GET_COND (pad));
-- arg-macro: procedure gst_pad_get_name (pad)
-- gst_object_get_name (GST_OBJECT_CAST (pad))
-- arg-macro: procedure gst_pad_get_parent (pad)
-- gst_object_get_parent (GST_OBJECT_CAST (pad))
-- GStreamer
-- * Copyright (C) 1999,2000 <NAME> <<EMAIL>>
-- * 2000 <NAME> <<EMAIL>>
-- *
-- * gstpad.h: Header for GstPad object
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
-- * Pad base class
--
type GstPad;
type anon_200;
type anon_201 is record
block_callback_called : aliased GLIB.gboolean; -- gst/gstpad.h:739
priv : System.Address; -- gst/gstpad.h:740
end record;
pragma Convention (C_Pass_By_Copy, anon_201);
type u_GstPad_u_gst_reserved_array is array (0 .. 1) of System.Address;
type anon_200 (discr : unsigned := 0) is record
case discr is
when 0 =>
ABI : aliased anon_201; -- gst/gstpad.h:741
when others =>
u_gst_reserved : u_GstPad_u_gst_reserved_array; -- gst/gstpad.h:742
end case;
end record;
pragma Convention (C_Pass_By_Copy, anon_200);
pragma Unchecked_Union (anon_200);--subtype GstPad is u_GstPad; -- gst/gstpad.h:50
-- skipped empty struct u_GstPadPrivate
-- skipped empty struct GstPadPrivate
type GstPadClass;
type u_GstPadClass_u_gst_reserved_array is array (0 .. 3) of System.Address;
--subtype GstPadClass is u_GstPadClass; -- gst/gstpad.h:52
--*
-- * GstPadLinkReturn:
-- * @GST_PAD_LINK_OK : link succeeded
-- * @GST_PAD_LINK_WRONG_HIERARCHY: pads have no common grandparent
-- * @GST_PAD_LINK_WAS_LINKED : pad was already linked
-- * @GST_PAD_LINK_WRONG_DIRECTION: pads have wrong direction
-- * @GST_PAD_LINK_NOFORMAT : pads do not have common format
-- * @GST_PAD_LINK_NOSCHED : pads cannot cooperate in scheduling
-- * @GST_PAD_LINK_REFUSED : refused for some reason
-- *
-- * Result values from gst_pad_link and friends.
--
subtype GstPadLinkReturn is int;
GST_PAD_LINK_OK : constant GstPadLinkReturn := 0;
GST_PAD_LINK_WRONG_HIERARCHY : constant GstPadLinkReturn := -1;
GST_PAD_LINK_WAS_LINKED : constant GstPadLinkReturn := -2;
GST_PAD_LINK_WRONG_DIRECTION : constant GstPadLinkReturn := -3;
GST_PAD_LINK_NOFORMAT : constant GstPadLinkReturn := -4;
GST_PAD_LINK_NOSCHED : constant GstPadLinkReturn := -5;
GST_PAD_LINK_REFUSED : constant GstPadLinkReturn := -6; -- gst/gstpad.h:74
--*
-- * GST_PAD_LINK_FAILED:
-- * @ret: the #GstPadLinkReturn value
-- *
-- * Macro to test if the given #GstPadLinkReturn value indicates a failed
-- * link step.
--
--*
-- * GST_PAD_LINK_SUCCESSFUL:
-- * @ret: the #GstPadLinkReturn value
-- *
-- * Macro to test if the given #GstPadLinkReturn value indicates a successful
-- * link step.
--
--*
-- * GstFlowReturn:
-- * @GST_FLOW_RESEND: Resend buffer, possibly with new caps (not
-- * sent yet) (unused/unimplemented).
-- * @GST_FLOW_OK: Data passing was ok.
-- * @GST_FLOW_NOT_LINKED: Pad is not linked.
-- * @GST_FLOW_WRONG_STATE: Pad is in wrong state.
-- * @GST_FLOW_UNEXPECTED: Did not expect anything, like after EOS.
-- * @GST_FLOW_NOT_NEGOTIATED: Pad is not negotiated.
-- * @GST_FLOW_ERROR: Some (fatal) error occured. Element generating
-- * this error should post an error message with more
-- * details.
-- * @GST_FLOW_NOT_SUPPORTED: This operation is not supported.
-- * @GST_FLOW_CUSTOM_SUCCESS: Elements can use values starting from
-- * this (and higher) to define custom success
-- * codes. Since 0.10.7.
-- * @GST_FLOW_CUSTOM_SUCCESS_1: Pre-defined custom success code (define your
-- * custom success code to this to avoid compiler
-- * warnings). Since 0.10.29.
-- * @GST_FLOW_CUSTOM_SUCCESS_2: Pre-defined custom success code. Since 0.10.29.
-- * @GST_FLOW_CUSTOM_ERROR: Elements can use values starting from
-- * this (and lower) to define custom error codes.
-- * Since 0.10.7.
-- * @GST_FLOW_CUSTOM_ERROR_1: Pre-defined custom error code (define your
-- * custom error code to this to avoid compiler
-- * warnings). Since 0.10.29.
-- * @GST_FLOW_CUSTOM_ERROR_2: Pre-defined custom error code. Since 0.10.29.
-- *
-- * The result of passing data to a pad.
-- *
-- * Note that the custom return values should not be exposed outside of the
-- * element scope and are available since 0.10.7.
--
-- FIXME 0.11: remove custom flow returns
-- custom success starts here
-- core predefined
-- expected failures
-- error cases
-- custom error starts here
subtype GstFlowReturn is int;
GST_FLOW_CUSTOM_SUCCESS_2 : constant GstFlowReturn := 102;
GST_FLOW_CUSTOM_SUCCESS_1 : constant GstFlowReturn := 101;
GST_FLOW_CUSTOM_SUCCESS : constant GstFlowReturn := 100;
GST_FLOW_RESEND : constant GstFlowReturn := 1;
GST_FLOW_OK : constant GstFlowReturn := 0;
GST_FLOW_NOT_LINKED : constant GstFlowReturn := -1;
GST_FLOW_WRONG_STATE : constant GstFlowReturn := -2;
GST_FLOW_UNEXPECTED : constant GstFlowReturn := -3;
GST_FLOW_NOT_NEGOTIATED : constant GstFlowReturn := -4;
GST_FLOW_ERROR : constant GstFlowReturn := -5;
GST_FLOW_NOT_SUPPORTED : constant GstFlowReturn := -6;
GST_FLOW_CUSTOM_ERROR : constant GstFlowReturn := -100;
GST_FLOW_CUSTOM_ERROR_1 : constant GstFlowReturn := -101;
GST_FLOW_CUSTOM_ERROR_2 : constant GstFlowReturn := -102; -- gst/gstpad.h:150
--*
-- * GST_FLOW_IS_FATAL:
-- * @ret: a #GstFlowReturn value
-- *
-- * Macro to test if the given #GstFlowReturn value indicates a fatal
-- * error. This macro is mainly used in elements driving the pipeline to decide
-- * whether an error message should be posted on the bus. Note that such
-- * elements may also need to post an error message in the #GST_FLOW_NOT_LINKED
-- * case which is not caught by this macro.
-- *
-- * Deprecated: This macro is badly named and can't be used in any real
-- * scenarios without additional checks.
--
--*
-- * GST_FLOW_IS_SUCCESS:
-- * @ret: a #GstFlowReturn value
-- *
-- * Macro to test if the given #GstFlowReturn value indicates a
-- * successful result
-- * This macro is mainly used in elements to decide if the processing
-- * of a buffer was successful.
-- *
-- * Since: 0.10.7
-- *
-- * Deprecated: This macro is badly named and can't be used in any real
-- * scenarios without additional checks.
--
function gst_flow_get_name (ret : GstFlowReturn) return access GLIB.gchar; -- gst/gstpad.h:187
pragma Import (C, gst_flow_get_name, "gst_flow_get_name");
function gst_flow_to_quark (ret : GstFlowReturn) return Glib.GQuark; -- gst/gstpad.h:188
pragma Import (C, gst_flow_to_quark, "gst_flow_to_quark");
--*
-- * GstPadLinkCheck:
-- * @GST_PAD_LINK_CHECK_NOTHING: Don't check hierarchy or caps compatibility.
-- * @GST_PAD_LINK_CHECK_HIERARCHY: Check the pads have same parents/grandparents.
-- * Could be omitted if it is already known that the two elements that own the
-- * pads are in the same bin.
-- * @GST_PAD_LINK_CHECK_TEMPLATE_CAPS: Check if the pads are compatible by using
-- * their template caps. This is much faster than @GST_PAD_LINK_CHECK_CAPS, but
-- * would be unsafe e.g. if one pad has %GST_CAPS_ANY.
-- * @GST_PAD_LINK_CHECK_CAPS: Check if the pads are compatible by comparing the
-- * caps returned by gst_pad_get_caps().
-- *
-- * The amount of checking to be done when linking pads. @GST_PAD_LINK_CHECK_CAPS
-- * and @GST_PAD_LINK_CHECK_TEMPLATE_CAPS are mutually exclusive. If both are
-- * specified, expensive but safe @GST_PAD_LINK_CHECK_CAPS are performed.
-- *
-- * <warning><para>
-- * Only disable some of the checks if you are 100% certain you know the link
-- * will not fail because of hierarchy/caps compatibility failures. If uncertain,
-- * use the default checks (%GST_PAD_LINK_CHECK_DEFAULT) or the regular methods
-- * for linking the pads.
-- * </para></warning>
-- *
-- * Since: 0.10.30
--
subtype GstPadLinkCheck is unsigned;
GST_PAD_LINK_CHECK_NOTHING : constant GstPadLinkCheck := 0;
GST_PAD_LINK_CHECK_HIERARCHY : constant GstPadLinkCheck := 1;
GST_PAD_LINK_CHECK_TEMPLATE_CAPS : constant GstPadLinkCheck := 2;
GST_PAD_LINK_CHECK_CAPS : constant GstPadLinkCheck := 4; -- gst/gstpad.h:221
--*
-- * GST_PAD_LINK_CHECK_DEFAULT:
-- *
-- * The default checks done when linking pads (i.e. the ones used by
-- * gst_pad_link()).
-- *
-- * Since: 0.10.30
--
--*
-- * GstActivateMode:
-- * @GST_ACTIVATE_NONE: Pad will not handle dataflow
-- * @GST_ACTIVATE_PUSH: Pad handles dataflow in downstream push mode
-- * @GST_ACTIVATE_PULL: Pad handles dataflow in upstream pull mode
-- *
-- * The status of a GstPad. After activating a pad, which usually happens when the
-- * parent element goes from READY to PAUSED, the GstActivateMode defines if the
-- * pad operates in push or pull mode.
--
type GstActivateMode is
(GST_ACTIVATE_NONE,
GST_ACTIVATE_PUSH,
GST_ACTIVATE_PULL);
pragma Convention (C, GstActivateMode); -- gst/gstpad.h:247
--*
-- * GST_PAD_MODE_ACTIVATE:
-- * @mode: a #GstActivateMode
-- *
-- * Macro to test if the given #GstActivateMode value indicates that datapassing
-- * is possible or not.
--
-- pad states
--*
-- * GstPadActivateFunction:
-- * @pad: a #GstPad
-- *
-- * This function is called when the pad is activated during the element
-- * READY to PAUSED state change. By default this function will call the
-- * activate function that puts the pad in push mode but elements can
-- * override this function to activate the pad in pull mode if they wish.
-- *
-- * Returns: TRUE if the pad could be activated.
--
type GstPadActivateFunction is access function (arg1 : access GstPad) return GLIB.gboolean;
pragma Convention (C, GstPadActivateFunction); -- gst/gstpad.h:270
--*
-- * GstPadActivateModeFunction:
-- * @pad: a #GstPad
-- * @active: activate or deactivate the pad.
-- *
-- * The prototype of the push and pull activate functions.
-- *
-- * Returns: TRUE if the pad could be activated or deactivated.
--
type GstPadActivateModeFunction is access function (arg1 : access GstPad; arg2 : GLIB.gboolean) return GLIB.gboolean;
pragma Convention (C, GstPadActivateModeFunction); -- gst/gstpad.h:280
-- data passing
--*
-- * GstPadChainFunction:
-- * @pad: the sink #GstPad that performed the chain.
-- * @buffer: the #GstBuffer that is chained, not %NULL.
-- *
-- * A function that will be called on sinkpads when chaining buffers.
-- * The function typically processes the data contained in the buffer and
-- * either consumes the data or passes it on to the internally linked pad(s).
-- *
-- * The implementer of this function receives a refcount to @buffer and should
-- * gst_buffer_unref() when the buffer is no longer needed.
-- *
-- * When a chain function detects an error in the data stream, it must post an
-- * error on the bus and return an appropriate #GstFlowReturn value.
-- *
-- * Returns: #GST_FLOW_OK for success
--
type GstPadChainFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GstFlowReturn;
pragma Convention (C, GstPadChainFunction); -- gst/gstpad.h:301
--*
-- * GstPadChainListFunction:
-- * @pad: the sink #GstPad that performed the chain.
-- * @list: the #GstBufferList that is chained, not %NULL.
-- *
-- * A function that will be called on sinkpads when chaining buffer lists.
-- * The function typically processes the data contained in the buffer list and
-- * either consumes the data or passes it on to the internally linked pad(s).
-- *
-- * The implementer of this function receives a refcount to @list and
-- * should gst_buffer_list_unref() when the list is no longer needed.
-- *
-- * When a chainlist function detects an error in the data stream, it must
-- * post an error on the bus and return an appropriate #GstFlowReturn value.
-- *
-- * Returns: #GST_FLOW_OK for success
--
type GstPadChainListFunction is access function (arg1 : access GstPad; arg2 : System.Address) return GstFlowReturn;
pragma Convention (C, GstPadChainListFunction); -- gst/gstpad.h:320
--*
-- * GstPadGetRangeFunction:
-- * @pad: the src #GstPad to perform the getrange on.
-- * @offset: the offset of the range
-- * @length: the length of the range
-- * @buffer: a memory location to hold the result buffer, cannot be NULL.
-- *
-- * This function will be called on source pads when a peer element
-- * request a buffer at the specified @offset and @length. If this function
-- * returns #GST_FLOW_OK, the result buffer will be stored in @buffer. The
-- * contents of @buffer is invalid for any other return value.
-- *
-- * This function is installed on a source pad with
-- * gst_pad_set_getrange_function() and can only be called on source pads after
-- * they are successfully activated with gst_pad_activate_pull().
-- *
-- * @offset and @length are always given in byte units. @offset must normally be a value
-- * between 0 and the length in bytes of the data available on @pad. The
-- * length (duration in bytes) can be retrieved with a #GST_QUERY_DURATION or with a
-- * #GST_QUERY_SEEKING.
-- *
-- * Any @offset larger or equal than the length will make the function return
-- * #GST_FLOW_UNEXPECTED, which corresponds to EOS. In this case @buffer does not
-- * contain a valid buffer.
-- *
-- * The buffer size of @buffer will only be smaller than @length when @offset is
-- * near the end of the stream. In all other cases, the size of @buffer must be
-- * exactly the requested size.
-- *
-- * It is allowed to call this function with a 0 @length and valid @offset, in
-- * which case @buffer will contain a 0-sized buffer and the function returns
-- * #GST_FLOW_OK.
-- *
-- * When this function is called with a -1 @offset, the sequentially next buffer
-- * of length @length in the stream is returned.
-- *
-- * When this function is called with a -1 @length, a buffer with a default
-- * optimal length is returned in @buffer. The length might depend on the value
-- * of @offset.
-- *
-- * Returns: #GST_FLOW_OK for success and a valid buffer in @buffer. Any other
-- * return value leaves @buffer undefined.
--
type GstPadGetRangeFunction is access function
(arg1 : access GstPad;
arg2 : GLIB.guint64;
arg3 : GLIB.guint;
arg4 : System.Address) return GstFlowReturn;
pragma Convention (C, GstPadGetRangeFunction); -- gst/gstpad.h:365
--*
-- * GstPadEventFunction:
-- * @pad: the #GstPad to handle the event.
-- * @event: the #GstEvent to handle.
-- *
-- * Function signature to handle an event for the pad.
-- *
-- * Returns: TRUE if the pad could handle the event.
--
type GstPadEventFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean;
pragma Convention (C, GstPadEventFunction); -- gst/gstpad.h:377
-- FIXME: 0.11: deprecate me, check range should use seeking query
--*
-- * GstPadCheckGetRangeFunction:
-- * @pad: a #GstPad
-- *
-- * Check if @pad can be activated in pull mode.
-- *
-- * This function will be deprecated after 0.10; use the seeking query to check
-- * if a pad can support random access.
-- *
-- * Returns: TRUE if the pad can operate in pull mode.
--
type GstPadCheckGetRangeFunction is access function (arg1 : access GstPad) return GLIB.gboolean;
pragma Convention (C, GstPadCheckGetRangeFunction); -- gst/gstpad.h:392
-- internal links
--*
-- * GstPadIntLinkFunction:
-- * @pad: The #GstPad to query.
-- *
-- * The signature of the internal pad link function.
-- *
-- * Returns: (element-type Gst.Pad) (transfer container): a newly allocated #GList of pads that are linked to the given pad on
-- * the inside of the parent element.
-- *
-- * The caller must call g_list_free() on it after use.
-- *
-- * Deprecated: use the threadsafe #GstPadIterIntLinkFunction instead.
--
type GstPadIntLinkFunction is access function (arg1 : access GstPad) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList;
pragma Convention (C, GstPadIntLinkFunction); -- gst/gstpad.h:409
--*
-- * GstPadIterIntLinkFunction:
-- * @pad: The #GstPad to query.
-- *
-- * The signature of the internal pad link iterator function.
-- *
-- * Returns: a new #GstIterator that will iterate over all pads that are
-- * linked to the given pad on the inside of the parent element.
-- *
-- * the caller must call gst_iterator_free() after usage.
-- *
-- * Since 0.10.21
--
type GstPadIterIntLinkFunction is access function (arg1 : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator;
pragma Convention (C, GstPadIterIntLinkFunction); -- gst/gstpad.h:426
-- generic query function
--*
-- * GstPadQueryTypeFunction:
-- * @pad: a #GstPad to query
-- *
-- * The signature of the query types function.
-- *
-- * Returns: a constant array of query types
--
type GstPadQueryTypeFunction is access function (arg1 : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQueryType;
pragma Convention (C, GstPadQueryTypeFunction); -- gst/gstpad.h:437
--*
-- * GstPadQueryFunction:
-- * @pad: the #GstPad to query.
-- * @query: the #GstQuery object to execute
-- *
-- * The signature of the query function.
-- *
-- * Returns: TRUE if the query could be performed.
--
type GstPadQueryFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean;
pragma Convention (C, GstPadQueryFunction); -- gst/gstpad.h:448
-- linking
--*
-- * GstPadLinkFunction
-- * @pad: the #GstPad that is linked.
-- * @peer: the peer #GstPad of the link
-- *
-- * Function signature to handle a new link on the pad.
-- *
-- * Returns: the result of the link with the specified peer.
--
type GstPadLinkFunction is access function (arg1 : access GstPad; arg2 : access GstPad) return GstPadLinkReturn;
pragma Convention (C, GstPadLinkFunction); -- gst/gstpad.h:461
--*
-- * GstPadUnlinkFunction
-- * @pad: the #GstPad that is linked.
-- *
-- * Function signature to handle a unlinking the pad prom its peer.
--
type GstPadUnlinkFunction is access procedure (arg1 : access GstPad);
pragma Convention (C, GstPadUnlinkFunction); -- gst/gstpad.h:468
-- caps nego
--*
-- * GstPadGetCapsFunction:
-- * @pad: the #GstPad to get the capabilities of.
-- *
-- * Returns a copy of the capabilities of the specified pad. By default this
-- * function will return the pad template capabilities, but can optionally
-- * be overridden by elements.
-- *
-- * Returns: a newly allocated copy #GstCaps of the pad.
--
type GstPadGetCapsFunction is access function (arg1 : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
pragma Convention (C, GstPadGetCapsFunction); -- gst/gstpad.h:482
--*
-- * GstPadSetCapsFunction:
-- * @pad: the #GstPad to set the capabilities of.
-- * @caps: the #GstCaps to set
-- *
-- * Set @caps on @pad. By default this function updates the caps of the
-- * pad but the function can be overriden by elements to perform extra
-- * actions or verifications.
-- *
-- * Returns: TRUE if the caps could be set on the pad.
--
type GstPadSetCapsFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean;
pragma Convention (C, GstPadSetCapsFunction); -- gst/gstpad.h:495
--*
-- * GstPadAcceptCapsFunction:
-- * @pad: the #GstPad to check
-- * @caps: the #GstCaps to check
-- *
-- * Check if @pad can accept @caps. By default this function will see if @caps
-- * intersect with the result from gst_pad_get_caps() by can be overridden to
-- * perform extra checks.
-- *
-- * Returns: TRUE if the caps can be accepted by the pad.
--
type GstPadAcceptCapsFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean;
pragma Convention (C, GstPadAcceptCapsFunction); -- gst/gstpad.h:507
--*
-- * GstPadFixateCapsFunction:
-- * @pad: a #GstPad
-- * @caps: the #GstCaps to fixate
-- *
-- * Given possibly unfixed caps @caps, let @pad use its default preferred
-- * format to make a fixed caps. @caps should be writable. By default this
-- * function will pick the first value of any ranges or lists in the caps but
-- * elements can override this function to perform other behaviour.
--
type GstPadFixateCapsFunction is access procedure (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps);
pragma Convention (C, GstPadFixateCapsFunction); -- gst/gstpad.h:518
--*
-- * GstPadBufferAllocFunction:
-- * @pad: a sink #GstPad
-- * @offset: the desired offset of the buffer
-- * @size: the desired size of the buffer
-- * @caps: the desired caps of the buffer
-- * @buf: pointer to hold the allocated buffer.
-- *
-- * Ask the sinkpad @pad to allocate a buffer with @offset, @size and @caps.
-- * The result will be stored in @buf.
-- *
-- * The purpose of this function is to allocate a buffer that is optimal to
-- * be processed by @pad. The function is mostly overridden by elements that can
-- * provide a hardware buffer in order to avoid additional memcpy operations.
-- *
-- * The function can return a buffer that has caps different from the requested
-- * @caps, in which case the upstream element requests a format change to this
-- * new caps.
-- * If a format change was requested, the returned buffer will be one to hold
-- * the data of said new caps, so its size might be different from the requested
-- * @size.
-- *
-- * When this function returns anything else than #GST_FLOW_OK, the buffer allocation
-- * failed and @buf does not contain valid data. If the function returns #GST_FLOW_OK and
-- * the @buf is NULL, a #GstBuffer will be created with @caps, @offset and @size.
-- *
-- * By default this function returns a new buffer of @size and with @caps containing
-- * purely malloced data. The buffer should be freed with gst_buffer_unref()
-- * after usage.
-- *
-- * Returns: #GST_FLOW_OK if @buf contains a valid buffer, any other return
-- * value means @buf does not hold a valid buffer.
--
type GstPadBufferAllocFunction is access function
(arg1 : access GstPad;
arg2 : GLIB.guint64;
arg3 : GLIB.guint;
arg4 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
arg5 : System.Address) return GstFlowReturn;
pragma Convention (C, GstPadBufferAllocFunction); -- gst/gstpad.h:552
-- misc
--*
-- * GstPadDispatcherFunction:
-- * @pad: the #GstPad that is dispatched.
-- * @data: the gpointer to optional user data.
-- *
-- * A dispatcher function is called for all internally linked pads, see
-- * gst_pad_dispatcher().
-- *
-- * Returns: TRUE if the dispatching procedure has to be stopped.
--
type GstPadDispatcherFunction is access function (arg1 : access GstPad; arg2 : System.Address) return GLIB.gboolean;
pragma Convention (C, GstPadDispatcherFunction); -- gst/gstpad.h:566
--*
-- * GstPadBlockCallback:
-- * @pad: the #GstPad that is blockend or unblocked.
-- * @blocked: blocking state for the pad
-- * @user_data: the gpointer to optional user data.
-- *
-- * Callback used by gst_pad_set_blocked_async(). Gets called when the blocking
-- * operation succeeds.
--
type GstPadBlockCallback is access procedure
(arg1 : access GstPad;
arg2 : GLIB.gboolean;
arg3 : System.Address);
pragma Convention (C, GstPadBlockCallback); -- gst/gstpad.h:577
--*
-- * GstPadDirection:
-- * @GST_PAD_UNKNOWN: direction is unknown.
-- * @GST_PAD_SRC: the pad is a source pad.
-- * @GST_PAD_SINK: the pad is a sink pad.
-- *
-- * The direction of a pad.
--
type GstPadDirection is
(GST_PAD_UNKNOWN,
GST_PAD_SRC,
GST_PAD_SINK);
pragma Convention (C, GstPadDirection); -- gst/gstpad.h:591
--*
-- * GstPadFlags:
-- * @GST_PAD_BLOCKED: is dataflow on a pad blocked
-- * @GST_PAD_FLUSHING: is pad refusing buffers
-- * @GST_PAD_IN_GETCAPS: GstPadGetCapsFunction() is running now
-- * @GST_PAD_IN_SETCAPS: GstPadSetCapsFunction() is running now
-- * @GST_PAD_BLOCKING: is pad currently blocking on a buffer or event
-- * @GST_PAD_FLAG_LAST: offset to define more flags
-- *
-- * Pad state flags
--
-- padding
type GstPadFlags is new unsigned;
GST_PAD_BLOCKED : constant GstPadFlags := 16;
GST_PAD_FLUSHING : constant GstPadFlags := 32;
GST_PAD_IN_GETCAPS : constant GstPadFlags := 64;
GST_PAD_IN_SETCAPS : constant GstPadFlags := 128;
GST_PAD_BLOCKING : constant GstPadFlags := 256;
GST_PAD_FLAG_LAST : constant GstPadFlags := 4096; -- gst/gstpad.h:612
-- FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h)
-- subtype GstPadTemplate is GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate -- gst/gstpad.h:615
--*
-- * GstPad:
-- * @element_private: private data owned by the parent element
-- * @padtemplate: padtemplate for this pad
-- * @direction: the direction of the pad, cannot change after creating
-- * the pad.
-- * @stream_rec_lock: recursive stream lock of the pad, used to protect
-- * the data used in streaming.
-- * @task: task for this pad if the pad is actively driving dataflow.
-- * @preroll_lock: lock used when prerolling
-- * @preroll_cond: conf to signal preroll
-- * @block_cond: conditional to signal pad block
-- * @block_callback: callback for the pad block if any
-- * @block_data: user data for @block_callback
-- * @caps: the current caps of the pad
-- * @getcapsfunc: function to get caps of the pad
-- * @setcapsfunc: function to set caps on the pad
-- * @acceptcapsfunc: function to check if pad can accept caps
-- * @fixatecapsfunc: function to fixate caps
-- * @activatefunc: pad activation function
-- * @activatepushfunc: function to activate/deactivate pad in push mode
-- * @activatepullfunc: function to activate/deactivate pad in pull mode
-- * @linkfunc: function called when pad is linked
-- * @unlinkfunc: function called when pad is unlinked
-- * @peer: the pad this pad is linked to
-- * @sched_private: private storage for the scheduler
-- * @chainfunc: function to chain buffer to pad
-- * @checkgetrangefunc: function to check if pad can operate in pull mode
-- * @getrangefunc: function to get a range of data from a pad
-- * @eventfunc: function to send an event to a pad
-- * @mode: current activation mode of the pad
-- * @querytypefunc: get list of supported queries
-- * @queryfunc: perform a query on the pad
-- * @intlinkfunc: get the internal links of this pad
-- * @bufferallocfunc: function to allocate a buffer for this pad
-- * @do_buffer_signals: counter counting installed buffer signals
-- * @do_event_signals: counter counting installed event signals
-- * @iterintlinkfunc: get the internal links iterator of this pad
-- * @block_destroy_data: notify function for gst_pad_set_blocked_async_full()
-- *
-- * The #GstPad structure. Use the functions to update the variables.
--
type GstPad is record
object : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObject; -- gst/gstpad.h:660
element_private : System.Address; -- gst/gstpad.h:663
padtemplate : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; -- gst/gstpad.h:665
direction : aliased GstPadDirection; -- gst/gstpad.h:667
stream_rec_lock : access GStreamer.GST_Low_Level.glib_2_0_glib_deprecated_gthread_h.GStaticRecMutex; -- gst/gstpad.h:671
c_task : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttask_h.GstTask; -- gst/gstpad.h:672
preroll_lock : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GMutex; -- gst/gstpad.h:674
preroll_cond : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GCond; -- gst/gstpad.h:675
block_cond : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GCond; -- gst/gstpad.h:679
block_callback : GstPadBlockCallback; -- gst/gstpad.h:680
block_data : System.Address; -- gst/gstpad.h:681
caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:684
getcapsfunc : GstPadGetCapsFunction; -- gst/gstpad.h:685
setcapsfunc : GstPadSetCapsFunction; -- gst/gstpad.h:686
acceptcapsfunc : GstPadAcceptCapsFunction; -- gst/gstpad.h:687
fixatecapsfunc : GstPadFixateCapsFunction; -- gst/gstpad.h:688
activatefunc : GstPadActivateFunction; -- gst/gstpad.h:690
activatepushfunc : GstPadActivateModeFunction; -- gst/gstpad.h:691
activatepullfunc : GstPadActivateModeFunction; -- gst/gstpad.h:692
linkfunc : GstPadLinkFunction; -- gst/gstpad.h:695
unlinkfunc : GstPadUnlinkFunction; -- gst/gstpad.h:696
peer : access GstPad; -- gst/gstpad.h:697
sched_private : System.Address; -- gst/gstpad.h:699
chainfunc : GstPadChainFunction; -- gst/gstpad.h:702
checkgetrangefunc : GstPadCheckGetRangeFunction; -- gst/gstpad.h:703
getrangefunc : GstPadGetRangeFunction; -- gst/gstpad.h:704
eventfunc : GstPadEventFunction; -- gst/gstpad.h:705
mode : aliased GstActivateMode; -- gst/gstpad.h:707
querytypefunc : GstPadQueryTypeFunction; -- gst/gstpad.h:710
queryfunc : GstPadQueryFunction; -- gst/gstpad.h:711
intlinkfunc : GstPadIntLinkFunction; -- gst/gstpad.h:715
bufferallocfunc : GstPadBufferAllocFunction; -- gst/gstpad.h:722
do_buffer_signals : aliased GLIB.gint; -- gst/gstpad.h:726
do_event_signals : aliased GLIB.gint; -- gst/gstpad.h:727
iterintlinkfunc : GstPadIterIntLinkFunction; -- gst/gstpad.h:731
block_destroy_data : GStreamer.GST_Low_Level.glib_2_0_glib_gtypes_h.GDestroyNotify; -- gst/gstpad.h:734
abidata : aliased anon_200; -- gst/gstpad.h:743
end record;
pragma Convention (C_Pass_By_Copy, GstPad); -- gst/gstpad.h:659
--< public >
--< public >
-- with STREAM_LOCK
-- streaming rec_lock
--< public >
-- with PREROLL_LOCK
--< public >
-- with LOCK
-- block cond, mutex is from the object
-- the pad capabilities
-- pad link
-- data transport functions
-- generic query method
-- internal links
-- whether to emit signals for have-data. counts number
-- * of handlers attached.
-- ABI added
-- iterate internal links
-- free block_data
--< private >
type GstPadClass is record
parent_class : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObjectClass; -- gst/gstpad.h:747
linked : access procedure (arg1 : access GstPad; arg2 : access GstPad); -- gst/gstpad.h:750
unlinked : access procedure (arg1 : access GstPad; arg2 : access GstPad); -- gst/gstpad.h:751
request_link : access procedure (arg1 : access GstPad); -- gst/gstpad.h:752
have_data : access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstminiobject_h.GstMiniObject) return GLIB.gboolean; -- gst/gstpad.h:753
u_gst_reserved : u_GstPadClass_u_gst_reserved_array; -- gst/gstpad.h:756
end record;
pragma Convention (C_Pass_By_Copy, GstPadClass); -- gst/gstpad.h:746
-- signal callbacks
--< private >
--**** helper macros ****
-- GstPad
--*
-- * GST_PAD_CAPS:
-- * @pad: a #GstPad.
-- *
-- * The caps for this pad.
--
--*
-- * GST_PAD_GET_STREAM_LOCK:
-- * @pad: a #GstPad
-- *
-- * Get the stream lock of @pad. The stream lock is protecting the
-- * resources used in the data processing functions of @pad.
--
--*
-- * GST_PAD_STREAM_LOCK:
-- * @pad: a #GstPad
-- *
-- * Lock the stream lock of @pad.
--
--*
-- * GST_PAD_STREAM_LOCK_FULL:
-- * @pad: a #GstPad
-- * @t: the number of times to recursively lock
-- *
-- * Lock the stream lock of @pad @t times.
--
--*
-- * GST_PAD_STREAM_TRYLOCK:
-- * @pad: a #GstPad
-- *
-- * Try to Lock the stream lock of the pad, return TRUE if the lock could be
-- * taken.
--
--*
-- * GST_PAD_STREAM_UNLOCK:
-- * @pad: a #GstPad
-- *
-- * Unlock the stream lock of @pad.
--
--*
-- * GST_PAD_STREAM_UNLOCK_FULL:
-- * @pad: a #GstPad
-- *
-- * Fully unlock the recursive stream lock of @pad, return the number of times
-- * @pad was locked.
--
-- FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h)
function gst_pad_get_type return GLIB.GType; -- gst/gstpad.h:885
pragma Import (C, gst_pad_get_type, "gst_pad_get_type");
-- creating pads
function gst_pad_new (name : access GLIB.gchar; direction : GstPadDirection) return access GstPad; -- gst/gstpad.h:888
pragma Import (C, gst_pad_new, "gst_pad_new");
function gst_pad_new_from_template (templ : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; name : access GLIB.gchar) return access GstPad; -- gst/gstpad.h:889
pragma Import (C, gst_pad_new_from_template, "gst_pad_new_from_template");
function gst_pad_new_from_static_template (templ : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstStaticPadTemplate; name : access GLIB.gchar) return access GstPad; -- gst/gstpad.h:890
pragma Import (C, gst_pad_new_from_static_template, "gst_pad_new_from_static_template");
--*
-- * gst_pad_get_name:
-- * @pad: the pad to get the name from
-- *
-- * Get a copy of the name of the pad. g_free() after usage.
-- *
-- * MT safe.
--
--*
-- * gst_pad_get_parent:
-- * @pad: the pad to get the parent of
-- *
-- * Get the parent of @pad. This function increases the refcount
-- * of the parent object so you should gst_object_unref() it after usage.
-- * Can return NULL if the pad did not have a parent.
-- *
-- * MT safe.
--
function gst_pad_get_direction (pad : access GstPad) return GstPadDirection; -- gst/gstpad.h:914
pragma Import (C, gst_pad_get_direction, "gst_pad_get_direction");
function gst_pad_set_active (pad : access GstPad; active : GLIB.gboolean) return GLIB.gboolean; -- gst/gstpad.h:916
pragma Import (C, gst_pad_set_active, "gst_pad_set_active");
function gst_pad_is_active (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:917
pragma Import (C, gst_pad_is_active, "gst_pad_is_active");
function gst_pad_activate_pull (pad : access GstPad; active : GLIB.gboolean) return GLIB.gboolean; -- gst/gstpad.h:918
pragma Import (C, gst_pad_activate_pull, "gst_pad_activate_pull");
function gst_pad_activate_push (pad : access GstPad; active : GLIB.gboolean) return GLIB.gboolean; -- gst/gstpad.h:919
pragma Import (C, gst_pad_activate_push, "gst_pad_activate_push");
function gst_pad_set_blocked (pad : access GstPad; blocked : GLIB.gboolean) return GLIB.gboolean; -- gst/gstpad.h:921
pragma Import (C, gst_pad_set_blocked, "gst_pad_set_blocked");
function gst_pad_set_blocked_async
(pad : access GstPad;
blocked : GLIB.gboolean;
callback : GstPadBlockCallback;
user_data : System.Address) return GLIB.gboolean; -- gst/gstpad.h:922
pragma Import (C, gst_pad_set_blocked_async, "gst_pad_set_blocked_async");
function gst_pad_set_blocked_async_full
(pad : access GstPad;
blocked : GLIB.gboolean;
callback : GstPadBlockCallback;
user_data : System.Address;
destroy_data : GStreamer.GST_Low_Level.glib_2_0_glib_gtypes_h.GDestroyNotify) return GLIB.gboolean; -- gst/gstpad.h:924
pragma Import (C, gst_pad_set_blocked_async_full, "gst_pad_set_blocked_async_full");
function gst_pad_is_blocked (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:927
pragma Import (C, gst_pad_is_blocked, "gst_pad_is_blocked");
function gst_pad_is_blocking (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:928
pragma Import (C, gst_pad_is_blocking, "gst_pad_is_blocking");
procedure gst_pad_set_element_private (pad : access GstPad; priv : System.Address); -- gst/gstpad.h:930
pragma Import (C, gst_pad_set_element_private, "gst_pad_set_element_private");
function gst_pad_get_element_private (pad : access GstPad) return System.Address; -- gst/gstpad.h:931
pragma Import (C, gst_pad_get_element_private, "gst_pad_get_element_private");
function gst_pad_get_pad_template (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; -- gst/gstpad.h:933
pragma Import (C, gst_pad_get_pad_template, "gst_pad_get_pad_template");
procedure gst_pad_set_bufferalloc_function (pad : access GstPad; bufalloc : GstPadBufferAllocFunction); -- gst/gstpad.h:935
pragma Import (C, gst_pad_set_bufferalloc_function, "gst_pad_set_bufferalloc_function");
function gst_pad_alloc_buffer
(pad : access GstPad;
offset : GLIB.guint64;
size : GLIB.gint;
caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
buf : System.Address) return GstFlowReturn; -- gst/gstpad.h:936
pragma Import (C, gst_pad_alloc_buffer, "gst_pad_alloc_buffer");
function gst_pad_alloc_buffer_and_set_caps
(pad : access GstPad;
offset : GLIB.guint64;
size : GLIB.gint;
caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
buf : System.Address) return GstFlowReturn; -- gst/gstpad.h:938
pragma Import (C, gst_pad_alloc_buffer_and_set_caps, "gst_pad_alloc_buffer_and_set_caps");
-- data passing setup functions
procedure gst_pad_set_activate_function (pad : access GstPad; activate : GstPadActivateFunction); -- gst/gstpad.h:942
pragma Import (C, gst_pad_set_activate_function, "gst_pad_set_activate_function");
procedure gst_pad_set_activatepull_function (pad : access GstPad; activatepull : GstPadActivateModeFunction); -- gst/gstpad.h:943
pragma Import (C, gst_pad_set_activatepull_function, "gst_pad_set_activatepull_function");
procedure gst_pad_set_activatepush_function (pad : access GstPad; activatepush : GstPadActivateModeFunction); -- gst/gstpad.h:944
pragma Import (C, gst_pad_set_activatepush_function, "gst_pad_set_activatepush_function");
procedure gst_pad_set_chain_function (pad : access GstPad; chain : GstPadChainFunction); -- gst/gstpad.h:945
pragma Import (C, gst_pad_set_chain_function, "gst_pad_set_chain_function");
procedure gst_pad_set_chain_list_function (pad : access GstPad; chainlist : GstPadChainListFunction); -- gst/gstpad.h:946
pragma Import (C, gst_pad_set_chain_list_function, "gst_pad_set_chain_list_function");
procedure gst_pad_set_getrange_function (pad : access GstPad; get : GstPadGetRangeFunction); -- gst/gstpad.h:947
pragma Import (C, gst_pad_set_getrange_function, "gst_pad_set_getrange_function");
procedure gst_pad_set_checkgetrange_function (pad : access GstPad; check : GstPadCheckGetRangeFunction); -- gst/gstpad.h:948
pragma Import (C, gst_pad_set_checkgetrange_function, "gst_pad_set_checkgetrange_function");
procedure gst_pad_set_event_function (pad : access GstPad; event : GstPadEventFunction); -- gst/gstpad.h:949
pragma Import (C, gst_pad_set_event_function, "gst_pad_set_event_function");
-- pad links
procedure gst_pad_set_link_function (pad : access GstPad; link : GstPadLinkFunction); -- gst/gstpad.h:952
pragma Import (C, gst_pad_set_link_function, "gst_pad_set_link_function");
procedure gst_pad_set_unlink_function (pad : access GstPad; unlink : GstPadUnlinkFunction); -- gst/gstpad.h:953
pragma Import (C, gst_pad_set_unlink_function, "gst_pad_set_unlink_function");
function gst_pad_can_link (srcpad : access GstPad; sinkpad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:955
pragma Import (C, gst_pad_can_link, "gst_pad_can_link");
function gst_pad_link (srcpad : access GstPad; sinkpad : access GstPad) return GstPadLinkReturn; -- gst/gstpad.h:956
pragma Import (C, gst_pad_link, "gst_pad_link");
function gst_pad_link_full
(srcpad : access GstPad;
sinkpad : access GstPad;
flags : GstPadLinkCheck) return GstPadLinkReturn; -- gst/gstpad.h:957
pragma Import (C, gst_pad_link_full, "gst_pad_link_full");
function gst_pad_unlink (srcpad : access GstPad; sinkpad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:958
pragma Import (C, gst_pad_unlink, "gst_pad_unlink");
function gst_pad_is_linked (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:959
pragma Import (C, gst_pad_is_linked, "gst_pad_is_linked");
function gst_pad_get_peer (pad : access GstPad) return access GstPad; -- gst/gstpad.h:961
pragma Import (C, gst_pad_get_peer, "gst_pad_get_peer");
-- capsnego functions
procedure gst_pad_set_getcaps_function (pad : access GstPad; getcaps : GstPadGetCapsFunction); -- gst/gstpad.h:964
pragma Import (C, gst_pad_set_getcaps_function, "gst_pad_set_getcaps_function");
procedure gst_pad_set_acceptcaps_function (pad : access GstPad; acceptcaps : GstPadAcceptCapsFunction); -- gst/gstpad.h:965
pragma Import (C, gst_pad_set_acceptcaps_function, "gst_pad_set_acceptcaps_function");
procedure gst_pad_set_fixatecaps_function (pad : access GstPad; fixatecaps : GstPadFixateCapsFunction); -- gst/gstpad.h:966
pragma Import (C, gst_pad_set_fixatecaps_function, "gst_pad_set_fixatecaps_function");
procedure gst_pad_set_setcaps_function (pad : access GstPad; setcaps : GstPadSetCapsFunction); -- gst/gstpad.h:967
pragma Import (C, gst_pad_set_setcaps_function, "gst_pad_set_setcaps_function");
function gst_pad_get_pad_template_caps (pad : access GstPad) return access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:969
pragma Import (C, gst_pad_get_pad_template_caps, "gst_pad_get_pad_template_caps");
-- capsnego function for linked/unlinked pads
function gst_pad_get_caps_reffed (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:972
pragma Import (C, gst_pad_get_caps_reffed, "gst_pad_get_caps_reffed");
function gst_pad_get_caps (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:973
pragma Import (C, gst_pad_get_caps, "gst_pad_get_caps");
procedure gst_pad_fixate_caps (pad : access GstPad; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps); -- gst/gstpad.h:974
pragma Import (C, gst_pad_fixate_caps, "gst_pad_fixate_caps");
function gst_pad_accept_caps (pad : access GstPad; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean; -- gst/gstpad.h:975
pragma Import (C, gst_pad_accept_caps, "gst_pad_accept_caps");
function gst_pad_set_caps (pad : access GstPad; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean; -- gst/gstpad.h:976
pragma Import (C, gst_pad_set_caps, "gst_pad_set_caps");
function gst_pad_peer_get_caps_reffed (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:978
pragma Import (C, gst_pad_peer_get_caps_reffed, "gst_pad_peer_get_caps_reffed");
function gst_pad_peer_get_caps (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:979
pragma Import (C, gst_pad_peer_get_caps, "gst_pad_peer_get_caps");
function gst_pad_peer_accept_caps (pad : access GstPad; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean; -- gst/gstpad.h:980
pragma Import (C, gst_pad_peer_accept_caps, "gst_pad_peer_accept_caps");
-- capsnego for linked pads
function gst_pad_get_allowed_caps (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:983
pragma Import (C, gst_pad_get_allowed_caps, "gst_pad_get_allowed_caps");
function gst_pad_get_negotiated_caps (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:984
pragma Import (C, gst_pad_get_negotiated_caps, "gst_pad_get_negotiated_caps");
-- data passing functions to peer
function gst_pad_push (pad : access GstPad; buffer : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GstFlowReturn; -- gst/gstpad.h:987
pragma Import (C, gst_pad_push, "gst_pad_push");
function gst_pad_push_list (pad : access GstPad; list : System.Address) return GstFlowReturn; -- gst/gstpad.h:988
pragma Import (C, gst_pad_push_list, "gst_pad_push_list");
function gst_pad_check_pull_range (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:989
pragma Import (C, gst_pad_check_pull_range, "gst_pad_check_pull_range");
function gst_pad_pull_range
(pad : access GstPad;
offset : GLIB.guint64;
size : GLIB.guint;
buffer : System.Address) return GstFlowReturn; -- gst/gstpad.h:990
pragma Import (C, gst_pad_pull_range, "gst_pad_pull_range");
function gst_pad_push_event (pad : access GstPad; event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/gstpad.h:992
pragma Import (C, gst_pad_push_event, "gst_pad_push_event");
function gst_pad_event_default (pad : access GstPad; event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/gstpad.h:993
pragma Import (C, gst_pad_event_default, "gst_pad_event_default");
-- data passing functions on pad
function gst_pad_chain (pad : access GstPad; buffer : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GstFlowReturn; -- gst/gstpad.h:996
pragma Import (C, gst_pad_chain, "gst_pad_chain");
function gst_pad_chain_list (pad : access GstPad; list : System.Address) return GstFlowReturn; -- gst/gstpad.h:997
pragma Import (C, gst_pad_chain_list, "gst_pad_chain_list");
function gst_pad_get_range
(pad : access GstPad;
offset : GLIB.guint64;
size : GLIB.guint;
buffer : System.Address) return GstFlowReturn; -- gst/gstpad.h:998
pragma Import (C, gst_pad_get_range, "gst_pad_get_range");
function gst_pad_send_event (pad : access GstPad; event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/gstpad.h:1000
pragma Import (C, gst_pad_send_event, "gst_pad_send_event");
-- pad tasks
function gst_pad_start_task
(pad : access GstPad;
func : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttask_h.GstTaskFunction;
data : System.Address) return GLIB.gboolean; -- gst/gstpad.h:1003
pragma Import (C, gst_pad_start_task, "gst_pad_start_task");
function gst_pad_pause_task (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:1005
pragma Import (C, gst_pad_pause_task, "gst_pad_pause_task");
function gst_pad_stop_task (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:1006
pragma Import (C, gst_pad_stop_task, "gst_pad_stop_task");
-- internal links
procedure gst_pad_set_internal_link_function (pad : access GstPad; intlink : GstPadIntLinkFunction); -- gst/gstpad.h:1010
pragma Import (C, gst_pad_set_internal_link_function, "gst_pad_set_internal_link_function");
function gst_pad_get_internal_links (pad : access GstPad) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstpad.h:1011
pragma Import (C, gst_pad_get_internal_links, "gst_pad_get_internal_links");
function gst_pad_get_internal_links_default (pad : access GstPad) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstpad.h:1012
pragma Import (C, gst_pad_get_internal_links_default, "gst_pad_get_internal_links_default");
procedure gst_pad_set_iterate_internal_links_function (pad : access GstPad; iterintlink : GstPadIterIntLinkFunction); -- gst/gstpad.h:1015
pragma Import (C, gst_pad_set_iterate_internal_links_function, "gst_pad_set_iterate_internal_links_function");
function gst_pad_iterate_internal_links (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator; -- gst/gstpad.h:1017
pragma Import (C, gst_pad_iterate_internal_links, "gst_pad_iterate_internal_links");
function gst_pad_iterate_internal_links_default (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator; -- gst/gstpad.h:1018
pragma Import (C, gst_pad_iterate_internal_links_default, "gst_pad_iterate_internal_links_default");
-- generic query function
procedure gst_pad_set_query_type_function (pad : access GstPad; type_func : GstPadQueryTypeFunction); -- gst/gstpad.h:1022
pragma Import (C, gst_pad_set_query_type_function, "gst_pad_set_query_type_function");
function gst_pad_get_query_types (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQueryType; -- gst/gstpad.h:1023
pragma Import (C, gst_pad_get_query_types, "gst_pad_get_query_types");
function gst_pad_get_query_types_default (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQueryType; -- gst/gstpad.h:1024
pragma Import (C, gst_pad_get_query_types_default, "gst_pad_get_query_types_default");
function gst_pad_query (pad : access GstPad; query : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/gstpad.h:1026
pragma Import (C, gst_pad_query, "gst_pad_query");
function gst_pad_peer_query (pad : access GstPad; query : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/gstpad.h:1027
pragma Import (C, gst_pad_peer_query, "gst_pad_peer_query");
procedure gst_pad_set_query_function (pad : access GstPad; query : GstPadQueryFunction); -- gst/gstpad.h:1028
pragma Import (C, gst_pad_set_query_function, "gst_pad_set_query_function");
function gst_pad_query_default (pad : access GstPad; query : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/gstpad.h:1029
pragma Import (C, gst_pad_query_default, "gst_pad_query_default");
-- misc helper functions
function gst_pad_dispatcher
(pad : access GstPad;
dispatch : GstPadDispatcherFunction;
data : System.Address) return GLIB.gboolean; -- gst/gstpad.h:1032
pragma Import (C, gst_pad_dispatcher, "gst_pad_dispatcher");
procedure gst_pad_load_and_link (self : GStreamer.GST_Low_Level.libxml2_libxml_tree_h.xmlNodePtr; parent : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObject); -- gst/gstpad.h:1036
pragma Import (C, gst_pad_load_and_link, "gst_pad_load_and_link");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h;
| true | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
with glib.Values;
with System;
with System;
-- with GStreamer.GST_Low_Level.glib_2_0_glib_gquark_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_glist_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h;
-- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_deprecated_gthread_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttask_h;
-- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstminiobject_h;
with glib;
-- with GStreamer.GST_Low_Level.libxml2_libxml_tree_h;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h is
-- unsupported macro: GST_TYPE_PAD (gst_pad_get_type ())
-- arg-macro: function GST_IS_PAD (obj)
-- return G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD);
-- arg-macro: function GST_IS_PAD_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD);
-- arg-macro: function GST_PAD (obj)
-- return G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD, GstPad);
-- arg-macro: function GST_PAD_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD, GstPadClass);
-- arg-macro: function GST_PAD_CAST (obj)
-- return (GstPad*)(obj);
-- arg-macro: function GST_PAD_LINK_FAILED (ret)
-- return (ret) < GST_PAD_LINK_OK;
-- arg-macro: function GST_PAD_LINK_SUCCESSFUL (ret)
-- return (ret) >= GST_PAD_LINK_OK;
-- arg-macro: function GST_FLOW_IS_FATAL (ret)
-- return (ret) <= GST_FLOW_UNEXPECTED;
-- arg-macro: function GST_FLOW_IS_SUCCESS (ret)
-- return (ret) >= GST_FLOW_OK;
-- unsupported macro: GST_PAD_LINK_CHECK_DEFAULT ((GstPadLinkCheck) (GST_PAD_LINK_CHECK_HIERARCHY | GST_PAD_LINK_CHECK_CAPS))
-- arg-macro: function GST_PAD_MODE_ACTIVATE (mode)
-- return (mode) /= GST_ACTIVATE_NONE;
-- arg-macro: function GST_PAD_NAME (pad)
-- return GST_OBJECT_NAME(pad);
-- arg-macro: function GST_PAD_PARENT (pad)
-- return GST_ELEMENT_CAST(GST_OBJECT_PARENT(pad));
-- arg-macro: function GST_PAD_ELEMENT_PRIVATE (pad)
-- return GST_PAD_CAST(pad).element_private;
-- arg-macro: function GST_PAD_PAD_TEMPLATE (pad)
-- return GST_PAD_CAST(pad).padtemplate;
-- arg-macro: function GST_PAD_DIRECTION (pad)
-- return GST_PAD_CAST(pad).direction;
-- arg-macro: function GST_PAD_TASK (pad)
-- return GST_PAD_CAST(pad).task;
-- arg-macro: function GST_PAD_ACTIVATE_MODE (pad)
-- return GST_PAD_CAST(pad).mode;
-- arg-macro: function GST_PAD_ACTIVATEFUNC (pad)
-- return GST_PAD_CAST(pad).activatefunc;
-- arg-macro: function GST_PAD_ACTIVATEPUSHFUNC (pad)
-- return GST_PAD_CAST(pad).activatepushfunc;
-- arg-macro: function GST_PAD_ACTIVATEPULLFUNC (pad)
-- return GST_PAD_CAST(pad).activatepullfunc;
-- arg-macro: function GST_PAD_CHAINFUNC (pad)
-- return GST_PAD_CAST(pad).chainfunc;
-- arg-macro: function GST_PAD_CHECKGETRANGEFUNC (pad)
-- return GST_PAD_CAST(pad).checkgetrangefunc;
-- arg-macro: function GST_PAD_GETRANGEFUNC (pad)
-- return GST_PAD_CAST(pad).getrangefunc;
-- arg-macro: function GST_PAD_EVENTFUNC (pad)
-- return GST_PAD_CAST(pad).eventfunc;
-- arg-macro: function GST_PAD_QUERYTYPEFUNC (pad)
-- return GST_PAD_CAST(pad).querytypefunc;
-- arg-macro: function GST_PAD_QUERYFUNC (pad)
-- return GST_PAD_CAST(pad).queryfunc;
-- arg-macro: function GST_PAD_INTLINKFUNC (pad)
-- return GST_PAD_CAST(pad).intlinkfunc;
-- arg-macro: function GST_PAD_ITERINTLINKFUNC (pad)
-- return GST_PAD_CAST(pad).iterintlinkfunc;
-- arg-macro: function GST_PAD_PEER (pad)
-- return GST_PAD_CAST(pad).peer;
-- arg-macro: function GST_PAD_LINKFUNC (pad)
-- return GST_PAD_CAST(pad).linkfunc;
-- arg-macro: function GST_PAD_UNLINKFUNC (pad)
-- return GST_PAD_CAST(pad).unlinkfunc;
-- arg-macro: function GST_PAD_CAPS (pad)
-- return GST_PAD_CAST(pad).caps;
-- arg-macro: function GST_PAD_GETCAPSFUNC (pad)
-- return GST_PAD_CAST(pad).getcapsfunc;
-- arg-macro: function GST_PAD_SETCAPSFUNC (pad)
-- return GST_PAD_CAST(pad).setcapsfunc;
-- arg-macro: function GST_PAD_ACCEPTCAPSFUNC (pad)
-- return GST_PAD_CAST(pad).acceptcapsfunc;
-- arg-macro: function GST_PAD_FIXATECAPSFUNC (pad)
-- return GST_PAD_CAST(pad).fixatecapsfunc;
-- arg-macro: function GST_PAD_BUFFERALLOCFUNC (pad)
-- return GST_PAD_CAST(pad).bufferallocfunc;
-- arg-macro: function GST_PAD_DO_BUFFER_SIGNALS (pad)
-- return GST_PAD_CAST(pad).do_buffer_signals;
-- arg-macro: function GST_PAD_DO_EVENT_SIGNALS (pad)
-- return GST_PAD_CAST(pad).do_event_signals;
-- arg-macro: function GST_PAD_IS_LINKED (pad)
-- return GST_PAD_PEER(pad) /= NULL;
-- arg-macro: function GST_PAD_IS_BLOCKED (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKED);
-- arg-macro: function GST_PAD_IS_BLOCKING (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKING);
-- arg-macro: function GST_PAD_IS_FLUSHING (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLUSHING);
-- arg-macro: function GST_PAD_IS_IN_GETCAPS (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_GETCAPS);
-- arg-macro: function GST_PAD_IS_IN_SETCAPS (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_SETCAPS);
-- arg-macro: function GST_PAD_IS_SRC (pad)
-- return GST_PAD_DIRECTION(pad) = GST_PAD_SRC;
-- arg-macro: function GST_PAD_IS_SINK (pad)
-- return GST_PAD_DIRECTION(pad) = GST_PAD_SINK;
-- arg-macro: function GST_PAD_SET_FLUSHING (pad)
-- return GST_OBJECT_FLAG_SET (pad, GST_PAD_FLUSHING);
-- arg-macro: function GST_PAD_UNSET_FLUSHING (pad)
-- return GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLUSHING);
-- arg-macro: function GST_PAD_GET_STREAM_LOCK (pad)
-- return GST_PAD_CAST(pad).stream_rec_lock;
-- arg-macro: function GST_PAD_STREAM_LOCK (pad)
-- return g_static_rec_mutex_lock(GST_PAD_GET_STREAM_LOCK(pad));
-- arg-macro: function GST_PAD_STREAM_LOCK_FULL (pad, t)
-- return g_static_rec_mutex_lock_full(GST_PAD_GET_STREAM_LOCK(pad), t);
-- arg-macro: function GST_PAD_STREAM_TRYLOCK (pad)
-- return g_static_rec_mutex_trylock(GST_PAD_GET_STREAM_LOCK(pad));
-- arg-macro: function GST_PAD_STREAM_UNLOCK (pad)
-- return g_static_rec_mutex_unlock(GST_PAD_GET_STREAM_LOCK(pad));
-- arg-macro: function GST_PAD_STREAM_UNLOCK_FULL (pad)
-- return g_static_rec_mutex_unlock_full(GST_PAD_GET_STREAM_LOCK(pad));
-- arg-macro: function GST_PAD_GET_PREROLL_LOCK (pad)
-- return GST_PAD_CAST(pad).preroll_lock;
-- arg-macro: function GST_PAD_PREROLL_LOCK (pad)
-- return g_mutex_lock(GST_PAD_GET_PREROLL_LOCK(pad));
-- arg-macro: function GST_PAD_PREROLL_TRYLOCK (pad)
-- return g_mutex_trylock(GST_PAD_GET_PREROLL_LOCK(pad));
-- arg-macro: function GST_PAD_PREROLL_UNLOCK (pad)
-- return g_mutex_unlock(GST_PAD_GET_PREROLL_LOCK(pad));
-- arg-macro: function GST_PAD_GET_PREROLL_COND (pad)
-- return GST_PAD_CAST(pad).preroll_cond;
-- arg-macro: procedure GST_PAD_PREROLL_WAIT (pad)
-- g_cond_wait (GST_PAD_GET_PREROLL_COND (pad), GST_PAD_GET_PREROLL_LOCK (pad))
-- arg-macro: procedure GST_PAD_PREROLL_TIMED_WAIT (pad, timeval)
-- g_cond_timed_wait (GST_PAD_GET_PREROLL_COND (pad), GST_PAD_GET_PREROLL_LOCK (pad), timeval)
-- arg-macro: procedure GST_PAD_PREROLL_SIGNAL (pad)
-- g_cond_signal (GST_PAD_GET_PREROLL_COND (pad));
-- arg-macro: procedure GST_PAD_PREROLL_BROADCAST (pad)
-- g_cond_broadcast (GST_PAD_GET_PREROLL_COND (pad));
-- arg-macro: function GST_PAD_BLOCK_GET_COND (pad)
-- return GST_PAD_CAST(pad).block_cond;
-- arg-macro: function GST_PAD_BLOCK_WAIT (pad)
-- return g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_OBJECT_GET_LOCK (pad));
-- arg-macro: function GST_PAD_BLOCK_SIGNAL (pad)
-- return g_cond_signal(GST_PAD_BLOCK_GET_COND (pad));
-- arg-macro: function GST_PAD_BLOCK_BROADCAST (pad)
-- return g_cond_broadcast(GST_PAD_BLOCK_GET_COND (pad));
-- arg-macro: procedure gst_pad_get_name (pad)
-- gst_object_get_name (GST_OBJECT_CAST (pad))
-- arg-macro: procedure gst_pad_get_parent (pad)
-- gst_object_get_parent (GST_OBJECT_CAST (pad))
-- GStreamer
-- * Copyright (C) 1999,2000 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
-- * 2000 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
-- *
-- * gstpad.h: Header for GstPad object
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
-- * Pad base class
--
type GstPad;
type anon_200;
type anon_201 is record
block_callback_called : aliased GLIB.gboolean; -- gst/gstpad.h:739
priv : System.Address; -- gst/gstpad.h:740
end record;
pragma Convention (C_Pass_By_Copy, anon_201);
type u_GstPad_u_gst_reserved_array is array (0 .. 1) of System.Address;
type anon_200 (discr : unsigned := 0) is record
case discr is
when 0 =>
ABI : aliased anon_201; -- gst/gstpad.h:741
when others =>
u_gst_reserved : u_GstPad_u_gst_reserved_array; -- gst/gstpad.h:742
end case;
end record;
pragma Convention (C_Pass_By_Copy, anon_200);
pragma Unchecked_Union (anon_200);--subtype GstPad is u_GstPad; -- gst/gstpad.h:50
-- skipped empty struct u_GstPadPrivate
-- skipped empty struct GstPadPrivate
type GstPadClass;
type u_GstPadClass_u_gst_reserved_array is array (0 .. 3) of System.Address;
--subtype GstPadClass is u_GstPadClass; -- gst/gstpad.h:52
--*
-- * GstPadLinkReturn:
-- * @GST_PAD_LINK_OK : link succeeded
-- * @GST_PAD_LINK_WRONG_HIERARCHY: pads have no common grandparent
-- * @GST_PAD_LINK_WAS_LINKED : pad was already linked
-- * @GST_PAD_LINK_WRONG_DIRECTION: pads have wrong direction
-- * @GST_PAD_LINK_NOFORMAT : pads do not have common format
-- * @GST_PAD_LINK_NOSCHED : pads cannot cooperate in scheduling
-- * @GST_PAD_LINK_REFUSED : refused for some reason
-- *
-- * Result values from gst_pad_link and friends.
--
subtype GstPadLinkReturn is int;
GST_PAD_LINK_OK : constant GstPadLinkReturn := 0;
GST_PAD_LINK_WRONG_HIERARCHY : constant GstPadLinkReturn := -1;
GST_PAD_LINK_WAS_LINKED : constant GstPadLinkReturn := -2;
GST_PAD_LINK_WRONG_DIRECTION : constant GstPadLinkReturn := -3;
GST_PAD_LINK_NOFORMAT : constant GstPadLinkReturn := -4;
GST_PAD_LINK_NOSCHED : constant GstPadLinkReturn := -5;
GST_PAD_LINK_REFUSED : constant GstPadLinkReturn := -6; -- gst/gstpad.h:74
--*
-- * GST_PAD_LINK_FAILED:
-- * @ret: the #GstPadLinkReturn value
-- *
-- * Macro to test if the given #GstPadLinkReturn value indicates a failed
-- * link step.
--
--*
-- * GST_PAD_LINK_SUCCESSFUL:
-- * @ret: the #GstPadLinkReturn value
-- *
-- * Macro to test if the given #GstPadLinkReturn value indicates a successful
-- * link step.
--
--*
-- * GstFlowReturn:
-- * @GST_FLOW_RESEND: Resend buffer, possibly with new caps (not
-- * sent yet) (unused/unimplemented).
-- * @GST_FLOW_OK: Data passing was ok.
-- * @GST_FLOW_NOT_LINKED: Pad is not linked.
-- * @GST_FLOW_WRONG_STATE: Pad is in wrong state.
-- * @GST_FLOW_UNEXPECTED: Did not expect anything, like after EOS.
-- * @GST_FLOW_NOT_NEGOTIATED: Pad is not negotiated.
-- * @GST_FLOW_ERROR: Some (fatal) error occured. Element generating
-- * this error should post an error message with more
-- * details.
-- * @GST_FLOW_NOT_SUPPORTED: This operation is not supported.
-- * @GST_FLOW_CUSTOM_SUCCESS: Elements can use values starting from
-- * this (and higher) to define custom success
-- * codes. Since 0.10.7.
-- * @GST_FLOW_CUSTOM_SUCCESS_1: Pre-defined custom success code (define your
-- * custom success code to this to avoid compiler
-- * warnings). Since 0.10.29.
-- * @GST_FLOW_CUSTOM_SUCCESS_2: Pre-defined custom success code. Since 0.10.29.
-- * @GST_FLOW_CUSTOM_ERROR: Elements can use values starting from
-- * this (and lower) to define custom error codes.
-- * Since 0.10.7.
-- * @GST_FLOW_CUSTOM_ERROR_1: Pre-defined custom error code (define your
-- * custom error code to this to avoid compiler
-- * warnings). Since 0.10.29.
-- * @GST_FLOW_CUSTOM_ERROR_2: Pre-defined custom error code. Since 0.10.29.
-- *
-- * The result of passing data to a pad.
-- *
-- * Note that the custom return values should not be exposed outside of the
-- * element scope and are available since 0.10.7.
--
-- FIXME 0.11: remove custom flow returns
-- custom success starts here
-- core predefined
-- expected failures
-- error cases
-- custom error starts here
subtype GstFlowReturn is int;
GST_FLOW_CUSTOM_SUCCESS_2 : constant GstFlowReturn := 102;
GST_FLOW_CUSTOM_SUCCESS_1 : constant GstFlowReturn := 101;
GST_FLOW_CUSTOM_SUCCESS : constant GstFlowReturn := 100;
GST_FLOW_RESEND : constant GstFlowReturn := 1;
GST_FLOW_OK : constant GstFlowReturn := 0;
GST_FLOW_NOT_LINKED : constant GstFlowReturn := -1;
GST_FLOW_WRONG_STATE : constant GstFlowReturn := -2;
GST_FLOW_UNEXPECTED : constant GstFlowReturn := -3;
GST_FLOW_NOT_NEGOTIATED : constant GstFlowReturn := -4;
GST_FLOW_ERROR : constant GstFlowReturn := -5;
GST_FLOW_NOT_SUPPORTED : constant GstFlowReturn := -6;
GST_FLOW_CUSTOM_ERROR : constant GstFlowReturn := -100;
GST_FLOW_CUSTOM_ERROR_1 : constant GstFlowReturn := -101;
GST_FLOW_CUSTOM_ERROR_2 : constant GstFlowReturn := -102; -- gst/gstpad.h:150
--*
-- * GST_FLOW_IS_FATAL:
-- * @ret: a #GstFlowReturn value
-- *
-- * Macro to test if the given #GstFlowReturn value indicates a fatal
-- * error. This macro is mainly used in elements driving the pipeline to decide
-- * whether an error message should be posted on the bus. Note that such
-- * elements may also need to post an error message in the #GST_FLOW_NOT_LINKED
-- * case which is not caught by this macro.
-- *
-- * Deprecated: This macro is badly named and can't be used in any real
-- * scenarios without additional checks.
--
--*
-- * GST_FLOW_IS_SUCCESS:
-- * @ret: a #GstFlowReturn value
-- *
-- * Macro to test if the given #GstFlowReturn value indicates a
-- * successful result
-- * This macro is mainly used in elements to decide if the processing
-- * of a buffer was successful.
-- *
-- * Since: 0.10.7
-- *
-- * Deprecated: This macro is badly named and can't be used in any real
-- * scenarios without additional checks.
--
function gst_flow_get_name (ret : GstFlowReturn) return access GLIB.gchar; -- gst/gstpad.h:187
pragma Import (C, gst_flow_get_name, "gst_flow_get_name");
function gst_flow_to_quark (ret : GstFlowReturn) return Glib.GQuark; -- gst/gstpad.h:188
pragma Import (C, gst_flow_to_quark, "gst_flow_to_quark");
--*
-- * GstPadLinkCheck:
-- * @GST_PAD_LINK_CHECK_NOTHING: Don't check hierarchy or caps compatibility.
-- * @GST_PAD_LINK_CHECK_HIERARCHY: Check the pads have same parents/grandparents.
-- * Could be omitted if it is already known that the two elements that own the
-- * pads are in the same bin.
-- * @GST_PAD_LINK_CHECK_TEMPLATE_CAPS: Check if the pads are compatible by using
-- * their template caps. This is much faster than @GST_PAD_LINK_CHECK_CAPS, but
-- * would be unsafe e.g. if one pad has %GST_CAPS_ANY.
-- * @GST_PAD_LINK_CHECK_CAPS: Check if the pads are compatible by comparing the
-- * caps returned by gst_pad_get_caps().
-- *
-- * The amount of checking to be done when linking pads. @GST_PAD_LINK_CHECK_CAPS
-- * and @GST_PAD_LINK_CHECK_TEMPLATE_CAPS are mutually exclusive. If both are
-- * specified, expensive but safe @GST_PAD_LINK_CHECK_CAPS are performed.
-- *
-- * <warning><para>
-- * Only disable some of the checks if you are 100% certain you know the link
-- * will not fail because of hierarchy/caps compatibility failures. If uncertain,
-- * use the default checks (%GST_PAD_LINK_CHECK_DEFAULT) or the regular methods
-- * for linking the pads.
-- * </para></warning>
-- *
-- * Since: 0.10.30
--
subtype GstPadLinkCheck is unsigned;
GST_PAD_LINK_CHECK_NOTHING : constant GstPadLinkCheck := 0;
GST_PAD_LINK_CHECK_HIERARCHY : constant GstPadLinkCheck := 1;
GST_PAD_LINK_CHECK_TEMPLATE_CAPS : constant GstPadLinkCheck := 2;
GST_PAD_LINK_CHECK_CAPS : constant GstPadLinkCheck := 4; -- gst/gstpad.h:221
--*
-- * GST_PAD_LINK_CHECK_DEFAULT:
-- *
-- * The default checks done when linking pads (i.e. the ones used by
-- * gst_pad_link()).
-- *
-- * Since: 0.10.30
--
--*
-- * GstActivateMode:
-- * @GST_ACTIVATE_NONE: Pad will not handle dataflow
-- * @GST_ACTIVATE_PUSH: Pad handles dataflow in downstream push mode
-- * @GST_ACTIVATE_PULL: Pad handles dataflow in upstream pull mode
-- *
-- * The status of a GstPad. After activating a pad, which usually happens when the
-- * parent element goes from READY to PAUSED, the GstActivateMode defines if the
-- * pad operates in push or pull mode.
--
type GstActivateMode is
(GST_ACTIVATE_NONE,
GST_ACTIVATE_PUSH,
GST_ACTIVATE_PULL);
pragma Convention (C, GstActivateMode); -- gst/gstpad.h:247
--*
-- * GST_PAD_MODE_ACTIVATE:
-- * @mode: a #GstActivateMode
-- *
-- * Macro to test if the given #GstActivateMode value indicates that datapassing
-- * is possible or not.
--
-- pad states
--*
-- * GstPadActivateFunction:
-- * @pad: a #GstPad
-- *
-- * This function is called when the pad is activated during the element
-- * READY to PAUSED state change. By default this function will call the
-- * activate function that puts the pad in push mode but elements can
-- * override this function to activate the pad in pull mode if they wish.
-- *
-- * Returns: TRUE if the pad could be activated.
--
type GstPadActivateFunction is access function (arg1 : access GstPad) return GLIB.gboolean;
pragma Convention (C, GstPadActivateFunction); -- gst/gstpad.h:270
--*
-- * GstPadActivateModeFunction:
-- * @pad: a #GstPad
-- * @active: activate or deactivate the pad.
-- *
-- * The prototype of the push and pull activate functions.
-- *
-- * Returns: TRUE if the pad could be activated or deactivated.
--
type GstPadActivateModeFunction is access function (arg1 : access GstPad; arg2 : GLIB.gboolean) return GLIB.gboolean;
pragma Convention (C, GstPadActivateModeFunction); -- gst/gstpad.h:280
-- data passing
--*
-- * GstPadChainFunction:
-- * @pad: the sink #GstPad that performed the chain.
-- * @buffer: the #GstBuffer that is chained, not %NULL.
-- *
-- * A function that will be called on sinkpads when chaining buffers.
-- * The function typically processes the data contained in the buffer and
-- * either consumes the data or passes it on to the internally linked pad(s).
-- *
-- * The implementer of this function receives a refcount to @buffer and should
-- * gst_buffer_unref() when the buffer is no longer needed.
-- *
-- * When a chain function detects an error in the data stream, it must post an
-- * error on the bus and return an appropriate #GstFlowReturn value.
-- *
-- * Returns: #GST_FLOW_OK for success
--
type GstPadChainFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GstFlowReturn;
pragma Convention (C, GstPadChainFunction); -- gst/gstpad.h:301
--*
-- * GstPadChainListFunction:
-- * @pad: the sink #GstPad that performed the chain.
-- * @list: the #GstBufferList that is chained, not %NULL.
-- *
-- * A function that will be called on sinkpads when chaining buffer lists.
-- * The function typically processes the data contained in the buffer list and
-- * either consumes the data or passes it on to the internally linked pad(s).
-- *
-- * The implementer of this function receives a refcount to @list and
-- * should gst_buffer_list_unref() when the list is no longer needed.
-- *
-- * When a chainlist function detects an error in the data stream, it must
-- * post an error on the bus and return an appropriate #GstFlowReturn value.
-- *
-- * Returns: #GST_FLOW_OK for success
--
type GstPadChainListFunction is access function (arg1 : access GstPad; arg2 : System.Address) return GstFlowReturn;
pragma Convention (C, GstPadChainListFunction); -- gst/gstpad.h:320
--*
-- * GstPadGetRangeFunction:
-- * @pad: the src #GstPad to perform the getrange on.
-- * @offset: the offset of the range
-- * @length: the length of the range
-- * @buffer: a memory location to hold the result buffer, cannot be NULL.
-- *
-- * This function will be called on source pads when a peer element
-- * request a buffer at the specified @offset and @length. If this function
-- * returns #GST_FLOW_OK, the result buffer will be stored in @buffer. The
-- * contents of @buffer is invalid for any other return value.
-- *
-- * This function is installed on a source pad with
-- * gst_pad_set_getrange_function() and can only be called on source pads after
-- * they are successfully activated with gst_pad_activate_pull().
-- *
-- * @offset and @length are always given in byte units. @offset must normally be a value
-- * between 0 and the length in bytes of the data available on @pad. The
-- * length (duration in bytes) can be retrieved with a #GST_QUERY_DURATION or with a
-- * #GST_QUERY_SEEKING.
-- *
-- * Any @offset larger or equal than the length will make the function return
-- * #GST_FLOW_UNEXPECTED, which corresponds to EOS. In this case @buffer does not
-- * contain a valid buffer.
-- *
-- * The buffer size of @buffer will only be smaller than @length when @offset is
-- * near the end of the stream. In all other cases, the size of @buffer must be
-- * exactly the requested size.
-- *
-- * It is allowed to call this function with a 0 @length and valid @offset, in
-- * which case @buffer will contain a 0-sized buffer and the function returns
-- * #GST_FLOW_OK.
-- *
-- * When this function is called with a -1 @offset, the sequentially next buffer
-- * of length @length in the stream is returned.
-- *
-- * When this function is called with a -1 @length, a buffer with a default
-- * optimal length is returned in @buffer. The length might depend on the value
-- * of @offset.
-- *
-- * Returns: #GST_FLOW_OK for success and a valid buffer in @buffer. Any other
-- * return value leaves @buffer undefined.
--
type GstPadGetRangeFunction is access function
(arg1 : access GstPad;
arg2 : GLIB.guint64;
arg3 : GLIB.guint;
arg4 : System.Address) return GstFlowReturn;
pragma Convention (C, GstPadGetRangeFunction); -- gst/gstpad.h:365
--*
-- * GstPadEventFunction:
-- * @pad: the #GstPad to handle the event.
-- * @event: the #GstEvent to handle.
-- *
-- * Function signature to handle an event for the pad.
-- *
-- * Returns: TRUE if the pad could handle the event.
--
type GstPadEventFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean;
pragma Convention (C, GstPadEventFunction); -- gst/gstpad.h:377
-- FIXME: 0.11: deprecate me, check range should use seeking query
--*
-- * GstPadCheckGetRangeFunction:
-- * @pad: a #GstPad
-- *
-- * Check if @pad can be activated in pull mode.
-- *
-- * This function will be deprecated after 0.10; use the seeking query to check
-- * if a pad can support random access.
-- *
-- * Returns: TRUE if the pad can operate in pull mode.
--
type GstPadCheckGetRangeFunction is access function (arg1 : access GstPad) return GLIB.gboolean;
pragma Convention (C, GstPadCheckGetRangeFunction); -- gst/gstpad.h:392
-- internal links
--*
-- * GstPadIntLinkFunction:
-- * @pad: The #GstPad to query.
-- *
-- * The signature of the internal pad link function.
-- *
-- * Returns: (element-type Gst.Pad) (transfer container): a newly allocated #GList of pads that are linked to the given pad on
-- * the inside of the parent element.
-- *
-- * The caller must call g_list_free() on it after use.
-- *
-- * Deprecated: use the threadsafe #GstPadIterIntLinkFunction instead.
--
type GstPadIntLinkFunction is access function (arg1 : access GstPad) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList;
pragma Convention (C, GstPadIntLinkFunction); -- gst/gstpad.h:409
--*
-- * GstPadIterIntLinkFunction:
-- * @pad: The #GstPad to query.
-- *
-- * The signature of the internal pad link iterator function.
-- *
-- * Returns: a new #GstIterator that will iterate over all pads that are
-- * linked to the given pad on the inside of the parent element.
-- *
-- * the caller must call gst_iterator_free() after usage.
-- *
-- * Since 0.10.21
--
type GstPadIterIntLinkFunction is access function (arg1 : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator;
pragma Convention (C, GstPadIterIntLinkFunction); -- gst/gstpad.h:426
-- generic query function
--*
-- * GstPadQueryTypeFunction:
-- * @pad: a #GstPad to query
-- *
-- * The signature of the query types function.
-- *
-- * Returns: a constant array of query types
--
type GstPadQueryTypeFunction is access function (arg1 : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQueryType;
pragma Convention (C, GstPadQueryTypeFunction); -- gst/gstpad.h:437
--*
-- * GstPadQueryFunction:
-- * @pad: the #GstPad to query.
-- * @query: the #GstQuery object to execute
-- *
-- * The signature of the query function.
-- *
-- * Returns: TRUE if the query could be performed.
--
type GstPadQueryFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean;
pragma Convention (C, GstPadQueryFunction); -- gst/gstpad.h:448
-- linking
--*
-- * GstPadLinkFunction
-- * @pad: the #GstPad that is linked.
-- * @peer: the peer #GstPad of the link
-- *
-- * Function signature to handle a new link on the pad.
-- *
-- * Returns: the result of the link with the specified peer.
--
type GstPadLinkFunction is access function (arg1 : access GstPad; arg2 : access GstPad) return GstPadLinkReturn;
pragma Convention (C, GstPadLinkFunction); -- gst/gstpad.h:461
--*
-- * GstPadUnlinkFunction
-- * @pad: the #GstPad that is linked.
-- *
-- * Function signature to handle a unlinking the pad prom its peer.
--
type GstPadUnlinkFunction is access procedure (arg1 : access GstPad);
pragma Convention (C, GstPadUnlinkFunction); -- gst/gstpad.h:468
-- caps nego
--*
-- * GstPadGetCapsFunction:
-- * @pad: the #GstPad to get the capabilities of.
-- *
-- * Returns a copy of the capabilities of the specified pad. By default this
-- * function will return the pad template capabilities, but can optionally
-- * be overridden by elements.
-- *
-- * Returns: a newly allocated copy #GstCaps of the pad.
--
type GstPadGetCapsFunction is access function (arg1 : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
pragma Convention (C, GstPadGetCapsFunction); -- gst/gstpad.h:482
--*
-- * GstPadSetCapsFunction:
-- * @pad: the #GstPad to set the capabilities of.
-- * @caps: the #GstCaps to set
-- *
-- * Set @caps on @pad. By default this function updates the caps of the
-- * pad but the function can be overriden by elements to perform extra
-- * actions or verifications.
-- *
-- * Returns: TRUE if the caps could be set on the pad.
--
type GstPadSetCapsFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean;
pragma Convention (C, GstPadSetCapsFunction); -- gst/gstpad.h:495
--*
-- * GstPadAcceptCapsFunction:
-- * @pad: the #GstPad to check
-- * @caps: the #GstCaps to check
-- *
-- * Check if @pad can accept @caps. By default this function will see if @caps
-- * intersect with the result from gst_pad_get_caps() by can be overridden to
-- * perform extra checks.
-- *
-- * Returns: TRUE if the caps can be accepted by the pad.
--
type GstPadAcceptCapsFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean;
pragma Convention (C, GstPadAcceptCapsFunction); -- gst/gstpad.h:507
--*
-- * GstPadFixateCapsFunction:
-- * @pad: a #GstPad
-- * @caps: the #GstCaps to fixate
-- *
-- * Given possibly unfixed caps @caps, let @pad use its default preferred
-- * format to make a fixed caps. @caps should be writable. By default this
-- * function will pick the first value of any ranges or lists in the caps but
-- * elements can override this function to perform other behaviour.
--
type GstPadFixateCapsFunction is access procedure (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps);
pragma Convention (C, GstPadFixateCapsFunction); -- gst/gstpad.h:518
--*
-- * GstPadBufferAllocFunction:
-- * @pad: a sink #GstPad
-- * @offset: the desired offset of the buffer
-- * @size: the desired size of the buffer
-- * @caps: the desired caps of the buffer
-- * @buf: pointer to hold the allocated buffer.
-- *
-- * Ask the sinkpad @pad to allocate a buffer with @offset, @size and @caps.
-- * The result will be stored in @buf.
-- *
-- * The purpose of this function is to allocate a buffer that is optimal to
-- * be processed by @pad. The function is mostly overridden by elements that can
-- * provide a hardware buffer in order to avoid additional memcpy operations.
-- *
-- * The function can return a buffer that has caps different from the requested
-- * @caps, in which case the upstream element requests a format change to this
-- * new caps.
-- * If a format change was requested, the returned buffer will be one to hold
-- * the data of said new caps, so its size might be different from the requested
-- * @size.
-- *
-- * When this function returns anything else than #GST_FLOW_OK, the buffer allocation
-- * failed and @buf does not contain valid data. If the function returns #GST_FLOW_OK and
-- * the @buf is NULL, a #GstBuffer will be created with @caps, @offset and @size.
-- *
-- * By default this function returns a new buffer of @size and with @caps containing
-- * purely malloced data. The buffer should be freed with gst_buffer_unref()
-- * after usage.
-- *
-- * Returns: #GST_FLOW_OK if @buf contains a valid buffer, any other return
-- * value means @buf does not hold a valid buffer.
--
type GstPadBufferAllocFunction is access function
(arg1 : access GstPad;
arg2 : GLIB.guint64;
arg3 : GLIB.guint;
arg4 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
arg5 : System.Address) return GstFlowReturn;
pragma Convention (C, GstPadBufferAllocFunction); -- gst/gstpad.h:552
-- misc
--*
-- * GstPadDispatcherFunction:
-- * @pad: the #GstPad that is dispatched.
-- * @data: the gpointer to optional user data.
-- *
-- * A dispatcher function is called for all internally linked pads, see
-- * gst_pad_dispatcher().
-- *
-- * Returns: TRUE if the dispatching procedure has to be stopped.
--
type GstPadDispatcherFunction is access function (arg1 : access GstPad; arg2 : System.Address) return GLIB.gboolean;
pragma Convention (C, GstPadDispatcherFunction); -- gst/gstpad.h:566
--*
-- * GstPadBlockCallback:
-- * @pad: the #GstPad that is blockend or unblocked.
-- * @blocked: blocking state for the pad
-- * @user_data: the gpointer to optional user data.
-- *
-- * Callback used by gst_pad_set_blocked_async(). Gets called when the blocking
-- * operation succeeds.
--
type GstPadBlockCallback is access procedure
(arg1 : access GstPad;
arg2 : GLIB.gboolean;
arg3 : System.Address);
pragma Convention (C, GstPadBlockCallback); -- gst/gstpad.h:577
--*
-- * GstPadDirection:
-- * @GST_PAD_UNKNOWN: direction is unknown.
-- * @GST_PAD_SRC: the pad is a source pad.
-- * @GST_PAD_SINK: the pad is a sink pad.
-- *
-- * The direction of a pad.
--
type GstPadDirection is
(GST_PAD_UNKNOWN,
GST_PAD_SRC,
GST_PAD_SINK);
pragma Convention (C, GstPadDirection); -- gst/gstpad.h:591
--*
-- * GstPadFlags:
-- * @GST_PAD_BLOCKED: is dataflow on a pad blocked
-- * @GST_PAD_FLUSHING: is pad refusing buffers
-- * @GST_PAD_IN_GETCAPS: GstPadGetCapsFunction() is running now
-- * @GST_PAD_IN_SETCAPS: GstPadSetCapsFunction() is running now
-- * @GST_PAD_BLOCKING: is pad currently blocking on a buffer or event
-- * @GST_PAD_FLAG_LAST: offset to define more flags
-- *
-- * Pad state flags
--
-- padding
type GstPadFlags is new unsigned;
GST_PAD_BLOCKED : constant GstPadFlags := 16;
GST_PAD_FLUSHING : constant GstPadFlags := 32;
GST_PAD_IN_GETCAPS : constant GstPadFlags := 64;
GST_PAD_IN_SETCAPS : constant GstPadFlags := 128;
GST_PAD_BLOCKING : constant GstPadFlags := 256;
GST_PAD_FLAG_LAST : constant GstPadFlags := 4096; -- gst/gstpad.h:612
-- FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h)
-- subtype GstPadTemplate is GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate -- gst/gstpad.h:615
--*
-- * GstPad:
-- * @element_private: private data owned by the parent element
-- * @padtemplate: padtemplate for this pad
-- * @direction: the direction of the pad, cannot change after creating
-- * the pad.
-- * @stream_rec_lock: recursive stream lock of the pad, used to protect
-- * the data used in streaming.
-- * @task: task for this pad if the pad is actively driving dataflow.
-- * @preroll_lock: lock used when prerolling
-- * @preroll_cond: conf to signal preroll
-- * @block_cond: conditional to signal pad block
-- * @block_callback: callback for the pad block if any
-- * @block_data: user data for @block_callback
-- * @caps: the current caps of the pad
-- * @getcapsfunc: function to get caps of the pad
-- * @setcapsfunc: function to set caps on the pad
-- * @acceptcapsfunc: function to check if pad can accept caps
-- * @fixatecapsfunc: function to fixate caps
-- * @activatefunc: pad activation function
-- * @activatepushfunc: function to activate/deactivate pad in push mode
-- * @activatepullfunc: function to activate/deactivate pad in pull mode
-- * @linkfunc: function called when pad is linked
-- * @unlinkfunc: function called when pad is unlinked
-- * @peer: the pad this pad is linked to
-- * @sched_private: private storage for the scheduler
-- * @chainfunc: function to chain buffer to pad
-- * @checkgetrangefunc: function to check if pad can operate in pull mode
-- * @getrangefunc: function to get a range of data from a pad
-- * @eventfunc: function to send an event to a pad
-- * @mode: current activation mode of the pad
-- * @querytypefunc: get list of supported queries
-- * @queryfunc: perform a query on the pad
-- * @intlinkfunc: get the internal links of this pad
-- * @bufferallocfunc: function to allocate a buffer for this pad
-- * @do_buffer_signals: counter counting installed buffer signals
-- * @do_event_signals: counter counting installed event signals
-- * @iterintlinkfunc: get the internal links iterator of this pad
-- * @block_destroy_data: notify function for gst_pad_set_blocked_async_full()
-- *
-- * The #GstPad structure. Use the functions to update the variables.
--
type GstPad is record
object : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObject; -- gst/gstpad.h:660
element_private : System.Address; -- gst/gstpad.h:663
padtemplate : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; -- gst/gstpad.h:665
direction : aliased GstPadDirection; -- gst/gstpad.h:667
stream_rec_lock : access GStreamer.GST_Low_Level.glib_2_0_glib_deprecated_gthread_h.GStaticRecMutex; -- gst/gstpad.h:671
c_task : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttask_h.GstTask; -- gst/gstpad.h:672
preroll_lock : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GMutex; -- gst/gstpad.h:674
preroll_cond : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GCond; -- gst/gstpad.h:675
block_cond : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GCond; -- gst/gstpad.h:679
block_callback : GstPadBlockCallback; -- gst/gstpad.h:680
block_data : System.Address; -- gst/gstpad.h:681
caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:684
getcapsfunc : GstPadGetCapsFunction; -- gst/gstpad.h:685
setcapsfunc : GstPadSetCapsFunction; -- gst/gstpad.h:686
acceptcapsfunc : GstPadAcceptCapsFunction; -- gst/gstpad.h:687
fixatecapsfunc : GstPadFixateCapsFunction; -- gst/gstpad.h:688
activatefunc : GstPadActivateFunction; -- gst/gstpad.h:690
activatepushfunc : GstPadActivateModeFunction; -- gst/gstpad.h:691
activatepullfunc : GstPadActivateModeFunction; -- gst/gstpad.h:692
linkfunc : GstPadLinkFunction; -- gst/gstpad.h:695
unlinkfunc : GstPadUnlinkFunction; -- gst/gstpad.h:696
peer : access GstPad; -- gst/gstpad.h:697
sched_private : System.Address; -- gst/gstpad.h:699
chainfunc : GstPadChainFunction; -- gst/gstpad.h:702
checkgetrangefunc : GstPadCheckGetRangeFunction; -- gst/gstpad.h:703
getrangefunc : GstPadGetRangeFunction; -- gst/gstpad.h:704
eventfunc : GstPadEventFunction; -- gst/gstpad.h:705
mode : aliased GstActivateMode; -- gst/gstpad.h:707
querytypefunc : GstPadQueryTypeFunction; -- gst/gstpad.h:710
queryfunc : GstPadQueryFunction; -- gst/gstpad.h:711
intlinkfunc : GstPadIntLinkFunction; -- gst/gstpad.h:715
bufferallocfunc : GstPadBufferAllocFunction; -- gst/gstpad.h:722
do_buffer_signals : aliased GLIB.gint; -- gst/gstpad.h:726
do_event_signals : aliased GLIB.gint; -- gst/gstpad.h:727
iterintlinkfunc : GstPadIterIntLinkFunction; -- gst/gstpad.h:731
block_destroy_data : GStreamer.GST_Low_Level.glib_2_0_glib_gtypes_h.GDestroyNotify; -- gst/gstpad.h:734
abidata : aliased anon_200; -- gst/gstpad.h:743
end record;
pragma Convention (C_Pass_By_Copy, GstPad); -- gst/gstpad.h:659
--< public >
--< public >
-- with STREAM_LOCK
-- streaming rec_lock
--< public >
-- with PREROLL_LOCK
--< public >
-- with LOCK
-- block cond, mutex is from the object
-- the pad capabilities
-- pad link
-- data transport functions
-- generic query method
-- internal links
-- whether to emit signals for have-data. counts number
-- * of handlers attached.
-- ABI added
-- iterate internal links
-- free block_data
--< private >
type GstPadClass is record
parent_class : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObjectClass; -- gst/gstpad.h:747
linked : access procedure (arg1 : access GstPad; arg2 : access GstPad); -- gst/gstpad.h:750
unlinked : access procedure (arg1 : access GstPad; arg2 : access GstPad); -- gst/gstpad.h:751
request_link : access procedure (arg1 : access GstPad); -- gst/gstpad.h:752
have_data : access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstminiobject_h.GstMiniObject) return GLIB.gboolean; -- gst/gstpad.h:753
u_gst_reserved : u_GstPadClass_u_gst_reserved_array; -- gst/gstpad.h:756
end record;
pragma Convention (C_Pass_By_Copy, GstPadClass); -- gst/gstpad.h:746
-- signal callbacks
--< private >
--**** helper macros ****
-- GstPad
--*
-- * GST_PAD_CAPS:
-- * @pad: a #GstPad.
-- *
-- * The caps for this pad.
--
--*
-- * GST_PAD_GET_STREAM_LOCK:
-- * @pad: a #GstPad
-- *
-- * Get the stream lock of @pad. The stream lock is protecting the
-- * resources used in the data processing functions of @pad.
--
--*
-- * GST_PAD_STREAM_LOCK:
-- * @pad: a #GstPad
-- *
-- * Lock the stream lock of @pad.
--
--*
-- * GST_PAD_STREAM_LOCK_FULL:
-- * @pad: a #GstPad
-- * @t: the number of times to recursively lock
-- *
-- * Lock the stream lock of @pad @t times.
--
--*
-- * GST_PAD_STREAM_TRYLOCK:
-- * @pad: a #GstPad
-- *
-- * Try to Lock the stream lock of the pad, return TRUE if the lock could be
-- * taken.
--
--*
-- * GST_PAD_STREAM_UNLOCK:
-- * @pad: a #GstPad
-- *
-- * Unlock the stream lock of @pad.
--
--*
-- * GST_PAD_STREAM_UNLOCK_FULL:
-- * @pad: a #GstPad
-- *
-- * Fully unlock the recursive stream lock of @pad, return the number of times
-- * @pad was locked.
--
-- FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h)
function gst_pad_get_type return GLIB.GType; -- gst/gstpad.h:885
pragma Import (C, gst_pad_get_type, "gst_pad_get_type");
-- creating pads
function gst_pad_new (name : access GLIB.gchar; direction : GstPadDirection) return access GstPad; -- gst/gstpad.h:888
pragma Import (C, gst_pad_new, "gst_pad_new");
function gst_pad_new_from_template (templ : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; name : access GLIB.gchar) return access GstPad; -- gst/gstpad.h:889
pragma Import (C, gst_pad_new_from_template, "gst_pad_new_from_template");
function gst_pad_new_from_static_template (templ : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstStaticPadTemplate; name : access GLIB.gchar) return access GstPad; -- gst/gstpad.h:890
pragma Import (C, gst_pad_new_from_static_template, "gst_pad_new_from_static_template");
--*
-- * gst_pad_get_name:
-- * @pad: the pad to get the name from
-- *
-- * Get a copy of the name of the pad. g_free() after usage.
-- *
-- * MT safe.
--
--*
-- * gst_pad_get_parent:
-- * @pad: the pad to get the parent of
-- *
-- * Get the parent of @pad. This function increases the refcount
-- * of the parent object so you should gst_object_unref() it after usage.
-- * Can return NULL if the pad did not have a parent.
-- *
-- * MT safe.
--
function gst_pad_get_direction (pad : access GstPad) return GstPadDirection; -- gst/gstpad.h:914
pragma Import (C, gst_pad_get_direction, "gst_pad_get_direction");
function gst_pad_set_active (pad : access GstPad; active : GLIB.gboolean) return GLIB.gboolean; -- gst/gstpad.h:916
pragma Import (C, gst_pad_set_active, "gst_pad_set_active");
function gst_pad_is_active (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:917
pragma Import (C, gst_pad_is_active, "gst_pad_is_active");
function gst_pad_activate_pull (pad : access GstPad; active : GLIB.gboolean) return GLIB.gboolean; -- gst/gstpad.h:918
pragma Import (C, gst_pad_activate_pull, "gst_pad_activate_pull");
function gst_pad_activate_push (pad : access GstPad; active : GLIB.gboolean) return GLIB.gboolean; -- gst/gstpad.h:919
pragma Import (C, gst_pad_activate_push, "gst_pad_activate_push");
function gst_pad_set_blocked (pad : access GstPad; blocked : GLIB.gboolean) return GLIB.gboolean; -- gst/gstpad.h:921
pragma Import (C, gst_pad_set_blocked, "gst_pad_set_blocked");
function gst_pad_set_blocked_async
(pad : access GstPad;
blocked : GLIB.gboolean;
callback : GstPadBlockCallback;
user_data : System.Address) return GLIB.gboolean; -- gst/gstpad.h:922
pragma Import (C, gst_pad_set_blocked_async, "gst_pad_set_blocked_async");
function gst_pad_set_blocked_async_full
(pad : access GstPad;
blocked : GLIB.gboolean;
callback : GstPadBlockCallback;
user_data : System.Address;
destroy_data : GStreamer.GST_Low_Level.glib_2_0_glib_gtypes_h.GDestroyNotify) return GLIB.gboolean; -- gst/gstpad.h:924
pragma Import (C, gst_pad_set_blocked_async_full, "gst_pad_set_blocked_async_full");
function gst_pad_is_blocked (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:927
pragma Import (C, gst_pad_is_blocked, "gst_pad_is_blocked");
function gst_pad_is_blocking (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:928
pragma Import (C, gst_pad_is_blocking, "gst_pad_is_blocking");
procedure gst_pad_set_element_private (pad : access GstPad; priv : System.Address); -- gst/gstpad.h:930
pragma Import (C, gst_pad_set_element_private, "gst_pad_set_element_private");
function gst_pad_get_element_private (pad : access GstPad) return System.Address; -- gst/gstpad.h:931
pragma Import (C, gst_pad_get_element_private, "gst_pad_get_element_private");
function gst_pad_get_pad_template (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; -- gst/gstpad.h:933
pragma Import (C, gst_pad_get_pad_template, "gst_pad_get_pad_template");
procedure gst_pad_set_bufferalloc_function (pad : access GstPad; bufalloc : GstPadBufferAllocFunction); -- gst/gstpad.h:935
pragma Import (C, gst_pad_set_bufferalloc_function, "gst_pad_set_bufferalloc_function");
function gst_pad_alloc_buffer
(pad : access GstPad;
offset : GLIB.guint64;
size : GLIB.gint;
caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
buf : System.Address) return GstFlowReturn; -- gst/gstpad.h:936
pragma Import (C, gst_pad_alloc_buffer, "gst_pad_alloc_buffer");
function gst_pad_alloc_buffer_and_set_caps
(pad : access GstPad;
offset : GLIB.guint64;
size : GLIB.gint;
caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
buf : System.Address) return GstFlowReturn; -- gst/gstpad.h:938
pragma Import (C, gst_pad_alloc_buffer_and_set_caps, "gst_pad_alloc_buffer_and_set_caps");
-- data passing setup functions
procedure gst_pad_set_activate_function (pad : access GstPad; activate : GstPadActivateFunction); -- gst/gstpad.h:942
pragma Import (C, gst_pad_set_activate_function, "gst_pad_set_activate_function");
procedure gst_pad_set_activatepull_function (pad : access GstPad; activatepull : GstPadActivateModeFunction); -- gst/gstpad.h:943
pragma Import (C, gst_pad_set_activatepull_function, "gst_pad_set_activatepull_function");
procedure gst_pad_set_activatepush_function (pad : access GstPad; activatepush : GstPadActivateModeFunction); -- gst/gstpad.h:944
pragma Import (C, gst_pad_set_activatepush_function, "gst_pad_set_activatepush_function");
procedure gst_pad_set_chain_function (pad : access GstPad; chain : GstPadChainFunction); -- gst/gstpad.h:945
pragma Import (C, gst_pad_set_chain_function, "gst_pad_set_chain_function");
procedure gst_pad_set_chain_list_function (pad : access GstPad; chainlist : GstPadChainListFunction); -- gst/gstpad.h:946
pragma Import (C, gst_pad_set_chain_list_function, "gst_pad_set_chain_list_function");
procedure gst_pad_set_getrange_function (pad : access GstPad; get : GstPadGetRangeFunction); -- gst/gstpad.h:947
pragma Import (C, gst_pad_set_getrange_function, "gst_pad_set_getrange_function");
procedure gst_pad_set_checkgetrange_function (pad : access GstPad; check : GstPadCheckGetRangeFunction); -- gst/gstpad.h:948
pragma Import (C, gst_pad_set_checkgetrange_function, "gst_pad_set_checkgetrange_function");
procedure gst_pad_set_event_function (pad : access GstPad; event : GstPadEventFunction); -- gst/gstpad.h:949
pragma Import (C, gst_pad_set_event_function, "gst_pad_set_event_function");
-- pad links
procedure gst_pad_set_link_function (pad : access GstPad; link : GstPadLinkFunction); -- gst/gstpad.h:952
pragma Import (C, gst_pad_set_link_function, "gst_pad_set_link_function");
procedure gst_pad_set_unlink_function (pad : access GstPad; unlink : GstPadUnlinkFunction); -- gst/gstpad.h:953
pragma Import (C, gst_pad_set_unlink_function, "gst_pad_set_unlink_function");
function gst_pad_can_link (srcpad : access GstPad; sinkpad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:955
pragma Import (C, gst_pad_can_link, "gst_pad_can_link");
function gst_pad_link (srcpad : access GstPad; sinkpad : access GstPad) return GstPadLinkReturn; -- gst/gstpad.h:956
pragma Import (C, gst_pad_link, "gst_pad_link");
function gst_pad_link_full
(srcpad : access GstPad;
sinkpad : access GstPad;
flags : GstPadLinkCheck) return GstPadLinkReturn; -- gst/gstpad.h:957
pragma Import (C, gst_pad_link_full, "gst_pad_link_full");
function gst_pad_unlink (srcpad : access GstPad; sinkpad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:958
pragma Import (C, gst_pad_unlink, "gst_pad_unlink");
function gst_pad_is_linked (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:959
pragma Import (C, gst_pad_is_linked, "gst_pad_is_linked");
function gst_pad_get_peer (pad : access GstPad) return access GstPad; -- gst/gstpad.h:961
pragma Import (C, gst_pad_get_peer, "gst_pad_get_peer");
-- capsnego functions
procedure gst_pad_set_getcaps_function (pad : access GstPad; getcaps : GstPadGetCapsFunction); -- gst/gstpad.h:964
pragma Import (C, gst_pad_set_getcaps_function, "gst_pad_set_getcaps_function");
procedure gst_pad_set_acceptcaps_function (pad : access GstPad; acceptcaps : GstPadAcceptCapsFunction); -- gst/gstpad.h:965
pragma Import (C, gst_pad_set_acceptcaps_function, "gst_pad_set_acceptcaps_function");
procedure gst_pad_set_fixatecaps_function (pad : access GstPad; fixatecaps : GstPadFixateCapsFunction); -- gst/gstpad.h:966
pragma Import (C, gst_pad_set_fixatecaps_function, "gst_pad_set_fixatecaps_function");
procedure gst_pad_set_setcaps_function (pad : access GstPad; setcaps : GstPadSetCapsFunction); -- gst/gstpad.h:967
pragma Import (C, gst_pad_set_setcaps_function, "gst_pad_set_setcaps_function");
function gst_pad_get_pad_template_caps (pad : access GstPad) return access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:969
pragma Import (C, gst_pad_get_pad_template_caps, "gst_pad_get_pad_template_caps");
-- capsnego function for linked/unlinked pads
function gst_pad_get_caps_reffed (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:972
pragma Import (C, gst_pad_get_caps_reffed, "gst_pad_get_caps_reffed");
function gst_pad_get_caps (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:973
pragma Import (C, gst_pad_get_caps, "gst_pad_get_caps");
procedure gst_pad_fixate_caps (pad : access GstPad; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps); -- gst/gstpad.h:974
pragma Import (C, gst_pad_fixate_caps, "gst_pad_fixate_caps");
function gst_pad_accept_caps (pad : access GstPad; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean; -- gst/gstpad.h:975
pragma Import (C, gst_pad_accept_caps, "gst_pad_accept_caps");
function gst_pad_set_caps (pad : access GstPad; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean; -- gst/gstpad.h:976
pragma Import (C, gst_pad_set_caps, "gst_pad_set_caps");
function gst_pad_peer_get_caps_reffed (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:978
pragma Import (C, gst_pad_peer_get_caps_reffed, "gst_pad_peer_get_caps_reffed");
function gst_pad_peer_get_caps (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:979
pragma Import (C, gst_pad_peer_get_caps, "gst_pad_peer_get_caps");
function gst_pad_peer_accept_caps (pad : access GstPad; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean; -- gst/gstpad.h:980
pragma Import (C, gst_pad_peer_accept_caps, "gst_pad_peer_accept_caps");
-- capsnego for linked pads
function gst_pad_get_allowed_caps (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:983
pragma Import (C, gst_pad_get_allowed_caps, "gst_pad_get_allowed_caps");
function gst_pad_get_negotiated_caps (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:984
pragma Import (C, gst_pad_get_negotiated_caps, "gst_pad_get_negotiated_caps");
-- data passing functions to peer
function gst_pad_push (pad : access GstPad; buffer : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GstFlowReturn; -- gst/gstpad.h:987
pragma Import (C, gst_pad_push, "gst_pad_push");
function gst_pad_push_list (pad : access GstPad; list : System.Address) return GstFlowReturn; -- gst/gstpad.h:988
pragma Import (C, gst_pad_push_list, "gst_pad_push_list");
function gst_pad_check_pull_range (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:989
pragma Import (C, gst_pad_check_pull_range, "gst_pad_check_pull_range");
function gst_pad_pull_range
(pad : access GstPad;
offset : GLIB.guint64;
size : GLIB.guint;
buffer : System.Address) return GstFlowReturn; -- gst/gstpad.h:990
pragma Import (C, gst_pad_pull_range, "gst_pad_pull_range");
function gst_pad_push_event (pad : access GstPad; event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/gstpad.h:992
pragma Import (C, gst_pad_push_event, "gst_pad_push_event");
function gst_pad_event_default (pad : access GstPad; event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/gstpad.h:993
pragma Import (C, gst_pad_event_default, "gst_pad_event_default");
-- data passing functions on pad
function gst_pad_chain (pad : access GstPad; buffer : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GstFlowReturn; -- gst/gstpad.h:996
pragma Import (C, gst_pad_chain, "gst_pad_chain");
function gst_pad_chain_list (pad : access GstPad; list : System.Address) return GstFlowReturn; -- gst/gstpad.h:997
pragma Import (C, gst_pad_chain_list, "gst_pad_chain_list");
function gst_pad_get_range
(pad : access GstPad;
offset : GLIB.guint64;
size : GLIB.guint;
buffer : System.Address) return GstFlowReturn; -- gst/gstpad.h:998
pragma Import (C, gst_pad_get_range, "gst_pad_get_range");
function gst_pad_send_event (pad : access GstPad; event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/gstpad.h:1000
pragma Import (C, gst_pad_send_event, "gst_pad_send_event");
-- pad tasks
function gst_pad_start_task
(pad : access GstPad;
func : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttask_h.GstTaskFunction;
data : System.Address) return GLIB.gboolean; -- gst/gstpad.h:1003
pragma Import (C, gst_pad_start_task, "gst_pad_start_task");
function gst_pad_pause_task (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:1005
pragma Import (C, gst_pad_pause_task, "gst_pad_pause_task");
function gst_pad_stop_task (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:1006
pragma Import (C, gst_pad_stop_task, "gst_pad_stop_task");
-- internal links
procedure gst_pad_set_internal_link_function (pad : access GstPad; intlink : GstPadIntLinkFunction); -- gst/gstpad.h:1010
pragma Import (C, gst_pad_set_internal_link_function, "gst_pad_set_internal_link_function");
function gst_pad_get_internal_links (pad : access GstPad) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstpad.h:1011
pragma Import (C, gst_pad_get_internal_links, "gst_pad_get_internal_links");
function gst_pad_get_internal_links_default (pad : access GstPad) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstpad.h:1012
pragma Import (C, gst_pad_get_internal_links_default, "gst_pad_get_internal_links_default");
procedure gst_pad_set_iterate_internal_links_function (pad : access GstPad; iterintlink : GstPadIterIntLinkFunction); -- gst/gstpad.h:1015
pragma Import (C, gst_pad_set_iterate_internal_links_function, "gst_pad_set_iterate_internal_links_function");
function gst_pad_iterate_internal_links (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator; -- gst/gstpad.h:1017
pragma Import (C, gst_pad_iterate_internal_links, "gst_pad_iterate_internal_links");
function gst_pad_iterate_internal_links_default (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator; -- gst/gstpad.h:1018
pragma Import (C, gst_pad_iterate_internal_links_default, "gst_pad_iterate_internal_links_default");
-- generic query function
procedure gst_pad_set_query_type_function (pad : access GstPad; type_func : GstPadQueryTypeFunction); -- gst/gstpad.h:1022
pragma Import (C, gst_pad_set_query_type_function, "gst_pad_set_query_type_function");
function gst_pad_get_query_types (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQueryType; -- gst/gstpad.h:1023
pragma Import (C, gst_pad_get_query_types, "gst_pad_get_query_types");
function gst_pad_get_query_types_default (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQueryType; -- gst/gstpad.h:1024
pragma Import (C, gst_pad_get_query_types_default, "gst_pad_get_query_types_default");
function gst_pad_query (pad : access GstPad; query : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/gstpad.h:1026
pragma Import (C, gst_pad_query, "gst_pad_query");
function gst_pad_peer_query (pad : access GstPad; query : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/gstpad.h:1027
pragma Import (C, gst_pad_peer_query, "gst_pad_peer_query");
procedure gst_pad_set_query_function (pad : access GstPad; query : GstPadQueryFunction); -- gst/gstpad.h:1028
pragma Import (C, gst_pad_set_query_function, "gst_pad_set_query_function");
function gst_pad_query_default (pad : access GstPad; query : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/gstpad.h:1029
pragma Import (C, gst_pad_query_default, "gst_pad_query_default");
-- misc helper functions
function gst_pad_dispatcher
(pad : access GstPad;
dispatch : GstPadDispatcherFunction;
data : System.Address) return GLIB.gboolean; -- gst/gstpad.h:1032
pragma Import (C, gst_pad_dispatcher, "gst_pad_dispatcher");
procedure gst_pad_load_and_link (self : GStreamer.GST_Low_Level.libxml2_libxml_tree_h.xmlNodePtr; parent : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObject); -- gst/gstpad.h:1036
pragma Import (C, gst_pad_load_and_link, "gst_pad_load_and_link");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h;
|
[
{
"context": "--\n-- Jan & Uwe R. Zimmer, Australia, July 2011\n--\n\npackage",
"end": 9,
"score": 0.9998730421066284,
"start": 6,
"tag": "NAME",
"value": "Jan"
},
{
"context": "--\n-- Jan & Uwe R. Zimmer, Australia, July 2011\n--\n\npackage Screenshots is\n",
"end": 25,
"score": 0.9998416900634766,
"start": 12,
"tag": "NAME",
"value": "Uwe R. Zimmer"
}
] | Sources/Interfaces/screenshots.ads | ForYouEyesOnly/Space-Convoy | 1 | --
-- Jan & Uwe R. Zimmer, Australia, July 2011
--
package Screenshots is
procedure Take_Shot;
end Screenshots;
| 23639 | --
-- <NAME> & <NAME>, Australia, July 2011
--
package Screenshots is
procedure Take_Shot;
end Screenshots;
| true | --
-- PI:NAME:<NAME>END_PI & PI:NAME:<NAME>END_PI, Australia, July 2011
--
package Screenshots is
procedure Take_Shot;
end Screenshots;
|
[
{
"context": "secunet Security Networks AG\n-- Copyright (C) 2017 Nico Huber <nico.h@gmx.de>\n--\n-- This program is free softwa",
"end": 91,
"score": 0.9997848272323608,
"start": 81,
"tag": "NAME",
"value": "Nico Huber"
},
{
"context": "ity Networks AG\n-- Copyright (C) 2017 Nico Huber <nico.h@gmx.de>\n--\n-- This program is free software; you can red",
"end": 106,
"score": 0.9999338984489441,
"start": 93,
"tag": "EMAIL",
"value": "nico.h@gmx.de"
}
] | firmware/coreboot/3rdparty/libgfxinit/common/hw-gfx-gma.ads | fabiojna02/OpenCellular | 1 | --
-- Copyright (C) 2015-2018 secunet Security Networks AG
-- Copyright (C) 2017 Nico Huber <nico.h@gmx.de>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 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.
--
with HW.Config;
with HW.Time;
with HW.Port_IO;
package HW.GFX.GMA
with
Abstract_State =>
(State,
Init_State,
Config_State,
(Device_State with External)),
Initializes =>
(Init_State,
Config_State)
is
GTT_Page_Size : constant := 4096;
type GTT_Address_Type is mod 2 ** 39;
subtype GTT_Range is Natural range 0 .. 16#8_0000# - 1;
GTT_Rotation_Offset : constant GTT_Range := GTT_Range'Last / 2 + 1;
type CPU_Type is
(G45,
Ironlake,
Sandybridge,
Ivybridge,
Haswell,
Broadwell,
Broxton,
Skylake);
type CPU_Variant is (Normal, ULT);
type Port_Type is
(Disabled,
Internal,
DP1,
DP2,
DP3,
HDMI1, -- or DVI
HDMI2, -- or DVI
HDMI3, -- or DVI
Analog);
type Cursor_Mode is (No_Cursor, ARGB_Cursor);
type Cursor_Size is (Cursor_64x64, Cursor_128x128, Cursor_256x256);
Cursor_Width : constant array (Cursor_Size) of Width_Type := (64, 128, 256);
subtype Cursor_Pos is Int32 range Int32'First / 2 .. Int32'Last / 2;
type Cursor_Type is record
Mode : Cursor_Mode;
Size : Cursor_Size;
Center_X : Cursor_Pos;
Center_Y : Cursor_Pos;
GTT_Offset : GTT_Range;
end record;
Default_Cursor : constant Cursor_Type :=
(Mode => No_Cursor,
Size => Cursor_Size'First,
Center_X => 0,
Center_Y => 0,
GTT_Offset => 0);
type Pipe_Config is record
Port : Port_Type;
Framebuffer : Framebuffer_Type;
Cursor : Cursor_Type;
Mode : Mode_Type;
end record;
type Pipe_Index is (Primary, Secondary, Tertiary);
type Pipe_Configs is array (Pipe_Index) of Pipe_Config;
-- Special framebuffer offset to indicate legacy VGA plane.
-- Only valid on primary pipe.
VGA_PLANE_FRAMEBUFFER_OFFSET : constant := 16#ffff_ffff#;
pragma Warnings (GNATprove, Off, "unused variable ""Write_Delay""",
Reason => "Write_Delay is used for debugging only");
procedure Initialize
(Write_Delay : in Word64 := 0;
Clean_State : in Boolean := False;
Success : out Boolean)
with
Global =>
(In_Out => (Config_State, Device_State, Port_IO.State),
Output => (State, Init_State),
Input => (Time.State)),
Post => Success = Is_Initialized;
function Is_Initialized return Boolean
with
Global => (Input => Init_State);
pragma Warnings (GNATprove, On, "unused variable ""Write_Delay""");
pragma Warnings (GNATprove, Off, "subprogram ""Power_Up_VGA"" has no effect",
Reason => "Effect depends on the platform compiled for");
procedure Power_Up_VGA
with
Pre => Is_Initialized;
procedure Update_Outputs (Configs : Pipe_Configs);
procedure Update_Cursor (Pipe : Pipe_Index; Cursor : Cursor_Type);
procedure Place_Cursor
(Pipe : Pipe_Index;
X : Cursor_Pos;
Y : Cursor_Pos);
procedure Move_Cursor
(Pipe : Pipe_Index;
X : Cursor_Pos;
Y : Cursor_Pos);
pragma Warnings (GNATprove, Off, "subprogram ""Dump_Configs"" has no effect",
Reason => "It's only used for debugging");
procedure Dump_Configs (Configs : Pipe_Configs);
procedure Write_GTT
(GTT_Page : GTT_Range;
Device_Address : GTT_Address_Type;
Valid : Boolean);
procedure Setup_Default_FB
(FB : in Framebuffer_Type;
Clear : in Boolean := True;
Success : out Boolean)
with
Pre => Is_Initialized and HW.Config.Dynamic_MMIO;
procedure Map_Linear_FB (Linear_FB : out Word64; FB : in Framebuffer_Type)
with
Pre => Is_Initialized and HW.Config.Dynamic_MMIO;
private
-- For the default framebuffer setup (see below) with 90 degree rotations,
-- we expect the offset which is used for the final scanout to be above
-- `GTT_Rotation_Offset`. So we can use `Offset - GTT_Rotation_Offset` for
-- the physical memory location and aperture mapping.
function Phys_Offset (FB : Framebuffer_Type) return Word32 is
(if Rotation_90 (FB)
then FB.Offset - Word32 (GTT_Rotation_Offset) * GTT_Page_Size
else FB.Offset);
----------------------------------------------------------------------------
-- State tracking for the currently configured pipes
Cur_Configs : Pipe_Configs with Part_Of => State;
function Requires_Scaling (Pipe_Cfg : Pipe_Config) return Boolean is
(Requires_Scaling (Pipe_Cfg.Framebuffer, Pipe_Cfg.Mode));
function Scaling_Type (Pipe_Cfg : Pipe_Config) return Scaling_Aspect is
(Scaling_Type (Pipe_Cfg.Framebuffer, Pipe_Cfg.Mode));
----------------------------------------------------------------------------
-- Internal representation of a single pipe's configuration
subtype Active_Port_Type is Port_Type
range Port_Type'Succ (Disabled) .. Port_Type'Last;
type GPU_Port is (DIGI_A, DIGI_B, DIGI_C, DIGI_D, DIGI_E, LVDS, VGA);
subtype Digital_Port is GPU_Port range DIGI_A .. DIGI_E;
subtype GMCH_DP_Port is GPU_Port range DIGI_B .. DIGI_D;
subtype GMCH_HDMI_Port is GPU_Port range DIGI_B .. DIGI_C;
type PCH_Port is
(PCH_DAC, PCH_LVDS,
PCH_HDMI_B, PCH_HDMI_C, PCH_HDMI_D,
PCH_DP_B, PCH_DP_C, PCH_DP_D);
subtype PCH_HDMI_Port is PCH_Port range PCH_HDMI_B .. PCH_HDMI_D;
subtype PCH_DP_Port is PCH_Port range PCH_DP_B .. PCH_DP_D;
type Port_Config is
record
Port : GPU_Port;
PCH_Port : GMA.PCH_Port;
Display : Display_Type;
Mode : Mode_Type;
Is_FDI : Boolean;
FDI : DP_Link;
DP : DP_Link;
end record;
type FDI_Training_Type is (Simple_Training, Full_Training, Auto_Training);
----------------------------------------------------------------------------
type DP_Port is (DP_A, DP_B, DP_C, DP_D);
----------------------------------------------------------------------------
subtype DDI_HDMI_Buf_Trans_Range is Integer range 0 .. 11;
----------------------------------------------------------------------------
Tile_Width : constant array (Tiling_Type) of Width_Type :=
(Linear => 16, X_Tiled => 128, Y_Tiled => 32);
Tile_Rows : constant array (Tiling_Type) of Height_Type :=
(Linear => 1, X_Tiled => 8, Y_Tiled => 32);
function FB_Pitch (Px : Pos_Pixel_Type; FB : Framebuffer_Type) return Natural
is (Natural (Div_Round_Up
(Pixel_To_Bytes (Px, FB), Tile_Width (FB.Tiling) * 4)));
function Valid_Stride (FB : Framebuffer_Type) return Boolean is
(FB.Width + FB.Start_X <= FB.Stride and
Pixel_To_Bytes (FB.Stride, FB) mod (Tile_Width (FB.Tiling) * 4) = 0 and
FB.Height + FB.Start_Y <= FB.V_Stride and
FB.V_Stride mod Tile_Rows (FB.Tiling) = 0);
end HW.GFX.GMA;
| 14380 | --
-- Copyright (C) 2015-2018 secunet Security Networks AG
-- Copyright (C) 2017 <NAME> <<EMAIL>>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 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.
--
with HW.Config;
with HW.Time;
with HW.Port_IO;
package HW.GFX.GMA
with
Abstract_State =>
(State,
Init_State,
Config_State,
(Device_State with External)),
Initializes =>
(Init_State,
Config_State)
is
GTT_Page_Size : constant := 4096;
type GTT_Address_Type is mod 2 ** 39;
subtype GTT_Range is Natural range 0 .. 16#8_0000# - 1;
GTT_Rotation_Offset : constant GTT_Range := GTT_Range'Last / 2 + 1;
type CPU_Type is
(G45,
Ironlake,
Sandybridge,
Ivybridge,
Haswell,
Broadwell,
Broxton,
Skylake);
type CPU_Variant is (Normal, ULT);
type Port_Type is
(Disabled,
Internal,
DP1,
DP2,
DP3,
HDMI1, -- or DVI
HDMI2, -- or DVI
HDMI3, -- or DVI
Analog);
type Cursor_Mode is (No_Cursor, ARGB_Cursor);
type Cursor_Size is (Cursor_64x64, Cursor_128x128, Cursor_256x256);
Cursor_Width : constant array (Cursor_Size) of Width_Type := (64, 128, 256);
subtype Cursor_Pos is Int32 range Int32'First / 2 .. Int32'Last / 2;
type Cursor_Type is record
Mode : Cursor_Mode;
Size : Cursor_Size;
Center_X : Cursor_Pos;
Center_Y : Cursor_Pos;
GTT_Offset : GTT_Range;
end record;
Default_Cursor : constant Cursor_Type :=
(Mode => No_Cursor,
Size => Cursor_Size'First,
Center_X => 0,
Center_Y => 0,
GTT_Offset => 0);
type Pipe_Config is record
Port : Port_Type;
Framebuffer : Framebuffer_Type;
Cursor : Cursor_Type;
Mode : Mode_Type;
end record;
type Pipe_Index is (Primary, Secondary, Tertiary);
type Pipe_Configs is array (Pipe_Index) of Pipe_Config;
-- Special framebuffer offset to indicate legacy VGA plane.
-- Only valid on primary pipe.
VGA_PLANE_FRAMEBUFFER_OFFSET : constant := 16#ffff_ffff#;
pragma Warnings (GNATprove, Off, "unused variable ""Write_Delay""",
Reason => "Write_Delay is used for debugging only");
procedure Initialize
(Write_Delay : in Word64 := 0;
Clean_State : in Boolean := False;
Success : out Boolean)
with
Global =>
(In_Out => (Config_State, Device_State, Port_IO.State),
Output => (State, Init_State),
Input => (Time.State)),
Post => Success = Is_Initialized;
function Is_Initialized return Boolean
with
Global => (Input => Init_State);
pragma Warnings (GNATprove, On, "unused variable ""Write_Delay""");
pragma Warnings (GNATprove, Off, "subprogram ""Power_Up_VGA"" has no effect",
Reason => "Effect depends on the platform compiled for");
procedure Power_Up_VGA
with
Pre => Is_Initialized;
procedure Update_Outputs (Configs : Pipe_Configs);
procedure Update_Cursor (Pipe : Pipe_Index; Cursor : Cursor_Type);
procedure Place_Cursor
(Pipe : Pipe_Index;
X : Cursor_Pos;
Y : Cursor_Pos);
procedure Move_Cursor
(Pipe : Pipe_Index;
X : Cursor_Pos;
Y : Cursor_Pos);
pragma Warnings (GNATprove, Off, "subprogram ""Dump_Configs"" has no effect",
Reason => "It's only used for debugging");
procedure Dump_Configs (Configs : Pipe_Configs);
procedure Write_GTT
(GTT_Page : GTT_Range;
Device_Address : GTT_Address_Type;
Valid : Boolean);
procedure Setup_Default_FB
(FB : in Framebuffer_Type;
Clear : in Boolean := True;
Success : out Boolean)
with
Pre => Is_Initialized and HW.Config.Dynamic_MMIO;
procedure Map_Linear_FB (Linear_FB : out Word64; FB : in Framebuffer_Type)
with
Pre => Is_Initialized and HW.Config.Dynamic_MMIO;
private
-- For the default framebuffer setup (see below) with 90 degree rotations,
-- we expect the offset which is used for the final scanout to be above
-- `GTT_Rotation_Offset`. So we can use `Offset - GTT_Rotation_Offset` for
-- the physical memory location and aperture mapping.
function Phys_Offset (FB : Framebuffer_Type) return Word32 is
(if Rotation_90 (FB)
then FB.Offset - Word32 (GTT_Rotation_Offset) * GTT_Page_Size
else FB.Offset);
----------------------------------------------------------------------------
-- State tracking for the currently configured pipes
Cur_Configs : Pipe_Configs with Part_Of => State;
function Requires_Scaling (Pipe_Cfg : Pipe_Config) return Boolean is
(Requires_Scaling (Pipe_Cfg.Framebuffer, Pipe_Cfg.Mode));
function Scaling_Type (Pipe_Cfg : Pipe_Config) return Scaling_Aspect is
(Scaling_Type (Pipe_Cfg.Framebuffer, Pipe_Cfg.Mode));
----------------------------------------------------------------------------
-- Internal representation of a single pipe's configuration
subtype Active_Port_Type is Port_Type
range Port_Type'Succ (Disabled) .. Port_Type'Last;
type GPU_Port is (DIGI_A, DIGI_B, DIGI_C, DIGI_D, DIGI_E, LVDS, VGA);
subtype Digital_Port is GPU_Port range DIGI_A .. DIGI_E;
subtype GMCH_DP_Port is GPU_Port range DIGI_B .. DIGI_D;
subtype GMCH_HDMI_Port is GPU_Port range DIGI_B .. DIGI_C;
type PCH_Port is
(PCH_DAC, PCH_LVDS,
PCH_HDMI_B, PCH_HDMI_C, PCH_HDMI_D,
PCH_DP_B, PCH_DP_C, PCH_DP_D);
subtype PCH_HDMI_Port is PCH_Port range PCH_HDMI_B .. PCH_HDMI_D;
subtype PCH_DP_Port is PCH_Port range PCH_DP_B .. PCH_DP_D;
type Port_Config is
record
Port : GPU_Port;
PCH_Port : GMA.PCH_Port;
Display : Display_Type;
Mode : Mode_Type;
Is_FDI : Boolean;
FDI : DP_Link;
DP : DP_Link;
end record;
type FDI_Training_Type is (Simple_Training, Full_Training, Auto_Training);
----------------------------------------------------------------------------
type DP_Port is (DP_A, DP_B, DP_C, DP_D);
----------------------------------------------------------------------------
subtype DDI_HDMI_Buf_Trans_Range is Integer range 0 .. 11;
----------------------------------------------------------------------------
Tile_Width : constant array (Tiling_Type) of Width_Type :=
(Linear => 16, X_Tiled => 128, Y_Tiled => 32);
Tile_Rows : constant array (Tiling_Type) of Height_Type :=
(Linear => 1, X_Tiled => 8, Y_Tiled => 32);
function FB_Pitch (Px : Pos_Pixel_Type; FB : Framebuffer_Type) return Natural
is (Natural (Div_Round_Up
(Pixel_To_Bytes (Px, FB), Tile_Width (FB.Tiling) * 4)));
function Valid_Stride (FB : Framebuffer_Type) return Boolean is
(FB.Width + FB.Start_X <= FB.Stride and
Pixel_To_Bytes (FB.Stride, FB) mod (Tile_Width (FB.Tiling) * 4) = 0 and
FB.Height + FB.Start_Y <= FB.V_Stride and
FB.V_Stride mod Tile_Rows (FB.Tiling) = 0);
end HW.GFX.GMA;
| true | --
-- Copyright (C) 2015-2018 secunet Security Networks AG
-- Copyright (C) 2017 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 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.
--
with HW.Config;
with HW.Time;
with HW.Port_IO;
package HW.GFX.GMA
with
Abstract_State =>
(State,
Init_State,
Config_State,
(Device_State with External)),
Initializes =>
(Init_State,
Config_State)
is
GTT_Page_Size : constant := 4096;
type GTT_Address_Type is mod 2 ** 39;
subtype GTT_Range is Natural range 0 .. 16#8_0000# - 1;
GTT_Rotation_Offset : constant GTT_Range := GTT_Range'Last / 2 + 1;
type CPU_Type is
(G45,
Ironlake,
Sandybridge,
Ivybridge,
Haswell,
Broadwell,
Broxton,
Skylake);
type CPU_Variant is (Normal, ULT);
type Port_Type is
(Disabled,
Internal,
DP1,
DP2,
DP3,
HDMI1, -- or DVI
HDMI2, -- or DVI
HDMI3, -- or DVI
Analog);
type Cursor_Mode is (No_Cursor, ARGB_Cursor);
type Cursor_Size is (Cursor_64x64, Cursor_128x128, Cursor_256x256);
Cursor_Width : constant array (Cursor_Size) of Width_Type := (64, 128, 256);
subtype Cursor_Pos is Int32 range Int32'First / 2 .. Int32'Last / 2;
type Cursor_Type is record
Mode : Cursor_Mode;
Size : Cursor_Size;
Center_X : Cursor_Pos;
Center_Y : Cursor_Pos;
GTT_Offset : GTT_Range;
end record;
Default_Cursor : constant Cursor_Type :=
(Mode => No_Cursor,
Size => Cursor_Size'First,
Center_X => 0,
Center_Y => 0,
GTT_Offset => 0);
type Pipe_Config is record
Port : Port_Type;
Framebuffer : Framebuffer_Type;
Cursor : Cursor_Type;
Mode : Mode_Type;
end record;
type Pipe_Index is (Primary, Secondary, Tertiary);
type Pipe_Configs is array (Pipe_Index) of Pipe_Config;
-- Special framebuffer offset to indicate legacy VGA plane.
-- Only valid on primary pipe.
VGA_PLANE_FRAMEBUFFER_OFFSET : constant := 16#ffff_ffff#;
pragma Warnings (GNATprove, Off, "unused variable ""Write_Delay""",
Reason => "Write_Delay is used for debugging only");
procedure Initialize
(Write_Delay : in Word64 := 0;
Clean_State : in Boolean := False;
Success : out Boolean)
with
Global =>
(In_Out => (Config_State, Device_State, Port_IO.State),
Output => (State, Init_State),
Input => (Time.State)),
Post => Success = Is_Initialized;
function Is_Initialized return Boolean
with
Global => (Input => Init_State);
pragma Warnings (GNATprove, On, "unused variable ""Write_Delay""");
pragma Warnings (GNATprove, Off, "subprogram ""Power_Up_VGA"" has no effect",
Reason => "Effect depends on the platform compiled for");
procedure Power_Up_VGA
with
Pre => Is_Initialized;
procedure Update_Outputs (Configs : Pipe_Configs);
procedure Update_Cursor (Pipe : Pipe_Index; Cursor : Cursor_Type);
procedure Place_Cursor
(Pipe : Pipe_Index;
X : Cursor_Pos;
Y : Cursor_Pos);
procedure Move_Cursor
(Pipe : Pipe_Index;
X : Cursor_Pos;
Y : Cursor_Pos);
pragma Warnings (GNATprove, Off, "subprogram ""Dump_Configs"" has no effect",
Reason => "It's only used for debugging");
procedure Dump_Configs (Configs : Pipe_Configs);
procedure Write_GTT
(GTT_Page : GTT_Range;
Device_Address : GTT_Address_Type;
Valid : Boolean);
procedure Setup_Default_FB
(FB : in Framebuffer_Type;
Clear : in Boolean := True;
Success : out Boolean)
with
Pre => Is_Initialized and HW.Config.Dynamic_MMIO;
procedure Map_Linear_FB (Linear_FB : out Word64; FB : in Framebuffer_Type)
with
Pre => Is_Initialized and HW.Config.Dynamic_MMIO;
private
-- For the default framebuffer setup (see below) with 90 degree rotations,
-- we expect the offset which is used for the final scanout to be above
-- `GTT_Rotation_Offset`. So we can use `Offset - GTT_Rotation_Offset` for
-- the physical memory location and aperture mapping.
function Phys_Offset (FB : Framebuffer_Type) return Word32 is
(if Rotation_90 (FB)
then FB.Offset - Word32 (GTT_Rotation_Offset) * GTT_Page_Size
else FB.Offset);
----------------------------------------------------------------------------
-- State tracking for the currently configured pipes
Cur_Configs : Pipe_Configs with Part_Of => State;
function Requires_Scaling (Pipe_Cfg : Pipe_Config) return Boolean is
(Requires_Scaling (Pipe_Cfg.Framebuffer, Pipe_Cfg.Mode));
function Scaling_Type (Pipe_Cfg : Pipe_Config) return Scaling_Aspect is
(Scaling_Type (Pipe_Cfg.Framebuffer, Pipe_Cfg.Mode));
----------------------------------------------------------------------------
-- Internal representation of a single pipe's configuration
subtype Active_Port_Type is Port_Type
range Port_Type'Succ (Disabled) .. Port_Type'Last;
type GPU_Port is (DIGI_A, DIGI_B, DIGI_C, DIGI_D, DIGI_E, LVDS, VGA);
subtype Digital_Port is GPU_Port range DIGI_A .. DIGI_E;
subtype GMCH_DP_Port is GPU_Port range DIGI_B .. DIGI_D;
subtype GMCH_HDMI_Port is GPU_Port range DIGI_B .. DIGI_C;
type PCH_Port is
(PCH_DAC, PCH_LVDS,
PCH_HDMI_B, PCH_HDMI_C, PCH_HDMI_D,
PCH_DP_B, PCH_DP_C, PCH_DP_D);
subtype PCH_HDMI_Port is PCH_Port range PCH_HDMI_B .. PCH_HDMI_D;
subtype PCH_DP_Port is PCH_Port range PCH_DP_B .. PCH_DP_D;
type Port_Config is
record
Port : GPU_Port;
PCH_Port : GMA.PCH_Port;
Display : Display_Type;
Mode : Mode_Type;
Is_FDI : Boolean;
FDI : DP_Link;
DP : DP_Link;
end record;
type FDI_Training_Type is (Simple_Training, Full_Training, Auto_Training);
----------------------------------------------------------------------------
type DP_Port is (DP_A, DP_B, DP_C, DP_D);
----------------------------------------------------------------------------
subtype DDI_HDMI_Buf_Trans_Range is Integer range 0 .. 11;
----------------------------------------------------------------------------
Tile_Width : constant array (Tiling_Type) of Width_Type :=
(Linear => 16, X_Tiled => 128, Y_Tiled => 32);
Tile_Rows : constant array (Tiling_Type) of Height_Type :=
(Linear => 1, X_Tiled => 8, Y_Tiled => 32);
function FB_Pitch (Px : Pos_Pixel_Type; FB : Framebuffer_Type) return Natural
is (Natural (Div_Round_Up
(Pixel_To_Bytes (Px, FB), Tile_Width (FB.Tiling) * 4)));
function Valid_Stride (FB : Framebuffer_Type) return Boolean is
(FB.Width + FB.Start_X <= FB.Stride and
Pixel_To_Bytes (FB.Stride, FB) mod (Tile_Width (FB.Tiling) * 4) = 0 and
FB.Height + FB.Start_Y <= FB.V_Stride and
FB.V_Stride mod Tile_Rows (FB.Tiling) = 0);
end HW.GFX.GMA;
|
[
{
"context": "ystore key management\n-- Copyright (C) 2019, 2020 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@g",
"end": 161,
"score": 0.999881386756897,
"start": 146,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "ight (C) 2019, 2020 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under",
"end": 192,
"score": 0.9998865127563477,
"start": 177,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "0 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under the Apache License, Versio",
"end": 219,
"score": 0.9999245405197144,
"start": 194,
"tag": "EMAIL",
"value": "Stephane.Carrez@gmail.com"
},
{
"context": "ir sign # 1 | 32b |\n-- | Data key # 1 | 32b |\n-- | Data iv # 1 | 16b | Encrypted by u",
"end": 1922,
"score": 0.676626443862915,
"start": 1919,
"tag": "KEY",
"value": "32b"
},
{
"context": "ta sign #1 | 32b |\n-- | Key key # 1 | 32b |\n-- | Key iv # 1 | 16b v\n-- | Key sign",
"end": 2047,
"score": 0.6540470719337463,
"start": 2045,
"tag": "KEY",
"value": "2b"
},
{
"context": "ord'Access);\n PBKDF2_HMAC_SHA256 (Password => Lock_IV,\n Salt => Salt_Key,\n",
"end": 11736,
"score": 0.9957926869392395,
"start": 11729,
"tag": "PASSWORD",
"value": "Lock_IV"
}
] | src/keystore-keys.adb | My-Colaborations/ada-keystore | 25 | -----------------------------------------------------------------------
-- keystore-keys -- Keystore key management
-- Copyright (C) 2019, 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.Streams;
with Util.Log.Loggers;
with Util.Encoders.SHA256;
with Util.Encoders.HMAC.SHA256;
with Util.Encoders.KDF.PBKDF2_HMAC_SHA256;
with Keystore.Logs;
with Keystore.Buffers;
-- === Master keys ===
-- Wallet header encrypted with the parent wallet id
--
-- ```
-- +------------------+
-- | 01 01 | 2b
-- | Encrypt size | 2b
-- | Parent Wallet id | 4b
-- | PAD 0 | 4b
-- | PAD 0 | 4b
-- +------------------+
-- | Wallet magic | 4b
-- | Wallet version | 4b
-- | Wallet lid | 4b
-- | Wallet block ID | 4b
-- +------------------+
-- | Wallet gid | 16b
-- +------------------+
-- | Wallet key count | 4b
-- | PAD 0 | 4b
-- +------------------+
-- | Key type | 4b
-- | Key size | 4b
-- | Counter for key | 4b
-- | Counter for iv | 4b
-- | Salt for key | 32b
-- | Salt for iv | 32b
-- | Key slot sign | 32b
-- | Dir key # 1 | 32b ---
-- | Dir iv # 1 | 16b ^
-- | Dir sign # 1 | 32b |
-- | Data key # 1 | 32b |
-- | Data iv # 1 | 16b | Encrypted by user's password
-- | Data sign #1 | 32b |
-- | Key key # 1 | 32b |
-- | Key iv # 1 | 16b v
-- | Key sign #1 | 32b ---
-- | Slot HMAC-256 | 32b
-- | PAD 0 / Random | 80b
-- +------------------+
-- | Key slot #2 | 512b
-- +------------------+
-- | Key slot #3 | 512b
-- +------------------+
-- | Key slot #4 | 512b
-- +------------------+
-- | Key slot #5 | 512b
-- +------------------+
-- | Key slot #6 | 512b
-- +------------------+
-- | Key slot #7 | 512b
-- +------------------+
-- | PAD 0 / Random |
-- +------------------+
-- | Block HMAC-256 | 32b
-- +------------------+
-- ```
--
package body Keystore.Keys is
use Interfaces;
use Ada.Streams;
use Util.Encoders.KDF;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Keystore.Keys");
procedure Save_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in out Keystore.Passwords.Provider'Class;
Slot : in Key_Slot;
Config : in Wallet_Config;
Stream : in out IO.Wallet_Stream'Class);
procedure Erase_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Slot : in Key_Slot;
Stream : in out IO.Wallet_Stream'Class);
procedure Extract (Buffer : in out Marshallers.Marshaller;
Lock_Key : in Secret_Key;
Lock_IV : in Secret_Key;
Crypt : in out Cryptor;
Hmac : in out Util.Encoders.HMAC.SHA256.Context);
function Verify_GPG (Manager : in Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in Passwords.Slot_Provider'Class;
Config : in out Wallet_Config) return Boolean;
function Verify_PBKDF2 (Manager : in Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in Passwords.Provider'Class;
Size : in Positive;
Config : in out Wallet_Config) return Boolean;
procedure Generate (Manager : in out Key_Manager;
Crypt : in out Cryptor);
procedure Save (Buffer : in out IO.Marshaller;
Lock_Key : in Secret_Key;
Lock_IV : in Secret_Key;
Crypt : in Cryptor;
Hmac : in out Util.Encoders.HMAC.SHA256.Context);
procedure Load (Manager : in out Key_Manager;
Block : in Keystore.IO.Storage_Block;
Ident : in Wallet_Identifier;
Buffer : in out IO.Marshaller;
Root : out Keystore.IO.Storage_Block;
UUID : out UUID_Type;
Stream : in out IO.Wallet_Stream'Class);
-- ------------------------------
-- Set the IV vector to be used for the encryption and decryption of the given block number.
-- ------------------------------
procedure Set_IV (Into : in out Cryptor;
Block : in IO.Block_Number) is
Block_IV : constant Util.Encoders.AES.Word_Block_Type
:= (others => Interfaces.Unsigned_32 (Block));
begin
Into.Decipher.Set_IV (Into.IV, Block_IV);
Into.Cipher.Set_IV (Into.IV, Block_IV);
end Set_IV;
procedure Set_Key (Into : in out Cryptor;
From : in Cryptor) is
begin
Into.Cipher.Set_Key (From.Key, Util.Encoders.AES.CBC);
Into.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Into.Decipher.Set_Key (From.Key, Util.Encoders.AES.CBC);
Into.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
end Set_Key;
-- ------------------------------
-- Extract the AES encryption key, the AES IV and the signature key.
-- Update the HMAC with the extracted encryption keys for global verification.
-- ------------------------------
procedure Extract (Buffer : in out Marshallers.Marshaller;
Lock_Key : in Secret_Key;
Lock_IV : in Secret_Key;
Crypt : in out Cryptor;
Hmac : in out Util.Encoders.HMAC.SHA256.Context) is
begin
Marshallers.Get_Secret (Buffer, Crypt.Key, Lock_Key, Lock_IV);
Marshallers.Get_Secret (Buffer, Crypt.IV, Lock_Key, Lock_IV);
Marshallers.Get_Secret (Buffer, Crypt.Sign, Lock_Key, Lock_IV);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.Key);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.IV);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.Sign);
Crypt.Cipher.Set_Key (Crypt.Key, Util.Encoders.AES.CBC);
Crypt.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Crypt.Decipher.Set_Key (Crypt.Key, Util.Encoders.AES.CBC);
Crypt.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
end Extract;
procedure Generate (Manager : in out Key_Manager;
Crypt : in out Cryptor) is
begin
Manager.Random.Generate (Crypt.Sign);
Manager.Random.Generate (Crypt.Key);
Manager.Random.Generate (Crypt.IV);
Crypt.Cipher.Set_Key (Crypt.Key, Util.Encoders.AES.CBC);
Crypt.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Crypt.Decipher.Set_Key (Crypt.Key, Util.Encoders.AES.CBC);
Crypt.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
end Generate;
procedure Save (Buffer : in out Marshallers.Marshaller;
Lock_Key : in Secret_Key;
Lock_IV : in Secret_Key;
Crypt : in Cryptor;
Hmac : in out Util.Encoders.HMAC.SHA256.Context) is
begin
Marshallers.Put_Secret (Buffer, Crypt.Key, Lock_Key, Lock_IV);
Marshallers.Put_Secret (Buffer, Crypt.IV, Lock_Key, Lock_IV);
Marshallers.Put_Secret (Buffer, Crypt.Sign, Lock_Key, Lock_IV);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.Key);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.IV);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.Sign);
end Save;
function Verify_GPG (Manager : in Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in Passwords.Slot_Provider'Class;
Config : in out Wallet_Config) return Boolean is
procedure Get_Password (Key : in Secret_Key;
IV : in Secret_Key);
Buf : constant Buffers.Buffer_Accessor := Buffer.Buffer.Data.Value;
Sign : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Result : Util.Encoders.SHA256.Hash_Array;
Hmac : Util.Encoders.HMAC.SHA256.Context;
-- Get the directory encryption key and IV.
procedure Get_Password (Key : in Secret_Key;
IV : in Secret_Key) is
begin
Extract (Buffer, Key, IV, Config.Dir, Hmac);
Extract (Buffer, Key, IV, Config.Data, Hmac);
Extract (Buffer, Key, IV, Config.Key, Hmac);
end Get_Password;
begin
Marshallers.Get_Secret (Buffer, Sign, Manager.Crypt.Key, Manager.Crypt.IV);
-- Build a signature from the master key and the wallet salt.
Util.Encoders.HMAC.SHA256.Set_Key (Hmac, Sign);
Password.Get_Key (Get_Password'Access);
Util.Encoders.HMAC.SHA256.Finish (Hmac, Result);
return Result = Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + Result'Length);
end Verify_GPG;
function Verify_PBKDF2 (Manager : in Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in Passwords.Provider'Class;
Size : in Positive;
Config : in out Wallet_Config) return Boolean is
procedure Get_Password (Secret : in Secret_Key);
Buf : constant Buffers.Buffer_Accessor := Buffer.Buffer.Data.Value;
Salt_Key : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Salt_IV : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Sign : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Lock_Key : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Lock_IV : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Result : Util.Encoders.SHA256.Hash_Array;
Hmac : Util.Encoders.HMAC.SHA256.Context;
Counter_Key : Interfaces.Unsigned_32;
Counter_IV : Interfaces.Unsigned_32;
-- Generate a derived key from the password, salt, counter.
procedure Get_Password (Secret : in Secret_Key) is
begin
PBKDF2_HMAC_SHA256 (Password => Secret,
Salt => Salt_IV,
Counter => Positive (Counter_IV),
Result => Lock_IV);
end Get_Password;
begin
Counter_Key := Marshallers.Get_Unsigned_32 (Buffer);
Counter_IV := Marshallers.Get_Unsigned_32 (Buffer);
if Counter_Key = 0 or Counter_IV = 0 or Size /= Util.Encoders.AES.AES_256_Length then
return False;
end if;
Marshallers.Get_Secret (Buffer, Salt_Key, Manager.Crypt.Key, Manager.Crypt.IV);
Marshallers.Get_Secret (Buffer, Salt_IV, Manager.Crypt.Key, Manager.Crypt.IV);
Marshallers.Get_Secret (Buffer, Sign, Manager.Crypt.Key, Manager.Crypt.IV);
Password.Get_Password (Get_Password'Access);
PBKDF2_HMAC_SHA256 (Password => Lock_IV,
Salt => Salt_Key,
Counter => Positive (Counter_Key),
Result => Lock_Key);
-- Build a signature from the master key and the wallet salt.
Util.Encoders.HMAC.SHA256.Set_Key (Hmac, Sign);
-- Get the directory encryption key and IV.
Extract (Buffer, Lock_Key, Lock_IV, Config.Dir, Hmac);
Extract (Buffer, Lock_Key, Lock_IV, Config.Data, Hmac);
Extract (Buffer, Lock_Key, Lock_IV, Config.Key, Hmac);
Util.Encoders.HMAC.SHA256.Finish (Hmac, Result);
return Result = Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + Result'Length);
end Verify_PBKDF2;
-- ------------------------------
-- Save the wallet config encryption keys in the key slot and protect that
-- key using the user's password. New salts and counters are generated and
-- the user's password is passed through PBKDF2 to get the encryption key
-- that protects the key slot.
-- ------------------------------
procedure Save_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in out Keystore.Passwords.Provider'Class;
Slot : in Key_Slot;
Config : in Wallet_Config;
Stream : in out IO.Wallet_Stream'Class) is
procedure Save_GPG_Key (Password : in out Keystore.Passwords.Slot_Provider'Class);
procedure Save_PBKDF2_Key;
Slot_Sign : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Hmac : Util.Encoders.HMAC.SHA256.Context;
Result : Util.Encoders.SHA256.Hash_Array;
Buf : constant Buffers.Buffer_Accessor := Buffer.Buffer.Data.Value;
procedure Save_PBKDF2_Key is
procedure Get_Password (Secret : in Secret_Key);
Lock_Key : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Lock_IV : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Salt_Key : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Salt_IV : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Counter_Key : Positive;
Counter_IV : Positive;
-- Generate a derived key from the password, salt, counter.
procedure Get_Password (Secret : in Secret_Key) is
begin
PBKDF2_HMAC_SHA256 (Password => Secret,
Salt => Salt_IV,
Counter => Counter_IV,
Result => Lock_IV);
end Get_Password;
begin
-- Make a first random counter in range 100_000 .. 1_148_575.
Counter_Key := 1 + Natural (Manager.Random.Generate mod Config.Max_Counter);
if Counter_Key < Positive (Config.Min_Counter) then
Counter_Key := Positive (Config.Min_Counter);
end if;
-- Make a second random counter in range 100_000 .. 372_140.
Counter_IV := 1 + Natural (Manager.Random.Generate mod Config.Max_Counter);
if Counter_IV < Positive (Config.Min_Counter) then
Counter_IV := Positive (Config.Min_Counter);
end if;
Manager.Random.Generate (Salt_Key);
Manager.Random.Generate (Salt_IV);
Marshallers.Put_Unsigned_32 (Buffer, WH_KEY_PBKDF2);
Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Lock_Key.Length));
Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Counter_Key));
Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Counter_IV));
Marshallers.Put_Secret (Buffer, Salt_Key, Manager.Crypt.Key, Manager.Crypt.IV);
Marshallers.Put_Secret (Buffer, Salt_IV, Manager.Crypt.Key, Manager.Crypt.IV);
Marshallers.Put_Secret (Buffer, Slot_Sign, Manager.Crypt.Key, Manager.Crypt.IV);
Password.Get_Password (Get_Password'Access);
PBKDF2_HMAC_SHA256 (Password => Lock_IV,
Salt => Salt_Key,
Counter => Counter_Key,
Result => Lock_Key);
Save (Buffer, Lock_Key, Lock_IV, Config.Dir, Hmac);
Save (Buffer, Lock_Key, Lock_IV, Config.Data, Hmac);
Save (Buffer, Lock_Key, Lock_IV, Config.Key, Hmac);
end Save_PBKDF2_Key;
procedure Save_GPG_Key (Password : in out Keystore.Passwords.Slot_Provider'Class) is
procedure Get_Key (Key : in Secret_Key;
IV : in Secret_Key);
procedure Get_Key (Key : in Secret_Key;
IV : in Secret_Key) is
begin
Marshallers.Put_Unsigned_32 (Buffer, Password.Get_Tag);
Marshallers.Put_Secret (Buffer, Slot_Sign, Manager.Crypt.Key, Manager.Crypt.IV);
Save (Buffer, Key, IV, Config.Dir, Hmac);
Save (Buffer, Key, IV, Config.Data, Hmac);
Save (Buffer, Key, IV, Config.Key, Hmac);
end Get_Key;
begin
Marshallers.Put_Unsigned_32 (Buffer, WH_KEY_GPG2);
Password.Get_Key (Get_Key'Access);
end Save_GPG_Key;
begin
Log.Info ("Saving key for wallet {0}", To_String (Config.UUID));
Manager.Random.Generate (Slot_Sign);
-- Build a signature from the lock key.
Util.Encoders.HMAC.SHA256.Set_Key (Hmac, Slot_Sign);
Buffer.Pos := Key_Position (Slot);
Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + WH_KEY_SIZE) := (others => 0);
if Password in Keystore.Passwords.Slot_Provider'Class then
Save_GPG_Key (Keystore.Passwords.Slot_Provider'Class (Password));
else
Save_PBKDF2_Key;
end if;
Util.Encoders.HMAC.SHA256.Finish (Hmac, Result);
Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + Result'Length) := Result;
Set_IV (Manager.Crypt, Buffer.Buffer.Block.Block);
Stream.Write (Cipher => Manager.Crypt.Cipher,
Sign => Manager.Crypt.Sign,
From => Buffer.Buffer);
end Save_Key;
-- ------------------------------
-- Erase the walley key slot amd save the waller master block.
-- ------------------------------
procedure Erase_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Slot : in Key_Slot;
Stream : in out IO.Wallet_Stream'Class) is
Buf : constant Buffers.Buffer_Accessor := Buffer.Buffer.Data.Value;
begin
Buffer.Pos := Key_Position (Slot);
Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + WH_KEY_SIZE) := (others => 0);
Stream.Write (Cipher => Manager.Crypt.Cipher,
Sign => Manager.Crypt.Sign,
From => Buffer.Buffer);
end Erase_Key;
-- ------------------------------
-- Load the wallet header keys
-- ------------------------------
procedure Load (Manager : in out Key_Manager;
Block : in Keystore.IO.Storage_Block;
Ident : in Wallet_Identifier;
Buffer : in out IO.Marshaller;
Root : out Keystore.IO.Storage_Block;
UUID : out UUID_Type;
Stream : in out IO.Wallet_Stream'Class) is
Value : Interfaces.Unsigned_32;
Size : IO.Block_Index;
begin
Keystore.Logs.Info (Log, "Loading master block{0}", Block);
Set_IV (Manager.Crypt, Block.Block);
Buffer.Buffer := Buffers.Allocate (Block);
Manager.Header_Block := Block;
begin
Stream.Read (Decipher => Manager.Crypt.Decipher,
Sign => Manager.Crypt.Sign,
Decrypt_Size => Size,
Into => Buffer.Buffer);
exception
when Invalid_Signature =>
Keystore.Logs.Warn (Log, "Invalid signature for wallet block{0}," &
" may be an invalid wallet key was used",
Manager.Header_Block);
raise Bad_Password;
end;
if Marshallers.Get_Header_16 (Buffer) /= IO.BT_WALLET_HEADER then
Keystore.Logs.Warn (Log, "Invalid wallet block header BN{0}", Manager.Header_Block);
raise Invalid_Block;
end if;
Marshallers.Skip (Buffer, 2);
Value := Marshallers.Get_Unsigned_32 (Buffer);
Marshallers.Skip (Buffer, 8);
if Marshallers.Get_Unsigned_32 (Buffer) /= WH_MAGIC then
Keystore.Logs.Warn (Log, "Invalid wallet magic in header BN{0}", Manager.Header_Block);
raise Invalid_Block;
end if;
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value /= 1 then
Log.Warn ("Version{0} not supported in header BN{0}",
Interfaces.Unsigned_32'Image (Value),
IO.Block_Number'Image (Manager.Header_Block.Block));
raise Invalid_Block;
end if;
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value /= Interfaces.Unsigned_32 (Ident) then
Log.Warn ("Wallet id{0} does not match in header BN{0}",
Interfaces.Unsigned_32'Image (Value),
IO.Block_Number'Image (Manager.Header_Block.Block));
raise Invalid_Block;
end if;
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value = 0 then
Log.Warn ("Wallet block{0} is invalid in header BN{0}",
Interfaces.Unsigned_32'Image (Value),
IO.Block_Number'Image (Manager.Header_Block.Block));
raise Invalid_Block;
end if;
Root.Storage := Block.Storage;
Root.Block := IO.Block_Number (Value);
-- Extract wallet uuid.
Marshallers.Get_UUID (Buffer, UUID);
end Load;
-- Open the key manager and read the wallet header block. Use the secret key
-- to decrypt/encrypt the wallet header block.
procedure Open (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Provider'Class;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Root : out Keystore.IO.Storage_Block;
Config : in out Wallet_Config;
Process : access procedure (Buffer : in out Marshallers.Marshaller;
Slot : in Key_Slot);
Stream : in out IO.Wallet_Stream'Class) is
procedure Open (Password : in out Keystore.Passwords.Slot_Provider'Class);
Value : Interfaces.Unsigned_32;
Buffer : Marshallers.Marshaller;
procedure Open (Password : in out Keystore.Passwords.Slot_Provider'Class) is
begin
while Password.Has_Password loop
for Slot in Key_Slot'Range loop
Buffer.Pos := Key_Position (Slot);
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value = WH_KEY_GPG2 then
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value = Password.Get_Tag then
if Verify_GPG (Manager, Buffer, Password, Config) then
Config.Slot := Slot;
if Process /= null then
Process (Buffer, Slot);
end if;
return;
end if;
end if;
end if;
end loop;
Password.Next;
end loop;
Keystore.Logs.Info (Log, "No password match for wallet block{0}", Manager.Header_Block);
raise Bad_Password;
end Open;
begin
Load (Manager, Block, Ident, Buffer, Root, Config.UUID, Stream);
-- See which key slot is used.
for Slot in Key_Slot'Range loop
Buffer.Pos := Key_Position (Slot);
Value := Marshallers.Get_Unsigned_32 (Buffer);
Config.Keys (Slot) := Value /= 0;
end loop;
if Password in Keystore.Passwords.Slot_Provider'Class then
Open (Keystore.Passwords.Slot_Provider'Class (Password));
else
for Slot in Key_Slot'Range loop
Buffer.Pos := Key_Position (Slot);
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value = WH_KEY_PBKDF2 then
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value > 0 and Value <= WH_KEY_SIZE then
if Verify_PBKDF2 (Manager, Buffer, Password, Positive (Value), Config) then
Config.Slot := Slot;
if Process /= null then
Process (Buffer, Slot);
end if;
return;
end if;
end if;
end if;
end loop;
Keystore.Logs.Info (Log, "No password match for wallet block{0}", Manager.Header_Block);
raise Bad_Password;
end if;
end Open;
procedure Create (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Provider'Class;
Slot : in Key_Slot;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Root : in Keystore.IO.Storage_Block;
Config : in out Wallet_Config;
Stream : in out IO.Wallet_Stream'Class) is
Buffer : IO.Marshaller;
begin
Buffer.Buffer := Buffers.Allocate (Block);
Generate (Manager, Config.Data);
Generate (Manager, Config.Dir);
Generate (Manager, Config.Key);
Manager.Random.Generate (Config.UUID);
Manager.Header_Block := Block;
-- Build wallet header.
if Config.Randomize then
Manager.Random.Generate (Buffer.Buffer.Data.Value.Data);
else
Buffer.Buffer.Data.Value.Data := (others => 0);
end if;
Marshallers.Set_Header (Into => Buffer,
Tag => IO.BT_WALLET_HEADER,
Id => Ident);
Marshallers.Put_Unsigned_32 (Buffer, WH_MAGIC);
Marshallers.Put_Unsigned_32 (Buffer, 1);
Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Ident));
Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Root.Block));
-- Write wallet uuid.
Marshallers.Put_UUID (Buffer, Config.UUID);
if Config.Randomize then
for Slot in Key_Slot'Range loop
Buffer.Pos := Key_Position (Slot);
Marshallers.Put_Unsigned_32 (Buffer, 0);
end loop;
end if;
Save_Key (Manager, Buffer, Password, Slot, Config, Stream);
end Create;
-- ------------------------------
-- Create a new masker keys for a children wallet and save the new keys in the buffer.
-- ------------------------------
procedure Create_Master_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Crypt : in Cryptor) is
begin
Manager.Random.Generate (Manager.Crypt.Key);
Manager.Random.Generate (Manager.Crypt.IV);
Manager.Crypt.Decipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Manager.Crypt.Cipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Marshallers.Put_Secret (Buffer, Manager.Crypt.Key, Crypt.Key, Crypt.IV);
Marshallers.Put_Secret (Buffer, Manager.Crypt.IV, Crypt.Key, Crypt.IV);
end Create_Master_Key;
-- ------------------------------
-- Extract from the buffer the master keys to open the children wallet.
-- ------------------------------
procedure Load_Master_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Crypt : in Cryptor) is
begin
Marshallers.Get_Secret (Buffer, Manager.Crypt.Key, Crypt.Key, Crypt.IV);
Marshallers.Get_Secret (Buffer, Manager.Crypt.IV, Crypt.Key, Crypt.IV);
Manager.Crypt.Decipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Manager.Crypt.Cipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
end Load_Master_Key;
-- ------------------------------
-- Set the master key by using the password provider.
-- ------------------------------
procedure Set_Master_Key (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Keys.Key_Provider'Class) is
begin
Password.Get_Keys (Manager.Crypt.Key, Manager.Crypt.IV, Manager.Crypt.Sign);
Manager.Crypt.Decipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Manager.Crypt.Cipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
end Set_Master_Key;
procedure Set_Key (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Provider'Class;
New_Password : in out Keystore.Passwords.Provider'Class;
Config : in Keystore.Wallet_Config;
Mode : in Mode_Type;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Stream : in out IO.Wallet_Stream'Class) is
procedure Process (Buffer : in out Marshallers.Marshaller;
Slot : in Key_Slot);
Local_Config : Wallet_Config;
Root : Keystore.IO.Storage_Block;
procedure Process (Buffer : in out Marshallers.Marshaller;
Slot : in Key_Slot) is
function Find_Free_Slot return Key_Slot;
function Find_Free_Slot return Key_Slot is
Value : Interfaces.Unsigned_32;
begin
for Slot in Key_Slot'Range loop
Buffer.Pos := Key_Position (Slot);
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value = 0 then
return Slot;
end if;
end loop;
Log.Info ("No available free slot to add a new key");
raise No_Key_Slot;
end Find_Free_Slot;
begin
Local_Config.Min_Counter := Unsigned_32 (Config.Min_Counter);
Local_Config.Max_Counter := Unsigned_32 (Config.Max_Counter);
case Mode is
when KEY_ADD =>
Save_Key (Manager, Buffer, New_Password, Find_Free_Slot,
Local_Config, Stream);
when KEY_REPLACE =>
Save_Key (Manager, Buffer, New_Password, Slot, Local_Config, Stream);
when KEY_REMOVE =>
Erase_Key (Manager, Buffer, Slot, Stream);
end case;
end Process;
begin
Open (Manager, Password, Ident, Block, Root, Local_Config,
Process'Access, Stream);
end Set_Key;
-- ------------------------------
-- Remove the key from the key slot identified by `Slot`. The password is necessary to
-- make sure a valid password is available. The `Remove_Current` must be set to remove
-- the slot when it corresponds to the used password.
-- ------------------------------
procedure Remove_Key (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Provider'Class;
Slot : in Key_Slot;
Remove_Current : in Boolean;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Stream : in out IO.Wallet_Stream'Class) is
procedure Process (Buffer : in out Marshallers.Marshaller;
Password_Slot : in Key_Slot);
procedure Process (Buffer : in out Marshallers.Marshaller;
Password_Slot : in Key_Slot) is
begin
if Slot /= Password_Slot or Remove_Current then
Erase_Key (Manager, Buffer, Slot, Stream);
else
Log.Info ("Refusing to delete key slot used by current password");
raise Used_Key_Slot;
end if;
end Process;
Local_Config : Wallet_Config;
Root : Keystore.IO.Storage_Block;
begin
Open (Manager, Password, Ident, Block, Root, Local_Config,
Process'Access, Stream);
end Remove_Key;
end Keystore.Keys;
| 30202 | -----------------------------------------------------------------------
-- keystore-keys -- Keystore key management
-- Copyright (C) 2019, 2020 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Streams;
with Util.Log.Loggers;
with Util.Encoders.SHA256;
with Util.Encoders.HMAC.SHA256;
with Util.Encoders.KDF.PBKDF2_HMAC_SHA256;
with Keystore.Logs;
with Keystore.Buffers;
-- === Master keys ===
-- Wallet header encrypted with the parent wallet id
--
-- ```
-- +------------------+
-- | 01 01 | 2b
-- | Encrypt size | 2b
-- | Parent Wallet id | 4b
-- | PAD 0 | 4b
-- | PAD 0 | 4b
-- +------------------+
-- | Wallet magic | 4b
-- | Wallet version | 4b
-- | Wallet lid | 4b
-- | Wallet block ID | 4b
-- +------------------+
-- | Wallet gid | 16b
-- +------------------+
-- | Wallet key count | 4b
-- | PAD 0 | 4b
-- +------------------+
-- | Key type | 4b
-- | Key size | 4b
-- | Counter for key | 4b
-- | Counter for iv | 4b
-- | Salt for key | 32b
-- | Salt for iv | 32b
-- | Key slot sign | 32b
-- | Dir key # 1 | 32b ---
-- | Dir iv # 1 | 16b ^
-- | Dir sign # 1 | 32b |
-- | Data key # 1 | <KEY> |
-- | Data iv # 1 | 16b | Encrypted by user's password
-- | Data sign #1 | 32b |
-- | Key key # 1 | 3<KEY> |
-- | Key iv # 1 | 16b v
-- | Key sign #1 | 32b ---
-- | Slot HMAC-256 | 32b
-- | PAD 0 / Random | 80b
-- +------------------+
-- | Key slot #2 | 512b
-- +------------------+
-- | Key slot #3 | 512b
-- +------------------+
-- | Key slot #4 | 512b
-- +------------------+
-- | Key slot #5 | 512b
-- +------------------+
-- | Key slot #6 | 512b
-- +------------------+
-- | Key slot #7 | 512b
-- +------------------+
-- | PAD 0 / Random |
-- +------------------+
-- | Block HMAC-256 | 32b
-- +------------------+
-- ```
--
package body Keystore.Keys is
use Interfaces;
use Ada.Streams;
use Util.Encoders.KDF;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Keystore.Keys");
procedure Save_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in out Keystore.Passwords.Provider'Class;
Slot : in Key_Slot;
Config : in Wallet_Config;
Stream : in out IO.Wallet_Stream'Class);
procedure Erase_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Slot : in Key_Slot;
Stream : in out IO.Wallet_Stream'Class);
procedure Extract (Buffer : in out Marshallers.Marshaller;
Lock_Key : in Secret_Key;
Lock_IV : in Secret_Key;
Crypt : in out Cryptor;
Hmac : in out Util.Encoders.HMAC.SHA256.Context);
function Verify_GPG (Manager : in Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in Passwords.Slot_Provider'Class;
Config : in out Wallet_Config) return Boolean;
function Verify_PBKDF2 (Manager : in Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in Passwords.Provider'Class;
Size : in Positive;
Config : in out Wallet_Config) return Boolean;
procedure Generate (Manager : in out Key_Manager;
Crypt : in out Cryptor);
procedure Save (Buffer : in out IO.Marshaller;
Lock_Key : in Secret_Key;
Lock_IV : in Secret_Key;
Crypt : in Cryptor;
Hmac : in out Util.Encoders.HMAC.SHA256.Context);
procedure Load (Manager : in out Key_Manager;
Block : in Keystore.IO.Storage_Block;
Ident : in Wallet_Identifier;
Buffer : in out IO.Marshaller;
Root : out Keystore.IO.Storage_Block;
UUID : out UUID_Type;
Stream : in out IO.Wallet_Stream'Class);
-- ------------------------------
-- Set the IV vector to be used for the encryption and decryption of the given block number.
-- ------------------------------
procedure Set_IV (Into : in out Cryptor;
Block : in IO.Block_Number) is
Block_IV : constant Util.Encoders.AES.Word_Block_Type
:= (others => Interfaces.Unsigned_32 (Block));
begin
Into.Decipher.Set_IV (Into.IV, Block_IV);
Into.Cipher.Set_IV (Into.IV, Block_IV);
end Set_IV;
procedure Set_Key (Into : in out Cryptor;
From : in Cryptor) is
begin
Into.Cipher.Set_Key (From.Key, Util.Encoders.AES.CBC);
Into.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Into.Decipher.Set_Key (From.Key, Util.Encoders.AES.CBC);
Into.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
end Set_Key;
-- ------------------------------
-- Extract the AES encryption key, the AES IV and the signature key.
-- Update the HMAC with the extracted encryption keys for global verification.
-- ------------------------------
procedure Extract (Buffer : in out Marshallers.Marshaller;
Lock_Key : in Secret_Key;
Lock_IV : in Secret_Key;
Crypt : in out Cryptor;
Hmac : in out Util.Encoders.HMAC.SHA256.Context) is
begin
Marshallers.Get_Secret (Buffer, Crypt.Key, Lock_Key, Lock_IV);
Marshallers.Get_Secret (Buffer, Crypt.IV, Lock_Key, Lock_IV);
Marshallers.Get_Secret (Buffer, Crypt.Sign, Lock_Key, Lock_IV);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.Key);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.IV);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.Sign);
Crypt.Cipher.Set_Key (Crypt.Key, Util.Encoders.AES.CBC);
Crypt.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Crypt.Decipher.Set_Key (Crypt.Key, Util.Encoders.AES.CBC);
Crypt.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
end Extract;
procedure Generate (Manager : in out Key_Manager;
Crypt : in out Cryptor) is
begin
Manager.Random.Generate (Crypt.Sign);
Manager.Random.Generate (Crypt.Key);
Manager.Random.Generate (Crypt.IV);
Crypt.Cipher.Set_Key (Crypt.Key, Util.Encoders.AES.CBC);
Crypt.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Crypt.Decipher.Set_Key (Crypt.Key, Util.Encoders.AES.CBC);
Crypt.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
end Generate;
procedure Save (Buffer : in out Marshallers.Marshaller;
Lock_Key : in Secret_Key;
Lock_IV : in Secret_Key;
Crypt : in Cryptor;
Hmac : in out Util.Encoders.HMAC.SHA256.Context) is
begin
Marshallers.Put_Secret (Buffer, Crypt.Key, Lock_Key, Lock_IV);
Marshallers.Put_Secret (Buffer, Crypt.IV, Lock_Key, Lock_IV);
Marshallers.Put_Secret (Buffer, Crypt.Sign, Lock_Key, Lock_IV);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.Key);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.IV);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.Sign);
end Save;
function Verify_GPG (Manager : in Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in Passwords.Slot_Provider'Class;
Config : in out Wallet_Config) return Boolean is
procedure Get_Password (Key : in Secret_Key;
IV : in Secret_Key);
Buf : constant Buffers.Buffer_Accessor := Buffer.Buffer.Data.Value;
Sign : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Result : Util.Encoders.SHA256.Hash_Array;
Hmac : Util.Encoders.HMAC.SHA256.Context;
-- Get the directory encryption key and IV.
procedure Get_Password (Key : in Secret_Key;
IV : in Secret_Key) is
begin
Extract (Buffer, Key, IV, Config.Dir, Hmac);
Extract (Buffer, Key, IV, Config.Data, Hmac);
Extract (Buffer, Key, IV, Config.Key, Hmac);
end Get_Password;
begin
Marshallers.Get_Secret (Buffer, Sign, Manager.Crypt.Key, Manager.Crypt.IV);
-- Build a signature from the master key and the wallet salt.
Util.Encoders.HMAC.SHA256.Set_Key (Hmac, Sign);
Password.Get_Key (Get_Password'Access);
Util.Encoders.HMAC.SHA256.Finish (Hmac, Result);
return Result = Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + Result'Length);
end Verify_GPG;
function Verify_PBKDF2 (Manager : in Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in Passwords.Provider'Class;
Size : in Positive;
Config : in out Wallet_Config) return Boolean is
procedure Get_Password (Secret : in Secret_Key);
Buf : constant Buffers.Buffer_Accessor := Buffer.Buffer.Data.Value;
Salt_Key : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Salt_IV : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Sign : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Lock_Key : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Lock_IV : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Result : Util.Encoders.SHA256.Hash_Array;
Hmac : Util.Encoders.HMAC.SHA256.Context;
Counter_Key : Interfaces.Unsigned_32;
Counter_IV : Interfaces.Unsigned_32;
-- Generate a derived key from the password, salt, counter.
procedure Get_Password (Secret : in Secret_Key) is
begin
PBKDF2_HMAC_SHA256 (Password => Secret,
Salt => Salt_IV,
Counter => Positive (Counter_IV),
Result => Lock_IV);
end Get_Password;
begin
Counter_Key := Marshallers.Get_Unsigned_32 (Buffer);
Counter_IV := Marshallers.Get_Unsigned_32 (Buffer);
if Counter_Key = 0 or Counter_IV = 0 or Size /= Util.Encoders.AES.AES_256_Length then
return False;
end if;
Marshallers.Get_Secret (Buffer, Salt_Key, Manager.Crypt.Key, Manager.Crypt.IV);
Marshallers.Get_Secret (Buffer, Salt_IV, Manager.Crypt.Key, Manager.Crypt.IV);
Marshallers.Get_Secret (Buffer, Sign, Manager.Crypt.Key, Manager.Crypt.IV);
Password.Get_Password (Get_Password'Access);
PBKDF2_HMAC_SHA256 (Password => <PASSWORD>,
Salt => Salt_Key,
Counter => Positive (Counter_Key),
Result => Lock_Key);
-- Build a signature from the master key and the wallet salt.
Util.Encoders.HMAC.SHA256.Set_Key (Hmac, Sign);
-- Get the directory encryption key and IV.
Extract (Buffer, Lock_Key, Lock_IV, Config.Dir, Hmac);
Extract (Buffer, Lock_Key, Lock_IV, Config.Data, Hmac);
Extract (Buffer, Lock_Key, Lock_IV, Config.Key, Hmac);
Util.Encoders.HMAC.SHA256.Finish (Hmac, Result);
return Result = Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + Result'Length);
end Verify_PBKDF2;
-- ------------------------------
-- Save the wallet config encryption keys in the key slot and protect that
-- key using the user's password. New salts and counters are generated and
-- the user's password is passed through PBKDF2 to get the encryption key
-- that protects the key slot.
-- ------------------------------
procedure Save_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in out Keystore.Passwords.Provider'Class;
Slot : in Key_Slot;
Config : in Wallet_Config;
Stream : in out IO.Wallet_Stream'Class) is
procedure Save_GPG_Key (Password : in out Keystore.Passwords.Slot_Provider'Class);
procedure Save_PBKDF2_Key;
Slot_Sign : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Hmac : Util.Encoders.HMAC.SHA256.Context;
Result : Util.Encoders.SHA256.Hash_Array;
Buf : constant Buffers.Buffer_Accessor := Buffer.Buffer.Data.Value;
procedure Save_PBKDF2_Key is
procedure Get_Password (Secret : in Secret_Key);
Lock_Key : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Lock_IV : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Salt_Key : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Salt_IV : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Counter_Key : Positive;
Counter_IV : Positive;
-- Generate a derived key from the password, salt, counter.
procedure Get_Password (Secret : in Secret_Key) is
begin
PBKDF2_HMAC_SHA256 (Password => Secret,
Salt => Salt_IV,
Counter => Counter_IV,
Result => Lock_IV);
end Get_Password;
begin
-- Make a first random counter in range 100_000 .. 1_148_575.
Counter_Key := 1 + Natural (Manager.Random.Generate mod Config.Max_Counter);
if Counter_Key < Positive (Config.Min_Counter) then
Counter_Key := Positive (Config.Min_Counter);
end if;
-- Make a second random counter in range 100_000 .. 372_140.
Counter_IV := 1 + Natural (Manager.Random.Generate mod Config.Max_Counter);
if Counter_IV < Positive (Config.Min_Counter) then
Counter_IV := Positive (Config.Min_Counter);
end if;
Manager.Random.Generate (Salt_Key);
Manager.Random.Generate (Salt_IV);
Marshallers.Put_Unsigned_32 (Buffer, WH_KEY_PBKDF2);
Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Lock_Key.Length));
Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Counter_Key));
Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Counter_IV));
Marshallers.Put_Secret (Buffer, Salt_Key, Manager.Crypt.Key, Manager.Crypt.IV);
Marshallers.Put_Secret (Buffer, Salt_IV, Manager.Crypt.Key, Manager.Crypt.IV);
Marshallers.Put_Secret (Buffer, Slot_Sign, Manager.Crypt.Key, Manager.Crypt.IV);
Password.Get_Password (Get_Password'Access);
PBKDF2_HMAC_SHA256 (Password => Lock_IV,
Salt => Salt_Key,
Counter => Counter_Key,
Result => Lock_Key);
Save (Buffer, Lock_Key, Lock_IV, Config.Dir, Hmac);
Save (Buffer, Lock_Key, Lock_IV, Config.Data, Hmac);
Save (Buffer, Lock_Key, Lock_IV, Config.Key, Hmac);
end Save_PBKDF2_Key;
procedure Save_GPG_Key (Password : in out Keystore.Passwords.Slot_Provider'Class) is
procedure Get_Key (Key : in Secret_Key;
IV : in Secret_Key);
procedure Get_Key (Key : in Secret_Key;
IV : in Secret_Key) is
begin
Marshallers.Put_Unsigned_32 (Buffer, Password.Get_Tag);
Marshallers.Put_Secret (Buffer, Slot_Sign, Manager.Crypt.Key, Manager.Crypt.IV);
Save (Buffer, Key, IV, Config.Dir, Hmac);
Save (Buffer, Key, IV, Config.Data, Hmac);
Save (Buffer, Key, IV, Config.Key, Hmac);
end Get_Key;
begin
Marshallers.Put_Unsigned_32 (Buffer, WH_KEY_GPG2);
Password.Get_Key (Get_Key'Access);
end Save_GPG_Key;
begin
Log.Info ("Saving key for wallet {0}", To_String (Config.UUID));
Manager.Random.Generate (Slot_Sign);
-- Build a signature from the lock key.
Util.Encoders.HMAC.SHA256.Set_Key (Hmac, Slot_Sign);
Buffer.Pos := Key_Position (Slot);
Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + WH_KEY_SIZE) := (others => 0);
if Password in Keystore.Passwords.Slot_Provider'Class then
Save_GPG_Key (Keystore.Passwords.Slot_Provider'Class (Password));
else
Save_PBKDF2_Key;
end if;
Util.Encoders.HMAC.SHA256.Finish (Hmac, Result);
Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + Result'Length) := Result;
Set_IV (Manager.Crypt, Buffer.Buffer.Block.Block);
Stream.Write (Cipher => Manager.Crypt.Cipher,
Sign => Manager.Crypt.Sign,
From => Buffer.Buffer);
end Save_Key;
-- ------------------------------
-- Erase the walley key slot amd save the waller master block.
-- ------------------------------
procedure Erase_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Slot : in Key_Slot;
Stream : in out IO.Wallet_Stream'Class) is
Buf : constant Buffers.Buffer_Accessor := Buffer.Buffer.Data.Value;
begin
Buffer.Pos := Key_Position (Slot);
Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + WH_KEY_SIZE) := (others => 0);
Stream.Write (Cipher => Manager.Crypt.Cipher,
Sign => Manager.Crypt.Sign,
From => Buffer.Buffer);
end Erase_Key;
-- ------------------------------
-- Load the wallet header keys
-- ------------------------------
procedure Load (Manager : in out Key_Manager;
Block : in Keystore.IO.Storage_Block;
Ident : in Wallet_Identifier;
Buffer : in out IO.Marshaller;
Root : out Keystore.IO.Storage_Block;
UUID : out UUID_Type;
Stream : in out IO.Wallet_Stream'Class) is
Value : Interfaces.Unsigned_32;
Size : IO.Block_Index;
begin
Keystore.Logs.Info (Log, "Loading master block{0}", Block);
Set_IV (Manager.Crypt, Block.Block);
Buffer.Buffer := Buffers.Allocate (Block);
Manager.Header_Block := Block;
begin
Stream.Read (Decipher => Manager.Crypt.Decipher,
Sign => Manager.Crypt.Sign,
Decrypt_Size => Size,
Into => Buffer.Buffer);
exception
when Invalid_Signature =>
Keystore.Logs.Warn (Log, "Invalid signature for wallet block{0}," &
" may be an invalid wallet key was used",
Manager.Header_Block);
raise Bad_Password;
end;
if Marshallers.Get_Header_16 (Buffer) /= IO.BT_WALLET_HEADER then
Keystore.Logs.Warn (Log, "Invalid wallet block header BN{0}", Manager.Header_Block);
raise Invalid_Block;
end if;
Marshallers.Skip (Buffer, 2);
Value := Marshallers.Get_Unsigned_32 (Buffer);
Marshallers.Skip (Buffer, 8);
if Marshallers.Get_Unsigned_32 (Buffer) /= WH_MAGIC then
Keystore.Logs.Warn (Log, "Invalid wallet magic in header BN{0}", Manager.Header_Block);
raise Invalid_Block;
end if;
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value /= 1 then
Log.Warn ("Version{0} not supported in header BN{0}",
Interfaces.Unsigned_32'Image (Value),
IO.Block_Number'Image (Manager.Header_Block.Block));
raise Invalid_Block;
end if;
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value /= Interfaces.Unsigned_32 (Ident) then
Log.Warn ("Wallet id{0} does not match in header BN{0}",
Interfaces.Unsigned_32'Image (Value),
IO.Block_Number'Image (Manager.Header_Block.Block));
raise Invalid_Block;
end if;
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value = 0 then
Log.Warn ("Wallet block{0} is invalid in header BN{0}",
Interfaces.Unsigned_32'Image (Value),
IO.Block_Number'Image (Manager.Header_Block.Block));
raise Invalid_Block;
end if;
Root.Storage := Block.Storage;
Root.Block := IO.Block_Number (Value);
-- Extract wallet uuid.
Marshallers.Get_UUID (Buffer, UUID);
end Load;
-- Open the key manager and read the wallet header block. Use the secret key
-- to decrypt/encrypt the wallet header block.
procedure Open (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Provider'Class;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Root : out Keystore.IO.Storage_Block;
Config : in out Wallet_Config;
Process : access procedure (Buffer : in out Marshallers.Marshaller;
Slot : in Key_Slot);
Stream : in out IO.Wallet_Stream'Class) is
procedure Open (Password : in out Keystore.Passwords.Slot_Provider'Class);
Value : Interfaces.Unsigned_32;
Buffer : Marshallers.Marshaller;
procedure Open (Password : in out Keystore.Passwords.Slot_Provider'Class) is
begin
while Password.Has_Password loop
for Slot in Key_Slot'Range loop
Buffer.Pos := Key_Position (Slot);
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value = WH_KEY_GPG2 then
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value = Password.Get_Tag then
if Verify_GPG (Manager, Buffer, Password, Config) then
Config.Slot := Slot;
if Process /= null then
Process (Buffer, Slot);
end if;
return;
end if;
end if;
end if;
end loop;
Password.Next;
end loop;
Keystore.Logs.Info (Log, "No password match for wallet block{0}", Manager.Header_Block);
raise Bad_Password;
end Open;
begin
Load (Manager, Block, Ident, Buffer, Root, Config.UUID, Stream);
-- See which key slot is used.
for Slot in Key_Slot'Range loop
Buffer.Pos := Key_Position (Slot);
Value := Marshallers.Get_Unsigned_32 (Buffer);
Config.Keys (Slot) := Value /= 0;
end loop;
if Password in Keystore.Passwords.Slot_Provider'Class then
Open (Keystore.Passwords.Slot_Provider'Class (Password));
else
for Slot in Key_Slot'Range loop
Buffer.Pos := Key_Position (Slot);
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value = WH_KEY_PBKDF2 then
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value > 0 and Value <= WH_KEY_SIZE then
if Verify_PBKDF2 (Manager, Buffer, Password, Positive (Value), Config) then
Config.Slot := Slot;
if Process /= null then
Process (Buffer, Slot);
end if;
return;
end if;
end if;
end if;
end loop;
Keystore.Logs.Info (Log, "No password match for wallet block{0}", Manager.Header_Block);
raise Bad_Password;
end if;
end Open;
procedure Create (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Provider'Class;
Slot : in Key_Slot;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Root : in Keystore.IO.Storage_Block;
Config : in out Wallet_Config;
Stream : in out IO.Wallet_Stream'Class) is
Buffer : IO.Marshaller;
begin
Buffer.Buffer := Buffers.Allocate (Block);
Generate (Manager, Config.Data);
Generate (Manager, Config.Dir);
Generate (Manager, Config.Key);
Manager.Random.Generate (Config.UUID);
Manager.Header_Block := Block;
-- Build wallet header.
if Config.Randomize then
Manager.Random.Generate (Buffer.Buffer.Data.Value.Data);
else
Buffer.Buffer.Data.Value.Data := (others => 0);
end if;
Marshallers.Set_Header (Into => Buffer,
Tag => IO.BT_WALLET_HEADER,
Id => Ident);
Marshallers.Put_Unsigned_32 (Buffer, WH_MAGIC);
Marshallers.Put_Unsigned_32 (Buffer, 1);
Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Ident));
Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Root.Block));
-- Write wallet uuid.
Marshallers.Put_UUID (Buffer, Config.UUID);
if Config.Randomize then
for Slot in Key_Slot'Range loop
Buffer.Pos := Key_Position (Slot);
Marshallers.Put_Unsigned_32 (Buffer, 0);
end loop;
end if;
Save_Key (Manager, Buffer, Password, Slot, Config, Stream);
end Create;
-- ------------------------------
-- Create a new masker keys for a children wallet and save the new keys in the buffer.
-- ------------------------------
procedure Create_Master_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Crypt : in Cryptor) is
begin
Manager.Random.Generate (Manager.Crypt.Key);
Manager.Random.Generate (Manager.Crypt.IV);
Manager.Crypt.Decipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Manager.Crypt.Cipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Marshallers.Put_Secret (Buffer, Manager.Crypt.Key, Crypt.Key, Crypt.IV);
Marshallers.Put_Secret (Buffer, Manager.Crypt.IV, Crypt.Key, Crypt.IV);
end Create_Master_Key;
-- ------------------------------
-- Extract from the buffer the master keys to open the children wallet.
-- ------------------------------
procedure Load_Master_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Crypt : in Cryptor) is
begin
Marshallers.Get_Secret (Buffer, Manager.Crypt.Key, Crypt.Key, Crypt.IV);
Marshallers.Get_Secret (Buffer, Manager.Crypt.IV, Crypt.Key, Crypt.IV);
Manager.Crypt.Decipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Manager.Crypt.Cipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
end Load_Master_Key;
-- ------------------------------
-- Set the master key by using the password provider.
-- ------------------------------
procedure Set_Master_Key (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Keys.Key_Provider'Class) is
begin
Password.Get_Keys (Manager.Crypt.Key, Manager.Crypt.IV, Manager.Crypt.Sign);
Manager.Crypt.Decipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Manager.Crypt.Cipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
end Set_Master_Key;
procedure Set_Key (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Provider'Class;
New_Password : in out Keystore.Passwords.Provider'Class;
Config : in Keystore.Wallet_Config;
Mode : in Mode_Type;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Stream : in out IO.Wallet_Stream'Class) is
procedure Process (Buffer : in out Marshallers.Marshaller;
Slot : in Key_Slot);
Local_Config : Wallet_Config;
Root : Keystore.IO.Storage_Block;
procedure Process (Buffer : in out Marshallers.Marshaller;
Slot : in Key_Slot) is
function Find_Free_Slot return Key_Slot;
function Find_Free_Slot return Key_Slot is
Value : Interfaces.Unsigned_32;
begin
for Slot in Key_Slot'Range loop
Buffer.Pos := Key_Position (Slot);
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value = 0 then
return Slot;
end if;
end loop;
Log.Info ("No available free slot to add a new key");
raise No_Key_Slot;
end Find_Free_Slot;
begin
Local_Config.Min_Counter := Unsigned_32 (Config.Min_Counter);
Local_Config.Max_Counter := Unsigned_32 (Config.Max_Counter);
case Mode is
when KEY_ADD =>
Save_Key (Manager, Buffer, New_Password, Find_Free_Slot,
Local_Config, Stream);
when KEY_REPLACE =>
Save_Key (Manager, Buffer, New_Password, Slot, Local_Config, Stream);
when KEY_REMOVE =>
Erase_Key (Manager, Buffer, Slot, Stream);
end case;
end Process;
begin
Open (Manager, Password, Ident, Block, Root, Local_Config,
Process'Access, Stream);
end Set_Key;
-- ------------------------------
-- Remove the key from the key slot identified by `Slot`. The password is necessary to
-- make sure a valid password is available. The `Remove_Current` must be set to remove
-- the slot when it corresponds to the used password.
-- ------------------------------
procedure Remove_Key (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Provider'Class;
Slot : in Key_Slot;
Remove_Current : in Boolean;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Stream : in out IO.Wallet_Stream'Class) is
procedure Process (Buffer : in out Marshallers.Marshaller;
Password_Slot : in Key_Slot);
procedure Process (Buffer : in out Marshallers.Marshaller;
Password_Slot : in Key_Slot) is
begin
if Slot /= Password_Slot or Remove_Current then
Erase_Key (Manager, Buffer, Slot, Stream);
else
Log.Info ("Refusing to delete key slot used by current password");
raise Used_Key_Slot;
end if;
end Process;
Local_Config : Wallet_Config;
Root : Keystore.IO.Storage_Block;
begin
Open (Manager, Password, Ident, Block, Root, Local_Config,
Process'Access, Stream);
end Remove_Key;
end Keystore.Keys;
| true | -----------------------------------------------------------------------
-- keystore-keys -- Keystore key management
-- Copyright (C) 2019, 2020 PI:NAME:<NAME>END_PI
-- Written by PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Streams;
with Util.Log.Loggers;
with Util.Encoders.SHA256;
with Util.Encoders.HMAC.SHA256;
with Util.Encoders.KDF.PBKDF2_HMAC_SHA256;
with Keystore.Logs;
with Keystore.Buffers;
-- === Master keys ===
-- Wallet header encrypted with the parent wallet id
--
-- ```
-- +------------------+
-- | 01 01 | 2b
-- | Encrypt size | 2b
-- | Parent Wallet id | 4b
-- | PAD 0 | 4b
-- | PAD 0 | 4b
-- +------------------+
-- | Wallet magic | 4b
-- | Wallet version | 4b
-- | Wallet lid | 4b
-- | Wallet block ID | 4b
-- +------------------+
-- | Wallet gid | 16b
-- +------------------+
-- | Wallet key count | 4b
-- | PAD 0 | 4b
-- +------------------+
-- | Key type | 4b
-- | Key size | 4b
-- | Counter for key | 4b
-- | Counter for iv | 4b
-- | Salt for key | 32b
-- | Salt for iv | 32b
-- | Key slot sign | 32b
-- | Dir key # 1 | 32b ---
-- | Dir iv # 1 | 16b ^
-- | Dir sign # 1 | 32b |
-- | Data key # 1 | PI:KEY:<KEY>END_PI |
-- | Data iv # 1 | 16b | Encrypted by user's password
-- | Data sign #1 | 32b |
-- | Key key # 1 | 3PI:KEY:<KEY>END_PI |
-- | Key iv # 1 | 16b v
-- | Key sign #1 | 32b ---
-- | Slot HMAC-256 | 32b
-- | PAD 0 / Random | 80b
-- +------------------+
-- | Key slot #2 | 512b
-- +------------------+
-- | Key slot #3 | 512b
-- +------------------+
-- | Key slot #4 | 512b
-- +------------------+
-- | Key slot #5 | 512b
-- +------------------+
-- | Key slot #6 | 512b
-- +------------------+
-- | Key slot #7 | 512b
-- +------------------+
-- | PAD 0 / Random |
-- +------------------+
-- | Block HMAC-256 | 32b
-- +------------------+
-- ```
--
package body Keystore.Keys is
use Interfaces;
use Ada.Streams;
use Util.Encoders.KDF;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Keystore.Keys");
procedure Save_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in out Keystore.Passwords.Provider'Class;
Slot : in Key_Slot;
Config : in Wallet_Config;
Stream : in out IO.Wallet_Stream'Class);
procedure Erase_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Slot : in Key_Slot;
Stream : in out IO.Wallet_Stream'Class);
procedure Extract (Buffer : in out Marshallers.Marshaller;
Lock_Key : in Secret_Key;
Lock_IV : in Secret_Key;
Crypt : in out Cryptor;
Hmac : in out Util.Encoders.HMAC.SHA256.Context);
function Verify_GPG (Manager : in Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in Passwords.Slot_Provider'Class;
Config : in out Wallet_Config) return Boolean;
function Verify_PBKDF2 (Manager : in Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in Passwords.Provider'Class;
Size : in Positive;
Config : in out Wallet_Config) return Boolean;
procedure Generate (Manager : in out Key_Manager;
Crypt : in out Cryptor);
procedure Save (Buffer : in out IO.Marshaller;
Lock_Key : in Secret_Key;
Lock_IV : in Secret_Key;
Crypt : in Cryptor;
Hmac : in out Util.Encoders.HMAC.SHA256.Context);
procedure Load (Manager : in out Key_Manager;
Block : in Keystore.IO.Storage_Block;
Ident : in Wallet_Identifier;
Buffer : in out IO.Marshaller;
Root : out Keystore.IO.Storage_Block;
UUID : out UUID_Type;
Stream : in out IO.Wallet_Stream'Class);
-- ------------------------------
-- Set the IV vector to be used for the encryption and decryption of the given block number.
-- ------------------------------
procedure Set_IV (Into : in out Cryptor;
Block : in IO.Block_Number) is
Block_IV : constant Util.Encoders.AES.Word_Block_Type
:= (others => Interfaces.Unsigned_32 (Block));
begin
Into.Decipher.Set_IV (Into.IV, Block_IV);
Into.Cipher.Set_IV (Into.IV, Block_IV);
end Set_IV;
procedure Set_Key (Into : in out Cryptor;
From : in Cryptor) is
begin
Into.Cipher.Set_Key (From.Key, Util.Encoders.AES.CBC);
Into.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Into.Decipher.Set_Key (From.Key, Util.Encoders.AES.CBC);
Into.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
end Set_Key;
-- ------------------------------
-- Extract the AES encryption key, the AES IV and the signature key.
-- Update the HMAC with the extracted encryption keys for global verification.
-- ------------------------------
procedure Extract (Buffer : in out Marshallers.Marshaller;
Lock_Key : in Secret_Key;
Lock_IV : in Secret_Key;
Crypt : in out Cryptor;
Hmac : in out Util.Encoders.HMAC.SHA256.Context) is
begin
Marshallers.Get_Secret (Buffer, Crypt.Key, Lock_Key, Lock_IV);
Marshallers.Get_Secret (Buffer, Crypt.IV, Lock_Key, Lock_IV);
Marshallers.Get_Secret (Buffer, Crypt.Sign, Lock_Key, Lock_IV);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.Key);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.IV);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.Sign);
Crypt.Cipher.Set_Key (Crypt.Key, Util.Encoders.AES.CBC);
Crypt.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Crypt.Decipher.Set_Key (Crypt.Key, Util.Encoders.AES.CBC);
Crypt.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
end Extract;
procedure Generate (Manager : in out Key_Manager;
Crypt : in out Cryptor) is
begin
Manager.Random.Generate (Crypt.Sign);
Manager.Random.Generate (Crypt.Key);
Manager.Random.Generate (Crypt.IV);
Crypt.Cipher.Set_Key (Crypt.Key, Util.Encoders.AES.CBC);
Crypt.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Crypt.Decipher.Set_Key (Crypt.Key, Util.Encoders.AES.CBC);
Crypt.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
end Generate;
procedure Save (Buffer : in out Marshallers.Marshaller;
Lock_Key : in Secret_Key;
Lock_IV : in Secret_Key;
Crypt : in Cryptor;
Hmac : in out Util.Encoders.HMAC.SHA256.Context) is
begin
Marshallers.Put_Secret (Buffer, Crypt.Key, Lock_Key, Lock_IV);
Marshallers.Put_Secret (Buffer, Crypt.IV, Lock_Key, Lock_IV);
Marshallers.Put_Secret (Buffer, Crypt.Sign, Lock_Key, Lock_IV);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.Key);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.IV);
Util.Encoders.HMAC.SHA256.Update (Hmac, Crypt.Sign);
end Save;
function Verify_GPG (Manager : in Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in Passwords.Slot_Provider'Class;
Config : in out Wallet_Config) return Boolean is
procedure Get_Password (Key : in Secret_Key;
IV : in Secret_Key);
Buf : constant Buffers.Buffer_Accessor := Buffer.Buffer.Data.Value;
Sign : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Result : Util.Encoders.SHA256.Hash_Array;
Hmac : Util.Encoders.HMAC.SHA256.Context;
-- Get the directory encryption key and IV.
procedure Get_Password (Key : in Secret_Key;
IV : in Secret_Key) is
begin
Extract (Buffer, Key, IV, Config.Dir, Hmac);
Extract (Buffer, Key, IV, Config.Data, Hmac);
Extract (Buffer, Key, IV, Config.Key, Hmac);
end Get_Password;
begin
Marshallers.Get_Secret (Buffer, Sign, Manager.Crypt.Key, Manager.Crypt.IV);
-- Build a signature from the master key and the wallet salt.
Util.Encoders.HMAC.SHA256.Set_Key (Hmac, Sign);
Password.Get_Key (Get_Password'Access);
Util.Encoders.HMAC.SHA256.Finish (Hmac, Result);
return Result = Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + Result'Length);
end Verify_GPG;
function Verify_PBKDF2 (Manager : in Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in Passwords.Provider'Class;
Size : in Positive;
Config : in out Wallet_Config) return Boolean is
procedure Get_Password (Secret : in Secret_Key);
Buf : constant Buffers.Buffer_Accessor := Buffer.Buffer.Data.Value;
Salt_Key : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Salt_IV : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Sign : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Lock_Key : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Lock_IV : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Result : Util.Encoders.SHA256.Hash_Array;
Hmac : Util.Encoders.HMAC.SHA256.Context;
Counter_Key : Interfaces.Unsigned_32;
Counter_IV : Interfaces.Unsigned_32;
-- Generate a derived key from the password, salt, counter.
procedure Get_Password (Secret : in Secret_Key) is
begin
PBKDF2_HMAC_SHA256 (Password => Secret,
Salt => Salt_IV,
Counter => Positive (Counter_IV),
Result => Lock_IV);
end Get_Password;
begin
Counter_Key := Marshallers.Get_Unsigned_32 (Buffer);
Counter_IV := Marshallers.Get_Unsigned_32 (Buffer);
if Counter_Key = 0 or Counter_IV = 0 or Size /= Util.Encoders.AES.AES_256_Length then
return False;
end if;
Marshallers.Get_Secret (Buffer, Salt_Key, Manager.Crypt.Key, Manager.Crypt.IV);
Marshallers.Get_Secret (Buffer, Salt_IV, Manager.Crypt.Key, Manager.Crypt.IV);
Marshallers.Get_Secret (Buffer, Sign, Manager.Crypt.Key, Manager.Crypt.IV);
Password.Get_Password (Get_Password'Access);
PBKDF2_HMAC_SHA256 (Password => PI:PASSWORD:<PASSWORD>END_PI,
Salt => Salt_Key,
Counter => Positive (Counter_Key),
Result => Lock_Key);
-- Build a signature from the master key and the wallet salt.
Util.Encoders.HMAC.SHA256.Set_Key (Hmac, Sign);
-- Get the directory encryption key and IV.
Extract (Buffer, Lock_Key, Lock_IV, Config.Dir, Hmac);
Extract (Buffer, Lock_Key, Lock_IV, Config.Data, Hmac);
Extract (Buffer, Lock_Key, Lock_IV, Config.Key, Hmac);
Util.Encoders.HMAC.SHA256.Finish (Hmac, Result);
return Result = Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + Result'Length);
end Verify_PBKDF2;
-- ------------------------------
-- Save the wallet config encryption keys in the key slot and protect that
-- key using the user's password. New salts and counters are generated and
-- the user's password is passed through PBKDF2 to get the encryption key
-- that protects the key slot.
-- ------------------------------
procedure Save_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Password : in out Keystore.Passwords.Provider'Class;
Slot : in Key_Slot;
Config : in Wallet_Config;
Stream : in out IO.Wallet_Stream'Class) is
procedure Save_GPG_Key (Password : in out Keystore.Passwords.Slot_Provider'Class);
procedure Save_PBKDF2_Key;
Slot_Sign : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Hmac : Util.Encoders.HMAC.SHA256.Context;
Result : Util.Encoders.SHA256.Hash_Array;
Buf : constant Buffers.Buffer_Accessor := Buffer.Buffer.Data.Value;
procedure Save_PBKDF2_Key is
procedure Get_Password (Secret : in Secret_Key);
Lock_Key : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Lock_IV : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Salt_Key : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Salt_IV : Secret_Key (Length => Util.Encoders.AES.AES_256_Length);
Counter_Key : Positive;
Counter_IV : Positive;
-- Generate a derived key from the password, salt, counter.
procedure Get_Password (Secret : in Secret_Key) is
begin
PBKDF2_HMAC_SHA256 (Password => Secret,
Salt => Salt_IV,
Counter => Counter_IV,
Result => Lock_IV);
end Get_Password;
begin
-- Make a first random counter in range 100_000 .. 1_148_575.
Counter_Key := 1 + Natural (Manager.Random.Generate mod Config.Max_Counter);
if Counter_Key < Positive (Config.Min_Counter) then
Counter_Key := Positive (Config.Min_Counter);
end if;
-- Make a second random counter in range 100_000 .. 372_140.
Counter_IV := 1 + Natural (Manager.Random.Generate mod Config.Max_Counter);
if Counter_IV < Positive (Config.Min_Counter) then
Counter_IV := Positive (Config.Min_Counter);
end if;
Manager.Random.Generate (Salt_Key);
Manager.Random.Generate (Salt_IV);
Marshallers.Put_Unsigned_32 (Buffer, WH_KEY_PBKDF2);
Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Lock_Key.Length));
Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Counter_Key));
Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Counter_IV));
Marshallers.Put_Secret (Buffer, Salt_Key, Manager.Crypt.Key, Manager.Crypt.IV);
Marshallers.Put_Secret (Buffer, Salt_IV, Manager.Crypt.Key, Manager.Crypt.IV);
Marshallers.Put_Secret (Buffer, Slot_Sign, Manager.Crypt.Key, Manager.Crypt.IV);
Password.Get_Password (Get_Password'Access);
PBKDF2_HMAC_SHA256 (Password => Lock_IV,
Salt => Salt_Key,
Counter => Counter_Key,
Result => Lock_Key);
Save (Buffer, Lock_Key, Lock_IV, Config.Dir, Hmac);
Save (Buffer, Lock_Key, Lock_IV, Config.Data, Hmac);
Save (Buffer, Lock_Key, Lock_IV, Config.Key, Hmac);
end Save_PBKDF2_Key;
procedure Save_GPG_Key (Password : in out Keystore.Passwords.Slot_Provider'Class) is
procedure Get_Key (Key : in Secret_Key;
IV : in Secret_Key);
procedure Get_Key (Key : in Secret_Key;
IV : in Secret_Key) is
begin
Marshallers.Put_Unsigned_32 (Buffer, Password.Get_Tag);
Marshallers.Put_Secret (Buffer, Slot_Sign, Manager.Crypt.Key, Manager.Crypt.IV);
Save (Buffer, Key, IV, Config.Dir, Hmac);
Save (Buffer, Key, IV, Config.Data, Hmac);
Save (Buffer, Key, IV, Config.Key, Hmac);
end Get_Key;
begin
Marshallers.Put_Unsigned_32 (Buffer, WH_KEY_GPG2);
Password.Get_Key (Get_Key'Access);
end Save_GPG_Key;
begin
Log.Info ("Saving key for wallet {0}", To_String (Config.UUID));
Manager.Random.Generate (Slot_Sign);
-- Build a signature from the lock key.
Util.Encoders.HMAC.SHA256.Set_Key (Hmac, Slot_Sign);
Buffer.Pos := Key_Position (Slot);
Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + WH_KEY_SIZE) := (others => 0);
if Password in Keystore.Passwords.Slot_Provider'Class then
Save_GPG_Key (Keystore.Passwords.Slot_Provider'Class (Password));
else
Save_PBKDF2_Key;
end if;
Util.Encoders.HMAC.SHA256.Finish (Hmac, Result);
Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + Result'Length) := Result;
Set_IV (Manager.Crypt, Buffer.Buffer.Block.Block);
Stream.Write (Cipher => Manager.Crypt.Cipher,
Sign => Manager.Crypt.Sign,
From => Buffer.Buffer);
end Save_Key;
-- ------------------------------
-- Erase the walley key slot amd save the waller master block.
-- ------------------------------
procedure Erase_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Slot : in Key_Slot;
Stream : in out IO.Wallet_Stream'Class) is
Buf : constant Buffers.Buffer_Accessor := Buffer.Buffer.Data.Value;
begin
Buffer.Pos := Key_Position (Slot);
Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + WH_KEY_SIZE) := (others => 0);
Stream.Write (Cipher => Manager.Crypt.Cipher,
Sign => Manager.Crypt.Sign,
From => Buffer.Buffer);
end Erase_Key;
-- ------------------------------
-- Load the wallet header keys
-- ------------------------------
procedure Load (Manager : in out Key_Manager;
Block : in Keystore.IO.Storage_Block;
Ident : in Wallet_Identifier;
Buffer : in out IO.Marshaller;
Root : out Keystore.IO.Storage_Block;
UUID : out UUID_Type;
Stream : in out IO.Wallet_Stream'Class) is
Value : Interfaces.Unsigned_32;
Size : IO.Block_Index;
begin
Keystore.Logs.Info (Log, "Loading master block{0}", Block);
Set_IV (Manager.Crypt, Block.Block);
Buffer.Buffer := Buffers.Allocate (Block);
Manager.Header_Block := Block;
begin
Stream.Read (Decipher => Manager.Crypt.Decipher,
Sign => Manager.Crypt.Sign,
Decrypt_Size => Size,
Into => Buffer.Buffer);
exception
when Invalid_Signature =>
Keystore.Logs.Warn (Log, "Invalid signature for wallet block{0}," &
" may be an invalid wallet key was used",
Manager.Header_Block);
raise Bad_Password;
end;
if Marshallers.Get_Header_16 (Buffer) /= IO.BT_WALLET_HEADER then
Keystore.Logs.Warn (Log, "Invalid wallet block header BN{0}", Manager.Header_Block);
raise Invalid_Block;
end if;
Marshallers.Skip (Buffer, 2);
Value := Marshallers.Get_Unsigned_32 (Buffer);
Marshallers.Skip (Buffer, 8);
if Marshallers.Get_Unsigned_32 (Buffer) /= WH_MAGIC then
Keystore.Logs.Warn (Log, "Invalid wallet magic in header BN{0}", Manager.Header_Block);
raise Invalid_Block;
end if;
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value /= 1 then
Log.Warn ("Version{0} not supported in header BN{0}",
Interfaces.Unsigned_32'Image (Value),
IO.Block_Number'Image (Manager.Header_Block.Block));
raise Invalid_Block;
end if;
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value /= Interfaces.Unsigned_32 (Ident) then
Log.Warn ("Wallet id{0} does not match in header BN{0}",
Interfaces.Unsigned_32'Image (Value),
IO.Block_Number'Image (Manager.Header_Block.Block));
raise Invalid_Block;
end if;
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value = 0 then
Log.Warn ("Wallet block{0} is invalid in header BN{0}",
Interfaces.Unsigned_32'Image (Value),
IO.Block_Number'Image (Manager.Header_Block.Block));
raise Invalid_Block;
end if;
Root.Storage := Block.Storage;
Root.Block := IO.Block_Number (Value);
-- Extract wallet uuid.
Marshallers.Get_UUID (Buffer, UUID);
end Load;
-- Open the key manager and read the wallet header block. Use the secret key
-- to decrypt/encrypt the wallet header block.
procedure Open (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Provider'Class;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Root : out Keystore.IO.Storage_Block;
Config : in out Wallet_Config;
Process : access procedure (Buffer : in out Marshallers.Marshaller;
Slot : in Key_Slot);
Stream : in out IO.Wallet_Stream'Class) is
procedure Open (Password : in out Keystore.Passwords.Slot_Provider'Class);
Value : Interfaces.Unsigned_32;
Buffer : Marshallers.Marshaller;
procedure Open (Password : in out Keystore.Passwords.Slot_Provider'Class) is
begin
while Password.Has_Password loop
for Slot in Key_Slot'Range loop
Buffer.Pos := Key_Position (Slot);
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value = WH_KEY_GPG2 then
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value = Password.Get_Tag then
if Verify_GPG (Manager, Buffer, Password, Config) then
Config.Slot := Slot;
if Process /= null then
Process (Buffer, Slot);
end if;
return;
end if;
end if;
end if;
end loop;
Password.Next;
end loop;
Keystore.Logs.Info (Log, "No password match for wallet block{0}", Manager.Header_Block);
raise Bad_Password;
end Open;
begin
Load (Manager, Block, Ident, Buffer, Root, Config.UUID, Stream);
-- See which key slot is used.
for Slot in Key_Slot'Range loop
Buffer.Pos := Key_Position (Slot);
Value := Marshallers.Get_Unsigned_32 (Buffer);
Config.Keys (Slot) := Value /= 0;
end loop;
if Password in Keystore.Passwords.Slot_Provider'Class then
Open (Keystore.Passwords.Slot_Provider'Class (Password));
else
for Slot in Key_Slot'Range loop
Buffer.Pos := Key_Position (Slot);
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value = WH_KEY_PBKDF2 then
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value > 0 and Value <= WH_KEY_SIZE then
if Verify_PBKDF2 (Manager, Buffer, Password, Positive (Value), Config) then
Config.Slot := Slot;
if Process /= null then
Process (Buffer, Slot);
end if;
return;
end if;
end if;
end if;
end loop;
Keystore.Logs.Info (Log, "No password match for wallet block{0}", Manager.Header_Block);
raise Bad_Password;
end if;
end Open;
procedure Create (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Provider'Class;
Slot : in Key_Slot;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Root : in Keystore.IO.Storage_Block;
Config : in out Wallet_Config;
Stream : in out IO.Wallet_Stream'Class) is
Buffer : IO.Marshaller;
begin
Buffer.Buffer := Buffers.Allocate (Block);
Generate (Manager, Config.Data);
Generate (Manager, Config.Dir);
Generate (Manager, Config.Key);
Manager.Random.Generate (Config.UUID);
Manager.Header_Block := Block;
-- Build wallet header.
if Config.Randomize then
Manager.Random.Generate (Buffer.Buffer.Data.Value.Data);
else
Buffer.Buffer.Data.Value.Data := (others => 0);
end if;
Marshallers.Set_Header (Into => Buffer,
Tag => IO.BT_WALLET_HEADER,
Id => Ident);
Marshallers.Put_Unsigned_32 (Buffer, WH_MAGIC);
Marshallers.Put_Unsigned_32 (Buffer, 1);
Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Ident));
Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Root.Block));
-- Write wallet uuid.
Marshallers.Put_UUID (Buffer, Config.UUID);
if Config.Randomize then
for Slot in Key_Slot'Range loop
Buffer.Pos := Key_Position (Slot);
Marshallers.Put_Unsigned_32 (Buffer, 0);
end loop;
end if;
Save_Key (Manager, Buffer, Password, Slot, Config, Stream);
end Create;
-- ------------------------------
-- Create a new masker keys for a children wallet and save the new keys in the buffer.
-- ------------------------------
procedure Create_Master_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Crypt : in Cryptor) is
begin
Manager.Random.Generate (Manager.Crypt.Key);
Manager.Random.Generate (Manager.Crypt.IV);
Manager.Crypt.Decipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Manager.Crypt.Cipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Marshallers.Put_Secret (Buffer, Manager.Crypt.Key, Crypt.Key, Crypt.IV);
Marshallers.Put_Secret (Buffer, Manager.Crypt.IV, Crypt.Key, Crypt.IV);
end Create_Master_Key;
-- ------------------------------
-- Extract from the buffer the master keys to open the children wallet.
-- ------------------------------
procedure Load_Master_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Crypt : in Cryptor) is
begin
Marshallers.Get_Secret (Buffer, Manager.Crypt.Key, Crypt.Key, Crypt.IV);
Marshallers.Get_Secret (Buffer, Manager.Crypt.IV, Crypt.Key, Crypt.IV);
Manager.Crypt.Decipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Manager.Crypt.Cipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
end Load_Master_Key;
-- ------------------------------
-- Set the master key by using the password provider.
-- ------------------------------
procedure Set_Master_Key (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Keys.Key_Provider'Class) is
begin
Password.Get_Keys (Manager.Crypt.Key, Manager.Crypt.IV, Manager.Crypt.Sign);
Manager.Crypt.Decipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Decipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
Manager.Crypt.Cipher.Set_Key (Manager.Crypt.Key, Util.Encoders.AES.CBC);
Manager.Crypt.Cipher.Set_Padding (Util.Encoders.AES.NO_PADDING);
end Set_Master_Key;
procedure Set_Key (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Provider'Class;
New_Password : in out Keystore.Passwords.Provider'Class;
Config : in Keystore.Wallet_Config;
Mode : in Mode_Type;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Stream : in out IO.Wallet_Stream'Class) is
procedure Process (Buffer : in out Marshallers.Marshaller;
Slot : in Key_Slot);
Local_Config : Wallet_Config;
Root : Keystore.IO.Storage_Block;
procedure Process (Buffer : in out Marshallers.Marshaller;
Slot : in Key_Slot) is
function Find_Free_Slot return Key_Slot;
function Find_Free_Slot return Key_Slot is
Value : Interfaces.Unsigned_32;
begin
for Slot in Key_Slot'Range loop
Buffer.Pos := Key_Position (Slot);
Value := Marshallers.Get_Unsigned_32 (Buffer);
if Value = 0 then
return Slot;
end if;
end loop;
Log.Info ("No available free slot to add a new key");
raise No_Key_Slot;
end Find_Free_Slot;
begin
Local_Config.Min_Counter := Unsigned_32 (Config.Min_Counter);
Local_Config.Max_Counter := Unsigned_32 (Config.Max_Counter);
case Mode is
when KEY_ADD =>
Save_Key (Manager, Buffer, New_Password, Find_Free_Slot,
Local_Config, Stream);
when KEY_REPLACE =>
Save_Key (Manager, Buffer, New_Password, Slot, Local_Config, Stream);
when KEY_REMOVE =>
Erase_Key (Manager, Buffer, Slot, Stream);
end case;
end Process;
begin
Open (Manager, Password, Ident, Block, Root, Local_Config,
Process'Access, Stream);
end Set_Key;
-- ------------------------------
-- Remove the key from the key slot identified by `Slot`. The password is necessary to
-- make sure a valid password is available. The `Remove_Current` must be set to remove
-- the slot when it corresponds to the used password.
-- ------------------------------
procedure Remove_Key (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Provider'Class;
Slot : in Key_Slot;
Remove_Current : in Boolean;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Stream : in out IO.Wallet_Stream'Class) is
procedure Process (Buffer : in out Marshallers.Marshaller;
Password_Slot : in Key_Slot);
procedure Process (Buffer : in out Marshallers.Marshaller;
Password_Slot : in Key_Slot) is
begin
if Slot /= Password_Slot or Remove_Current then
Erase_Key (Manager, Buffer, Slot, Stream);
else
Log.Info ("Refusing to delete key slot used by current password");
raise Used_Key_Slot;
end if;
end Process;
Local_Config : Wallet_Config;
Root : Keystore.IO.Storage_Block;
begin
Open (Manager, Password, Ident, Block, Root, Local_Config,
Process'Access, Stream);
end Remove_Key;
end Keystore.Keys;
|
[
{
"context": "========================\n--\n-- Copyright 2021 (C) Holger Rodriguez\n--\n-- SPDX-License-Identifier: BSD-3-Clause\n--\np",
"end": 312,
"score": 0.9998354911804199,
"start": 296,
"tag": "NAME",
"value": "Holger Rodriguez"
}
] | src/edc_client-alpha-common.ads | hgrodriguez/edc-client | 0 | --===========================================================================
--
-- This package is the interface the Alpha internal procedures/functions
-- for avoiding duplicating code
--
--===========================================================================
--
-- Copyright 2021 (C) Holger Rodriguez
--
-- SPDX-License-Identifier: BSD-3-Clause
--
private package Edc_Client.Alpha.Common is
--------------------------------------------------------------------------
-- Shows a Single Letter
--------------------------------------------------------------------------
procedure Show_Single_Letter (Position : Integer;
Block : Character;
Value : String);
--------------------------------------------------------------------------
-- Shows Double Letters
--------------------------------------------------------------------------
procedure Show_Double_Letters (Position : Integer;
Block : Character;
Value : String);
--------------------------------------------------------------------------
-- Shows Four Letters
--------------------------------------------------------------------------
procedure Show_Four_Letters (Position : Integer;
Block : Character;
Value : String);
end Edc_Client.Alpha.Common;
| 16543 | --===========================================================================
--
-- This package is the interface the Alpha internal procedures/functions
-- for avoiding duplicating code
--
--===========================================================================
--
-- Copyright 2021 (C) <NAME>
--
-- SPDX-License-Identifier: BSD-3-Clause
--
private package Edc_Client.Alpha.Common is
--------------------------------------------------------------------------
-- Shows a Single Letter
--------------------------------------------------------------------------
procedure Show_Single_Letter (Position : Integer;
Block : Character;
Value : String);
--------------------------------------------------------------------------
-- Shows Double Letters
--------------------------------------------------------------------------
procedure Show_Double_Letters (Position : Integer;
Block : Character;
Value : String);
--------------------------------------------------------------------------
-- Shows Four Letters
--------------------------------------------------------------------------
procedure Show_Four_Letters (Position : Integer;
Block : Character;
Value : String);
end Edc_Client.Alpha.Common;
| true | --===========================================================================
--
-- This package is the interface the Alpha internal procedures/functions
-- for avoiding duplicating code
--
--===========================================================================
--
-- Copyright 2021 (C) PI:NAME:<NAME>END_PI
--
-- SPDX-License-Identifier: BSD-3-Clause
--
private package Edc_Client.Alpha.Common is
--------------------------------------------------------------------------
-- Shows a Single Letter
--------------------------------------------------------------------------
procedure Show_Single_Letter (Position : Integer;
Block : Character;
Value : String);
--------------------------------------------------------------------------
-- Shows Double Letters
--------------------------------------------------------------------------
procedure Show_Double_Letters (Position : Integer;
Block : Character;
Value : String);
--------------------------------------------------------------------------
-- Shows Four Letters
--------------------------------------------------------------------------
procedure Show_Four_Letters (Position : Integer;
Block : Character;
Value : String);
end Edc_Client.Alpha.Common;
|
[
{
"context": " --\n-- Copyright © 2014-2015, Vadim Godunko <vgodunko@gmail.com> --\n-- All rig",
"end": 829,
"score": 0.9998872876167297,
"start": 816,
"tag": "NAME",
"value": "Vadim Godunko"
},
{
"context": " --\n-- Copyright © 2014-2015, Vadim Godunko <vgodunko@gmail.com> --\n-- All rights reserved. ",
"end": 849,
"score": 0.9999314546585083,
"start": 831,
"tag": "EMAIL",
"value": "vgodunko@gmail.com"
}
] | source/web/tools/a2js/webapi/dom/webapi-dom-events.ads | svn2github/matreshka | 24 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Web API Definition --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2015, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This package provides binding to interface Event as defined by DOM Level 4
-- specification.
------------------------------------------------------------------------------
limited with WebAPI.DOM.Event_Targets;
package WebAPI.DOM.Events is
pragma Preelaborate;
type Event is limited interface;
not overriding function Get_Event_Type
(Self : not null access constant Event)
return WebAPI.DOM_String is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "type";
-- The name of the event (case-insensitive). The name must be an XML name.
not overriding function Get_Target
(Self : not null access constant Event)
return WebAPI.DOM.Event_Targets.Event_Target_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "target";
-- Used to indicate the EventTarget to which the event was originally
-- dispatched.
not overriding function Get_Current_Target
(Self : not null access constant Event)
return WebAPI.DOM.Event_Targets.Event_Target_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "currentTarget";
-- Used to indicate the EventTarget whose EventListeners are currently
-- being processed. This is particularly useful during capturing and
-- bubbling.
not overriding function Get_Event_Phase
(Self : not null access constant Event)
return WebAPI.DOM.Event_Phases is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "eventPhase";
-- Returns the event's phase, which is one of NONE, CAPTURING_PHASE,
-- AT_TARGET, and BUBBLING_PHASE.
not overriding procedure Stop_Propagation
(Self : not null access Event) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "stopPropagation";
-- The stopPropagation method is used prevent further propagation of an
-- event during event flow. If this method is called by any EventListener
-- the event will cease propagating through the tree. The event will
-- complete dispatch to all listeners on the current EventTarget before
-- event flow stops. This method may be used during any stage of event
-- flow.
not overriding procedure Stop_Immediate_Propagation
(Self : not null access Event) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "stopImmediatePropagation()";
-- Invoking this method prevents event from reaching any registered event
-- listeners after the current one finishes running and, when dispatched in
-- a tree, also prevents event from reaching any other objects.
not overriding function Bubbles
(Self : not null access constant Event) return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "bubbles";
-- Used to indicate whether or not an event is a bubbling event. If the
-- event can bubble the value is true, else the value is false.
not overriding function Cancelable
(Self : not null access constant Event) return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "cancelable";
-- Used to indicate whether or not an event can have its default action
-- prevented. If the default action can be prevented the value is true,
-- else the value is false.
not overriding procedure Prevent_Default
(Self : not null access Event) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "preventDefault";
-- If an event is cancelable, the preventDefault method is used to signify
-- that the event is to be canceled, meaning any default action normally
-- taken by the implementation as a result of the event will not occur.
-- If, during any stage of event flow, the preventDefault method is called
-- the event is canceled. Any default action associated with the event
-- will not occur. Calling this method for a non - cancelable event has no
-- effect. Once preventDefault has been called it will remain in effect
-- throughout the remainder of the event's propagation. This method may be
-- used during any stage of event flow.
not overriding function Get_Default_Prevented
(Self : not null access constant Event) return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "defaultPrevented";
-- Returns true if preventDefault() was invoked while the cancelable
-- attribute value is true, and false otherwise.
not overriding function Get_Is_Trusted
(Self : not null access constant Event) return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "isTrusted";
-- Returns true if event was dispatched by the user agent, and false
-- otherwise.
not overriding function Get_Time_Stamp
(Self : not null access constant Event)
return WebAPI.DOM_Time_Stamp is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "timeStamp";
-- Returns the creation time of event as the number of milliseconds that
-- passed since 00:00:00 UTC on 1 January 1970.
end WebAPI.DOM.Events;
| 18013 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Web API Definition --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2015, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This package provides binding to interface Event as defined by DOM Level 4
-- specification.
------------------------------------------------------------------------------
limited with WebAPI.DOM.Event_Targets;
package WebAPI.DOM.Events is
pragma Preelaborate;
type Event is limited interface;
not overriding function Get_Event_Type
(Self : not null access constant Event)
return WebAPI.DOM_String is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "type";
-- The name of the event (case-insensitive). The name must be an XML name.
not overriding function Get_Target
(Self : not null access constant Event)
return WebAPI.DOM.Event_Targets.Event_Target_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "target";
-- Used to indicate the EventTarget to which the event was originally
-- dispatched.
not overriding function Get_Current_Target
(Self : not null access constant Event)
return WebAPI.DOM.Event_Targets.Event_Target_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "currentTarget";
-- Used to indicate the EventTarget whose EventListeners are currently
-- being processed. This is particularly useful during capturing and
-- bubbling.
not overriding function Get_Event_Phase
(Self : not null access constant Event)
return WebAPI.DOM.Event_Phases is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "eventPhase";
-- Returns the event's phase, which is one of NONE, CAPTURING_PHASE,
-- AT_TARGET, and BUBBLING_PHASE.
not overriding procedure Stop_Propagation
(Self : not null access Event) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "stopPropagation";
-- The stopPropagation method is used prevent further propagation of an
-- event during event flow. If this method is called by any EventListener
-- the event will cease propagating through the tree. The event will
-- complete dispatch to all listeners on the current EventTarget before
-- event flow stops. This method may be used during any stage of event
-- flow.
not overriding procedure Stop_Immediate_Propagation
(Self : not null access Event) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "stopImmediatePropagation()";
-- Invoking this method prevents event from reaching any registered event
-- listeners after the current one finishes running and, when dispatched in
-- a tree, also prevents event from reaching any other objects.
not overriding function Bubbles
(Self : not null access constant Event) return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "bubbles";
-- Used to indicate whether or not an event is a bubbling event. If the
-- event can bubble the value is true, else the value is false.
not overriding function Cancelable
(Self : not null access constant Event) return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "cancelable";
-- Used to indicate whether or not an event can have its default action
-- prevented. If the default action can be prevented the value is true,
-- else the value is false.
not overriding procedure Prevent_Default
(Self : not null access Event) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "preventDefault";
-- If an event is cancelable, the preventDefault method is used to signify
-- that the event is to be canceled, meaning any default action normally
-- taken by the implementation as a result of the event will not occur.
-- If, during any stage of event flow, the preventDefault method is called
-- the event is canceled. Any default action associated with the event
-- will not occur. Calling this method for a non - cancelable event has no
-- effect. Once preventDefault has been called it will remain in effect
-- throughout the remainder of the event's propagation. This method may be
-- used during any stage of event flow.
not overriding function Get_Default_Prevented
(Self : not null access constant Event) return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "defaultPrevented";
-- Returns true if preventDefault() was invoked while the cancelable
-- attribute value is true, and false otherwise.
not overriding function Get_Is_Trusted
(Self : not null access constant Event) return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "isTrusted";
-- Returns true if event was dispatched by the user agent, and false
-- otherwise.
not overriding function Get_Time_Stamp
(Self : not null access constant Event)
return WebAPI.DOM_Time_Stamp is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "timeStamp";
-- Returns the creation time of event as the number of milliseconds that
-- passed since 00:00:00 UTC on 1 January 1970.
end WebAPI.DOM.Events;
| true | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Web API Definition --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2015, PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> --
-- 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 binding to interface Event as defined by DOM Level 4
-- specification.
------------------------------------------------------------------------------
limited with WebAPI.DOM.Event_Targets;
package WebAPI.DOM.Events is
pragma Preelaborate;
type Event is limited interface;
not overriding function Get_Event_Type
(Self : not null access constant Event)
return WebAPI.DOM_String is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "type";
-- The name of the event (case-insensitive). The name must be an XML name.
not overriding function Get_Target
(Self : not null access constant Event)
return WebAPI.DOM.Event_Targets.Event_Target_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "target";
-- Used to indicate the EventTarget to which the event was originally
-- dispatched.
not overriding function Get_Current_Target
(Self : not null access constant Event)
return WebAPI.DOM.Event_Targets.Event_Target_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "currentTarget";
-- Used to indicate the EventTarget whose EventListeners are currently
-- being processed. This is particularly useful during capturing and
-- bubbling.
not overriding function Get_Event_Phase
(Self : not null access constant Event)
return WebAPI.DOM.Event_Phases is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "eventPhase";
-- Returns the event's phase, which is one of NONE, CAPTURING_PHASE,
-- AT_TARGET, and BUBBLING_PHASE.
not overriding procedure Stop_Propagation
(Self : not null access Event) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "stopPropagation";
-- The stopPropagation method is used prevent further propagation of an
-- event during event flow. If this method is called by any EventListener
-- the event will cease propagating through the tree. The event will
-- complete dispatch to all listeners on the current EventTarget before
-- event flow stops. This method may be used during any stage of event
-- flow.
not overriding procedure Stop_Immediate_Propagation
(Self : not null access Event) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "stopImmediatePropagation()";
-- Invoking this method prevents event from reaching any registered event
-- listeners after the current one finishes running and, when dispatched in
-- a tree, also prevents event from reaching any other objects.
not overriding function Bubbles
(Self : not null access constant Event) return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "bubbles";
-- Used to indicate whether or not an event is a bubbling event. If the
-- event can bubble the value is true, else the value is false.
not overriding function Cancelable
(Self : not null access constant Event) return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "cancelable";
-- Used to indicate whether or not an event can have its default action
-- prevented. If the default action can be prevented the value is true,
-- else the value is false.
not overriding procedure Prevent_Default
(Self : not null access Event) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "preventDefault";
-- If an event is cancelable, the preventDefault method is used to signify
-- that the event is to be canceled, meaning any default action normally
-- taken by the implementation as a result of the event will not occur.
-- If, during any stage of event flow, the preventDefault method is called
-- the event is canceled. Any default action associated with the event
-- will not occur. Calling this method for a non - cancelable event has no
-- effect. Once preventDefault has been called it will remain in effect
-- throughout the remainder of the event's propagation. This method may be
-- used during any stage of event flow.
not overriding function Get_Default_Prevented
(Self : not null access constant Event) return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "defaultPrevented";
-- Returns true if preventDefault() was invoked while the cancelable
-- attribute value is true, and false otherwise.
not overriding function Get_Is_Trusted
(Self : not null access constant Event) return Boolean is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "isTrusted";
-- Returns true if event was dispatched by the user agent, and false
-- otherwise.
not overriding function Get_Time_Stamp
(Self : not null access constant Event)
return WebAPI.DOM_Time_Stamp is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "timeStamp";
-- Returns the creation time of event as the number of milliseconds that
-- passed since 00:00:00 UTC on 1 January 1970.
end WebAPI.DOM.Events;
|
[
{
"context": " --\n-- Copyright © 2012-2013, Vadim Godunko <vgodunko@gmail.com> --\n-- All rig",
"end": 829,
"score": 0.9998872876167297,
"start": 816,
"tag": "NAME",
"value": "Vadim Godunko"
},
{
"context": " --\n-- Copyright © 2012-2013, Vadim Godunko <vgodunko@gmail.com> --\n-- All rights reserved. ",
"end": 849,
"score": 0.9999322891235352,
"start": 831,
"tag": "EMAIL",
"value": "vgodunko@gmail.com"
}
] | source/amf/dd/amf-internals-tables-dd_attributes.adb | svn2github/matreshka | 24 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling 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 file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Internals.Links;
with AMF.Internals.Tables.DC_Notification;
with AMF.Internals.Tables.DD_Element_Table;
with AMF.Internals.Tables.DD_Types;
with AMF.Internals.Tables.DG_Metamodel;
package body AMF.Internals.Tables.DD_Attributes is
use type Matreshka.Internals.Strings.Shared_String_Access;
-- Canvas
--
-- 5 Canvas::backgroundColor
-- 4 Canvas::backgroundFill
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 3 Group::member
-- 4 Canvas::packagedFill
-- 5 Canvas::packagedMarker
-- 6 Canvas::packagedStyle
-- 2 GraphicalElement::sharedStyle
-- Circle
--
-- 5 Circle::center
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 4 Circle::radius
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- ClipPath
--
-- 3 GraphicalElement::clipPath
-- 4 ClipPath::clippedElement
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 3 Group::member
-- 2 GraphicalElement::sharedStyle
-- Ellipse
--
-- 5 Ellipse::center
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 4 Ellipse::radii
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Group
--
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 3 Group::member
-- 2 GraphicalElement::sharedStyle
-- Image
--
-- 4 Image::bounds
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 6 Image::isAspectRatioPreserved
-- 5 Image::source
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Line
--
-- 3 GraphicalElement::clipPath
-- 8 Line::end
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 7 Line::start
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- LinearGradient
--
-- 2 Fill::canvas
-- 3 Gradient::stop
-- 1 Fill::transform
-- 4 LinearGradient::x1
-- 5 LinearGradient::x2
-- 6 LinearGradient::y1
-- 7 LinearGradient::y2
--
-- MarkedElement
--
-- 3 GraphicalElement::clipPath
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Marker
--
-- 4 Marker::canvas
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 6 Marker::reference
-- 5 Marker::size
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 3 Group::member
-- 2 GraphicalElement::sharedStyle
-- Path
--
-- 3 GraphicalElement::clipPath
-- 7 Path::command
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Pattern
--
-- 4 Pattern::bounds
-- 2 Fill::canvas
-- 3 Pattern::tile
-- 1 Fill::transform
--
-- Polygon
--
-- 3 GraphicalElement::clipPath
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 7 Polygon::point
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Polyline
--
-- 3 GraphicalElement::clipPath
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 7 Polyline::point
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- RadialGradient
--
-- 2 Fill::canvas
-- 5 RadialGradient::centerX
-- 6 RadialGradient::centerY
-- 7 RadialGradient::focusX
-- 8 RadialGradient::focusY
-- 4 RadialGradient::radius
-- 3 Gradient::stop
-- 1 Fill::transform
--
-- Rectangle
--
-- 4 Rectangle::bounds
-- 3 GraphicalElement::clipPath
-- 5 Rectangle::cornerRadius
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Style
--
-- 1 Style::fill
-- 2 Style::fillColor
-- 3 Style::fillOpacity
-- 12 Style::fontBold
-- 10 Style::fontColor
-- 11 Style::fontItalic
-- 9 Style::fontName
-- 8 Style::fontSize
-- 14 Style::fontStrikeThrough
-- 13 Style::fontUnderline
-- 6 Style::strokeColor
-- 7 Style::strokeDashLength
-- 5 Style::strokeOpacity
-- 4 Style::strokeWidth
--
-- Text
--
-- 6 Text::alignment
-- 4 Text::bounds
-- 3 GraphicalElement::clipPath
-- 5 Text::data
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
----------------------------
-- Internal_Get_Alignment --
----------------------------
function Internal_Get_Alignment
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Alignment_Kind is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Alignment_Kind_Value;
end Internal_Get_Alignment;
-----------------------------------
-- Internal_Get_Background_Color --
-----------------------------------
function Internal_Get_Background_Color
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Optional_DC_Color is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Color_Holder;
end Internal_Get_Background_Color;
----------------------------------
-- Internal_Get_Background_Fill --
----------------------------------
function Internal_Get_Background_Fill
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Background_Fill;
-------------------------
-- Internal_Get_Bounds --
-------------------------
function Internal_Get_Bounds
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Bounds is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Bounds_Value;
end Internal_Get_Bounds;
-------------------------
-- Internal_Get_Canvas --
-------------------------
function Internal_Get_Canvas
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Linear_Gradient =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Pattern =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Radial_Gradient =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Canvas;
-------------------------
-- Internal_Get_Center --
-------------------------
function Internal_Get_Center
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Point_Value;
end Internal_Get_Center;
---------------------------
-- Internal_Get_Center_X --
---------------------------
function Internal_Get_Center_X
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
end Internal_Get_Center_X;
---------------------------
-- Internal_Get_Center_Y --
---------------------------
function Internal_Get_Center_Y
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value;
end Internal_Get_Center_Y;
----------------------------
-- Internal_Get_Clip_Path --
----------------------------
function Internal_Get_Clip_Path
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Clip_Path;
----------------------------------
-- Internal_Get_Clipped_Element --
----------------------------------
function Internal_Get_Clipped_Element
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Clipped_Element;
--------------------------
-- Internal_Get_Command --
--------------------------
function Internal_Get_Command
(Self : AMF.Internals.AMF_Element)
return AMF.DG.Sequence_Of_Path_Command is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Path_Collection;
end Internal_Get_Command;
--------------------------------
-- Internal_Get_Corner_Radius --
--------------------------------
function Internal_Get_Corner_Radius
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
end Internal_Get_Corner_Radius;
-----------------------
-- Internal_Get_Data --
-----------------------
function Internal_Get_Data
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access is
begin
return
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).String_Value;
end Internal_Get_Data;
----------------------
-- Internal_Get_End --
----------------------
function Internal_Get_End
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Point_Value;
end Internal_Get_End;
-----------------------------
-- Internal_Get_End_Marker --
-----------------------------
function Internal_Get_End_Marker
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_End_Marker;
-----------------------
-- Internal_Get_Fill --
-----------------------
function Internal_Get_Fill
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Style =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (1).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Fill;
-----------------------------
-- Internal_Get_Fill_Color --
-----------------------------
function Internal_Get_Fill_Color
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Optional_DC_Color is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Color_Holder;
end Internal_Get_Fill_Color;
-------------------------------
-- Internal_Get_Fill_Opacity --
-------------------------------
function Internal_Get_Fill_Opacity
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Real_Holder;
end Internal_Get_Fill_Opacity;
--------------------------
-- Internal_Get_Focus_X --
--------------------------
function Internal_Get_Focus_X
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value;
end Internal_Get_Focus_X;
--------------------------
-- Internal_Get_Focus_Y --
--------------------------
function Internal_Get_Focus_Y
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Value;
end Internal_Get_Focus_Y;
----------------------------
-- Internal_Get_Font_Bold --
----------------------------
function Internal_Get_Font_Bold
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (12).Boolean_Holder;
end Internal_Get_Font_Bold;
-----------------------------
-- Internal_Get_Font_Color --
-----------------------------
function Internal_Get_Font_Color
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Optional_DC_Color is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (10).Color_Holder;
end Internal_Get_Font_Color;
------------------------------
-- Internal_Get_Font_Italic --
------------------------------
function Internal_Get_Font_Italic
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (11).Boolean_Holder;
end Internal_Get_Font_Italic;
----------------------------
-- Internal_Get_Font_Name --
----------------------------
function Internal_Get_Font_Name
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access is
begin
return
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (9).String_Value;
end Internal_Get_Font_Name;
----------------------------
-- Internal_Get_Font_Size --
----------------------------
function Internal_Get_Font_Size
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Holder;
end Internal_Get_Font_Size;
--------------------------------------
-- Internal_Get_Font_Strike_Through --
--------------------------------------
function Internal_Get_Font_Strike_Through
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (14).Boolean_Holder;
end Internal_Get_Font_Strike_Through;
---------------------------------
-- Internal_Get_Font_Underline --
---------------------------------
function Internal_Get_Font_Underline
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (13).Boolean_Holder;
end Internal_Get_Font_Underline;
------------------------
-- Internal_Get_Group --
------------------------
function Internal_Get_Group
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Group;
--------------------------------------------
-- Internal_Get_Is_Aspect_Ratio_Preserved --
--------------------------------------------
function Internal_Get_Is_Aspect_Ratio_Preserved
(Self : AMF.Internals.AMF_Element)
return Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Boolean_Value;
end Internal_Get_Is_Aspect_Ratio_Preserved;
------------------------------
-- Internal_Get_Local_Style --
------------------------------
function Internal_Get_Local_Style
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when others =>
raise Program_Error;
end case;
end Internal_Get_Local_Style;
-------------------------
-- Internal_Get_Member --
-------------------------
function Internal_Get_Member
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 3;
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 3;
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 3;
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 3;
when others =>
raise Program_Error;
end case;
end Internal_Get_Member;
-----------------------------
-- Internal_Get_Mid_Marker --
-----------------------------
function Internal_Get_Mid_Marker
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Mid_Marker;
--------------------------------
-- Internal_Get_Packaged_Fill --
--------------------------------
function Internal_Get_Packaged_Fill
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 4;
when others =>
raise Program_Error;
end case;
end Internal_Get_Packaged_Fill;
----------------------------------
-- Internal_Get_Packaged_Marker --
----------------------------------
function Internal_Get_Packaged_Marker
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 5;
when others =>
raise Program_Error;
end case;
end Internal_Get_Packaged_Marker;
---------------------------------
-- Internal_Get_Packaged_Style --
---------------------------------
function Internal_Get_Packaged_Style
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 6;
when others =>
raise Program_Error;
end case;
end Internal_Get_Packaged_Style;
------------------------
-- Internal_Get_Point --
------------------------
function Internal_Get_Point
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Sequence_Of_DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Point_Collection;
end Internal_Get_Point;
------------------------
-- Internal_Get_Radii --
------------------------
function Internal_Get_Radii
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Dimension is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Dimension_Value;
end Internal_Get_Radii;
-------------------------
-- Internal_Get_Radius --
-------------------------
function Internal_Get_Radius
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value;
end Internal_Get_Radius;
----------------------------
-- Internal_Get_Reference --
----------------------------
function Internal_Get_Reference
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Point_Value;
end Internal_Get_Reference;
-------------------------------
-- Internal_Get_Shared_Style --
-------------------------------
function Internal_Get_Shared_Style
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when others =>
raise Program_Error;
end case;
end Internal_Get_Shared_Style;
-----------------------
-- Internal_Get_Size --
-----------------------
function Internal_Get_Size
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Dimension is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Dimension_Value;
end Internal_Get_Size;
-------------------------
-- Internal_Get_Source --
-------------------------
function Internal_Get_Source
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access is
begin
return
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).String_Value;
end Internal_Get_Source;
------------------------
-- Internal_Get_Start --
------------------------
function Internal_Get_Start
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Point_Value;
end Internal_Get_Start;
-------------------------------
-- Internal_Get_Start_Marker --
-------------------------------
function Internal_Get_Start_Marker
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Start_Marker;
-----------------------
-- Internal_Get_Stop --
-----------------------
function Internal_Get_Stop
(Self : AMF.Internals.AMF_Element)
return AMF.DG.Set_Of_DG_Gradient_Stop is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Gradient_Collection;
end Internal_Get_Stop;
-------------------------------
-- Internal_Get_Stroke_Color --
-------------------------------
function Internal_Get_Stroke_Color
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Optional_DC_Color is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Color_Holder;
end Internal_Get_Stroke_Color;
-------------------------------------
-- Internal_Get_Stroke_Dash_Length --
-------------------------------------
function Internal_Get_Stroke_Dash_Length
(Self : AMF.Internals.AMF_Element)
return AMF.Real_Collections.Sequence_Of_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Collection;
end Internal_Get_Stroke_Dash_Length;
---------------------------------
-- Internal_Get_Stroke_Opacity --
---------------------------------
function Internal_Get_Stroke_Opacity
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Holder;
end Internal_Get_Stroke_Opacity;
-------------------------------
-- Internal_Get_Stroke_Width --
-------------------------------
function Internal_Get_Stroke_Width
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Holder;
end Internal_Get_Stroke_Width;
-----------------------
-- Internal_Get_Tile --
-----------------------
function Internal_Get_Tile
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Pattern =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Tile;
----------------------------
-- Internal_Get_Transform --
----------------------------
function Internal_Get_Transform
(Self : AMF.Internals.AMF_Element)
return AMF.DG.Sequence_Of_DG_Transform is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (1).Transform_Collection;
end Internal_Get_Transform;
---------------------
-- Internal_Get_X1 --
---------------------
function Internal_Get_X1
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value;
end Internal_Get_X1;
---------------------
-- Internal_Get_X2 --
---------------------
function Internal_Get_X2
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
end Internal_Get_X2;
---------------------
-- Internal_Get_Y1 --
---------------------
function Internal_Get_Y1
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value;
end Internal_Get_Y1;
---------------------
-- Internal_Get_Y2 --
---------------------
function Internal_Get_Y2
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value;
end Internal_Get_Y2;
----------------------------
-- Internal_Set_Alignment --
----------------------------
procedure Internal_Set_Alignment
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Alignment_Kind)
is
Old : AMF.DC.DC_Alignment_Kind;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Alignment_Kind_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Alignment_Kind_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Text_Alignment, Old, To);
end Internal_Set_Alignment;
-----------------------------------
-- Internal_Set_Background_Color --
-----------------------------------
procedure Internal_Set_Background_Color
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.Optional_DC_Color)
is
Old : AMF.DC.Optional_DC_Color;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Color_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Color_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Canvas_Background_Color, Old, To);
end Internal_Set_Background_Color;
----------------------------------
-- Internal_Set_Background_Fill --
----------------------------------
procedure Internal_Set_Background_Fill
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Background_Fill_Canvas,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Background_Fill;
-------------------------
-- Internal_Set_Bounds --
-------------------------
procedure Internal_Set_Bounds
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Bounds)
is
Old : AMF.DC.DC_Bounds;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Bounds_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Bounds_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Image_Bounds, Old, To);
end Internal_Set_Bounds;
-------------------------
-- Internal_Set_Canvas --
-------------------------
procedure Internal_Set_Canvas
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Linear_Gradient =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Packaged_Fill_Canvas,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Packaged_Marker_Canvas,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Pattern =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Packaged_Fill_Canvas,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Radial_Gradient =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Packaged_Fill_Canvas,
To,
Self);
when others =>
raise Program_Error;
end case;
end Internal_Set_Canvas;
-------------------------
-- Internal_Set_Center --
-------------------------
procedure Internal_Set_Center
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Point)
is
Old : AMF.DC.DC_Point;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Point_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Point_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Circle_Center, Old, To);
end Internal_Set_Center;
---------------------------
-- Internal_Set_Center_X --
---------------------------
procedure Internal_Set_Center_X
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Radial_Gradient_Center_X, Old, To);
end Internal_Set_Center_X;
---------------------------
-- Internal_Set_Center_Y --
---------------------------
procedure Internal_Set_Center_Y
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Radial_Gradient_Center_Y, Old, To);
end Internal_Set_Center_Y;
----------------------------
-- Internal_Set_Clip_Path --
----------------------------
procedure Internal_Set_Clip_Path
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Clip_Path;
----------------------------------
-- Internal_Set_Clipped_Element --
----------------------------------
procedure Internal_Set_Clipped_Element
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
To,
Self);
when others =>
raise Program_Error;
end case;
end Internal_Set_Clipped_Element;
--------------------------------
-- Internal_Set_Corner_Radius --
--------------------------------
procedure Internal_Set_Corner_Radius
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Rectangle_Corner_Radius, Old, To);
end Internal_Set_Corner_Radius;
-----------------------
-- Internal_Set_Data --
-----------------------
procedure Internal_Set_Data
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access)
is
Old : Matreshka.Internals.Strings.Shared_String_Access;
begin
Old :=
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).String_Value;
DD_Element_Table.Table (Self).Member (5).String_Value := To;
Matreshka.Internals.Strings.Reference
(DD_Element_Table.Table (Self).Member (5).String_Value);
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Text_Data, Old, To);
Matreshka.Internals.Strings.Dereference (Old);
end Internal_Set_Data;
----------------------
-- Internal_Set_End --
----------------------
procedure Internal_Set_End
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Point)
is
Old : AMF.DC.DC_Point;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Point_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Point_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Line_End, Old, To);
end Internal_Set_End;
-----------------------------
-- Internal_Set_End_Marker --
-----------------------------
procedure Internal_Set_End_Marker
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_End_Marker;
-----------------------
-- Internal_Set_Fill --
-----------------------
procedure Internal_Set_Fill
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Style =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Style_Fill_Style,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Fill;
-----------------------------
-- Internal_Set_Fill_Color --
-----------------------------
procedure Internal_Set_Fill_Color
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.Optional_DC_Color)
is
Old : AMF.DC.Optional_DC_Color;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Color_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Color_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Fill_Color, Old, To);
end Internal_Set_Fill_Color;
-------------------------------
-- Internal_Set_Fill_Opacity --
-------------------------------
procedure Internal_Set_Fill_Opacity
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Real)
is
Old : AMF.Optional_Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Real_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Real_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Fill_Opacity, Old, To);
end Internal_Set_Fill_Opacity;
--------------------------
-- Internal_Set_Focus_X --
--------------------------
procedure Internal_Set_Focus_X
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Radial_Gradient_Focus_X, Old, To);
end Internal_Set_Focus_X;
--------------------------
-- Internal_Set_Focus_Y --
--------------------------
procedure Internal_Set_Focus_Y
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Radial_Gradient_Focus_Y, Old, To);
end Internal_Set_Focus_Y;
----------------------------
-- Internal_Set_Font_Bold --
----------------------------
procedure Internal_Set_Font_Bold
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Boolean)
is
Old : AMF.Optional_Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (12).Boolean_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (12).Boolean_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Bold, Old, To);
end Internal_Set_Font_Bold;
-----------------------------
-- Internal_Set_Font_Color --
-----------------------------
procedure Internal_Set_Font_Color
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.Optional_DC_Color)
is
Old : AMF.DC.Optional_DC_Color;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (10).Color_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (10).Color_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Color, Old, To);
end Internal_Set_Font_Color;
------------------------------
-- Internal_Set_Font_Italic --
------------------------------
procedure Internal_Set_Font_Italic
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Boolean)
is
Old : AMF.Optional_Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (11).Boolean_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (11).Boolean_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Italic, Old, To);
end Internal_Set_Font_Italic;
----------------------------
-- Internal_Set_Font_Name --
----------------------------
procedure Internal_Set_Font_Name
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access)
is
Old : Matreshka.Internals.Strings.Shared_String_Access;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (9).String_Value;
DD_Element_Table.Table (Self).Member (9).String_Value := To;
if DD_Element_Table.Table (Self).Member (9).String_Value /= null then
Matreshka.Internals.Strings.Reference
(DD_Element_Table.Table (Self).Member (9).String_Value);
end if;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Name, Old, To);
if Old /= null then
Matreshka.Internals.Strings.Reference (Old);
end if;
end Internal_Set_Font_Name;
----------------------------
-- Internal_Set_Font_Size --
----------------------------
procedure Internal_Set_Font_Size
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Real)
is
Old : AMF.Optional_Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Size, Old, To);
end Internal_Set_Font_Size;
--------------------------------------
-- Internal_Set_Font_Strike_Through --
--------------------------------------
procedure Internal_Set_Font_Strike_Through
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Boolean)
is
Old : AMF.Optional_Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (14).Boolean_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (14).Boolean_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Strike_Through, Old, To);
end Internal_Set_Font_Strike_Through;
---------------------------------
-- Internal_Set_Font_Underline --
---------------------------------
procedure Internal_Set_Font_Underline
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Boolean)
is
Old : AMF.Optional_Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (13).Boolean_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (13).Boolean_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Underline, Old, To);
end Internal_Set_Font_Underline;
------------------------
-- Internal_Set_Group --
------------------------
procedure Internal_Set_Group
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when others =>
raise Program_Error;
end case;
end Internal_Set_Group;
--------------------------------------------
-- Internal_Set_Is_Aspect_Ratio_Preserved --
--------------------------------------------
procedure Internal_Set_Is_Aspect_Ratio_Preserved
(Self : AMF.Internals.AMF_Element;
To : Boolean)
is
Old : Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Boolean_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Boolean_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Image_Is_Aspect_Ratio_Preserved, Old, To);
end Internal_Set_Is_Aspect_Ratio_Preserved;
-----------------------------
-- Internal_Set_Mid_Marker --
-----------------------------
procedure Internal_Set_Mid_Marker
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Mid_Marker;
------------------------
-- Internal_Set_Radii --
------------------------
procedure Internal_Set_Radii
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Dimension)
is
Old : AMF.DC.DC_Dimension;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Dimension_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Dimension_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Ellipse_Radii, Old, To);
end Internal_Set_Radii;
-------------------------
-- Internal_Set_Radius --
-------------------------
procedure Internal_Set_Radius
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Circle_Radius, Old, To);
end Internal_Set_Radius;
----------------------------
-- Internal_Set_Reference --
----------------------------
procedure Internal_Set_Reference
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Point)
is
Old : AMF.DC.DC_Point;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Point_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Point_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Marker_Reference, Old, To);
end Internal_Set_Reference;
-----------------------
-- Internal_Set_Size --
-----------------------
procedure Internal_Set_Size
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Dimension)
is
Old : AMF.DC.DC_Dimension;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Dimension_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Dimension_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Marker_Size, Old, To);
end Internal_Set_Size;
-------------------------
-- Internal_Set_Source --
-------------------------
procedure Internal_Set_Source
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access)
is
Old : Matreshka.Internals.Strings.Shared_String_Access;
begin
Old :=
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).String_Value;
DD_Element_Table.Table (Self).Member (5).String_Value := To;
Matreshka.Internals.Strings.Reference
(DD_Element_Table.Table (Self).Member (5).String_Value);
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Image_Source, Old, To);
Matreshka.Internals.Strings.Dereference (Old);
end Internal_Set_Source;
------------------------
-- Internal_Set_Start --
------------------------
procedure Internal_Set_Start
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Point)
is
Old : AMF.DC.DC_Point;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Point_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Point_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Line_Start, Old, To);
end Internal_Set_Start;
-------------------------------
-- Internal_Set_Start_Marker --
-------------------------------
procedure Internal_Set_Start_Marker
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Start_Marker;
-------------------------------
-- Internal_Set_Stroke_Color --
-------------------------------
procedure Internal_Set_Stroke_Color
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.Optional_DC_Color)
is
Old : AMF.DC.Optional_DC_Color;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Color_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Color_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Stroke_Color, Old, To);
end Internal_Set_Stroke_Color;
---------------------------------
-- Internal_Set_Stroke_Opacity --
---------------------------------
procedure Internal_Set_Stroke_Opacity
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Real)
is
Old : AMF.Optional_Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Stroke_Opacity, Old, To);
end Internal_Set_Stroke_Opacity;
-------------------------------
-- Internal_Set_Stroke_Width --
-------------------------------
procedure Internal_Set_Stroke_Width
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Real)
is
Old : AMF.Optional_Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Stroke_Width, Old, To);
end Internal_Set_Stroke_Width;
-----------------------
-- Internal_Set_Tile --
-----------------------
procedure Internal_Set_Tile
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Pattern =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Pattern_Tile_Pattern,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Tile;
---------------------
-- Internal_Set_X1 --
---------------------
procedure Internal_Set_X1
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Linear_Gradient_X1, Old, To);
end Internal_Set_X1;
---------------------
-- Internal_Set_X2 --
---------------------
procedure Internal_Set_X2
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Linear_Gradient_X2, Old, To);
end Internal_Set_X2;
---------------------
-- Internal_Set_Y1 --
---------------------
procedure Internal_Set_Y1
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Linear_Gradient_Y1, Old, To);
end Internal_Set_Y1;
---------------------
-- Internal_Set_Y2 --
---------------------
procedure Internal_Set_Y2
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Linear_Gradient_Y2, Old, To);
end Internal_Set_Y2;
end AMF.Internals.Tables.DD_Attributes;
| 11706 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2013, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Internals.Links;
with AMF.Internals.Tables.DC_Notification;
with AMF.Internals.Tables.DD_Element_Table;
with AMF.Internals.Tables.DD_Types;
with AMF.Internals.Tables.DG_Metamodel;
package body AMF.Internals.Tables.DD_Attributes is
use type Matreshka.Internals.Strings.Shared_String_Access;
-- Canvas
--
-- 5 Canvas::backgroundColor
-- 4 Canvas::backgroundFill
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 3 Group::member
-- 4 Canvas::packagedFill
-- 5 Canvas::packagedMarker
-- 6 Canvas::packagedStyle
-- 2 GraphicalElement::sharedStyle
-- Circle
--
-- 5 Circle::center
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 4 Circle::radius
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- ClipPath
--
-- 3 GraphicalElement::clipPath
-- 4 ClipPath::clippedElement
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 3 Group::member
-- 2 GraphicalElement::sharedStyle
-- Ellipse
--
-- 5 Ellipse::center
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 4 Ellipse::radii
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Group
--
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 3 Group::member
-- 2 GraphicalElement::sharedStyle
-- Image
--
-- 4 Image::bounds
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 6 Image::isAspectRatioPreserved
-- 5 Image::source
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Line
--
-- 3 GraphicalElement::clipPath
-- 8 Line::end
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 7 Line::start
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- LinearGradient
--
-- 2 Fill::canvas
-- 3 Gradient::stop
-- 1 Fill::transform
-- 4 LinearGradient::x1
-- 5 LinearGradient::x2
-- 6 LinearGradient::y1
-- 7 LinearGradient::y2
--
-- MarkedElement
--
-- 3 GraphicalElement::clipPath
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Marker
--
-- 4 Marker::canvas
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 6 Marker::reference
-- 5 Marker::size
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 3 Group::member
-- 2 GraphicalElement::sharedStyle
-- Path
--
-- 3 GraphicalElement::clipPath
-- 7 Path::command
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Pattern
--
-- 4 Pattern::bounds
-- 2 Fill::canvas
-- 3 Pattern::tile
-- 1 Fill::transform
--
-- Polygon
--
-- 3 GraphicalElement::clipPath
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 7 Polygon::point
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Polyline
--
-- 3 GraphicalElement::clipPath
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 7 Polyline::point
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- RadialGradient
--
-- 2 Fill::canvas
-- 5 RadialGradient::centerX
-- 6 RadialGradient::centerY
-- 7 RadialGradient::focusX
-- 8 RadialGradient::focusY
-- 4 RadialGradient::radius
-- 3 Gradient::stop
-- 1 Fill::transform
--
-- Rectangle
--
-- 4 Rectangle::bounds
-- 3 GraphicalElement::clipPath
-- 5 Rectangle::cornerRadius
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Style
--
-- 1 Style::fill
-- 2 Style::fillColor
-- 3 Style::fillOpacity
-- 12 Style::fontBold
-- 10 Style::fontColor
-- 11 Style::fontItalic
-- 9 Style::fontName
-- 8 Style::fontSize
-- 14 Style::fontStrikeThrough
-- 13 Style::fontUnderline
-- 6 Style::strokeColor
-- 7 Style::strokeDashLength
-- 5 Style::strokeOpacity
-- 4 Style::strokeWidth
--
-- Text
--
-- 6 Text::alignment
-- 4 Text::bounds
-- 3 GraphicalElement::clipPath
-- 5 Text::data
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
----------------------------
-- Internal_Get_Alignment --
----------------------------
function Internal_Get_Alignment
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Alignment_Kind is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Alignment_Kind_Value;
end Internal_Get_Alignment;
-----------------------------------
-- Internal_Get_Background_Color --
-----------------------------------
function Internal_Get_Background_Color
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Optional_DC_Color is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Color_Holder;
end Internal_Get_Background_Color;
----------------------------------
-- Internal_Get_Background_Fill --
----------------------------------
function Internal_Get_Background_Fill
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Background_Fill;
-------------------------
-- Internal_Get_Bounds --
-------------------------
function Internal_Get_Bounds
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Bounds is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Bounds_Value;
end Internal_Get_Bounds;
-------------------------
-- Internal_Get_Canvas --
-------------------------
function Internal_Get_Canvas
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Linear_Gradient =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Pattern =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Radial_Gradient =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Canvas;
-------------------------
-- Internal_Get_Center --
-------------------------
function Internal_Get_Center
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Point_Value;
end Internal_Get_Center;
---------------------------
-- Internal_Get_Center_X --
---------------------------
function Internal_Get_Center_X
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
end Internal_Get_Center_X;
---------------------------
-- Internal_Get_Center_Y --
---------------------------
function Internal_Get_Center_Y
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value;
end Internal_Get_Center_Y;
----------------------------
-- Internal_Get_Clip_Path --
----------------------------
function Internal_Get_Clip_Path
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Clip_Path;
----------------------------------
-- Internal_Get_Clipped_Element --
----------------------------------
function Internal_Get_Clipped_Element
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Clipped_Element;
--------------------------
-- Internal_Get_Command --
--------------------------
function Internal_Get_Command
(Self : AMF.Internals.AMF_Element)
return AMF.DG.Sequence_Of_Path_Command is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Path_Collection;
end Internal_Get_Command;
--------------------------------
-- Internal_Get_Corner_Radius --
--------------------------------
function Internal_Get_Corner_Radius
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
end Internal_Get_Corner_Radius;
-----------------------
-- Internal_Get_Data --
-----------------------
function Internal_Get_Data
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access is
begin
return
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).String_Value;
end Internal_Get_Data;
----------------------
-- Internal_Get_End --
----------------------
function Internal_Get_End
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Point_Value;
end Internal_Get_End;
-----------------------------
-- Internal_Get_End_Marker --
-----------------------------
function Internal_Get_End_Marker
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_End_Marker;
-----------------------
-- Internal_Get_Fill --
-----------------------
function Internal_Get_Fill
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Style =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (1).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Fill;
-----------------------------
-- Internal_Get_Fill_Color --
-----------------------------
function Internal_Get_Fill_Color
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Optional_DC_Color is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Color_Holder;
end Internal_Get_Fill_Color;
-------------------------------
-- Internal_Get_Fill_Opacity --
-------------------------------
function Internal_Get_Fill_Opacity
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Real_Holder;
end Internal_Get_Fill_Opacity;
--------------------------
-- Internal_Get_Focus_X --
--------------------------
function Internal_Get_Focus_X
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value;
end Internal_Get_Focus_X;
--------------------------
-- Internal_Get_Focus_Y --
--------------------------
function Internal_Get_Focus_Y
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Value;
end Internal_Get_Focus_Y;
----------------------------
-- Internal_Get_Font_Bold --
----------------------------
function Internal_Get_Font_Bold
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (12).Boolean_Holder;
end Internal_Get_Font_Bold;
-----------------------------
-- Internal_Get_Font_Color --
-----------------------------
function Internal_Get_Font_Color
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Optional_DC_Color is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (10).Color_Holder;
end Internal_Get_Font_Color;
------------------------------
-- Internal_Get_Font_Italic --
------------------------------
function Internal_Get_Font_Italic
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (11).Boolean_Holder;
end Internal_Get_Font_Italic;
----------------------------
-- Internal_Get_Font_Name --
----------------------------
function Internal_Get_Font_Name
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access is
begin
return
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (9).String_Value;
end Internal_Get_Font_Name;
----------------------------
-- Internal_Get_Font_Size --
----------------------------
function Internal_Get_Font_Size
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Holder;
end Internal_Get_Font_Size;
--------------------------------------
-- Internal_Get_Font_Strike_Through --
--------------------------------------
function Internal_Get_Font_Strike_Through
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (14).Boolean_Holder;
end Internal_Get_Font_Strike_Through;
---------------------------------
-- Internal_Get_Font_Underline --
---------------------------------
function Internal_Get_Font_Underline
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (13).Boolean_Holder;
end Internal_Get_Font_Underline;
------------------------
-- Internal_Get_Group --
------------------------
function Internal_Get_Group
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Group;
--------------------------------------------
-- Internal_Get_Is_Aspect_Ratio_Preserved --
--------------------------------------------
function Internal_Get_Is_Aspect_Ratio_Preserved
(Self : AMF.Internals.AMF_Element)
return Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Boolean_Value;
end Internal_Get_Is_Aspect_Ratio_Preserved;
------------------------------
-- Internal_Get_Local_Style --
------------------------------
function Internal_Get_Local_Style
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when others =>
raise Program_Error;
end case;
end Internal_Get_Local_Style;
-------------------------
-- Internal_Get_Member --
-------------------------
function Internal_Get_Member
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 3;
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 3;
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 3;
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 3;
when others =>
raise Program_Error;
end case;
end Internal_Get_Member;
-----------------------------
-- Internal_Get_Mid_Marker --
-----------------------------
function Internal_Get_Mid_Marker
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Mid_Marker;
--------------------------------
-- Internal_Get_Packaged_Fill --
--------------------------------
function Internal_Get_Packaged_Fill
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 4;
when others =>
raise Program_Error;
end case;
end Internal_Get_Packaged_Fill;
----------------------------------
-- Internal_Get_Packaged_Marker --
----------------------------------
function Internal_Get_Packaged_Marker
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 5;
when others =>
raise Program_Error;
end case;
end Internal_Get_Packaged_Marker;
---------------------------------
-- Internal_Get_Packaged_Style --
---------------------------------
function Internal_Get_Packaged_Style
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 6;
when others =>
raise Program_Error;
end case;
end Internal_Get_Packaged_Style;
------------------------
-- Internal_Get_Point --
------------------------
function Internal_Get_Point
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Sequence_Of_DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Point_Collection;
end Internal_Get_Point;
------------------------
-- Internal_Get_Radii --
------------------------
function Internal_Get_Radii
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Dimension is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Dimension_Value;
end Internal_Get_Radii;
-------------------------
-- Internal_Get_Radius --
-------------------------
function Internal_Get_Radius
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value;
end Internal_Get_Radius;
----------------------------
-- Internal_Get_Reference --
----------------------------
function Internal_Get_Reference
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Point_Value;
end Internal_Get_Reference;
-------------------------------
-- Internal_Get_Shared_Style --
-------------------------------
function Internal_Get_Shared_Style
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when others =>
raise Program_Error;
end case;
end Internal_Get_Shared_Style;
-----------------------
-- Internal_Get_Size --
-----------------------
function Internal_Get_Size
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Dimension is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Dimension_Value;
end Internal_Get_Size;
-------------------------
-- Internal_Get_Source --
-------------------------
function Internal_Get_Source
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access is
begin
return
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).String_Value;
end Internal_Get_Source;
------------------------
-- Internal_Get_Start --
------------------------
function Internal_Get_Start
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Point_Value;
end Internal_Get_Start;
-------------------------------
-- Internal_Get_Start_Marker --
-------------------------------
function Internal_Get_Start_Marker
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Start_Marker;
-----------------------
-- Internal_Get_Stop --
-----------------------
function Internal_Get_Stop
(Self : AMF.Internals.AMF_Element)
return AMF.DG.Set_Of_DG_Gradient_Stop is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Gradient_Collection;
end Internal_Get_Stop;
-------------------------------
-- Internal_Get_Stroke_Color --
-------------------------------
function Internal_Get_Stroke_Color
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Optional_DC_Color is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Color_Holder;
end Internal_Get_Stroke_Color;
-------------------------------------
-- Internal_Get_Stroke_Dash_Length --
-------------------------------------
function Internal_Get_Stroke_Dash_Length
(Self : AMF.Internals.AMF_Element)
return AMF.Real_Collections.Sequence_Of_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Collection;
end Internal_Get_Stroke_Dash_Length;
---------------------------------
-- Internal_Get_Stroke_Opacity --
---------------------------------
function Internal_Get_Stroke_Opacity
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Holder;
end Internal_Get_Stroke_Opacity;
-------------------------------
-- Internal_Get_Stroke_Width --
-------------------------------
function Internal_Get_Stroke_Width
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Holder;
end Internal_Get_Stroke_Width;
-----------------------
-- Internal_Get_Tile --
-----------------------
function Internal_Get_Tile
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Pattern =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Tile;
----------------------------
-- Internal_Get_Transform --
----------------------------
function Internal_Get_Transform
(Self : AMF.Internals.AMF_Element)
return AMF.DG.Sequence_Of_DG_Transform is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (1).Transform_Collection;
end Internal_Get_Transform;
---------------------
-- Internal_Get_X1 --
---------------------
function Internal_Get_X1
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value;
end Internal_Get_X1;
---------------------
-- Internal_Get_X2 --
---------------------
function Internal_Get_X2
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
end Internal_Get_X2;
---------------------
-- Internal_Get_Y1 --
---------------------
function Internal_Get_Y1
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value;
end Internal_Get_Y1;
---------------------
-- Internal_Get_Y2 --
---------------------
function Internal_Get_Y2
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value;
end Internal_Get_Y2;
----------------------------
-- Internal_Set_Alignment --
----------------------------
procedure Internal_Set_Alignment
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Alignment_Kind)
is
Old : AMF.DC.DC_Alignment_Kind;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Alignment_Kind_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Alignment_Kind_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Text_Alignment, Old, To);
end Internal_Set_Alignment;
-----------------------------------
-- Internal_Set_Background_Color --
-----------------------------------
procedure Internal_Set_Background_Color
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.Optional_DC_Color)
is
Old : AMF.DC.Optional_DC_Color;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Color_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Color_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Canvas_Background_Color, Old, To);
end Internal_Set_Background_Color;
----------------------------------
-- Internal_Set_Background_Fill --
----------------------------------
procedure Internal_Set_Background_Fill
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Background_Fill_Canvas,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Background_Fill;
-------------------------
-- Internal_Set_Bounds --
-------------------------
procedure Internal_Set_Bounds
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Bounds)
is
Old : AMF.DC.DC_Bounds;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Bounds_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Bounds_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Image_Bounds, Old, To);
end Internal_Set_Bounds;
-------------------------
-- Internal_Set_Canvas --
-------------------------
procedure Internal_Set_Canvas
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Linear_Gradient =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Packaged_Fill_Canvas,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Packaged_Marker_Canvas,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Pattern =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Packaged_Fill_Canvas,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Radial_Gradient =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Packaged_Fill_Canvas,
To,
Self);
when others =>
raise Program_Error;
end case;
end Internal_Set_Canvas;
-------------------------
-- Internal_Set_Center --
-------------------------
procedure Internal_Set_Center
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Point)
is
Old : AMF.DC.DC_Point;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Point_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Point_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Circle_Center, Old, To);
end Internal_Set_Center;
---------------------------
-- Internal_Set_Center_X --
---------------------------
procedure Internal_Set_Center_X
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Radial_Gradient_Center_X, Old, To);
end Internal_Set_Center_X;
---------------------------
-- Internal_Set_Center_Y --
---------------------------
procedure Internal_Set_Center_Y
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Radial_Gradient_Center_Y, Old, To);
end Internal_Set_Center_Y;
----------------------------
-- Internal_Set_Clip_Path --
----------------------------
procedure Internal_Set_Clip_Path
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Clip_Path;
----------------------------------
-- Internal_Set_Clipped_Element --
----------------------------------
procedure Internal_Set_Clipped_Element
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
To,
Self);
when others =>
raise Program_Error;
end case;
end Internal_Set_Clipped_Element;
--------------------------------
-- Internal_Set_Corner_Radius --
--------------------------------
procedure Internal_Set_Corner_Radius
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Rectangle_Corner_Radius, Old, To);
end Internal_Set_Corner_Radius;
-----------------------
-- Internal_Set_Data --
-----------------------
procedure Internal_Set_Data
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access)
is
Old : Matreshka.Internals.Strings.Shared_String_Access;
begin
Old :=
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).String_Value;
DD_Element_Table.Table (Self).Member (5).String_Value := To;
Matreshka.Internals.Strings.Reference
(DD_Element_Table.Table (Self).Member (5).String_Value);
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Text_Data, Old, To);
Matreshka.Internals.Strings.Dereference (Old);
end Internal_Set_Data;
----------------------
-- Internal_Set_End --
----------------------
procedure Internal_Set_End
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Point)
is
Old : AMF.DC.DC_Point;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Point_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Point_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Line_End, Old, To);
end Internal_Set_End;
-----------------------------
-- Internal_Set_End_Marker --
-----------------------------
procedure Internal_Set_End_Marker
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_End_Marker;
-----------------------
-- Internal_Set_Fill --
-----------------------
procedure Internal_Set_Fill
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Style =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Style_Fill_Style,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Fill;
-----------------------------
-- Internal_Set_Fill_Color --
-----------------------------
procedure Internal_Set_Fill_Color
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.Optional_DC_Color)
is
Old : AMF.DC.Optional_DC_Color;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Color_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Color_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Fill_Color, Old, To);
end Internal_Set_Fill_Color;
-------------------------------
-- Internal_Set_Fill_Opacity --
-------------------------------
procedure Internal_Set_Fill_Opacity
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Real)
is
Old : AMF.Optional_Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Real_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Real_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Fill_Opacity, Old, To);
end Internal_Set_Fill_Opacity;
--------------------------
-- Internal_Set_Focus_X --
--------------------------
procedure Internal_Set_Focus_X
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Radial_Gradient_Focus_X, Old, To);
end Internal_Set_Focus_X;
--------------------------
-- Internal_Set_Focus_Y --
--------------------------
procedure Internal_Set_Focus_Y
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Radial_Gradient_Focus_Y, Old, To);
end Internal_Set_Focus_Y;
----------------------------
-- Internal_Set_Font_Bold --
----------------------------
procedure Internal_Set_Font_Bold
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Boolean)
is
Old : AMF.Optional_Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (12).Boolean_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (12).Boolean_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Bold, Old, To);
end Internal_Set_Font_Bold;
-----------------------------
-- Internal_Set_Font_Color --
-----------------------------
procedure Internal_Set_Font_Color
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.Optional_DC_Color)
is
Old : AMF.DC.Optional_DC_Color;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (10).Color_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (10).Color_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Color, Old, To);
end Internal_Set_Font_Color;
------------------------------
-- Internal_Set_Font_Italic --
------------------------------
procedure Internal_Set_Font_Italic
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Boolean)
is
Old : AMF.Optional_Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (11).Boolean_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (11).Boolean_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Italic, Old, To);
end Internal_Set_Font_Italic;
----------------------------
-- Internal_Set_Font_Name --
----------------------------
procedure Internal_Set_Font_Name
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access)
is
Old : Matreshka.Internals.Strings.Shared_String_Access;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (9).String_Value;
DD_Element_Table.Table (Self).Member (9).String_Value := To;
if DD_Element_Table.Table (Self).Member (9).String_Value /= null then
Matreshka.Internals.Strings.Reference
(DD_Element_Table.Table (Self).Member (9).String_Value);
end if;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Name, Old, To);
if Old /= null then
Matreshka.Internals.Strings.Reference (Old);
end if;
end Internal_Set_Font_Name;
----------------------------
-- Internal_Set_Font_Size --
----------------------------
procedure Internal_Set_Font_Size
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Real)
is
Old : AMF.Optional_Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Size, Old, To);
end Internal_Set_Font_Size;
--------------------------------------
-- Internal_Set_Font_Strike_Through --
--------------------------------------
procedure Internal_Set_Font_Strike_Through
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Boolean)
is
Old : AMF.Optional_Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (14).Boolean_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (14).Boolean_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Strike_Through, Old, To);
end Internal_Set_Font_Strike_Through;
---------------------------------
-- Internal_Set_Font_Underline --
---------------------------------
procedure Internal_Set_Font_Underline
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Boolean)
is
Old : AMF.Optional_Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (13).Boolean_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (13).Boolean_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Underline, Old, To);
end Internal_Set_Font_Underline;
------------------------
-- Internal_Set_Group --
------------------------
procedure Internal_Set_Group
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when others =>
raise Program_Error;
end case;
end Internal_Set_Group;
--------------------------------------------
-- Internal_Set_Is_Aspect_Ratio_Preserved --
--------------------------------------------
procedure Internal_Set_Is_Aspect_Ratio_Preserved
(Self : AMF.Internals.AMF_Element;
To : Boolean)
is
Old : Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Boolean_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Boolean_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Image_Is_Aspect_Ratio_Preserved, Old, To);
end Internal_Set_Is_Aspect_Ratio_Preserved;
-----------------------------
-- Internal_Set_Mid_Marker --
-----------------------------
procedure Internal_Set_Mid_Marker
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Mid_Marker;
------------------------
-- Internal_Set_Radii --
------------------------
procedure Internal_Set_Radii
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Dimension)
is
Old : AMF.DC.DC_Dimension;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Dimension_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Dimension_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Ellipse_Radii, Old, To);
end Internal_Set_Radii;
-------------------------
-- Internal_Set_Radius --
-------------------------
procedure Internal_Set_Radius
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Circle_Radius, Old, To);
end Internal_Set_Radius;
----------------------------
-- Internal_Set_Reference --
----------------------------
procedure Internal_Set_Reference
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Point)
is
Old : AMF.DC.DC_Point;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Point_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Point_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Marker_Reference, Old, To);
end Internal_Set_Reference;
-----------------------
-- Internal_Set_Size --
-----------------------
procedure Internal_Set_Size
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Dimension)
is
Old : AMF.DC.DC_Dimension;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Dimension_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Dimension_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Marker_Size, Old, To);
end Internal_Set_Size;
-------------------------
-- Internal_Set_Source --
-------------------------
procedure Internal_Set_Source
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access)
is
Old : Matreshka.Internals.Strings.Shared_String_Access;
begin
Old :=
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).String_Value;
DD_Element_Table.Table (Self).Member (5).String_Value := To;
Matreshka.Internals.Strings.Reference
(DD_Element_Table.Table (Self).Member (5).String_Value);
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Image_Source, Old, To);
Matreshka.Internals.Strings.Dereference (Old);
end Internal_Set_Source;
------------------------
-- Internal_Set_Start --
------------------------
procedure Internal_Set_Start
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Point)
is
Old : AMF.DC.DC_Point;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Point_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Point_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Line_Start, Old, To);
end Internal_Set_Start;
-------------------------------
-- Internal_Set_Start_Marker --
-------------------------------
procedure Internal_Set_Start_Marker
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Start_Marker;
-------------------------------
-- Internal_Set_Stroke_Color --
-------------------------------
procedure Internal_Set_Stroke_Color
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.Optional_DC_Color)
is
Old : AMF.DC.Optional_DC_Color;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Color_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Color_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Stroke_Color, Old, To);
end Internal_Set_Stroke_Color;
---------------------------------
-- Internal_Set_Stroke_Opacity --
---------------------------------
procedure Internal_Set_Stroke_Opacity
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Real)
is
Old : AMF.Optional_Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Stroke_Opacity, Old, To);
end Internal_Set_Stroke_Opacity;
-------------------------------
-- Internal_Set_Stroke_Width --
-------------------------------
procedure Internal_Set_Stroke_Width
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Real)
is
Old : AMF.Optional_Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Stroke_Width, Old, To);
end Internal_Set_Stroke_Width;
-----------------------
-- Internal_Set_Tile --
-----------------------
procedure Internal_Set_Tile
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Pattern =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Pattern_Tile_Pattern,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Tile;
---------------------
-- Internal_Set_X1 --
---------------------
procedure Internal_Set_X1
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Linear_Gradient_X1, Old, To);
end Internal_Set_X1;
---------------------
-- Internal_Set_X2 --
---------------------
procedure Internal_Set_X2
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Linear_Gradient_X2, Old, To);
end Internal_Set_X2;
---------------------
-- Internal_Set_Y1 --
---------------------
procedure Internal_Set_Y1
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Linear_Gradient_Y1, Old, To);
end Internal_Set_Y1;
---------------------
-- Internal_Set_Y2 --
---------------------
procedure Internal_Set_Y2
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Linear_Gradient_Y2, Old, To);
end Internal_Set_Y2;
end AMF.Internals.Tables.DD_Attributes;
| true | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2013, PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Internals.Links;
with AMF.Internals.Tables.DC_Notification;
with AMF.Internals.Tables.DD_Element_Table;
with AMF.Internals.Tables.DD_Types;
with AMF.Internals.Tables.DG_Metamodel;
package body AMF.Internals.Tables.DD_Attributes is
use type Matreshka.Internals.Strings.Shared_String_Access;
-- Canvas
--
-- 5 Canvas::backgroundColor
-- 4 Canvas::backgroundFill
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 3 Group::member
-- 4 Canvas::packagedFill
-- 5 Canvas::packagedMarker
-- 6 Canvas::packagedStyle
-- 2 GraphicalElement::sharedStyle
-- Circle
--
-- 5 Circle::center
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 4 Circle::radius
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- ClipPath
--
-- 3 GraphicalElement::clipPath
-- 4 ClipPath::clippedElement
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 3 Group::member
-- 2 GraphicalElement::sharedStyle
-- Ellipse
--
-- 5 Ellipse::center
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 4 Ellipse::radii
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Group
--
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 3 Group::member
-- 2 GraphicalElement::sharedStyle
-- Image
--
-- 4 Image::bounds
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 6 Image::isAspectRatioPreserved
-- 5 Image::source
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Line
--
-- 3 GraphicalElement::clipPath
-- 8 Line::end
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 7 Line::start
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- LinearGradient
--
-- 2 Fill::canvas
-- 3 Gradient::stop
-- 1 Fill::transform
-- 4 LinearGradient::x1
-- 5 LinearGradient::x2
-- 6 LinearGradient::y1
-- 7 LinearGradient::y2
--
-- MarkedElement
--
-- 3 GraphicalElement::clipPath
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Marker
--
-- 4 Marker::canvas
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 6 Marker::reference
-- 5 Marker::size
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 3 Group::member
-- 2 GraphicalElement::sharedStyle
-- Path
--
-- 3 GraphicalElement::clipPath
-- 7 Path::command
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Pattern
--
-- 4 Pattern::bounds
-- 2 Fill::canvas
-- 3 Pattern::tile
-- 1 Fill::transform
--
-- Polygon
--
-- 3 GraphicalElement::clipPath
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 7 Polygon::point
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Polyline
--
-- 3 GraphicalElement::clipPath
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 7 Polyline::point
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- RadialGradient
--
-- 2 Fill::canvas
-- 5 RadialGradient::centerX
-- 6 RadialGradient::centerY
-- 7 RadialGradient::focusX
-- 8 RadialGradient::focusY
-- 4 RadialGradient::radius
-- 3 Gradient::stop
-- 1 Fill::transform
--
-- Rectangle
--
-- 4 Rectangle::bounds
-- 3 GraphicalElement::clipPath
-- 5 Rectangle::cornerRadius
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Style
--
-- 1 Style::fill
-- 2 Style::fillColor
-- 3 Style::fillOpacity
-- 12 Style::fontBold
-- 10 Style::fontColor
-- 11 Style::fontItalic
-- 9 Style::fontName
-- 8 Style::fontSize
-- 14 Style::fontStrikeThrough
-- 13 Style::fontUnderline
-- 6 Style::strokeColor
-- 7 Style::strokeDashLength
-- 5 Style::strokeOpacity
-- 4 Style::strokeWidth
--
-- Text
--
-- 6 Text::alignment
-- 4 Text::bounds
-- 3 GraphicalElement::clipPath
-- 5 Text::data
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
----------------------------
-- Internal_Get_Alignment --
----------------------------
function Internal_Get_Alignment
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Alignment_Kind is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Alignment_Kind_Value;
end Internal_Get_Alignment;
-----------------------------------
-- Internal_Get_Background_Color --
-----------------------------------
function Internal_Get_Background_Color
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Optional_DC_Color is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Color_Holder;
end Internal_Get_Background_Color;
----------------------------------
-- Internal_Get_Background_Fill --
----------------------------------
function Internal_Get_Background_Fill
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Background_Fill;
-------------------------
-- Internal_Get_Bounds --
-------------------------
function Internal_Get_Bounds
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Bounds is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Bounds_Value;
end Internal_Get_Bounds;
-------------------------
-- Internal_Get_Canvas --
-------------------------
function Internal_Get_Canvas
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Linear_Gradient =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Pattern =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Radial_Gradient =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Canvas;
-------------------------
-- Internal_Get_Center --
-------------------------
function Internal_Get_Center
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Point_Value;
end Internal_Get_Center;
---------------------------
-- Internal_Get_Center_X --
---------------------------
function Internal_Get_Center_X
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
end Internal_Get_Center_X;
---------------------------
-- Internal_Get_Center_Y --
---------------------------
function Internal_Get_Center_Y
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value;
end Internal_Get_Center_Y;
----------------------------
-- Internal_Get_Clip_Path --
----------------------------
function Internal_Get_Clip_Path
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Clip_Path;
----------------------------------
-- Internal_Get_Clipped_Element --
----------------------------------
function Internal_Get_Clipped_Element
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Clipped_Element;
--------------------------
-- Internal_Get_Command --
--------------------------
function Internal_Get_Command
(Self : AMF.Internals.AMF_Element)
return AMF.DG.Sequence_Of_Path_Command is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Path_Collection;
end Internal_Get_Command;
--------------------------------
-- Internal_Get_Corner_Radius --
--------------------------------
function Internal_Get_Corner_Radius
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
end Internal_Get_Corner_Radius;
-----------------------
-- Internal_Get_Data --
-----------------------
function Internal_Get_Data
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access is
begin
return
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).String_Value;
end Internal_Get_Data;
----------------------
-- Internal_Get_End --
----------------------
function Internal_Get_End
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Point_Value;
end Internal_Get_End;
-----------------------------
-- Internal_Get_End_Marker --
-----------------------------
function Internal_Get_End_Marker
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_End_Marker;
-----------------------
-- Internal_Get_Fill --
-----------------------
function Internal_Get_Fill
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Style =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (1).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Fill;
-----------------------------
-- Internal_Get_Fill_Color --
-----------------------------
function Internal_Get_Fill_Color
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Optional_DC_Color is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Color_Holder;
end Internal_Get_Fill_Color;
-------------------------------
-- Internal_Get_Fill_Opacity --
-------------------------------
function Internal_Get_Fill_Opacity
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Real_Holder;
end Internal_Get_Fill_Opacity;
--------------------------
-- Internal_Get_Focus_X --
--------------------------
function Internal_Get_Focus_X
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value;
end Internal_Get_Focus_X;
--------------------------
-- Internal_Get_Focus_Y --
--------------------------
function Internal_Get_Focus_Y
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Value;
end Internal_Get_Focus_Y;
----------------------------
-- Internal_Get_Font_Bold --
----------------------------
function Internal_Get_Font_Bold
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (12).Boolean_Holder;
end Internal_Get_Font_Bold;
-----------------------------
-- Internal_Get_Font_Color --
-----------------------------
function Internal_Get_Font_Color
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Optional_DC_Color is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (10).Color_Holder;
end Internal_Get_Font_Color;
------------------------------
-- Internal_Get_Font_Italic --
------------------------------
function Internal_Get_Font_Italic
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (11).Boolean_Holder;
end Internal_Get_Font_Italic;
----------------------------
-- Internal_Get_Font_Name --
----------------------------
function Internal_Get_Font_Name
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access is
begin
return
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (9).String_Value;
end Internal_Get_Font_Name;
----------------------------
-- Internal_Get_Font_Size --
----------------------------
function Internal_Get_Font_Size
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Holder;
end Internal_Get_Font_Size;
--------------------------------------
-- Internal_Get_Font_Strike_Through --
--------------------------------------
function Internal_Get_Font_Strike_Through
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (14).Boolean_Holder;
end Internal_Get_Font_Strike_Through;
---------------------------------
-- Internal_Get_Font_Underline --
---------------------------------
function Internal_Get_Font_Underline
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (13).Boolean_Holder;
end Internal_Get_Font_Underline;
------------------------
-- Internal_Get_Group --
------------------------
function Internal_Get_Group
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Group;
--------------------------------------------
-- Internal_Get_Is_Aspect_Ratio_Preserved --
--------------------------------------------
function Internal_Get_Is_Aspect_Ratio_Preserved
(Self : AMF.Internals.AMF_Element)
return Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Boolean_Value;
end Internal_Get_Is_Aspect_Ratio_Preserved;
------------------------------
-- Internal_Get_Local_Style --
------------------------------
function Internal_Get_Local_Style
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when others =>
raise Program_Error;
end case;
end Internal_Get_Local_Style;
-------------------------
-- Internal_Get_Member --
-------------------------
function Internal_Get_Member
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 3;
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 3;
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 3;
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 3;
when others =>
raise Program_Error;
end case;
end Internal_Get_Member;
-----------------------------
-- Internal_Get_Mid_Marker --
-----------------------------
function Internal_Get_Mid_Marker
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Mid_Marker;
--------------------------------
-- Internal_Get_Packaged_Fill --
--------------------------------
function Internal_Get_Packaged_Fill
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 4;
when others =>
raise Program_Error;
end case;
end Internal_Get_Packaged_Fill;
----------------------------------
-- Internal_Get_Packaged_Marker --
----------------------------------
function Internal_Get_Packaged_Marker
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 5;
when others =>
raise Program_Error;
end case;
end Internal_Get_Packaged_Marker;
---------------------------------
-- Internal_Get_Packaged_Style --
---------------------------------
function Internal_Get_Packaged_Style
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 6;
when others =>
raise Program_Error;
end case;
end Internal_Get_Packaged_Style;
------------------------
-- Internal_Get_Point --
------------------------
function Internal_Get_Point
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Sequence_Of_DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Point_Collection;
end Internal_Get_Point;
------------------------
-- Internal_Get_Radii --
------------------------
function Internal_Get_Radii
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Dimension is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Dimension_Value;
end Internal_Get_Radii;
-------------------------
-- Internal_Get_Radius --
-------------------------
function Internal_Get_Radius
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value;
end Internal_Get_Radius;
----------------------------
-- Internal_Get_Reference --
----------------------------
function Internal_Get_Reference
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Point_Value;
end Internal_Get_Reference;
-------------------------------
-- Internal_Get_Shared_Style --
-------------------------------
function Internal_Get_Shared_Style
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when others =>
raise Program_Error;
end case;
end Internal_Get_Shared_Style;
-----------------------
-- Internal_Get_Size --
-----------------------
function Internal_Get_Size
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Dimension is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Dimension_Value;
end Internal_Get_Size;
-------------------------
-- Internal_Get_Source --
-------------------------
function Internal_Get_Source
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access is
begin
return
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).String_Value;
end Internal_Get_Source;
------------------------
-- Internal_Get_Start --
------------------------
function Internal_Get_Start
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Point_Value;
end Internal_Get_Start;
-------------------------------
-- Internal_Get_Start_Marker --
-------------------------------
function Internal_Get_Start_Marker
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Start_Marker;
-----------------------
-- Internal_Get_Stop --
-----------------------
function Internal_Get_Stop
(Self : AMF.Internals.AMF_Element)
return AMF.DG.Set_Of_DG_Gradient_Stop is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Gradient_Collection;
end Internal_Get_Stop;
-------------------------------
-- Internal_Get_Stroke_Color --
-------------------------------
function Internal_Get_Stroke_Color
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Optional_DC_Color is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Color_Holder;
end Internal_Get_Stroke_Color;
-------------------------------------
-- Internal_Get_Stroke_Dash_Length --
-------------------------------------
function Internal_Get_Stroke_Dash_Length
(Self : AMF.Internals.AMF_Element)
return AMF.Real_Collections.Sequence_Of_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Collection;
end Internal_Get_Stroke_Dash_Length;
---------------------------------
-- Internal_Get_Stroke_Opacity --
---------------------------------
function Internal_Get_Stroke_Opacity
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Holder;
end Internal_Get_Stroke_Opacity;
-------------------------------
-- Internal_Get_Stroke_Width --
-------------------------------
function Internal_Get_Stroke_Width
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Holder;
end Internal_Get_Stroke_Width;
-----------------------
-- Internal_Get_Tile --
-----------------------
function Internal_Get_Tile
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Pattern =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Tile;
----------------------------
-- Internal_Get_Transform --
----------------------------
function Internal_Get_Transform
(Self : AMF.Internals.AMF_Element)
return AMF.DG.Sequence_Of_DG_Transform is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (1).Transform_Collection;
end Internal_Get_Transform;
---------------------
-- Internal_Get_X1 --
---------------------
function Internal_Get_X1
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value;
end Internal_Get_X1;
---------------------
-- Internal_Get_X2 --
---------------------
function Internal_Get_X2
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
end Internal_Get_X2;
---------------------
-- Internal_Get_Y1 --
---------------------
function Internal_Get_Y1
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value;
end Internal_Get_Y1;
---------------------
-- Internal_Get_Y2 --
---------------------
function Internal_Get_Y2
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value;
end Internal_Get_Y2;
----------------------------
-- Internal_Set_Alignment --
----------------------------
procedure Internal_Set_Alignment
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Alignment_Kind)
is
Old : AMF.DC.DC_Alignment_Kind;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Alignment_Kind_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Alignment_Kind_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Text_Alignment, Old, To);
end Internal_Set_Alignment;
-----------------------------------
-- Internal_Set_Background_Color --
-----------------------------------
procedure Internal_Set_Background_Color
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.Optional_DC_Color)
is
Old : AMF.DC.Optional_DC_Color;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Color_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Color_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Canvas_Background_Color, Old, To);
end Internal_Set_Background_Color;
----------------------------------
-- Internal_Set_Background_Fill --
----------------------------------
procedure Internal_Set_Background_Fill
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Background_Fill_Canvas,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Background_Fill;
-------------------------
-- Internal_Set_Bounds --
-------------------------
procedure Internal_Set_Bounds
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Bounds)
is
Old : AMF.DC.DC_Bounds;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Bounds_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Bounds_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Image_Bounds, Old, To);
end Internal_Set_Bounds;
-------------------------
-- Internal_Set_Canvas --
-------------------------
procedure Internal_Set_Canvas
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Linear_Gradient =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Packaged_Fill_Canvas,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Packaged_Marker_Canvas,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Pattern =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Packaged_Fill_Canvas,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Radial_Gradient =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Packaged_Fill_Canvas,
To,
Self);
when others =>
raise Program_Error;
end case;
end Internal_Set_Canvas;
-------------------------
-- Internal_Set_Center --
-------------------------
procedure Internal_Set_Center
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Point)
is
Old : AMF.DC.DC_Point;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Point_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Point_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Circle_Center, Old, To);
end Internal_Set_Center;
---------------------------
-- Internal_Set_Center_X --
---------------------------
procedure Internal_Set_Center_X
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Radial_Gradient_Center_X, Old, To);
end Internal_Set_Center_X;
---------------------------
-- Internal_Set_Center_Y --
---------------------------
procedure Internal_Set_Center_Y
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Radial_Gradient_Center_Y, Old, To);
end Internal_Set_Center_Y;
----------------------------
-- Internal_Set_Clip_Path --
----------------------------
procedure Internal_Set_Clip_Path
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Clip_Path;
----------------------------------
-- Internal_Set_Clipped_Element --
----------------------------------
procedure Internal_Set_Clipped_Element
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
To,
Self);
when others =>
raise Program_Error;
end case;
end Internal_Set_Clipped_Element;
--------------------------------
-- Internal_Set_Corner_Radius --
--------------------------------
procedure Internal_Set_Corner_Radius
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Rectangle_Corner_Radius, Old, To);
end Internal_Set_Corner_Radius;
-----------------------
-- Internal_Set_Data --
-----------------------
procedure Internal_Set_Data
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access)
is
Old : Matreshka.Internals.Strings.Shared_String_Access;
begin
Old :=
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).String_Value;
DD_Element_Table.Table (Self).Member (5).String_Value := To;
Matreshka.Internals.Strings.Reference
(DD_Element_Table.Table (Self).Member (5).String_Value);
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Text_Data, Old, To);
Matreshka.Internals.Strings.Dereference (Old);
end Internal_Set_Data;
----------------------
-- Internal_Set_End --
----------------------
procedure Internal_Set_End
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Point)
is
Old : AMF.DC.DC_Point;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Point_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Point_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Line_End, Old, To);
end Internal_Set_End;
-----------------------------
-- Internal_Set_End_Marker --
-----------------------------
procedure Internal_Set_End_Marker
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_End_Marker;
-----------------------
-- Internal_Set_Fill --
-----------------------
procedure Internal_Set_Fill
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Style =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Style_Fill_Style,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Fill;
-----------------------------
-- Internal_Set_Fill_Color --
-----------------------------
procedure Internal_Set_Fill_Color
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.Optional_DC_Color)
is
Old : AMF.DC.Optional_DC_Color;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Color_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Color_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Fill_Color, Old, To);
end Internal_Set_Fill_Color;
-------------------------------
-- Internal_Set_Fill_Opacity --
-------------------------------
procedure Internal_Set_Fill_Opacity
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Real)
is
Old : AMF.Optional_Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Real_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Real_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Fill_Opacity, Old, To);
end Internal_Set_Fill_Opacity;
--------------------------
-- Internal_Set_Focus_X --
--------------------------
procedure Internal_Set_Focus_X
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Radial_Gradient_Focus_X, Old, To);
end Internal_Set_Focus_X;
--------------------------
-- Internal_Set_Focus_Y --
--------------------------
procedure Internal_Set_Focus_Y
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Radial_Gradient_Focus_Y, Old, To);
end Internal_Set_Focus_Y;
----------------------------
-- Internal_Set_Font_Bold --
----------------------------
procedure Internal_Set_Font_Bold
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Boolean)
is
Old : AMF.Optional_Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (12).Boolean_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (12).Boolean_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Bold, Old, To);
end Internal_Set_Font_Bold;
-----------------------------
-- Internal_Set_Font_Color --
-----------------------------
procedure Internal_Set_Font_Color
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.Optional_DC_Color)
is
Old : AMF.DC.Optional_DC_Color;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (10).Color_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (10).Color_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Color, Old, To);
end Internal_Set_Font_Color;
------------------------------
-- Internal_Set_Font_Italic --
------------------------------
procedure Internal_Set_Font_Italic
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Boolean)
is
Old : AMF.Optional_Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (11).Boolean_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (11).Boolean_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Italic, Old, To);
end Internal_Set_Font_Italic;
----------------------------
-- Internal_Set_Font_Name --
----------------------------
procedure Internal_Set_Font_Name
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access)
is
Old : Matreshka.Internals.Strings.Shared_String_Access;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (9).String_Value;
DD_Element_Table.Table (Self).Member (9).String_Value := To;
if DD_Element_Table.Table (Self).Member (9).String_Value /= null then
Matreshka.Internals.Strings.Reference
(DD_Element_Table.Table (Self).Member (9).String_Value);
end if;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Name, Old, To);
if Old /= null then
Matreshka.Internals.Strings.Reference (Old);
end if;
end Internal_Set_Font_Name;
----------------------------
-- Internal_Set_Font_Size --
----------------------------
procedure Internal_Set_Font_Size
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Real)
is
Old : AMF.Optional_Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Size, Old, To);
end Internal_Set_Font_Size;
--------------------------------------
-- Internal_Set_Font_Strike_Through --
--------------------------------------
procedure Internal_Set_Font_Strike_Through
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Boolean)
is
Old : AMF.Optional_Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (14).Boolean_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (14).Boolean_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Strike_Through, Old, To);
end Internal_Set_Font_Strike_Through;
---------------------------------
-- Internal_Set_Font_Underline --
---------------------------------
procedure Internal_Set_Font_Underline
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Boolean)
is
Old : AMF.Optional_Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (13).Boolean_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (13).Boolean_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Underline, Old, To);
end Internal_Set_Font_Underline;
------------------------
-- Internal_Set_Group --
------------------------
procedure Internal_Set_Group
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when others =>
raise Program_Error;
end case;
end Internal_Set_Group;
--------------------------------------------
-- Internal_Set_Is_Aspect_Ratio_Preserved --
--------------------------------------------
procedure Internal_Set_Is_Aspect_Ratio_Preserved
(Self : AMF.Internals.AMF_Element;
To : Boolean)
is
Old : Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Boolean_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Boolean_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Image_Is_Aspect_Ratio_Preserved, Old, To);
end Internal_Set_Is_Aspect_Ratio_Preserved;
-----------------------------
-- Internal_Set_Mid_Marker --
-----------------------------
procedure Internal_Set_Mid_Marker
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Mid_Marker;
------------------------
-- Internal_Set_Radii --
------------------------
procedure Internal_Set_Radii
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Dimension)
is
Old : AMF.DC.DC_Dimension;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Dimension_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Dimension_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Ellipse_Radii, Old, To);
end Internal_Set_Radii;
-------------------------
-- Internal_Set_Radius --
-------------------------
procedure Internal_Set_Radius
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Circle_Radius, Old, To);
end Internal_Set_Radius;
----------------------------
-- Internal_Set_Reference --
----------------------------
procedure Internal_Set_Reference
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Point)
is
Old : AMF.DC.DC_Point;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Point_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Point_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Marker_Reference, Old, To);
end Internal_Set_Reference;
-----------------------
-- Internal_Set_Size --
-----------------------
procedure Internal_Set_Size
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Dimension)
is
Old : AMF.DC.DC_Dimension;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Dimension_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Dimension_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Marker_Size, Old, To);
end Internal_Set_Size;
-------------------------
-- Internal_Set_Source --
-------------------------
procedure Internal_Set_Source
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access)
is
Old : Matreshka.Internals.Strings.Shared_String_Access;
begin
Old :=
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).String_Value;
DD_Element_Table.Table (Self).Member (5).String_Value := To;
Matreshka.Internals.Strings.Reference
(DD_Element_Table.Table (Self).Member (5).String_Value);
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Image_Source, Old, To);
Matreshka.Internals.Strings.Dereference (Old);
end Internal_Set_Source;
------------------------
-- Internal_Set_Start --
------------------------
procedure Internal_Set_Start
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Point)
is
Old : AMF.DC.DC_Point;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Point_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Point_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Line_Start, Old, To);
end Internal_Set_Start;
-------------------------------
-- Internal_Set_Start_Marker --
-------------------------------
procedure Internal_Set_Start_Marker
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Start_Marker;
-------------------------------
-- Internal_Set_Stroke_Color --
-------------------------------
procedure Internal_Set_Stroke_Color
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.Optional_DC_Color)
is
Old : AMF.DC.Optional_DC_Color;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Color_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Color_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Stroke_Color, Old, To);
end Internal_Set_Stroke_Color;
---------------------------------
-- Internal_Set_Stroke_Opacity --
---------------------------------
procedure Internal_Set_Stroke_Opacity
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Real)
is
Old : AMF.Optional_Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Stroke_Opacity, Old, To);
end Internal_Set_Stroke_Opacity;
-------------------------------
-- Internal_Set_Stroke_Width --
-------------------------------
procedure Internal_Set_Stroke_Width
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Real)
is
Old : AMF.Optional_Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Stroke_Width, Old, To);
end Internal_Set_Stroke_Width;
-----------------------
-- Internal_Set_Tile --
-----------------------
procedure Internal_Set_Tile
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Pattern =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Pattern_Tile_Pattern,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Tile;
---------------------
-- Internal_Set_X1 --
---------------------
procedure Internal_Set_X1
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Linear_Gradient_X1, Old, To);
end Internal_Set_X1;
---------------------
-- Internal_Set_X2 --
---------------------
procedure Internal_Set_X2
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Linear_Gradient_X2, Old, To);
end Internal_Set_X2;
---------------------
-- Internal_Set_Y1 --
---------------------
procedure Internal_Set_Y1
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Linear_Gradient_Y1, Old, To);
end Internal_Set_Y1;
---------------------
-- Internal_Set_Y2 --
---------------------
procedure Internal_Set_Y2
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Linear_Gradient_Y2, Old, To);
end Internal_Set_Y2;
end AMF.Internals.Tables.DD_Attributes;
|
[
{
"context": "e-Identifier: Apache-2.0\n--\n-- Copyright (c) 2017 onox <denkpadje@gmail.com>\n--\n-- Licensed under the A",
"end": 70,
"score": 0.9992837905883789,
"start": 66,
"tag": "USERNAME",
"value": "onox"
},
{
"context": "ifier: Apache-2.0\n--\n-- Copyright (c) 2017 onox <denkpadje@gmail.com>\n--\n-- Licensed under the Apache License, Versio",
"end": 91,
"score": 0.9999234080314636,
"start": 72,
"tag": "EMAIL",
"value": "denkpadje@gmail.com"
}
] | orka_transforms/src/orka-transforms-simd_quaternions.ads | onox/orka | 52 | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <denkpadje@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 Orka.Transforms.SIMD_Vectors;
generic
with package Vectors is new Orka.Transforms.SIMD_Vectors (<>);
package Orka.Transforms.SIMD_Quaternions is
pragma Pure;
type Quaternion is new Vectors.Vector_Type;
subtype Vector4 is Vectors.Vector_Type;
type Axis_Angle is record
Axis : Vectors.Direction;
Angle : Vectors.Element_Type;
end record;
Zero_Rotation : constant Quaternion := (0.0, 0.0, 0.0, 1.0);
function "+" (Left, Right : Quaternion) return Quaternion;
function "*" (Left, Right : Quaternion) return Quaternion;
function "*" (Left : Vectors.Element_Type; Right : Quaternion) return Quaternion;
function "*" (Left : Quaternion; Right : Vectors.Element_Type) return Quaternion;
function Conjugate (Elements : Quaternion) return Quaternion;
function Inverse (Elements : Quaternion) return Quaternion;
function Norm (Elements : Quaternion) return Vectors.Element_Type;
function Normalize (Elements : Quaternion) return Quaternion;
function Normalized (Elements : Quaternion) return Boolean;
function To_Axis_Angle (Elements : Quaternion) return Axis_Angle;
function From_Axis_Angle (Value : Axis_Angle) return Quaternion;
function R
(Axis : Vector4;
Angle : Vectors.Element_Type) return Quaternion
with Pre => Vectors.Normalized (Axis),
Post => Normalized (R'Result);
-- Return a quaternion that will cause a rotation of Angle radians
-- about the given Axis
function R (Left, Right : Vector4) return Quaternion
with Post => Normalized (R'Result);
-- Return the rotation from direction Left to Right
function Difference (Left, Right : Quaternion) return Quaternion
with Post => Normalized (Difference'Result);
-- Return a quaternion describing the rotation from quaternion Left
-- to Right (Right is a composite rotation of Left and the result)
procedure Rotate_At_Origin
(Vector : in out Vector4;
Elements : Quaternion)
with Pre => Normalized (Elements);
function Lerp
(Left, Right : Quaternion;
Time : Vectors.Element_Type) return Quaternion
with Pre => Time in 0.0 .. 1.0,
Post => Normalized (Lerp'Result);
-- Return the interpolated normalized quaternion on the chord
-- between the Left and Right quaternions.
function Slerp
(Left, Right : Quaternion;
Time : Vectors.Element_Type) return Quaternion
with Pre => Time in 0.0 .. 1.0,
Post => Normalized (Slerp'Result);
-- Return the interpolated unit quaternion on the shortest arc
-- between the Left and Right quaternions.
end Orka.Transforms.SIMD_Quaternions;
| 7232 | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <<EMAIL>>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Orka.Transforms.SIMD_Vectors;
generic
with package Vectors is new Orka.Transforms.SIMD_Vectors (<>);
package Orka.Transforms.SIMD_Quaternions is
pragma Pure;
type Quaternion is new Vectors.Vector_Type;
subtype Vector4 is Vectors.Vector_Type;
type Axis_Angle is record
Axis : Vectors.Direction;
Angle : Vectors.Element_Type;
end record;
Zero_Rotation : constant Quaternion := (0.0, 0.0, 0.0, 1.0);
function "+" (Left, Right : Quaternion) return Quaternion;
function "*" (Left, Right : Quaternion) return Quaternion;
function "*" (Left : Vectors.Element_Type; Right : Quaternion) return Quaternion;
function "*" (Left : Quaternion; Right : Vectors.Element_Type) return Quaternion;
function Conjugate (Elements : Quaternion) return Quaternion;
function Inverse (Elements : Quaternion) return Quaternion;
function Norm (Elements : Quaternion) return Vectors.Element_Type;
function Normalize (Elements : Quaternion) return Quaternion;
function Normalized (Elements : Quaternion) return Boolean;
function To_Axis_Angle (Elements : Quaternion) return Axis_Angle;
function From_Axis_Angle (Value : Axis_Angle) return Quaternion;
function R
(Axis : Vector4;
Angle : Vectors.Element_Type) return Quaternion
with Pre => Vectors.Normalized (Axis),
Post => Normalized (R'Result);
-- Return a quaternion that will cause a rotation of Angle radians
-- about the given Axis
function R (Left, Right : Vector4) return Quaternion
with Post => Normalized (R'Result);
-- Return the rotation from direction Left to Right
function Difference (Left, Right : Quaternion) return Quaternion
with Post => Normalized (Difference'Result);
-- Return a quaternion describing the rotation from quaternion Left
-- to Right (Right is a composite rotation of Left and the result)
procedure Rotate_At_Origin
(Vector : in out Vector4;
Elements : Quaternion)
with Pre => Normalized (Elements);
function Lerp
(Left, Right : Quaternion;
Time : Vectors.Element_Type) return Quaternion
with Pre => Time in 0.0 .. 1.0,
Post => Normalized (Lerp'Result);
-- Return the interpolated normalized quaternion on the chord
-- between the Left and Right quaternions.
function Slerp
(Left, Right : Quaternion;
Time : Vectors.Element_Type) return Quaternion
with Pre => Time in 0.0 .. 1.0,
Post => Normalized (Slerp'Result);
-- Return the interpolated unit quaternion on the shortest arc
-- between the Left and Right quaternions.
end Orka.Transforms.SIMD_Quaternions;
| true | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <PI:EMAIL:<EMAIL>END_PI>
--
-- 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 Orka.Transforms.SIMD_Vectors;
generic
with package Vectors is new Orka.Transforms.SIMD_Vectors (<>);
package Orka.Transforms.SIMD_Quaternions is
pragma Pure;
type Quaternion is new Vectors.Vector_Type;
subtype Vector4 is Vectors.Vector_Type;
type Axis_Angle is record
Axis : Vectors.Direction;
Angle : Vectors.Element_Type;
end record;
Zero_Rotation : constant Quaternion := (0.0, 0.0, 0.0, 1.0);
function "+" (Left, Right : Quaternion) return Quaternion;
function "*" (Left, Right : Quaternion) return Quaternion;
function "*" (Left : Vectors.Element_Type; Right : Quaternion) return Quaternion;
function "*" (Left : Quaternion; Right : Vectors.Element_Type) return Quaternion;
function Conjugate (Elements : Quaternion) return Quaternion;
function Inverse (Elements : Quaternion) return Quaternion;
function Norm (Elements : Quaternion) return Vectors.Element_Type;
function Normalize (Elements : Quaternion) return Quaternion;
function Normalized (Elements : Quaternion) return Boolean;
function To_Axis_Angle (Elements : Quaternion) return Axis_Angle;
function From_Axis_Angle (Value : Axis_Angle) return Quaternion;
function R
(Axis : Vector4;
Angle : Vectors.Element_Type) return Quaternion
with Pre => Vectors.Normalized (Axis),
Post => Normalized (R'Result);
-- Return a quaternion that will cause a rotation of Angle radians
-- about the given Axis
function R (Left, Right : Vector4) return Quaternion
with Post => Normalized (R'Result);
-- Return the rotation from direction Left to Right
function Difference (Left, Right : Quaternion) return Quaternion
with Post => Normalized (Difference'Result);
-- Return a quaternion describing the rotation from quaternion Left
-- to Right (Right is a composite rotation of Left and the result)
procedure Rotate_At_Origin
(Vector : in out Vector4;
Elements : Quaternion)
with Pre => Normalized (Elements);
function Lerp
(Left, Right : Quaternion;
Time : Vectors.Element_Type) return Quaternion
with Pre => Time in 0.0 .. 1.0,
Post => Normalized (Lerp'Result);
-- Return the interpolated normalized quaternion on the chord
-- between the Left and Right quaternions.
function Slerp
(Left, Right : Quaternion;
Time : Vectors.Element_Type) return Quaternion
with Pre => Time in 0.0 .. 1.0,
Post => Normalized (Slerp'Result);
-- Return the interpolated unit quaternion on the shortest arc
-- between the Left and Right quaternions.
end Orka.Transforms.SIMD_Quaternions;
|
[
{
"context": "-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifi",
"end": 43,
"score": 0.999860405921936,
"start": 33,
"tag": "NAME",
"value": "Max Reznik"
},
{
"context": "-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifier: MIT\n------------",
"end": 63,
"score": 0.9999290704727173,
"start": 45,
"tag": "EMAIL",
"value": "reznikmm@gmail.com"
}
] | source/oasis/program-elements-constrained_array_types.ads | reznikmm/gela | 0 | -- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Elements.Type_Definitions;
with Program.Lexical_Elements;
with Program.Elements.Discrete_Ranges;
with Program.Elements.Component_Definitions;
package Program.Elements.Constrained_Array_Types is
pragma Pure (Program.Elements.Constrained_Array_Types);
type Constrained_Array_Type is
limited interface and Program.Elements.Type_Definitions.Type_Definition;
type Constrained_Array_Type_Access is
access all Constrained_Array_Type'Class with Storage_Size => 0;
not overriding function Index_Subtypes
(Self : Constrained_Array_Type)
return not null Program.Elements.Discrete_Ranges
.Discrete_Range_Vector_Access is abstract;
not overriding function Component_Definition
(Self : Constrained_Array_Type)
return not null Program.Elements.Component_Definitions
.Component_Definition_Access is abstract;
type Constrained_Array_Type_Text is limited interface;
type Constrained_Array_Type_Text_Access is
access all Constrained_Array_Type_Text'Class with Storage_Size => 0;
not overriding function To_Constrained_Array_Type_Text
(Self : in out Constrained_Array_Type)
return Constrained_Array_Type_Text_Access is abstract;
not overriding function Array_Token
(Self : Constrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Left_Bracket_Token
(Self : Constrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Right_Bracket_Token
(Self : Constrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Of_Token
(Self : Constrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Constrained_Array_Types;
| 26147 | -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Elements.Type_Definitions;
with Program.Lexical_Elements;
with Program.Elements.Discrete_Ranges;
with Program.Elements.Component_Definitions;
package Program.Elements.Constrained_Array_Types is
pragma Pure (Program.Elements.Constrained_Array_Types);
type Constrained_Array_Type is
limited interface and Program.Elements.Type_Definitions.Type_Definition;
type Constrained_Array_Type_Access is
access all Constrained_Array_Type'Class with Storage_Size => 0;
not overriding function Index_Subtypes
(Self : Constrained_Array_Type)
return not null Program.Elements.Discrete_Ranges
.Discrete_Range_Vector_Access is abstract;
not overriding function Component_Definition
(Self : Constrained_Array_Type)
return not null Program.Elements.Component_Definitions
.Component_Definition_Access is abstract;
type Constrained_Array_Type_Text is limited interface;
type Constrained_Array_Type_Text_Access is
access all Constrained_Array_Type_Text'Class with Storage_Size => 0;
not overriding function To_Constrained_Array_Type_Text
(Self : in out Constrained_Array_Type)
return Constrained_Array_Type_Text_Access is abstract;
not overriding function Array_Token
(Self : Constrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Left_Bracket_Token
(Self : Constrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Right_Bracket_Token
(Self : Constrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Of_Token
(Self : Constrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Constrained_Array_Types;
| true | -- SPDX-FileCopyrightText: 2019 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Elements.Type_Definitions;
with Program.Lexical_Elements;
with Program.Elements.Discrete_Ranges;
with Program.Elements.Component_Definitions;
package Program.Elements.Constrained_Array_Types is
pragma Pure (Program.Elements.Constrained_Array_Types);
type Constrained_Array_Type is
limited interface and Program.Elements.Type_Definitions.Type_Definition;
type Constrained_Array_Type_Access is
access all Constrained_Array_Type'Class with Storage_Size => 0;
not overriding function Index_Subtypes
(Self : Constrained_Array_Type)
return not null Program.Elements.Discrete_Ranges
.Discrete_Range_Vector_Access is abstract;
not overriding function Component_Definition
(Self : Constrained_Array_Type)
return not null Program.Elements.Component_Definitions
.Component_Definition_Access is abstract;
type Constrained_Array_Type_Text is limited interface;
type Constrained_Array_Type_Text_Access is
access all Constrained_Array_Type_Text'Class with Storage_Size => 0;
not overriding function To_Constrained_Array_Type_Text
(Self : in out Constrained_Array_Type)
return Constrained_Array_Type_Text_Access is abstract;
not overriding function Array_Token
(Self : Constrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Left_Bracket_Token
(Self : Constrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Right_Bracket_Token
(Self : Constrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Of_Token
(Self : Constrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Constrained_Array_Types;
|
[
{
"context": "-- part of OpenGLAda, (c) 2017 Felix Krause\n-- released under the terms of the MIT license, ",
"end": 44,
"score": 0.9998408555984497,
"start": 32,
"tag": "NAME",
"value": "Felix Krause"
}
] | src/glfw/v2/glfw-events.ads | Roldak/OpenGLAda | 0 | -- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with Interfaces.C;
package Glfw.Events is
type Button_State is (Release, Press);
type Button_States is array (Positive range <>) of Button_State;
procedure Poll_Events;
procedure Wait_For_Events;
private
for Button_State use (Release => 0, Press => 1);
for Button_State'Size use Interfaces.C.int'Size;
for Button_States'Component_Size use Interfaces.C.char'Size;
pragma Convention (C, Button_States);
end Glfw.Events;
| 586 | -- part of OpenGLAda, (c) 2017 <NAME>
-- released under the terms of the MIT license, see the file "COPYING"
with Interfaces.C;
package Glfw.Events is
type Button_State is (Release, Press);
type Button_States is array (Positive range <>) of Button_State;
procedure Poll_Events;
procedure Wait_For_Events;
private
for Button_State use (Release => 0, Press => 1);
for Button_State'Size use Interfaces.C.int'Size;
for Button_States'Component_Size use Interfaces.C.char'Size;
pragma Convention (C, Button_States);
end Glfw.Events;
| true | -- part of OpenGLAda, (c) 2017 PI:NAME:<NAME>END_PI
-- released under the terms of the MIT license, see the file "COPYING"
with Interfaces.C;
package Glfw.Events is
type Button_State is (Release, Press);
type Button_States is array (Positive range <>) of Button_State;
procedure Poll_Events;
procedure Wait_For_Events;
private
for Button_State use (Release => 0, Press => 1);
for Button_State'Size use Interfaces.C.int'Size;
for Button_States'Component_Size use Interfaces.C.char'Size;
pragma Convention (C, Button_States);
end Glfw.Events;
|
[
{
"context": "-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifi",
"end": 43,
"score": 0.9998611211776733,
"start": 33,
"tag": "NAME",
"value": "Max Reznik"
},
{
"context": "-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifier: MIT\n------------",
"end": 63,
"score": 0.9999301433563232,
"start": 45,
"tag": "EMAIL",
"value": "reznikmm@gmail.com"
}
] | source/nodes/program-nodes-subtype_indications.ads | reznikmm/gela | 0 | -- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Constraints;
with Program.Elements.Subtype_Indications;
with Program.Element_Visitors;
package Program.Nodes.Subtype_Indications is
pragma Preelaborate;
type Subtype_Indication is
new Program.Nodes.Node
and Program.Elements.Subtype_Indications.Subtype_Indication
and Program.Elements.Subtype_Indications.Subtype_Indication_Text
with private;
function Create
(Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
Subtype_Mark : not null Program.Elements.Expressions.Expression_Access;
Constraint : Program.Elements.Constraints.Constraint_Access)
return Subtype_Indication;
type Implicit_Subtype_Indication is
new Program.Nodes.Node
and Program.Elements.Subtype_Indications.Subtype_Indication
with private;
function Create
(Subtype_Mark : not null Program.Elements.Expressions
.Expression_Access;
Constraint : Program.Elements.Constraints.Constraint_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Not_Null : Boolean := False)
return Implicit_Subtype_Indication
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Subtype_Indication is
abstract new Program.Nodes.Node
and Program.Elements.Subtype_Indications.Subtype_Indication
with record
Subtype_Mark : not null Program.Elements.Expressions.Expression_Access;
Constraint : Program.Elements.Constraints.Constraint_Access;
end record;
procedure Initialize (Self : in out Base_Subtype_Indication'Class);
overriding procedure Visit
(Self : not null access Base_Subtype_Indication;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Subtype_Mark
(Self : Base_Subtype_Indication)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Constraint
(Self : Base_Subtype_Indication)
return Program.Elements.Constraints.Constraint_Access;
overriding function Is_Subtype_Indication
(Self : Base_Subtype_Indication)
return Boolean;
overriding function Is_Definition
(Self : Base_Subtype_Indication)
return Boolean;
type Subtype_Indication is
new Base_Subtype_Indication
and Program.Elements.Subtype_Indications.Subtype_Indication_Text
with record
Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Subtype_Indication_Text
(Self : in out Subtype_Indication)
return Program.Elements.Subtype_Indications
.Subtype_Indication_Text_Access;
overriding function Not_Token
(Self : Subtype_Indication)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Null_Token
(Self : Subtype_Indication)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Has_Not_Null (Self : Subtype_Indication) return Boolean;
type Implicit_Subtype_Indication is
new Base_Subtype_Indication
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
Has_Not_Null : Boolean;
end record;
overriding function To_Subtype_Indication_Text
(Self : in out Implicit_Subtype_Indication)
return Program.Elements.Subtype_Indications
.Subtype_Indication_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Subtype_Indication)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Subtype_Indication)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Subtype_Indication)
return Boolean;
overriding function Has_Not_Null
(Self : Implicit_Subtype_Indication)
return Boolean;
end Program.Nodes.Subtype_Indications;
| 21242 | -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Constraints;
with Program.Elements.Subtype_Indications;
with Program.Element_Visitors;
package Program.Nodes.Subtype_Indications is
pragma Preelaborate;
type Subtype_Indication is
new Program.Nodes.Node
and Program.Elements.Subtype_Indications.Subtype_Indication
and Program.Elements.Subtype_Indications.Subtype_Indication_Text
with private;
function Create
(Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
Subtype_Mark : not null Program.Elements.Expressions.Expression_Access;
Constraint : Program.Elements.Constraints.Constraint_Access)
return Subtype_Indication;
type Implicit_Subtype_Indication is
new Program.Nodes.Node
and Program.Elements.Subtype_Indications.Subtype_Indication
with private;
function Create
(Subtype_Mark : not null Program.Elements.Expressions
.Expression_Access;
Constraint : Program.Elements.Constraints.Constraint_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Not_Null : Boolean := False)
return Implicit_Subtype_Indication
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Subtype_Indication is
abstract new Program.Nodes.Node
and Program.Elements.Subtype_Indications.Subtype_Indication
with record
Subtype_Mark : not null Program.Elements.Expressions.Expression_Access;
Constraint : Program.Elements.Constraints.Constraint_Access;
end record;
procedure Initialize (Self : in out Base_Subtype_Indication'Class);
overriding procedure Visit
(Self : not null access Base_Subtype_Indication;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Subtype_Mark
(Self : Base_Subtype_Indication)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Constraint
(Self : Base_Subtype_Indication)
return Program.Elements.Constraints.Constraint_Access;
overriding function Is_Subtype_Indication
(Self : Base_Subtype_Indication)
return Boolean;
overriding function Is_Definition
(Self : Base_Subtype_Indication)
return Boolean;
type Subtype_Indication is
new Base_Subtype_Indication
and Program.Elements.Subtype_Indications.Subtype_Indication_Text
with record
Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Subtype_Indication_Text
(Self : in out Subtype_Indication)
return Program.Elements.Subtype_Indications
.Subtype_Indication_Text_Access;
overriding function Not_Token
(Self : Subtype_Indication)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Null_Token
(Self : Subtype_Indication)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Has_Not_Null (Self : Subtype_Indication) return Boolean;
type Implicit_Subtype_Indication is
new Base_Subtype_Indication
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
Has_Not_Null : Boolean;
end record;
overriding function To_Subtype_Indication_Text
(Self : in out Implicit_Subtype_Indication)
return Program.Elements.Subtype_Indications
.Subtype_Indication_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Subtype_Indication)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Subtype_Indication)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Subtype_Indication)
return Boolean;
overriding function Has_Not_Null
(Self : Implicit_Subtype_Indication)
return Boolean;
end Program.Nodes.Subtype_Indications;
| true | -- SPDX-FileCopyrightText: 2019 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Constraints;
with Program.Elements.Subtype_Indications;
with Program.Element_Visitors;
package Program.Nodes.Subtype_Indications is
pragma Preelaborate;
type Subtype_Indication is
new Program.Nodes.Node
and Program.Elements.Subtype_Indications.Subtype_Indication
and Program.Elements.Subtype_Indications.Subtype_Indication_Text
with private;
function Create
(Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
Subtype_Mark : not null Program.Elements.Expressions.Expression_Access;
Constraint : Program.Elements.Constraints.Constraint_Access)
return Subtype_Indication;
type Implicit_Subtype_Indication is
new Program.Nodes.Node
and Program.Elements.Subtype_Indications.Subtype_Indication
with private;
function Create
(Subtype_Mark : not null Program.Elements.Expressions
.Expression_Access;
Constraint : Program.Elements.Constraints.Constraint_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Not_Null : Boolean := False)
return Implicit_Subtype_Indication
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Subtype_Indication is
abstract new Program.Nodes.Node
and Program.Elements.Subtype_Indications.Subtype_Indication
with record
Subtype_Mark : not null Program.Elements.Expressions.Expression_Access;
Constraint : Program.Elements.Constraints.Constraint_Access;
end record;
procedure Initialize (Self : in out Base_Subtype_Indication'Class);
overriding procedure Visit
(Self : not null access Base_Subtype_Indication;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Subtype_Mark
(Self : Base_Subtype_Indication)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Constraint
(Self : Base_Subtype_Indication)
return Program.Elements.Constraints.Constraint_Access;
overriding function Is_Subtype_Indication
(Self : Base_Subtype_Indication)
return Boolean;
overriding function Is_Definition
(Self : Base_Subtype_Indication)
return Boolean;
type Subtype_Indication is
new Base_Subtype_Indication
and Program.Elements.Subtype_Indications.Subtype_Indication_Text
with record
Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Subtype_Indication_Text
(Self : in out Subtype_Indication)
return Program.Elements.Subtype_Indications
.Subtype_Indication_Text_Access;
overriding function Not_Token
(Self : Subtype_Indication)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Null_Token
(Self : Subtype_Indication)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Has_Not_Null (Self : Subtype_Indication) return Boolean;
type Implicit_Subtype_Indication is
new Base_Subtype_Indication
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
Has_Not_Null : Boolean;
end record;
overriding function To_Subtype_Indication_Text
(Self : in out Implicit_Subtype_Indication)
return Program.Elements.Subtype_Indications
.Subtype_Indication_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Subtype_Indication)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Subtype_Indication)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Subtype_Indication)
return Boolean;
overriding function Has_Not_Null
(Self : Implicit_Subtype_Indication)
return Boolean;
end Program.Nodes.Subtype_Indications;
|
[
{
"context": " --\n-- * Richard Wai (ANNEXI-STRAYLINE) ",
"end": 886,
"score": 0.9998109936714172,
"start": 875,
"tag": "NAME",
"value": "Richard Wai"
}
] | repositories-cache-checkout_git.adb | annexi-strayline/AURA | 13 | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- Reference Implementation --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Streams;
with Ada.Assertions;
with Ada.Directories;
with Ada.Strings.Fixed;
with Ada.Strings.Bounded;
with Child_Processes;
with Child_Processes.Path_Searching;
with Child_Processes.Wait_And_Buffer;
separate (Repositories.Cache)
package body Checkout_Git is
Git_Cache_Failure: exception;
package Program_Paths renames Child_Processes.Path_Searching;
Git_Program : aliased constant String := "git";
Git : constant Program_Paths.Elaboration_Path_Search
:= Program_Paths.Initialize (Git_Program);
Git_Timeout : constant Duration := 300.0; -- 5 minutes
Output_Poll_Rate: constant Duration := 0.5;
package Output_Buffers is
new Ada.Strings.Bounded.Generic_Bounded_Length (8096);
procedure Buffer_Append (Buffer: in out Output_Buffers.Bounded_String;
Item : in String)
is begin
-- Since we are using bounded inputs, we'd rather not crash just because
-- the input exceeds the buffers, but rather have it truncate.
Output_Buffers.Append (Source => Buffer,
New_Item => Item,
Drop => Ada.Strings.Right);
end Buffer_Append;
procedure Wait_And_Buffer is new Child_Processes.Wait_And_Buffer
(Buffer_Type => Output_Buffers.Bounded_String,
Append => Buffer_Append,
Empty_Buffer => Output_Buffers.Null_Bounded_String);
--
-- Checkout_Git_Order
--
-- Checkout_Order checks out a git repository when the cache does
-- not exist (or has been invalidated)
type Cache_Git_Order is new Workers.Work_Order with
record
Repo : Repository;
Index: Repository_Index;
end record;
overriding procedure Execute (Order: in out Cache_Git_Order);
overriding function Image (Order: Cache_Git_Order) return String;
-----------
-- Image --
-----------
function Image (Order: Cache_Git_Order) return String
is ( "[Cache_Git_Order]" & New_Line
& " Repoistory No."
& Repository_Index'Image (Order.Index) & New_Line
& " Git : " & UBS.To_String (Order.Repo.Location)
& (if (UBS.Length (Order.Repo.Snapshot) > 0) then
New_Line & " Commit: " & UBS.To_String (Order.Repo.Snapshot)
else
"")
& (if (UBS.Length (Order.Repo.Tracking_Branch) > 0) then
New_Line & " Branch: "
& UBS.To_String (Order.Repo.Tracking_Branch)
else
""));
-------------
-- Execute --
-------------
procedure Execute (Order: in out Cache_Git_Order) is
use Child_Processes;
use type Ada.Directories.File_Kind;
Trimmed_Index: constant String
:= Ada.Strings.Fixed.Trim
(Source => Repository_Index'Image (Order.Index),
Side => Ada.Strings.Both);
Cache_Path: constant String := Cache_Root & '/' & Trimmed_Index;
STDERR: Output_Buffers.Bounded_String;
STDOUT: Output_Buffers.Bounded_String;
procedure Wait_Proc (Title: in String;
Proc : in out Child_Process'Class)
is
type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
Timed_Out: Boolean;
Proc_Exit: Exit_Status := Failure;
begin
-- Wait until finish, if timeout, kill the process. If
-- exit status = Failure then drain Standard_Error. In both cases,
-- raise an exception
Wait_And_Buffer (Process => Proc,
Poll_Rate => Output_Poll_Rate,
Timeout => Git_Timeout,
Output => STDOUT,
Error => STDERR,
Timed_Out => Timed_Out,
Status => Proc_Exit);
if Timed_Out then
-- This should actually be very rare
Proc.Kill;
raise Git_Cache_Failure with Title
& " timed-out"
& " STDOUT: " & Output_Buffers.To_String (STDOUT)
& " STDERR: " & Output_Buffers.To_String (STDERR);
elsif Proc_Exit = Failure then
raise Git_Cache_Failure with Title & " failed: "
& Output_Buffers.To_String (STDERR);
end if;
end Wait_Proc;
procedure Git_Command (Args : in String;
Ignore_Fail: Boolean := False) is
Proc: Child_Process'Class
:= Spawn_Process
(Image_Path => Program_Paths.Image_Path (Git),
Arguments => Args,
Working_Directory => Cache_Path);
begin
Wait_Proc (Title => "git " & Args,
Proc => Proc);
exception
when Git_Cache_Failure =>
if Ignore_Fail then
return;
else
raise;
end if;
end Git_Command;
Cache_Bad: Boolean := False;
begin
UBS.Set_Unbounded_String (Target => Order.Repo.Cache_Path,
Source => Cache_Path);
Order.Repo.Cache_State := Available;
-- These will only be updated in the registry if the checkout is
-- successful
-- Verify that git is actually available
if not Program_Paths.Found (Git) then
raise Program_Error with
"Unable to checkout git repository: Could not find git!";
end if;
-- First step is to see if this repo is already cached, and if it is,
-- that it is on the right commit or branch, and that it has no
-- unstaged/uncommited changes. If that is all good, we're done. If any
-- of that is off, we wipe it and start from scratch (the user should
-- never be messing with a git cache directly)
if Ada.Directories.Exists (Cache_Path) then
if Ada.Directories.Kind (Cache_Path) = Ada.Directories.Directory then
begin
if UBS.Length (Order.Repo.Snapshot) > 0 then
-- If Snapshot is not empty, this means the repo is on a
-- specific commit (regardless of any Tracking_Branch).
Git_Command ("log -1 --pretty=format:%H");
if Output_Buffers.To_String (STDOUT)
/= UBS.To_String (Order.Repo.Snapshot)
then
Cache_Bad := True;
end if;
end if;
-- Check for any pollution. We expect a short status to only
-- have one line, giving either "## HEAD" (Snapshot) or
--"## branch...origin/branch" (Tracking_Branch)
--
-- Any lines following that indicate changes to the cache, which
-- is not acceptable
Git_Command ("status -s -b");
-- If we have a snapshot, we expect a detached head
if UBS.Length (Order.Repo.Snapshot) > 0
-- "## HEAD "
-- ^ ^
-- 1 8
and then Output_Buffers.Slice (Source => STDOUT,
Low => 1,
High => 8)
/= "## HEAD "
then
Cache_Bad := True;
else
-- If we don't have a snapshot, we expect to see the correct
-- branch
pragma Assert (UBS.Length (Order.Repo.Tracking_Branch) > 0);
-- This should be checked when the repo file is parsed
declare
Expected: constant String
:= "## "
& UBS.To_String (Order.Repo.Tracking_Branch)
& "...origin/"
& UBS.To_String (Order.Repo.Tracking_Branch);
begin
if Output_Buffers.Slice (Source => STDOUT,
Low => 1,
High => Expected'Length)
/= Expected
then
Cache_Bad := True;
end if;
end;
end if;
-- Finally, there should be only one line
if Output_Buffers.Count (Source => STDOUT,
Pattern => String'(1 .. 1 => New_Line))
> 1
then
Cache_Bad := True;
end if;
exception
when Git_Cache_Failure =>
-- Any of the above commands failing simply means the cache
-- is invalid, so we just need to destroy it
Cache_Bad := True;
end;
if not Cache_Bad then
-- done.
Update_Repository (Index => Order.Index,
Updated => Order.Repo);
return;
else
-- Expunge
Ada.Directories.Delete_Tree (Cache_Path);
end if;
else
-- Path points at a non-directory file, that's not ok
Ada.Directories.Delete_File (Cache_Path);
end if;
end if;
-- If we get here, then either the cache didn't exist, or something was
-- wrong with it and it was obliterated
-- Create the cache path
Ada.Directories.Create_Path (Cache_Path);
-- Clone the repo
Git_Command ("clone -n -q -j 0 " -- Quiet and don't checkout anything
& UBS.To_String (Order.Repo.Location) & ' '
& Cache_Path);
-- If the snapshot is set, that takes priority
if UBS.Length (Order.Repo.Snapshot) > 0 then
Git_Command ("checkout --detach "
& UBS.To_String (Order.Repo.Snapshot));
-- If Tracking_Branch is set, and we have no snapshow, check that out
elsif UBS.Length (Order.Repo.Tracking_Branch) > 0 then
Git_Command ("checkout "
& UBS.To_String (Order.Repo.Tracking_Branch));
-- Otherwise, we just use the default branch
else
Git_Command ("checkout "
& UBS.To_String (Order.Repo.Tracking_Branch));
end if;
-- Finally we checkout submodules, if any
Git_Command ("submodule --quiet update "
& "--init --checkout --recursive -j 0");
Update_Repository (Index => Order.Index,
Updated => Order.Repo);
end Execute;
--------------
-- Dispatch --
--------------
procedure Dispatch (Repo: in Repository; Index: in Repository_Index) is
Order: Cache_Git_Order
:= (Tracker => Caching_Progress'Access,
Repo => Repo,
Index => Index);
begin
Workers.Enqueue_Order (Order);
end Dispatch;
end Checkout_Git;
| 3655 | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- Reference Implementation --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * <NAME> (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Streams;
with Ada.Assertions;
with Ada.Directories;
with Ada.Strings.Fixed;
with Ada.Strings.Bounded;
with Child_Processes;
with Child_Processes.Path_Searching;
with Child_Processes.Wait_And_Buffer;
separate (Repositories.Cache)
package body Checkout_Git is
Git_Cache_Failure: exception;
package Program_Paths renames Child_Processes.Path_Searching;
Git_Program : aliased constant String := "git";
Git : constant Program_Paths.Elaboration_Path_Search
:= Program_Paths.Initialize (Git_Program);
Git_Timeout : constant Duration := 300.0; -- 5 minutes
Output_Poll_Rate: constant Duration := 0.5;
package Output_Buffers is
new Ada.Strings.Bounded.Generic_Bounded_Length (8096);
procedure Buffer_Append (Buffer: in out Output_Buffers.Bounded_String;
Item : in String)
is begin
-- Since we are using bounded inputs, we'd rather not crash just because
-- the input exceeds the buffers, but rather have it truncate.
Output_Buffers.Append (Source => Buffer,
New_Item => Item,
Drop => Ada.Strings.Right);
end Buffer_Append;
procedure Wait_And_Buffer is new Child_Processes.Wait_And_Buffer
(Buffer_Type => Output_Buffers.Bounded_String,
Append => Buffer_Append,
Empty_Buffer => Output_Buffers.Null_Bounded_String);
--
-- Checkout_Git_Order
--
-- Checkout_Order checks out a git repository when the cache does
-- not exist (or has been invalidated)
type Cache_Git_Order is new Workers.Work_Order with
record
Repo : Repository;
Index: Repository_Index;
end record;
overriding procedure Execute (Order: in out Cache_Git_Order);
overriding function Image (Order: Cache_Git_Order) return String;
-----------
-- Image --
-----------
function Image (Order: Cache_Git_Order) return String
is ( "[Cache_Git_Order]" & New_Line
& " Repoistory No."
& Repository_Index'Image (Order.Index) & New_Line
& " Git : " & UBS.To_String (Order.Repo.Location)
& (if (UBS.Length (Order.Repo.Snapshot) > 0) then
New_Line & " Commit: " & UBS.To_String (Order.Repo.Snapshot)
else
"")
& (if (UBS.Length (Order.Repo.Tracking_Branch) > 0) then
New_Line & " Branch: "
& UBS.To_String (Order.Repo.Tracking_Branch)
else
""));
-------------
-- Execute --
-------------
procedure Execute (Order: in out Cache_Git_Order) is
use Child_Processes;
use type Ada.Directories.File_Kind;
Trimmed_Index: constant String
:= Ada.Strings.Fixed.Trim
(Source => Repository_Index'Image (Order.Index),
Side => Ada.Strings.Both);
Cache_Path: constant String := Cache_Root & '/' & Trimmed_Index;
STDERR: Output_Buffers.Bounded_String;
STDOUT: Output_Buffers.Bounded_String;
procedure Wait_Proc (Title: in String;
Proc : in out Child_Process'Class)
is
type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
Timed_Out: Boolean;
Proc_Exit: Exit_Status := Failure;
begin
-- Wait until finish, if timeout, kill the process. If
-- exit status = Failure then drain Standard_Error. In both cases,
-- raise an exception
Wait_And_Buffer (Process => Proc,
Poll_Rate => Output_Poll_Rate,
Timeout => Git_Timeout,
Output => STDOUT,
Error => STDERR,
Timed_Out => Timed_Out,
Status => Proc_Exit);
if Timed_Out then
-- This should actually be very rare
Proc.Kill;
raise Git_Cache_Failure with Title
& " timed-out"
& " STDOUT: " & Output_Buffers.To_String (STDOUT)
& " STDERR: " & Output_Buffers.To_String (STDERR);
elsif Proc_Exit = Failure then
raise Git_Cache_Failure with Title & " failed: "
& Output_Buffers.To_String (STDERR);
end if;
end Wait_Proc;
procedure Git_Command (Args : in String;
Ignore_Fail: Boolean := False) is
Proc: Child_Process'Class
:= Spawn_Process
(Image_Path => Program_Paths.Image_Path (Git),
Arguments => Args,
Working_Directory => Cache_Path);
begin
Wait_Proc (Title => "git " & Args,
Proc => Proc);
exception
when Git_Cache_Failure =>
if Ignore_Fail then
return;
else
raise;
end if;
end Git_Command;
Cache_Bad: Boolean := False;
begin
UBS.Set_Unbounded_String (Target => Order.Repo.Cache_Path,
Source => Cache_Path);
Order.Repo.Cache_State := Available;
-- These will only be updated in the registry if the checkout is
-- successful
-- Verify that git is actually available
if not Program_Paths.Found (Git) then
raise Program_Error with
"Unable to checkout git repository: Could not find git!";
end if;
-- First step is to see if this repo is already cached, and if it is,
-- that it is on the right commit or branch, and that it has no
-- unstaged/uncommited changes. If that is all good, we're done. If any
-- of that is off, we wipe it and start from scratch (the user should
-- never be messing with a git cache directly)
if Ada.Directories.Exists (Cache_Path) then
if Ada.Directories.Kind (Cache_Path) = Ada.Directories.Directory then
begin
if UBS.Length (Order.Repo.Snapshot) > 0 then
-- If Snapshot is not empty, this means the repo is on a
-- specific commit (regardless of any Tracking_Branch).
Git_Command ("log -1 --pretty=format:%H");
if Output_Buffers.To_String (STDOUT)
/= UBS.To_String (Order.Repo.Snapshot)
then
Cache_Bad := True;
end if;
end if;
-- Check for any pollution. We expect a short status to only
-- have one line, giving either "## HEAD" (Snapshot) or
--"## branch...origin/branch" (Tracking_Branch)
--
-- Any lines following that indicate changes to the cache, which
-- is not acceptable
Git_Command ("status -s -b");
-- If we have a snapshot, we expect a detached head
if UBS.Length (Order.Repo.Snapshot) > 0
-- "## HEAD "
-- ^ ^
-- 1 8
and then Output_Buffers.Slice (Source => STDOUT,
Low => 1,
High => 8)
/= "## HEAD "
then
Cache_Bad := True;
else
-- If we don't have a snapshot, we expect to see the correct
-- branch
pragma Assert (UBS.Length (Order.Repo.Tracking_Branch) > 0);
-- This should be checked when the repo file is parsed
declare
Expected: constant String
:= "## "
& UBS.To_String (Order.Repo.Tracking_Branch)
& "...origin/"
& UBS.To_String (Order.Repo.Tracking_Branch);
begin
if Output_Buffers.Slice (Source => STDOUT,
Low => 1,
High => Expected'Length)
/= Expected
then
Cache_Bad := True;
end if;
end;
end if;
-- Finally, there should be only one line
if Output_Buffers.Count (Source => STDOUT,
Pattern => String'(1 .. 1 => New_Line))
> 1
then
Cache_Bad := True;
end if;
exception
when Git_Cache_Failure =>
-- Any of the above commands failing simply means the cache
-- is invalid, so we just need to destroy it
Cache_Bad := True;
end;
if not Cache_Bad then
-- done.
Update_Repository (Index => Order.Index,
Updated => Order.Repo);
return;
else
-- Expunge
Ada.Directories.Delete_Tree (Cache_Path);
end if;
else
-- Path points at a non-directory file, that's not ok
Ada.Directories.Delete_File (Cache_Path);
end if;
end if;
-- If we get here, then either the cache didn't exist, or something was
-- wrong with it and it was obliterated
-- Create the cache path
Ada.Directories.Create_Path (Cache_Path);
-- Clone the repo
Git_Command ("clone -n -q -j 0 " -- Quiet and don't checkout anything
& UBS.To_String (Order.Repo.Location) & ' '
& Cache_Path);
-- If the snapshot is set, that takes priority
if UBS.Length (Order.Repo.Snapshot) > 0 then
Git_Command ("checkout --detach "
& UBS.To_String (Order.Repo.Snapshot));
-- If Tracking_Branch is set, and we have no snapshow, check that out
elsif UBS.Length (Order.Repo.Tracking_Branch) > 0 then
Git_Command ("checkout "
& UBS.To_String (Order.Repo.Tracking_Branch));
-- Otherwise, we just use the default branch
else
Git_Command ("checkout "
& UBS.To_String (Order.Repo.Tracking_Branch));
end if;
-- Finally we checkout submodules, if any
Git_Command ("submodule --quiet update "
& "--init --checkout --recursive -j 0");
Update_Repository (Index => Order.Index,
Updated => Order.Repo);
end Execute;
--------------
-- Dispatch --
--------------
procedure Dispatch (Repo: in Repository; Index: in Repository_Index) is
Order: Cache_Git_Order
:= (Tracker => Caching_Progress'Access,
Repo => Repo,
Index => Index);
begin
Workers.Enqueue_Order (Order);
end Dispatch;
end Checkout_Git;
| true | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- Reference Implementation --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * PI:NAME:<NAME>END_PI (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Streams;
with Ada.Assertions;
with Ada.Directories;
with Ada.Strings.Fixed;
with Ada.Strings.Bounded;
with Child_Processes;
with Child_Processes.Path_Searching;
with Child_Processes.Wait_And_Buffer;
separate (Repositories.Cache)
package body Checkout_Git is
Git_Cache_Failure: exception;
package Program_Paths renames Child_Processes.Path_Searching;
Git_Program : aliased constant String := "git";
Git : constant Program_Paths.Elaboration_Path_Search
:= Program_Paths.Initialize (Git_Program);
Git_Timeout : constant Duration := 300.0; -- 5 minutes
Output_Poll_Rate: constant Duration := 0.5;
package Output_Buffers is
new Ada.Strings.Bounded.Generic_Bounded_Length (8096);
procedure Buffer_Append (Buffer: in out Output_Buffers.Bounded_String;
Item : in String)
is begin
-- Since we are using bounded inputs, we'd rather not crash just because
-- the input exceeds the buffers, but rather have it truncate.
Output_Buffers.Append (Source => Buffer,
New_Item => Item,
Drop => Ada.Strings.Right);
end Buffer_Append;
procedure Wait_And_Buffer is new Child_Processes.Wait_And_Buffer
(Buffer_Type => Output_Buffers.Bounded_String,
Append => Buffer_Append,
Empty_Buffer => Output_Buffers.Null_Bounded_String);
--
-- Checkout_Git_Order
--
-- Checkout_Order checks out a git repository when the cache does
-- not exist (or has been invalidated)
type Cache_Git_Order is new Workers.Work_Order with
record
Repo : Repository;
Index: Repository_Index;
end record;
overriding procedure Execute (Order: in out Cache_Git_Order);
overriding function Image (Order: Cache_Git_Order) return String;
-----------
-- Image --
-----------
function Image (Order: Cache_Git_Order) return String
is ( "[Cache_Git_Order]" & New_Line
& " Repoistory No."
& Repository_Index'Image (Order.Index) & New_Line
& " Git : " & UBS.To_String (Order.Repo.Location)
& (if (UBS.Length (Order.Repo.Snapshot) > 0) then
New_Line & " Commit: " & UBS.To_String (Order.Repo.Snapshot)
else
"")
& (if (UBS.Length (Order.Repo.Tracking_Branch) > 0) then
New_Line & " Branch: "
& UBS.To_String (Order.Repo.Tracking_Branch)
else
""));
-------------
-- Execute --
-------------
procedure Execute (Order: in out Cache_Git_Order) is
use Child_Processes;
use type Ada.Directories.File_Kind;
Trimmed_Index: constant String
:= Ada.Strings.Fixed.Trim
(Source => Repository_Index'Image (Order.Index),
Side => Ada.Strings.Both);
Cache_Path: constant String := Cache_Root & '/' & Trimmed_Index;
STDERR: Output_Buffers.Bounded_String;
STDOUT: Output_Buffers.Bounded_String;
procedure Wait_Proc (Title: in String;
Proc : in out Child_Process'Class)
is
type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
Timed_Out: Boolean;
Proc_Exit: Exit_Status := Failure;
begin
-- Wait until finish, if timeout, kill the process. If
-- exit status = Failure then drain Standard_Error. In both cases,
-- raise an exception
Wait_And_Buffer (Process => Proc,
Poll_Rate => Output_Poll_Rate,
Timeout => Git_Timeout,
Output => STDOUT,
Error => STDERR,
Timed_Out => Timed_Out,
Status => Proc_Exit);
if Timed_Out then
-- This should actually be very rare
Proc.Kill;
raise Git_Cache_Failure with Title
& " timed-out"
& " STDOUT: " & Output_Buffers.To_String (STDOUT)
& " STDERR: " & Output_Buffers.To_String (STDERR);
elsif Proc_Exit = Failure then
raise Git_Cache_Failure with Title & " failed: "
& Output_Buffers.To_String (STDERR);
end if;
end Wait_Proc;
procedure Git_Command (Args : in String;
Ignore_Fail: Boolean := False) is
Proc: Child_Process'Class
:= Spawn_Process
(Image_Path => Program_Paths.Image_Path (Git),
Arguments => Args,
Working_Directory => Cache_Path);
begin
Wait_Proc (Title => "git " & Args,
Proc => Proc);
exception
when Git_Cache_Failure =>
if Ignore_Fail then
return;
else
raise;
end if;
end Git_Command;
Cache_Bad: Boolean := False;
begin
UBS.Set_Unbounded_String (Target => Order.Repo.Cache_Path,
Source => Cache_Path);
Order.Repo.Cache_State := Available;
-- These will only be updated in the registry if the checkout is
-- successful
-- Verify that git is actually available
if not Program_Paths.Found (Git) then
raise Program_Error with
"Unable to checkout git repository: Could not find git!";
end if;
-- First step is to see if this repo is already cached, and if it is,
-- that it is on the right commit or branch, and that it has no
-- unstaged/uncommited changes. If that is all good, we're done. If any
-- of that is off, we wipe it and start from scratch (the user should
-- never be messing with a git cache directly)
if Ada.Directories.Exists (Cache_Path) then
if Ada.Directories.Kind (Cache_Path) = Ada.Directories.Directory then
begin
if UBS.Length (Order.Repo.Snapshot) > 0 then
-- If Snapshot is not empty, this means the repo is on a
-- specific commit (regardless of any Tracking_Branch).
Git_Command ("log -1 --pretty=format:%H");
if Output_Buffers.To_String (STDOUT)
/= UBS.To_String (Order.Repo.Snapshot)
then
Cache_Bad := True;
end if;
end if;
-- Check for any pollution. We expect a short status to only
-- have one line, giving either "## HEAD" (Snapshot) or
--"## branch...origin/branch" (Tracking_Branch)
--
-- Any lines following that indicate changes to the cache, which
-- is not acceptable
Git_Command ("status -s -b");
-- If we have a snapshot, we expect a detached head
if UBS.Length (Order.Repo.Snapshot) > 0
-- "## HEAD "
-- ^ ^
-- 1 8
and then Output_Buffers.Slice (Source => STDOUT,
Low => 1,
High => 8)
/= "## HEAD "
then
Cache_Bad := True;
else
-- If we don't have a snapshot, we expect to see the correct
-- branch
pragma Assert (UBS.Length (Order.Repo.Tracking_Branch) > 0);
-- This should be checked when the repo file is parsed
declare
Expected: constant String
:= "## "
& UBS.To_String (Order.Repo.Tracking_Branch)
& "...origin/"
& UBS.To_String (Order.Repo.Tracking_Branch);
begin
if Output_Buffers.Slice (Source => STDOUT,
Low => 1,
High => Expected'Length)
/= Expected
then
Cache_Bad := True;
end if;
end;
end if;
-- Finally, there should be only one line
if Output_Buffers.Count (Source => STDOUT,
Pattern => String'(1 .. 1 => New_Line))
> 1
then
Cache_Bad := True;
end if;
exception
when Git_Cache_Failure =>
-- Any of the above commands failing simply means the cache
-- is invalid, so we just need to destroy it
Cache_Bad := True;
end;
if not Cache_Bad then
-- done.
Update_Repository (Index => Order.Index,
Updated => Order.Repo);
return;
else
-- Expunge
Ada.Directories.Delete_Tree (Cache_Path);
end if;
else
-- Path points at a non-directory file, that's not ok
Ada.Directories.Delete_File (Cache_Path);
end if;
end if;
-- If we get here, then either the cache didn't exist, or something was
-- wrong with it and it was obliterated
-- Create the cache path
Ada.Directories.Create_Path (Cache_Path);
-- Clone the repo
Git_Command ("clone -n -q -j 0 " -- Quiet and don't checkout anything
& UBS.To_String (Order.Repo.Location) & ' '
& Cache_Path);
-- If the snapshot is set, that takes priority
if UBS.Length (Order.Repo.Snapshot) > 0 then
Git_Command ("checkout --detach "
& UBS.To_String (Order.Repo.Snapshot));
-- If Tracking_Branch is set, and we have no snapshow, check that out
elsif UBS.Length (Order.Repo.Tracking_Branch) > 0 then
Git_Command ("checkout "
& UBS.To_String (Order.Repo.Tracking_Branch));
-- Otherwise, we just use the default branch
else
Git_Command ("checkout "
& UBS.To_String (Order.Repo.Tracking_Branch));
end if;
-- Finally we checkout submodules, if any
Git_Command ("submodule --quiet update "
& "--init --checkout --recursive -j 0");
Update_Repository (Index => Order.Index,
Updated => Order.Repo);
end Execute;
--------------
-- Dispatch --
--------------
procedure Dispatch (Repo: in Repository; Index: in Repository_Index) is
Order: Cache_Git_Order
:= (Tracker => Caching_Progress'Access,
Repo => Repo,
Index => Index);
begin
Workers.Enqueue_Order (Order);
end Dispatch;
end Checkout_Git;
|
[
{
"context": "-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>\n-- MIT license. Please refer t",
"end": 36,
"score": 0.9998739361763,
"start": 22,
"tag": "NAME",
"value": "Thierry Rascle"
},
{
"context": "-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>\n-- MIT license. Please refer to the LICENSE file",
"end": 54,
"score": 0.9999342560768127,
"start": 38,
"tag": "EMAIL",
"value": "thierr26@free.fr"
}
] | src/apsepp-test_reporter_class-stub-create.adb | thierr26/ada-apsepp | 0 | -- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
function Apsepp.Test_Reporter_Class.Stub.Create return Test_Reporter_Stub is
begin
return (Test_Reporter_Interfa with null record);
end Apsepp.Test_Reporter_Class.Stub.Create;
| 15555 | -- Copyright (C) 2019 <NAME> <<EMAIL>>
-- MIT license. Please refer to the LICENSE file.
function Apsepp.Test_Reporter_Class.Stub.Create return Test_Reporter_Stub is
begin
return (Test_Reporter_Interfa with null record);
end Apsepp.Test_Reporter_Class.Stub.Create;
| true | -- Copyright (C) 2019 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
-- MIT license. Please refer to the LICENSE file.
function Apsepp.Test_Reporter_Class.Stub.Create return Test_Reporter_Stub is
begin
return (Test_Reporter_Interfa with null record);
end Apsepp.Test_Reporter_Class.Stub.Create;
|
[
{
"context": "t Multimedia Library\n-- // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)\n-- //\n-- // This software",
"end": 162,
"score": 0.9998873472213745,
"start": 148,
"tag": "NAME",
"value": "Laurent Gomila"
},
{
"context": "ary\n-- // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)\n-- //\n-- // This software is provided 'as-is', w",
"end": 185,
"score": 0.999930202960968,
"start": 164,
"tag": "EMAIL",
"value": "laurent.gom@gmail.com"
}
] | include/sf-audio-music.ads | danva994/ASFML-1.6 | 1 | -- ////////////////////////////////////////////////////////////
-- //
-- // SFML - Simple and Fast Multimedia Library
-- // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
-- //
-- // This software is provided 'as-is', without any express or implied
-- // warranty.
-- // In no event will the authors be held liable for any damages arising from
-- // the use of this software.
-- //
-- // Permission is granted to anyone to use this software for any purpose,
-- // including commercial applications, and to alter it and redistribute it
-- // freely,
-- // subject to the following restrictions:
-- //
-- // 1. The origin of this software must not be misrepresented;
-- // you must not claim that you wrote the original software.
-- // If you use this software in a product, an acknowledgment
-- // in the product documentation would be appreciated but is not required.
-- //
-- // 2. Altered source versions must be plainly marked as such,
-- // and must not be misrepresented as being the original software.
-- //
-- // 3. This notice may not be removed or altered from any source
-- // distribution.
-- //
-- ////////////////////////////////////////////////////////////
-- ////////////////////////////////////////////////////////////
-- // Headers
-- ////////////////////////////////////////////////////////////
with Sf.Config;
with Sf.Audio.SoundStatus;
with Sf.Audio.Types;
package Sf.Audio.Music is
use Sf.Config;
use Sf.Audio.SoundStatus;
use Sf.Audio.Types;
-- ////////////////////////////////////////////////////////////
-- /// Create a new music and load it from a file
-- ///
-- /// \param Filename : Path of the music file to open
-- ///
-- /// \return A new sfMusic object (NULL if failed)
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_CreateFromFile (Filename : String) return sfMusic_Ptr;
-- ////////////////////////////////////////////////////////////
-- /// Create a new music and load it from a file in memory
-- ///
-- /// \param Data : Pointer to the file data in memory
-- /// \param SizeInBytes : Size of the data to load, in bytes
-- ///
-- /// \return A new sfMusic object (NULL if failed)
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_CreateFromMemory (Data : sfInt8_Ptr; SizeInBytes : sfSize_t) return sfMusic_Ptr;
-- ////////////////////////////////////////////////////////////
-- /// Destroy an existing music
-- ///
-- /// \param Music : Music to delete
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_Destroy (Music : sfMusic_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Set a music loop state
-- ///
-- /// \param Music : Music to set the loop state
-- /// \param Loop : sfTrue to play in loop, sfFalse to play once
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetLoop (Music : sfMusic_Ptr; Enable : sfBool);
-- ////////////////////////////////////////////////////////////
-- /// Tell whether or not a music is looping
-- ///
-- /// \param Music : Music to get the loop state from
-- ///
-- /// \return sfTrue if the music is looping, sfFalse otherwise
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetLoop (Music : sfMusic_Ptr) return sfBool;
-- ////////////////////////////////////////////////////////////
-- /// Get a music duration
-- ///
-- /// \param Music : Music to get the duration from
-- ///
-- /// \return Music duration, in seconds
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetDuration (Music : sfMusic_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Start playing a music
-- ///
-- /// \param Music : Music to play
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_Play (Music : sfMusic_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Pause a music
-- ///
-- /// \param Music : Music to pause
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_Pause (Music : sfMusic_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Stop playing a music
-- ///
-- /// \param Music : Music to stop
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_Stop (Music : sfMusic_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Return the number of channels of a music (1 = mono, 2 = stereo)
-- ///
-- /// \param Music : Music to get the channels count from
-- ///
-- /// \return Number of channels
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetChannelsCount (Music : sfMusic_Ptr) return sfUint32;
-- ////////////////////////////////////////////////////////////
-- /// Get the stream sample rate of a music
-- ///
-- /// \param Music : Music to get the sample rate from
-- ///
-- /// \return Stream frequency (number of samples per second)
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetSampleRate (Music : sfMusic_Ptr) return sfUint32;
-- ////////////////////////////////////////////////////////////
-- /// Get the status of a music (stopped, paused, playing)
-- ///
-- /// \param Music : Music to get the status from
-- ///
-- /// \return Current status of the sound
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetStatus (Music : sfMusic_Ptr) return sfSoundStatus;
-- ////////////////////////////////////////////////////////////
-- /// Get the current playing position of a music
-- ///
-- /// \param Music : Music to get the position from
-- ///
-- /// \return Current playing position, expressed in seconds
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetPlayingOffset (Music : sfMusic_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Set the pitch of a music
-- ///
-- /// \param Music : Music to modify
-- /// \param Pitch : New pitch
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetPitch (Music : sfMusic_Ptr; Pitch : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the volume of a music
-- ///
-- /// \param Music : Music to modify
-- /// \param Volume : Volume (in range [0, 100])
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetVolume (Music : sfMusic_Ptr; Volume : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the position of a music
-- ///
-- /// \param Music : Music to modify
-- /// \param X : X position of the sound in the world
-- /// \param Y : Y position of the sound in the world
-- /// \param Z : Z position of the sound in the world
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetPosition (Music : sfMusic_Ptr; X, Y, Z : Float);
-- ////////////////////////////////////////////////////////////
-- /// Make the music's position relative to the listener's
-- /// position, or absolute.
-- /// The default value is false (absolute)
-- ///
-- /// \param Music : Music to modify
-- /// \param Relative : True to set the position relative, false to set it absolute
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetRelativeToListener (Music : sfMusic_Ptr; Relative : sfBool);
-- ////////////////////////////////////////////////////////////
-- /// Set the minimum distance - closer than this distance,
-- /// the listener will hear the music at its maximum volume.
-- /// The default minimum distance is 1.0
-- ///
-- /// \param Music : Music to modify
-- /// \param MinDistance : New minimum distance for the music
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetMinDistance (Music : sfMusic_Ptr; MinDistance : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the attenuation factor - the higher the attenuation, the
-- /// more the sound will be attenuated with distance from listener.
-- /// The default attenuation factor 1.0
-- ///
-- /// \param Sound : Sound to modify
-- /// \param Attenuation : New attenuation factor for the sound
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetAttenuation (Music : sfMusic_Ptr; Attenuation : Float);
-- ////////////////////////////////////////////////////////////
-- /// Get the pitch of a music
-- ///
-- /// \param Music : Music to get the pitch from
-- ///
-- /// \return Pitch value
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetPitch (Music : sfMusic_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the volume of a music
-- ///
-- /// \param Music : Music to get the volume from
-- ///
-- /// \return Volume value (in range [1, 100])
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetVolume (Music : sfMusic_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the position of a music
-- ///
-- /// \param Music : Music to get the position from
-- /// \param X : X position of the sound in the world
-- /// \param Y : Y position of the sound in the world
-- /// \param Z : Z position of the sound in the world
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_GetPosition (Music : sfMusic_Ptr; X, Y, Z : access Float);
-- ////////////////////////////////////////////////////////////
-- /// Tell if the music's position is relative to the listener's
-- /// position, or if it's absolute
-- ///
-- /// \param Music : Music to check
-- ///
-- /// \return sfTrue if the position is relative, sfFalse if it's absolute
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_IsRelativeToListener (Music : sfMusic_Ptr) return sfBool;
-- ////////////////////////////////////////////////////////////
-- /// Get the minimum distance of a music
-- ///
-- /// \param Music : Music to get the minimum distance from
-- ///
-- /// \return Minimum distance for the music
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetMinDistance (Music : sfMusic_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the attenuation factor of a music
-- ///
-- /// \param Music : Music to get the attenuation factor from
-- ///
-- /// \return Attenuation factor for the a music
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetAttenuation (Music : sfMusic_Ptr) return Float;
private
pragma Import (C, sfMusic_CreateFromMemory, "sfMusic_CreateFromMemory");
pragma Import (C, sfMusic_Destroy, "sfMusic_Destroy");
pragma Import (C, sfMusic_SetLoop, "sfMusic_SetLoop");
pragma Import (C, sfMusic_GetLoop, "sfMusic_GetLoop");
pragma Import (C, sfMusic_GetDuration, "sfMusic_GetDuration");
pragma Import (C, sfMusic_Play, "sfMusic_Play");
pragma Import (C, sfMusic_Pause, "sfMusic_Pause");
pragma Import (C, sfMusic_Stop, "sfMusic_Stop");
pragma Import (C, sfMusic_GetChannelsCount, "sfMusic_GetChannelsCount");
pragma Import (C, sfMusic_GetSampleRate, "sfMusic_GetSampleRate");
pragma Import (C, sfMusic_GetStatus, "sfMusic_GetStatus");
pragma Import (C, sfMusic_GetPlayingOffset, "sfMusic_GetPlayingOffset");
pragma Import (C, sfMusic_SetPitch, "sfMusic_SetPitch");
pragma Import (C, sfMusic_SetVolume, "sfMusic_SetVolume");
pragma Import (C, sfMusic_SetPosition, "sfMusic_SetPosition");
pragma Import (C, sfMusic_SetRelativeToListener, "sfMusic_SetRelativeToListener");
pragma Import (C, sfMusic_SetMinDistance, "sfMusic_SetMinDistance");
pragma Import (C, sfMusic_SetAttenuation, "sfMusic_SetAttenuation");
pragma Import (C, sfMusic_GetPitch, "sfMusic_GetPitch");
pragma Import (C, sfMusic_GetVolume, "sfMusic_GetVolume");
pragma Import (C, sfMusic_GetPosition, "sfMusic_GetPosition");
pragma Import (C, sfMusic_IsRelativeToListener, "sfMusic_IsRelativeToListener");
pragma Import (C, sfMusic_GetMinDistance, "sfMusic_GetMinDistance");
pragma Import (C, sfMusic_GetAttenuation, "sfMusic_GetAttenuation");
end Sf.Audio.Music;
| 2127 | -- ////////////////////////////////////////////////////////////
-- //
-- // SFML - Simple and Fast Multimedia Library
-- // Copyright (C) 2007-2009 <NAME> (<EMAIL>)
-- //
-- // This software is provided 'as-is', without any express or implied
-- // warranty.
-- // In no event will the authors be held liable for any damages arising from
-- // the use of this software.
-- //
-- // Permission is granted to anyone to use this software for any purpose,
-- // including commercial applications, and to alter it and redistribute it
-- // freely,
-- // subject to the following restrictions:
-- //
-- // 1. The origin of this software must not be misrepresented;
-- // you must not claim that you wrote the original software.
-- // If you use this software in a product, an acknowledgment
-- // in the product documentation would be appreciated but is not required.
-- //
-- // 2. Altered source versions must be plainly marked as such,
-- // and must not be misrepresented as being the original software.
-- //
-- // 3. This notice may not be removed or altered from any source
-- // distribution.
-- //
-- ////////////////////////////////////////////////////////////
-- ////////////////////////////////////////////////////////////
-- // Headers
-- ////////////////////////////////////////////////////////////
with Sf.Config;
with Sf.Audio.SoundStatus;
with Sf.Audio.Types;
package Sf.Audio.Music is
use Sf.Config;
use Sf.Audio.SoundStatus;
use Sf.Audio.Types;
-- ////////////////////////////////////////////////////////////
-- /// Create a new music and load it from a file
-- ///
-- /// \param Filename : Path of the music file to open
-- ///
-- /// \return A new sfMusic object (NULL if failed)
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_CreateFromFile (Filename : String) return sfMusic_Ptr;
-- ////////////////////////////////////////////////////////////
-- /// Create a new music and load it from a file in memory
-- ///
-- /// \param Data : Pointer to the file data in memory
-- /// \param SizeInBytes : Size of the data to load, in bytes
-- ///
-- /// \return A new sfMusic object (NULL if failed)
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_CreateFromMemory (Data : sfInt8_Ptr; SizeInBytes : sfSize_t) return sfMusic_Ptr;
-- ////////////////////////////////////////////////////////////
-- /// Destroy an existing music
-- ///
-- /// \param Music : Music to delete
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_Destroy (Music : sfMusic_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Set a music loop state
-- ///
-- /// \param Music : Music to set the loop state
-- /// \param Loop : sfTrue to play in loop, sfFalse to play once
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetLoop (Music : sfMusic_Ptr; Enable : sfBool);
-- ////////////////////////////////////////////////////////////
-- /// Tell whether or not a music is looping
-- ///
-- /// \param Music : Music to get the loop state from
-- ///
-- /// \return sfTrue if the music is looping, sfFalse otherwise
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetLoop (Music : sfMusic_Ptr) return sfBool;
-- ////////////////////////////////////////////////////////////
-- /// Get a music duration
-- ///
-- /// \param Music : Music to get the duration from
-- ///
-- /// \return Music duration, in seconds
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetDuration (Music : sfMusic_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Start playing a music
-- ///
-- /// \param Music : Music to play
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_Play (Music : sfMusic_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Pause a music
-- ///
-- /// \param Music : Music to pause
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_Pause (Music : sfMusic_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Stop playing a music
-- ///
-- /// \param Music : Music to stop
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_Stop (Music : sfMusic_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Return the number of channels of a music (1 = mono, 2 = stereo)
-- ///
-- /// \param Music : Music to get the channels count from
-- ///
-- /// \return Number of channels
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetChannelsCount (Music : sfMusic_Ptr) return sfUint32;
-- ////////////////////////////////////////////////////////////
-- /// Get the stream sample rate of a music
-- ///
-- /// \param Music : Music to get the sample rate from
-- ///
-- /// \return Stream frequency (number of samples per second)
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetSampleRate (Music : sfMusic_Ptr) return sfUint32;
-- ////////////////////////////////////////////////////////////
-- /// Get the status of a music (stopped, paused, playing)
-- ///
-- /// \param Music : Music to get the status from
-- ///
-- /// \return Current status of the sound
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetStatus (Music : sfMusic_Ptr) return sfSoundStatus;
-- ////////////////////////////////////////////////////////////
-- /// Get the current playing position of a music
-- ///
-- /// \param Music : Music to get the position from
-- ///
-- /// \return Current playing position, expressed in seconds
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetPlayingOffset (Music : sfMusic_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Set the pitch of a music
-- ///
-- /// \param Music : Music to modify
-- /// \param Pitch : New pitch
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetPitch (Music : sfMusic_Ptr; Pitch : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the volume of a music
-- ///
-- /// \param Music : Music to modify
-- /// \param Volume : Volume (in range [0, 100])
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetVolume (Music : sfMusic_Ptr; Volume : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the position of a music
-- ///
-- /// \param Music : Music to modify
-- /// \param X : X position of the sound in the world
-- /// \param Y : Y position of the sound in the world
-- /// \param Z : Z position of the sound in the world
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetPosition (Music : sfMusic_Ptr; X, Y, Z : Float);
-- ////////////////////////////////////////////////////////////
-- /// Make the music's position relative to the listener's
-- /// position, or absolute.
-- /// The default value is false (absolute)
-- ///
-- /// \param Music : Music to modify
-- /// \param Relative : True to set the position relative, false to set it absolute
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetRelativeToListener (Music : sfMusic_Ptr; Relative : sfBool);
-- ////////////////////////////////////////////////////////////
-- /// Set the minimum distance - closer than this distance,
-- /// the listener will hear the music at its maximum volume.
-- /// The default minimum distance is 1.0
-- ///
-- /// \param Music : Music to modify
-- /// \param MinDistance : New minimum distance for the music
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetMinDistance (Music : sfMusic_Ptr; MinDistance : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the attenuation factor - the higher the attenuation, the
-- /// more the sound will be attenuated with distance from listener.
-- /// The default attenuation factor 1.0
-- ///
-- /// \param Sound : Sound to modify
-- /// \param Attenuation : New attenuation factor for the sound
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetAttenuation (Music : sfMusic_Ptr; Attenuation : Float);
-- ////////////////////////////////////////////////////////////
-- /// Get the pitch of a music
-- ///
-- /// \param Music : Music to get the pitch from
-- ///
-- /// \return Pitch value
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetPitch (Music : sfMusic_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the volume of a music
-- ///
-- /// \param Music : Music to get the volume from
-- ///
-- /// \return Volume value (in range [1, 100])
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetVolume (Music : sfMusic_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the position of a music
-- ///
-- /// \param Music : Music to get the position from
-- /// \param X : X position of the sound in the world
-- /// \param Y : Y position of the sound in the world
-- /// \param Z : Z position of the sound in the world
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_GetPosition (Music : sfMusic_Ptr; X, Y, Z : access Float);
-- ////////////////////////////////////////////////////////////
-- /// Tell if the music's position is relative to the listener's
-- /// position, or if it's absolute
-- ///
-- /// \param Music : Music to check
-- ///
-- /// \return sfTrue if the position is relative, sfFalse if it's absolute
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_IsRelativeToListener (Music : sfMusic_Ptr) return sfBool;
-- ////////////////////////////////////////////////////////////
-- /// Get the minimum distance of a music
-- ///
-- /// \param Music : Music to get the minimum distance from
-- ///
-- /// \return Minimum distance for the music
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetMinDistance (Music : sfMusic_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the attenuation factor of a music
-- ///
-- /// \param Music : Music to get the attenuation factor from
-- ///
-- /// \return Attenuation factor for the a music
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetAttenuation (Music : sfMusic_Ptr) return Float;
private
pragma Import (C, sfMusic_CreateFromMemory, "sfMusic_CreateFromMemory");
pragma Import (C, sfMusic_Destroy, "sfMusic_Destroy");
pragma Import (C, sfMusic_SetLoop, "sfMusic_SetLoop");
pragma Import (C, sfMusic_GetLoop, "sfMusic_GetLoop");
pragma Import (C, sfMusic_GetDuration, "sfMusic_GetDuration");
pragma Import (C, sfMusic_Play, "sfMusic_Play");
pragma Import (C, sfMusic_Pause, "sfMusic_Pause");
pragma Import (C, sfMusic_Stop, "sfMusic_Stop");
pragma Import (C, sfMusic_GetChannelsCount, "sfMusic_GetChannelsCount");
pragma Import (C, sfMusic_GetSampleRate, "sfMusic_GetSampleRate");
pragma Import (C, sfMusic_GetStatus, "sfMusic_GetStatus");
pragma Import (C, sfMusic_GetPlayingOffset, "sfMusic_GetPlayingOffset");
pragma Import (C, sfMusic_SetPitch, "sfMusic_SetPitch");
pragma Import (C, sfMusic_SetVolume, "sfMusic_SetVolume");
pragma Import (C, sfMusic_SetPosition, "sfMusic_SetPosition");
pragma Import (C, sfMusic_SetRelativeToListener, "sfMusic_SetRelativeToListener");
pragma Import (C, sfMusic_SetMinDistance, "sfMusic_SetMinDistance");
pragma Import (C, sfMusic_SetAttenuation, "sfMusic_SetAttenuation");
pragma Import (C, sfMusic_GetPitch, "sfMusic_GetPitch");
pragma Import (C, sfMusic_GetVolume, "sfMusic_GetVolume");
pragma Import (C, sfMusic_GetPosition, "sfMusic_GetPosition");
pragma Import (C, sfMusic_IsRelativeToListener, "sfMusic_IsRelativeToListener");
pragma Import (C, sfMusic_GetMinDistance, "sfMusic_GetMinDistance");
pragma Import (C, sfMusic_GetAttenuation, "sfMusic_GetAttenuation");
end Sf.Audio.Music;
| true | -- ////////////////////////////////////////////////////////////
-- //
-- // SFML - Simple and Fast Multimedia Library
-- // Copyright (C) 2007-2009 PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
-- //
-- // This software is provided 'as-is', without any express or implied
-- // warranty.
-- // In no event will the authors be held liable for any damages arising from
-- // the use of this software.
-- //
-- // Permission is granted to anyone to use this software for any purpose,
-- // including commercial applications, and to alter it and redistribute it
-- // freely,
-- // subject to the following restrictions:
-- //
-- // 1. The origin of this software must not be misrepresented;
-- // you must not claim that you wrote the original software.
-- // If you use this software in a product, an acknowledgment
-- // in the product documentation would be appreciated but is not required.
-- //
-- // 2. Altered source versions must be plainly marked as such,
-- // and must not be misrepresented as being the original software.
-- //
-- // 3. This notice may not be removed or altered from any source
-- // distribution.
-- //
-- ////////////////////////////////////////////////////////////
-- ////////////////////////////////////////////////////////////
-- // Headers
-- ////////////////////////////////////////////////////////////
with Sf.Config;
with Sf.Audio.SoundStatus;
with Sf.Audio.Types;
package Sf.Audio.Music is
use Sf.Config;
use Sf.Audio.SoundStatus;
use Sf.Audio.Types;
-- ////////////////////////////////////////////////////////////
-- /// Create a new music and load it from a file
-- ///
-- /// \param Filename : Path of the music file to open
-- ///
-- /// \return A new sfMusic object (NULL if failed)
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_CreateFromFile (Filename : String) return sfMusic_Ptr;
-- ////////////////////////////////////////////////////////////
-- /// Create a new music and load it from a file in memory
-- ///
-- /// \param Data : Pointer to the file data in memory
-- /// \param SizeInBytes : Size of the data to load, in bytes
-- ///
-- /// \return A new sfMusic object (NULL if failed)
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_CreateFromMemory (Data : sfInt8_Ptr; SizeInBytes : sfSize_t) return sfMusic_Ptr;
-- ////////////////////////////////////////////////////////////
-- /// Destroy an existing music
-- ///
-- /// \param Music : Music to delete
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_Destroy (Music : sfMusic_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Set a music loop state
-- ///
-- /// \param Music : Music to set the loop state
-- /// \param Loop : sfTrue to play in loop, sfFalse to play once
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetLoop (Music : sfMusic_Ptr; Enable : sfBool);
-- ////////////////////////////////////////////////////////////
-- /// Tell whether or not a music is looping
-- ///
-- /// \param Music : Music to get the loop state from
-- ///
-- /// \return sfTrue if the music is looping, sfFalse otherwise
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetLoop (Music : sfMusic_Ptr) return sfBool;
-- ////////////////////////////////////////////////////////////
-- /// Get a music duration
-- ///
-- /// \param Music : Music to get the duration from
-- ///
-- /// \return Music duration, in seconds
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetDuration (Music : sfMusic_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Start playing a music
-- ///
-- /// \param Music : Music to play
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_Play (Music : sfMusic_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Pause a music
-- ///
-- /// \param Music : Music to pause
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_Pause (Music : sfMusic_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Stop playing a music
-- ///
-- /// \param Music : Music to stop
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_Stop (Music : sfMusic_Ptr);
-- ////////////////////////////////////////////////////////////
-- /// Return the number of channels of a music (1 = mono, 2 = stereo)
-- ///
-- /// \param Music : Music to get the channels count from
-- ///
-- /// \return Number of channels
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetChannelsCount (Music : sfMusic_Ptr) return sfUint32;
-- ////////////////////////////////////////////////////////////
-- /// Get the stream sample rate of a music
-- ///
-- /// \param Music : Music to get the sample rate from
-- ///
-- /// \return Stream frequency (number of samples per second)
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetSampleRate (Music : sfMusic_Ptr) return sfUint32;
-- ////////////////////////////////////////////////////////////
-- /// Get the status of a music (stopped, paused, playing)
-- ///
-- /// \param Music : Music to get the status from
-- ///
-- /// \return Current status of the sound
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetStatus (Music : sfMusic_Ptr) return sfSoundStatus;
-- ////////////////////////////////////////////////////////////
-- /// Get the current playing position of a music
-- ///
-- /// \param Music : Music to get the position from
-- ///
-- /// \return Current playing position, expressed in seconds
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetPlayingOffset (Music : sfMusic_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Set the pitch of a music
-- ///
-- /// \param Music : Music to modify
-- /// \param Pitch : New pitch
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetPitch (Music : sfMusic_Ptr; Pitch : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the volume of a music
-- ///
-- /// \param Music : Music to modify
-- /// \param Volume : Volume (in range [0, 100])
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetVolume (Music : sfMusic_Ptr; Volume : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the position of a music
-- ///
-- /// \param Music : Music to modify
-- /// \param X : X position of the sound in the world
-- /// \param Y : Y position of the sound in the world
-- /// \param Z : Z position of the sound in the world
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetPosition (Music : sfMusic_Ptr; X, Y, Z : Float);
-- ////////////////////////////////////////////////////////////
-- /// Make the music's position relative to the listener's
-- /// position, or absolute.
-- /// The default value is false (absolute)
-- ///
-- /// \param Music : Music to modify
-- /// \param Relative : True to set the position relative, false to set it absolute
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetRelativeToListener (Music : sfMusic_Ptr; Relative : sfBool);
-- ////////////////////////////////////////////////////////////
-- /// Set the minimum distance - closer than this distance,
-- /// the listener will hear the music at its maximum volume.
-- /// The default minimum distance is 1.0
-- ///
-- /// \param Music : Music to modify
-- /// \param MinDistance : New minimum distance for the music
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetMinDistance (Music : sfMusic_Ptr; MinDistance : Float);
-- ////////////////////////////////////////////////////////////
-- /// Set the attenuation factor - the higher the attenuation, the
-- /// more the sound will be attenuated with distance from listener.
-- /// The default attenuation factor 1.0
-- ///
-- /// \param Sound : Sound to modify
-- /// \param Attenuation : New attenuation factor for the sound
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_SetAttenuation (Music : sfMusic_Ptr; Attenuation : Float);
-- ////////////////////////////////////////////////////////////
-- /// Get the pitch of a music
-- ///
-- /// \param Music : Music to get the pitch from
-- ///
-- /// \return Pitch value
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetPitch (Music : sfMusic_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the volume of a music
-- ///
-- /// \param Music : Music to get the volume from
-- ///
-- /// \return Volume value (in range [1, 100])
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetVolume (Music : sfMusic_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the position of a music
-- ///
-- /// \param Music : Music to get the position from
-- /// \param X : X position of the sound in the world
-- /// \param Y : Y position of the sound in the world
-- /// \param Z : Z position of the sound in the world
-- ///
-- ////////////////////////////////////////////////////////////
procedure sfMusic_GetPosition (Music : sfMusic_Ptr; X, Y, Z : access Float);
-- ////////////////////////////////////////////////////////////
-- /// Tell if the music's position is relative to the listener's
-- /// position, or if it's absolute
-- ///
-- /// \param Music : Music to check
-- ///
-- /// \return sfTrue if the position is relative, sfFalse if it's absolute
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_IsRelativeToListener (Music : sfMusic_Ptr) return sfBool;
-- ////////////////////////////////////////////////////////////
-- /// Get the minimum distance of a music
-- ///
-- /// \param Music : Music to get the minimum distance from
-- ///
-- /// \return Minimum distance for the music
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetMinDistance (Music : sfMusic_Ptr) return Float;
-- ////////////////////////////////////////////////////////////
-- /// Get the attenuation factor of a music
-- ///
-- /// \param Music : Music to get the attenuation factor from
-- ///
-- /// \return Attenuation factor for the a music
-- ///
-- ////////////////////////////////////////////////////////////
function sfMusic_GetAttenuation (Music : sfMusic_Ptr) return Float;
private
pragma Import (C, sfMusic_CreateFromMemory, "sfMusic_CreateFromMemory");
pragma Import (C, sfMusic_Destroy, "sfMusic_Destroy");
pragma Import (C, sfMusic_SetLoop, "sfMusic_SetLoop");
pragma Import (C, sfMusic_GetLoop, "sfMusic_GetLoop");
pragma Import (C, sfMusic_GetDuration, "sfMusic_GetDuration");
pragma Import (C, sfMusic_Play, "sfMusic_Play");
pragma Import (C, sfMusic_Pause, "sfMusic_Pause");
pragma Import (C, sfMusic_Stop, "sfMusic_Stop");
pragma Import (C, sfMusic_GetChannelsCount, "sfMusic_GetChannelsCount");
pragma Import (C, sfMusic_GetSampleRate, "sfMusic_GetSampleRate");
pragma Import (C, sfMusic_GetStatus, "sfMusic_GetStatus");
pragma Import (C, sfMusic_GetPlayingOffset, "sfMusic_GetPlayingOffset");
pragma Import (C, sfMusic_SetPitch, "sfMusic_SetPitch");
pragma Import (C, sfMusic_SetVolume, "sfMusic_SetVolume");
pragma Import (C, sfMusic_SetPosition, "sfMusic_SetPosition");
pragma Import (C, sfMusic_SetRelativeToListener, "sfMusic_SetRelativeToListener");
pragma Import (C, sfMusic_SetMinDistance, "sfMusic_SetMinDistance");
pragma Import (C, sfMusic_SetAttenuation, "sfMusic_SetAttenuation");
pragma Import (C, sfMusic_GetPitch, "sfMusic_GetPitch");
pragma Import (C, sfMusic_GetVolume, "sfMusic_GetVolume");
pragma Import (C, sfMusic_GetPosition, "sfMusic_GetPosition");
pragma Import (C, sfMusic_IsRelativeToListener, "sfMusic_IsRelativeToListener");
pragma Import (C, sfMusic_GetMinDistance, "sfMusic_GetMinDistance");
pragma Import (C, sfMusic_GetAttenuation, "sfMusic_GetAttenuation");
end Sf.Audio.Music;
|
[
{
"context": "--\n -- Jan & Uwe R. Zimmer, Australia, July 2011\n --\n\nwith G",
"end": 10,
"score": 0.9998701810836792,
"start": 7,
"tag": "NAME",
"value": "Jan"
},
{
"context": "--\n -- Jan & Uwe R. Zimmer, Australia, July 2011\n --\n\nwith GLOBE_3D;\n\npackag",
"end": 26,
"score": 0.9998627305030823,
"start": 13,
"tag": "NAME",
"value": "Uwe R. Zimmer"
}
] | Sources/Model/arrow_p.ads | ForYouEyesOnly/Space-Convoy | 1 | --
-- Jan & Uwe R. Zimmer, Australia, July 2011
--
with GLOBE_3D;
package Arrow_P is
procedure Create (object : in out GLOBE_3D.p_Object_3D;
object_scale : GLOBE_3D.Real;
centre : GLOBE_3D.Point_3D);
end Arrow_P;
| 25371 | --
-- <NAME> & <NAME>, Australia, July 2011
--
with GLOBE_3D;
package Arrow_P is
procedure Create (object : in out GLOBE_3D.p_Object_3D;
object_scale : GLOBE_3D.Real;
centre : GLOBE_3D.Point_3D);
end Arrow_P;
| true | --
-- PI:NAME:<NAME>END_PI & PI:NAME:<NAME>END_PI, Australia, July 2011
--
with GLOBE_3D;
package Arrow_P is
procedure Create (object : in out GLOBE_3D.p_Object_3D;
object_scale : GLOBE_3D.Real;
centre : GLOBE_3D.Point_3D);
end Arrow_P;
|
[
{
"context": "--\n-- Copyright (c) 2015, John Leimon <jleimon@gmail.com>\n--\n-- Permission to use, cop",
"end": 38,
"score": 0.9998214840888977,
"start": 27,
"tag": "NAME",
"value": "John Leimon"
},
{
"context": "--\n-- Copyright (c) 2015, John Leimon <jleimon@gmail.com>\n--\n-- Permission to use, copy, modify, and/or d",
"end": 57,
"score": 0.9999250769615173,
"start": 40,
"tag": "EMAIL",
"value": "jleimon@gmail.com"
}
] | pixy/src/host/pantilt_in_ada/specs/x86_64_linux_gnu_bits_confname_h.ads | GambuzX/Pixy-SIW | 1 | --
-- Copyright (c) 2015, John Leimon <jleimon@gmail.com>
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above copyright
-- notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
-- TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
-- NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
-- CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
-- PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-- ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package x86_64_linux_gnu_bits_confname_h is
end x86_64_linux_gnu_bits_confname_h;
| 13053 | --
-- Copyright (c) 2015, <NAME> <<EMAIL>>
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above copyright
-- notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
-- TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
-- NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
-- CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
-- PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-- ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package x86_64_linux_gnu_bits_confname_h is
end x86_64_linux_gnu_bits_confname_h;
| true | --
-- Copyright (c) 2015, PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above copyright
-- notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
-- TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
-- NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
-- CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
-- PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-- ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package x86_64_linux_gnu_bits_confname_h is
end x86_64_linux_gnu_bits_confname_h;
|
[
{
"context": "-- Copyright (c) 2021 Devin Hill\n-- zlib License -- see LICENSE for details.\n\n\npac",
"end": 32,
"score": 0.9998410940170288,
"start": 22,
"tag": "NAME",
"value": "Devin Hill"
}
] | src/GBA.Numerics.Vectors.adb | 98devin/ada-gba-dev | 7 | -- Copyright (c) 2021 Devin Hill
-- zlib License -- see LICENSE for details.
package body GBA.Numerics.Vectors is
function Pointwise (V, W : Vec) return Vec is
begin
return
( 0 => Operator (V (0), W (0))
, 1 => Operator (V (1), W (1))
);
end;
function Scalar (V : Vec; E : Element) return Vec is
begin
return
( 0 => Operator (V (0), E)
, 1 => Operator (V (1), E)
);
end;
function EMul (X, Y : Element) return Element is
( X * Y ) with Inline_Always;
function EDiv (X, Y : Element) return Element is
( X / Y ) with Inline_Always;
function VAdd is new Pointwise ("+");
function VSub is new Pointwise ("-");
function VMul is new Pointwise (EMul);
function VDiv is new Pointwise (EDiv);
function VAdd is new Scalar ("+");
function VSub is new Scalar ("-");
function VMul is new Scalar (EMul);
function VDiv is new Scalar (EDiv);
function "+" (V, W : Vec) return Vec
renames VAdd;
function "-" (V, W : Vec) return Vec
renames VSub;
function "*" (V, W : Vec) return Vec
renames VMul;
function "/" (V, W : Vec) return Vec
renames VDiv;
function "+" (V : Vec; E : Element) return Vec
renames VAdd;
function "-" (V : Vec; E : Element) return Vec
renames VSub;
function "*" (V : Vec; E : Element) return Vec
renames VMul;
function "/" (V : Vec; E : Element) return Vec
renames VDiv;
function Dot (V, W : Vec) return Element is
begin
return Vec'(V * W)'Reduce ("+", 0.0);
end;
end GBA.Numerics.Vectors; | 6368 | -- Copyright (c) 2021 <NAME>
-- zlib License -- see LICENSE for details.
package body GBA.Numerics.Vectors is
function Pointwise (V, W : Vec) return Vec is
begin
return
( 0 => Operator (V (0), W (0))
, 1 => Operator (V (1), W (1))
);
end;
function Scalar (V : Vec; E : Element) return Vec is
begin
return
( 0 => Operator (V (0), E)
, 1 => Operator (V (1), E)
);
end;
function EMul (X, Y : Element) return Element is
( X * Y ) with Inline_Always;
function EDiv (X, Y : Element) return Element is
( X / Y ) with Inline_Always;
function VAdd is new Pointwise ("+");
function VSub is new Pointwise ("-");
function VMul is new Pointwise (EMul);
function VDiv is new Pointwise (EDiv);
function VAdd is new Scalar ("+");
function VSub is new Scalar ("-");
function VMul is new Scalar (EMul);
function VDiv is new Scalar (EDiv);
function "+" (V, W : Vec) return Vec
renames VAdd;
function "-" (V, W : Vec) return Vec
renames VSub;
function "*" (V, W : Vec) return Vec
renames VMul;
function "/" (V, W : Vec) return Vec
renames VDiv;
function "+" (V : Vec; E : Element) return Vec
renames VAdd;
function "-" (V : Vec; E : Element) return Vec
renames VSub;
function "*" (V : Vec; E : Element) return Vec
renames VMul;
function "/" (V : Vec; E : Element) return Vec
renames VDiv;
function Dot (V, W : Vec) return Element is
begin
return Vec'(V * W)'Reduce ("+", 0.0);
end;
end GBA.Numerics.Vectors; | true | -- Copyright (c) 2021 PI:NAME:<NAME>END_PI
-- zlib License -- see LICENSE for details.
package body GBA.Numerics.Vectors is
function Pointwise (V, W : Vec) return Vec is
begin
return
( 0 => Operator (V (0), W (0))
, 1 => Operator (V (1), W (1))
);
end;
function Scalar (V : Vec; E : Element) return Vec is
begin
return
( 0 => Operator (V (0), E)
, 1 => Operator (V (1), E)
);
end;
function EMul (X, Y : Element) return Element is
( X * Y ) with Inline_Always;
function EDiv (X, Y : Element) return Element is
( X / Y ) with Inline_Always;
function VAdd is new Pointwise ("+");
function VSub is new Pointwise ("-");
function VMul is new Pointwise (EMul);
function VDiv is new Pointwise (EDiv);
function VAdd is new Scalar ("+");
function VSub is new Scalar ("-");
function VMul is new Scalar (EMul);
function VDiv is new Scalar (EDiv);
function "+" (V, W : Vec) return Vec
renames VAdd;
function "-" (V, W : Vec) return Vec
renames VSub;
function "*" (V, W : Vec) return Vec
renames VMul;
function "/" (V, W : Vec) return Vec
renames VDiv;
function "+" (V : Vec; E : Element) return Vec
renames VAdd;
function "-" (V : Vec; E : Element) return Vec
renames VSub;
function "*" (V : Vec; E : Element) return Vec
renames VMul;
function "/" (V : Vec; E : Element) return Vec
renames VDiv;
function Dot (V, W : Vec) return Element is
begin
return Vec'(V * W)'Reduce ("+", 0.0);
end;
end GBA.Numerics.Vectors; |
[
{
"context": "A554#;\n -- FLASH_Periph.FCTL2 := (FWKEY => 16#A5#, FSSEL => Fssel_1, FN => 20);\n end Init;\n\nb",
"end": 3794,
"score": 0.5604448914527893,
"start": 3793,
"tag": "KEY",
"value": "6"
},
{
"context": "4#;\n -- FLASH_Periph.FCTL2 := (FWKEY => 16#A5#, FSSEL => Fssel_1, FN => 20);\n end Init;\n\nbegi",
"end": 3797,
"score": 0.6135167479515076,
"start": 3796,
"tag": "KEY",
"value": "5"
}
] | apps/bootloader/main_direct.adb | ekoeppen/MSP430_Generic_Ada_Drivers | 0 | with System.Machine_Code; use System.Machine_Code;
with System.Storage_Elements; use System.Storage_Elements;
with System.Address_To_Access_Conversions;
with System; use System;
with Interfaces; use Interfaces;
with MSPGD.Board; use MSPGD.Board;
with MSP430_SVD; use MSP430_SVD;
with MSP430_SVD.FLASH; use MSP430_SVD.FLASH;
with MSP430_SVD.SYSTEM_CLOCK; use MSP430_SVD.SYSTEM_CLOCK;
procedure Main is
pragma Preelaborate;
Flash_Start : Unsigned_16
with Import, External_Name => "__flash_start";
Flash_Segment_Size : constant Unsigned_16 := 512;
type Flash_Memory_Type is array (Unsigned_16 range 0 .. 65535) of Unsigned_8;
type Flash_Memory_Pointer is access all Flash_Memory_Type;
package Convert is new System.Address_To_Access_Conversions (Flash_Memory_Type);
Flash_Memory : constant Convert.Object_Pointer := Convert.To_Pointer (System'To_Address (0));
Line : array (Unsigned_16 range 0 .. 47) of Unsigned_8;
Write_Addr : Unsigned_16;
Count : Unsigned_8;
XON : constant Byte := 17;
XOFF : constant Byte := 19;
FCTL1 : Unsigned_16 with Import, Address => System'To_Address (16#0128#);
FCTL2 : Unsigned_16 with Import, Address => System'To_Address (16#012A#);
FCTL3 : Unsigned_16 with Import, Address => System'To_Address (16#012C#);
function Nibble (N : Unsigned_8) return Unsigned_8 is
begin
return (if N >= 65 then N - 65 + 10 else N - 48);
end Nibble;
function From_Hex (I : Unsigned_16) return Unsigned_8 is
begin
return 16 * Nibble (Line (I)) + Nibble (Line (I + 1));
end From_Hex;
procedure Erase_Flash is
Addr : Unsigned_16 := Flash_Start;
R_Low : Unsigned_8 := Flash_Memory (65534);
R_High : Unsigned_8 := Flash_Memory (65535);
begin
FCTL3 := 16#A500#;
FCTL1 := 16#A502#;
Flash_Memory (65534) := 0;
while Addr <= 65535 loop
if Addr /= 16#FA00# then Flash_Memory (Addr) := 0; end if;
Addr := Addr + Flash_Segment_Size;
end loop;
Flash_Memory (65534) := R_Low;
Flash_Memory (65535) := R_High;
FCTL1 := 16#A500#;
FCTL3 := 16#A510#;
end Erase_Flash;
procedure Write_Flash is
begin
FCTL3 := 16#A500#;
FCTL1 := 16#A540#;
for I in Unsigned_8 range 0 .. Count loop
Flash_Memory (Write_Addr) := From_Hex (Unsigned_16 (I) * 2);
Write_Addr := Write_Addr + Unsigned_16 (1);
end loop;
FCTL1 := 16#A500#;
FCTL3 := 16#A510#;
end Write_Flash;
procedure Reset is
begin
UART.Transmit (XON);
FCTL1 := 16#0000#;
end Reset;
procedure Read_Line is
Record_Type : Unsigned_8;
begin
UART.Transmit (XON);
for I in Line'Range loop
Line (I) := Unsigned_8 (UART.Receive);
exit when Line (I) = 10;
end loop;
UART.Transmit (XOFF);
Count := From_Hex (1);
Write_Addr := (Unsigned_16 (From_Hex (3)) * 256 + Unsigned_16 (From_Hex (5)));
Record_Type := From_Hex (7);
case Record_Type is
when 16#00# => Write_Flash;
when 16#01# => Reset;
when 16#80# => Erase_Flash;
when others => null;
end case;
end Read_Line;
procedure Init is
CALDCO_8MHz : DCOCTL_Register with Import, Address => System'To_Address (16#10FC#);
CALBC1_8MHz : BCSCTL1_Register with Import, Address => System'To_Address (16#10FD#);
begin
BUTTON.Init;
if BUTTON.Is_Set then
null;
end if;
-- SYSTEM_CLOCK_Periph.DCOCTL.MOD_k.Val := 0;
-- SYSTEM_CLOCK_Periph.DCOCTL.DCO.Val := 0;
SYSTEM_CLOCK_Periph.BCSCTL1 := CALBC1_8MHz;
SYSTEM_CLOCK_Periph.DCOCTL := CALDCO_8MHz;
RX.Init;
TX.Init;
UART.Init;
FCTL2 := 16#A554#;
-- FLASH_Periph.FCTL2 := (FWKEY => 16#A5#, FSSEL => Fssel_1, FN => 20);
end Init;
begin
Init;
loop
Read_Line;
end loop;
end Main;
| 11231 | with System.Machine_Code; use System.Machine_Code;
with System.Storage_Elements; use System.Storage_Elements;
with System.Address_To_Access_Conversions;
with System; use System;
with Interfaces; use Interfaces;
with MSPGD.Board; use MSPGD.Board;
with MSP430_SVD; use MSP430_SVD;
with MSP430_SVD.FLASH; use MSP430_SVD.FLASH;
with MSP430_SVD.SYSTEM_CLOCK; use MSP430_SVD.SYSTEM_CLOCK;
procedure Main is
pragma Preelaborate;
Flash_Start : Unsigned_16
with Import, External_Name => "__flash_start";
Flash_Segment_Size : constant Unsigned_16 := 512;
type Flash_Memory_Type is array (Unsigned_16 range 0 .. 65535) of Unsigned_8;
type Flash_Memory_Pointer is access all Flash_Memory_Type;
package Convert is new System.Address_To_Access_Conversions (Flash_Memory_Type);
Flash_Memory : constant Convert.Object_Pointer := Convert.To_Pointer (System'To_Address (0));
Line : array (Unsigned_16 range 0 .. 47) of Unsigned_8;
Write_Addr : Unsigned_16;
Count : Unsigned_8;
XON : constant Byte := 17;
XOFF : constant Byte := 19;
FCTL1 : Unsigned_16 with Import, Address => System'To_Address (16#0128#);
FCTL2 : Unsigned_16 with Import, Address => System'To_Address (16#012A#);
FCTL3 : Unsigned_16 with Import, Address => System'To_Address (16#012C#);
function Nibble (N : Unsigned_8) return Unsigned_8 is
begin
return (if N >= 65 then N - 65 + 10 else N - 48);
end Nibble;
function From_Hex (I : Unsigned_16) return Unsigned_8 is
begin
return 16 * Nibble (Line (I)) + Nibble (Line (I + 1));
end From_Hex;
procedure Erase_Flash is
Addr : Unsigned_16 := Flash_Start;
R_Low : Unsigned_8 := Flash_Memory (65534);
R_High : Unsigned_8 := Flash_Memory (65535);
begin
FCTL3 := 16#A500#;
FCTL1 := 16#A502#;
Flash_Memory (65534) := 0;
while Addr <= 65535 loop
if Addr /= 16#FA00# then Flash_Memory (Addr) := 0; end if;
Addr := Addr + Flash_Segment_Size;
end loop;
Flash_Memory (65534) := R_Low;
Flash_Memory (65535) := R_High;
FCTL1 := 16#A500#;
FCTL3 := 16#A510#;
end Erase_Flash;
procedure Write_Flash is
begin
FCTL3 := 16#A500#;
FCTL1 := 16#A540#;
for I in Unsigned_8 range 0 .. Count loop
Flash_Memory (Write_Addr) := From_Hex (Unsigned_16 (I) * 2);
Write_Addr := Write_Addr + Unsigned_16 (1);
end loop;
FCTL1 := 16#A500#;
FCTL3 := 16#A510#;
end Write_Flash;
procedure Reset is
begin
UART.Transmit (XON);
FCTL1 := 16#0000#;
end Reset;
procedure Read_Line is
Record_Type : Unsigned_8;
begin
UART.Transmit (XON);
for I in Line'Range loop
Line (I) := Unsigned_8 (UART.Receive);
exit when Line (I) = 10;
end loop;
UART.Transmit (XOFF);
Count := From_Hex (1);
Write_Addr := (Unsigned_16 (From_Hex (3)) * 256 + Unsigned_16 (From_Hex (5)));
Record_Type := From_Hex (7);
case Record_Type is
when 16#00# => Write_Flash;
when 16#01# => Reset;
when 16#80# => Erase_Flash;
when others => null;
end case;
end Read_Line;
procedure Init is
CALDCO_8MHz : DCOCTL_Register with Import, Address => System'To_Address (16#10FC#);
CALBC1_8MHz : BCSCTL1_Register with Import, Address => System'To_Address (16#10FD#);
begin
BUTTON.Init;
if BUTTON.Is_Set then
null;
end if;
-- SYSTEM_CLOCK_Periph.DCOCTL.MOD_k.Val := 0;
-- SYSTEM_CLOCK_Periph.DCOCTL.DCO.Val := 0;
SYSTEM_CLOCK_Periph.BCSCTL1 := CALBC1_8MHz;
SYSTEM_CLOCK_Periph.DCOCTL := CALDCO_8MHz;
RX.Init;
TX.Init;
UART.Init;
FCTL2 := 16#A554#;
-- FLASH_Periph.FCTL2 := (FWKEY => 1<KEY>#A<KEY>#, FSSEL => Fssel_1, FN => 20);
end Init;
begin
Init;
loop
Read_Line;
end loop;
end Main;
| true | with System.Machine_Code; use System.Machine_Code;
with System.Storage_Elements; use System.Storage_Elements;
with System.Address_To_Access_Conversions;
with System; use System;
with Interfaces; use Interfaces;
with MSPGD.Board; use MSPGD.Board;
with MSP430_SVD; use MSP430_SVD;
with MSP430_SVD.FLASH; use MSP430_SVD.FLASH;
with MSP430_SVD.SYSTEM_CLOCK; use MSP430_SVD.SYSTEM_CLOCK;
procedure Main is
pragma Preelaborate;
Flash_Start : Unsigned_16
with Import, External_Name => "__flash_start";
Flash_Segment_Size : constant Unsigned_16 := 512;
type Flash_Memory_Type is array (Unsigned_16 range 0 .. 65535) of Unsigned_8;
type Flash_Memory_Pointer is access all Flash_Memory_Type;
package Convert is new System.Address_To_Access_Conversions (Flash_Memory_Type);
Flash_Memory : constant Convert.Object_Pointer := Convert.To_Pointer (System'To_Address (0));
Line : array (Unsigned_16 range 0 .. 47) of Unsigned_8;
Write_Addr : Unsigned_16;
Count : Unsigned_8;
XON : constant Byte := 17;
XOFF : constant Byte := 19;
FCTL1 : Unsigned_16 with Import, Address => System'To_Address (16#0128#);
FCTL2 : Unsigned_16 with Import, Address => System'To_Address (16#012A#);
FCTL3 : Unsigned_16 with Import, Address => System'To_Address (16#012C#);
function Nibble (N : Unsigned_8) return Unsigned_8 is
begin
return (if N >= 65 then N - 65 + 10 else N - 48);
end Nibble;
function From_Hex (I : Unsigned_16) return Unsigned_8 is
begin
return 16 * Nibble (Line (I)) + Nibble (Line (I + 1));
end From_Hex;
procedure Erase_Flash is
Addr : Unsigned_16 := Flash_Start;
R_Low : Unsigned_8 := Flash_Memory (65534);
R_High : Unsigned_8 := Flash_Memory (65535);
begin
FCTL3 := 16#A500#;
FCTL1 := 16#A502#;
Flash_Memory (65534) := 0;
while Addr <= 65535 loop
if Addr /= 16#FA00# then Flash_Memory (Addr) := 0; end if;
Addr := Addr + Flash_Segment_Size;
end loop;
Flash_Memory (65534) := R_Low;
Flash_Memory (65535) := R_High;
FCTL1 := 16#A500#;
FCTL3 := 16#A510#;
end Erase_Flash;
procedure Write_Flash is
begin
FCTL3 := 16#A500#;
FCTL1 := 16#A540#;
for I in Unsigned_8 range 0 .. Count loop
Flash_Memory (Write_Addr) := From_Hex (Unsigned_16 (I) * 2);
Write_Addr := Write_Addr + Unsigned_16 (1);
end loop;
FCTL1 := 16#A500#;
FCTL3 := 16#A510#;
end Write_Flash;
procedure Reset is
begin
UART.Transmit (XON);
FCTL1 := 16#0000#;
end Reset;
procedure Read_Line is
Record_Type : Unsigned_8;
begin
UART.Transmit (XON);
for I in Line'Range loop
Line (I) := Unsigned_8 (UART.Receive);
exit when Line (I) = 10;
end loop;
UART.Transmit (XOFF);
Count := From_Hex (1);
Write_Addr := (Unsigned_16 (From_Hex (3)) * 256 + Unsigned_16 (From_Hex (5)));
Record_Type := From_Hex (7);
case Record_Type is
when 16#00# => Write_Flash;
when 16#01# => Reset;
when 16#80# => Erase_Flash;
when others => null;
end case;
end Read_Line;
procedure Init is
CALDCO_8MHz : DCOCTL_Register with Import, Address => System'To_Address (16#10FC#);
CALBC1_8MHz : BCSCTL1_Register with Import, Address => System'To_Address (16#10FD#);
begin
BUTTON.Init;
if BUTTON.Is_Set then
null;
end if;
-- SYSTEM_CLOCK_Periph.DCOCTL.MOD_k.Val := 0;
-- SYSTEM_CLOCK_Periph.DCOCTL.DCO.Val := 0;
SYSTEM_CLOCK_Periph.BCSCTL1 := CALBC1_8MHz;
SYSTEM_CLOCK_Periph.DCOCTL := CALDCO_8MHz;
RX.Init;
TX.Init;
UART.Init;
FCTL2 := 16#A554#;
-- FLASH_Periph.FCTL2 := (FWKEY => 1PI:KEY:<KEY>END_PI#API:KEY:<KEY>END_PI#, FSSEL => Fssel_1, FN => 20);
end Init;
begin
Init;
loop
Read_Line;
end loop;
end Main;
|
[
{
"context": " --\n-- Copyright © 2011-2014, Vadim Godunko <vgodunko@gmail.com> --\n-- All rig",
"end": 829,
"score": 0.9998841285705566,
"start": 816,
"tag": "NAME",
"value": "Vadim Godunko"
},
{
"context": " --\n-- Copyright © 2011-2014, Vadim Godunko <vgodunko@gmail.com> --\n-- All rights reserved. ",
"end": 849,
"score": 0.9999324083328247,
"start": 831,
"tag": "EMAIL",
"value": "vgodunko@gmail.com"
}
] | source/sql/oci/matreshka-internals-sql_drivers-oracle-queries.adb | svn2github/matreshka | 24 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- SQL Database Access --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-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.Unchecked_Deallocation;
with League.Calendars.ISO_8601;
with League.Strings.Internals;
with Matreshka.Internals.Utf16;
with Matreshka.Internals.Strings.C;
with Matreshka.Internals.SQL_Drivers.Oracle.Plug_In;
package body Matreshka.Internals.SQL_Drivers.Oracle.Queries is
use type Interfaces.Unsigned_32;
use type Interfaces.Unsigned_16;
use type Interfaces.Integer_8;
use type Sb2;
use type SQL.Parameter_Directions;
use type Plug_In.Control_Side;
use type System.Storage_Elements.Storage_Count;
procedure Free is
new Ada.Unchecked_Deallocation (Bound_Value_Node, Bound_Value_Access);
procedure Free is
new Ada.Unchecked_Deallocation
(Defined_Value_Array, Defined_Value_Array_Access);
procedure Free is
new Ada.Unchecked_Deallocation
(System.Storage_Elements.Storage_Array, Storage_Array_Access);
type Utf16_Code_Unit_Access is
access all Matreshka.Internals.Utf16.Utf16_Code_Unit;
function OCICallbackInBind
(ictxp : Bound_Value_Access;
bindp : Oracle.Bind;
iter : Ub4;
index : Ub4;
bufpp : access Utf16_Code_Unit_Access;
alenp : access Ub4;
piecep : access Ub1;
indp : access Sb2_Ptr)
return Error_Code;
pragma Convention (C, OCICallbackInBind);
function OCICallbackOutBind
(octxp : Bound_Value_Access;
bindp : Oracle.Bind;
iter : Ub4;
index : Ub4;
bufpp : access Utf16_Code_Unit_Access;
alenp : access Ub4_Ptr;
piecep : access Ub1;
indp : access Sb2_Ptr;
rcodepp : access Sb2_Ptr)
return Error_Code;
pragma Convention (C, OCICallbackOutBind);
function "+"
(Left : Matreshka.Internals.Utf16.Utf16_String_Index;
Right : Ub4) return Matreshka.Internals.Utf16.Utf16_String_Index;
UTC_TZ : constant Wide_String := "+00:00";
---------
-- "+" --
---------
function "+"
(Left : Matreshka.Internals.Utf16.Utf16_String_Index;
Right : Ub4) return Matreshka.Internals.Utf16.Utf16_String_Index
is
use type Matreshka.Internals.Utf16.Utf16_String_Index;
begin
return Left + Matreshka.Internals.Utf16.Utf16_String_Index (Right) / 2;
end "+";
----------------
-- Bind_Value --
----------------
overriding procedure Bind_Value
(Self : not null access OCI_Query;
Name : League.Strings.Universal_String;
Value : League.Holders.Holder;
Direction : SQL.Parameter_Directions)
is
Code : Error_Code;
Pos : Parameter_Maps.Cursor;
Ok : Boolean;
procedure Bind
(Name : League.Strings.Universal_String;
Item : in out Bound_Value_Access);
----------
-- Bind --
----------
procedure Bind
(Name : League.Strings.Universal_String;
Item : in out Bound_Value_Access)
is
Length : Ub4;
Plugin : Plug_In_Access := Plug_In_Access (Self.DB.Plugins);
Control : Plug_In.Control_Side := Plug_In.Driver;
Extra_Type : Data_Type;
Extra_Size : System.Storage_Elements.Storage_Count := 0;
begin
while Plugin /= null loop
Plugin.Check_Parameter
(Value,
Control,
Extra_Type,
Extra_Size);
exit when Control = Plug_In.Plug_In;
Plugin := Plugin.Next;
end loop;
if Item /= null and then Item.Length < Extra_Size then
Free (Item);
end if;
if Item = null then
Item := new Bound_Value_Node (Extra_Size);
end if;
Item.Value := Value;
Item.Direction := Direction;
Item.Plugin := Plugin;
Item.Extra_Type := Extra_Type;
Item.Extra_Size := Extra_Size;
if Item.Plugin /= null then
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Extra (1)'Address,
Ub4 (Item.Extra_Size),
Item.Extra_Type,
Item.Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
Free (Item);
return; -- How to report errors?
end if;
Item.Plugin.Encode (Value, Item.Extra (1 .. Item.Extra_Size));
elsif League.Holders.Is_Universal_String (Value) then
Length := 64 * 1024; -- 64kbyte max length of out string param
if Direction = SQL.In_Parameter then
if League.Holders.Is_Empty (Value) then
Length := 2;
else
Length :=
Ub4
(League.Strings.Internals.Internal
(League.Holders.Element (Value)).Unused) * 2 + 2;
end if;
end if;
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Value_Length => Length,
Value_Type => SQLT_STR,
Mode => OCI_DATA_AT_EXEC);
if Databases.Check_Error (Self.DB, Code) then
Free (Item);
return; -- How to report errors?
end if;
Code :=
OCIBindDynamic
(Item.Bind,
Self.DB.Error,
Item.all'Address,
OCICallbackInBind'Address,
Item.all'Address,
OCICallbackOutBind'Address);
Item.String_Size := 0;
elsif League.Holders.Is_Abstract_Integer (Value) then
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Int'Address,
Item.Int'Size / 8,
SQLT_INT,
Item.Is_Null'Access);
if not League.Holders.Is_Empty (Value) then
Item.Int := League.Holders.Element (Value);
end if;
elsif League.Holders.Is_Abstract_Float (Value) then
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Float'Address,
Item.Float'Size / 8,
SQLT_FLT,
Item.Is_Null'Access);
if not League.Holders.Is_Empty (Value) then
Item.Float := League.Holders.Element (Value);
end if;
elsif League.Holders.Is_Date (Value) then
declare
Aux : League.Calendars.Date;
begin
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Date'Address,
Item.Date'Size / 8,
SQLT_ODT,
Item.Is_Null'Access);
if not League.Holders.Is_Empty (Value) then
Aux := League.Holders.Element (Value);
Item.Date := Utils.Encode_Date (Aux);
end if;
end;
elsif League.Holders.Is_Date_Time (Value) then
if Item.Timestamp = null then
Code := OCIDescriptorAlloc
(Databases.Env,
Item.Timestamp'Access,
OCI_DTYPE_TIMESTAMP_TZ);
end if;
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Timestamp'Address,
Item.Timestamp'Size / 8,
SQLT_TIMESTAMP_TZ,
Item.Is_Null'Access);
if not League.Holders.Is_Empty (Value) then
declare
use type Size_T;
Aux : constant League.Calendars.Date_Time :=
League.Holders.Element (Value);
Year : League.Calendars.ISO_8601.Year_Number;
Month : League.Calendars.ISO_8601.Month_Number;
Day : League.Calendars.ISO_8601.Day_Number;
Hour : League.Calendars.ISO_8601.Hour_Number;
Minute : League.Calendars.ISO_8601.Minute_Number;
Second : League.Calendars.ISO_8601.Second_Number;
Fraction : League.Calendars.ISO_8601.Nanosecond_100_Number;
begin
League.Calendars.ISO_8601.Split
(Aux, Year, Month, Day, Hour, Minute, Second, Fraction);
Code := OCIDateTimeConstruct
(Env => Databases.Env,
Error => Self.DB.Error,
Date => Item.Timestamp,
Year => Sb2 (Year),
Month => Ub1 (Month),
Day => Ub1 (Day),
Hour => Ub1 (Hour),
Min => Ub1 (Minute),
Sec => Ub1 (Second),
Fract => Ub4 (Fraction) * 100,
TZ => UTC_TZ (UTC_TZ'First)'Address,
TZ_Len => UTC_TZ'Length * 2);
end;
end if;
elsif League.Holders.Is_Empty (Value) then
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Int'Address,
Item.Int'Size / 8,
SQLT_INT,
Item.Is_Null'Access);
else
Free (Item);
return;
end if;
if Databases.Check_Error (Self.DB, Code) then
Free (Item);
return; -- How to report errors?
end if;
Item.Is_Null := -Boolean'Pos
(League.Holders.Is_Empty (Value) or Direction = SQL.Out_Parameter);
end Bind;
begin
if Self.State = Prepared then
Self.Parameters.Insert (Name, null, Pos, Ok);
Self.Parameters.Update_Element (Pos, Bind'Access);
end if;
end Bind_Value;
-----------------
-- Bound_Value --
-----------------
overriding function Bound_Value
(Self : not null access OCI_Query;
Name : League.Strings.Universal_String)
return League.Holders.Holder
is
Empty : League.Holders.Holder;
Pos : constant Parameter_Maps.Cursor := Self.Parameters.Find (Name);
Item : Bound_Value_Access;
begin
if Parameter_Maps.Has_Element (Pos) then
Item := Parameter_Maps.Element (Pos);
end if;
if Item = null then
return Empty;
else
return Item.Value;
end if;
end Bound_Value;
-------------------
-- Error_Message --
-------------------
overriding function Error_Message
(Self : not null access OCI_Query)
return League.Strings.Universal_String is
begin
return Self.DB.Error_Message;
end Error_Message;
-------------
-- Execute --
-------------
overriding function Execute
(Self : not null access OCI_Query) return Boolean
is
procedure Fixup_Parameter (Position : Parameter_Maps.Cursor);
---------------------
-- Fixup_Parameter --
---------------------
procedure Fixup_Parameter (Position : Parameter_Maps.Cursor) is
use type Matreshka.Internals.Strings.Shared_String_Access;
Ok : Boolean;
Item : constant Bound_Value_Access :=
Parameter_Maps.Element (Position);
begin
if Item = null or else Item.Direction = SQL.In_Parameter then
return;
elsif Item.String /= null then
Item.String.Unused := Item.String.Unused + Item.String_Size;
Matreshka.Internals.Strings.C.Validate_And_Fixup
(Item.String, Item.String.Unused, Ok);
League.Holders.Replace_Element
(Item.Value,
League.Strings.Internals.Wrap (Item.String));
Item.String := null;
Item.String_Size := 0;
if Item.Is_Null = -1 then
League.Holders.Clear (Item.Value);
end if;
elsif League.Holders.Is_Abstract_Integer (Item.Value) then
if Item.Is_Null = 0 then
League.Holders.Replace_Element (Item.Value, Item.Int);
else
League.Holders.Clear (Item.Value);
end if;
elsif League.Holders.Is_Abstract_Float (Item.Value) then
if Item.Is_Null = 0 then
League.Holders.Replace_Element (Item.Value, Item.Float);
else
League.Holders.Clear (Item.Value);
end if;
elsif Item.Is_Null /= 0 then
League.Holders.Clear (Item.Value);
end if;
end Fixup_Parameter;
Count : aliased Ub4;
Code : Error_Code;
begin -- Execute
if Self.State not in Ready then
return False;
end if;
Code :=
OCIStmtExecute
(Self.DB.Service,
Self.Handle,
Self.DB.Error,
Iters => Boolean'Pos (not Self.Is_Select));
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Self.Parameters.Iterate (Fixup_Parameter'Access);
if Self.Is_Select and not Self.Is_Described then
Self.Is_Described := True;
Self.Column_Count := 0;
Code :=
OCIAttrGet
(Target => Self.Handle,
Target_Type => OCI_HTYPE_STMT,
Buffer => Count'Address,
Length => null,
Attr => OCI_ATTR_PARAM_COUNT,
Error => Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
if Self.Columns /= null and then Self.Columns'Length < Count then
Free (Self.Columns);
end if;
if Self.Columns = null and Count > 0 then
Self.Columns := new Defined_Value_Array (1 .. Positive (Count));
end if;
for J in 1 .. Natural (Count) loop
declare
Param : aliased Parameter;
Column : Plug_In.Column_Description;
Plugin : Plug_In_Access := Plug_In_Access (Self.DB.Plugins);
Control : Plug_In.Control_Side := Plug_In.Driver;
begin
Code :=
OCIParamGet
(Self.Handle,
OCI_HTYPE_STMT,
Self.DB.Error,
Param'Access,
Ub4 (J));
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Code :=
OCIAttrGet
(Param,
OCI_DTYPE_PARAM,
Column.Column_Type'Address,
null,
OCI_ATTR_DATA_TYPE,
Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Code :=
OCIAttrGet
(Param,
OCI_DTYPE_PARAM,
Column.Size'Address,
null,
OCI_ATTR_DATA_SIZE,
Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Code :=
OCIAttrGet
(Param,
OCI_DTYPE_PARAM,
Column.Precision'Address,
null,
OCI_ATTR_PRECISION,
Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Code :=
OCIAttrGet
(Param,
OCI_DTYPE_PARAM,
Column.Scale'Address,
null,
OCI_ATTR_SCALE,
Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
-- Look for plugin
while Plugin /= null loop
Plugin.Check_Column
(Column,
Control,
Self.Columns (J).Extra_Type,
Self.Columns (J).Extra_Size);
exit when Control = Plug_In.Plug_In;
Plugin := Plugin.Next;
end loop;
Self.Columns (J).Plugin := Plugin;
if Plugin /= null then
-- Drop insufficient Extra space
if Self.Columns (J).Extra /= null and then
Self.Columns (J).Extra'Length < Self.Columns (J).Extra_Size
then
Free (Self.Columns (J).Extra);
end if;
-- Allocate Extra space
if Self.Columns (J).Extra = null then
Self.Columns (J).Extra := new
System.Storage_Elements.Storage_Array
(1 .. Self.Columns (J).Extra_Size);
end if;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).Extra (1)'Address,
Value_Length => Ub4 (Self.Columns (J).Extra_Size),
Value_Type => Self.Columns (J).Extra_Type,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
elsif Column.Column_Type in SQLT_CHR | SQLT_AFC then
Self.Columns (J).Column_Type := String_Column;
Self.Columns (J).Size :=
Utf16.Utf16_String_Index (Column.Size + 1);
declare
use Matreshka.Internals.Strings;
Ptr : Shared_String_Access
renames Self.Columns (J).String;
begin
if Ptr = null then
Ptr := Allocate (Self.Columns (J).Size);
elsif not Can_Be_Reused (Ptr, Self.Columns (J).Size) then
Dereference (Ptr);
Ptr := Allocate (Self.Columns (J).Size);
end if;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Ptr.Value (0)'Address,
Value_Length => Ptr.Value'Length * 2,
Value_Type => SQLT_STR,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
end;
elsif Column.Column_Type in
SQLT_NUM | SQLT_IBFLOAT | SQLT_IBDOUBLE
then
if Column.Column_Type = SQLT_NUM and Column.Scale = 0 then
Self.Columns (J).Column_Type := Integer_Column;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).Int'Address,
Value_Length => Self.Columns (J).Int'Size / 8,
Value_Type => SQLT_INT,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
else
Self.Columns (J).Column_Type := Float_Column;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).Float'Address,
Value_Length => Self.Columns (J).Float'Size / 8,
Value_Type => SQLT_FLT,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
end if;
elsif Column.Column_Type in SQLT_DAT then
Self.Columns (J).Column_Type := Date_Column;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).Date'Address,
Value_Length => Self.Columns (J).Date'Size / 8,
Value_Type => SQLT_ODT,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
elsif Column.Column_Type in
SQLT_TIMESTAMP | SQLT_TIMESTAMP_TZ | SQLT_TIMESTAMP_LTZ
then
if Self.Columns (J).Timestamp = null then
Code := OCIDescriptorAlloc
(Databases.Env,
Self.Columns (J).Timestamp'Access,
OCI_DTYPE_TIMESTAMP_TZ);
end if;
Self.Columns (J).Column_Type := Time_Column;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).Timestamp'Address,
Value_Length => Self.Columns (J).Timestamp'Size / 8,
Value_Type => SQLT_TIMESTAMP_TZ,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
else
exit;
-- raise Constraint_Error with "Unsupported type";
end if;
Code := OCIDescriptorFree (Param, OCI_DTYPE_PARAM);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
end;
Self.Column_Count := J;
end loop;
end if;
if Self.Is_Select then
Self.State := Executed;
else
Self.State := No_More_Rows;
end if;
return True;
end Execute;
------------
-- Finish --
------------
overriding procedure Finish (Self : not null access OCI_Query) is
Code : Error_Code;
begin
if Self.State in Active then
if Self.State in Fetching then
-- Cancel cursor by fetching no rows
Code := OCIStmtFetch2 (Self.Handle, Self.DB.Error, Rows => 0);
if Databases.Check_Error (Self.DB, Code) then
null; -- How to report errors?
end if;
end if;
Self.State := Prepared;
end if;
end Finish;
----------------
-- Invalidate --
----------------
overriding procedure Invalidate (Self : not null access OCI_Query) is
procedure Drop (Pos : Parameter_Maps.Cursor);
----------
-- Drop --
----------
procedure Drop (Pos : Parameter_Maps.Cursor) is
Code : Error_Code;
Item : Bound_Value_Access := Parameter_Maps.Element (Pos);
begin
if Item /= null and then Item.Timestamp /= null then
Code := OCIHandleFree
(Item.Timestamp, OCI_DTYPE_TIMESTAMP_TZ);
if Databases.Check_Error (Self.DB, Code) then
null; -- How to report errors?
end if;
Item.Timestamp := null;
end if;
Free (Item);
Self.Parameters.Replace_Element (Pos, null);
end Drop;
Code : Error_Code;
begin
if Self.Handle /= null then
Code := OCIHandleFree (Self.Handle, OCI_HTYPE_STMT);
if Databases.Check_Error (Self.DB, Code) then
null; -- How to report errors?
end if;
Self.Handle := null;
end if;
Self.Parameters.Iterate (Drop'Access);
if Self.Columns /= null then
declare
use Matreshka.Internals.Strings;
begin
for J in Self.Columns'Range loop
if Self.Columns (J).String /= null then
Dereference (Self.Columns (J).String);
elsif Self.Columns (J).Timestamp /= null then
Code := OCIHandleFree
(Self.Columns (J).Timestamp, OCI_DTYPE_TIMESTAMP_TZ);
Self.Columns (J).Timestamp := null;
end if;
end loop;
Free (Self.Columns);
end;
end if;
-- Call Invalidate of parent tagged type.
Abstract_Query (Self.all).Invalidate;
end Invalidate;
---------------
-- Is_Active --
---------------
overriding function Is_Active
(Self : not null access OCI_Query) return Boolean is
begin
return Self.State in Active;
end Is_Active;
--------------
-- Is_Valid --
--------------
overriding function Is_Valid
(Self : not null access OCI_Query) return Boolean is
begin
return Self.State = Has_Row;
end Is_Valid;
----------
-- Next --
----------
overriding function Next
(Self : not null access OCI_Query) return Boolean
is
use Matreshka.Internals.Strings;
Ok : Boolean;
Code : Error_Code;
begin
if Self.State not in Fetching then
return False;
end if;
-- Rebind used strings columns
for J in 1 .. Self.Column_Count loop
if Self.Columns (J).Plugin = null
and then Self.Columns (J).Column_Type = String_Column
and then not Can_Be_Reused
(Self.Columns (J).String, Self.Columns (J).Size)
then
Dereference (Self.Columns (J).String);
Self.Columns (J).String := Allocate (Self.Columns (J).Size);
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).String.Value (0)'Address,
Value_Length => Self.Columns (J).String.Value'Length * 2,
Value_Type => SQLT_STR,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
Self.State := No_More_Rows;
return False;
end if;
end if;
end loop;
Code := OCIStmtFetch2 (Self.Handle, Self.DB.Error);
if Code = OCI_NO_DATA or else Databases.Check_Error (Self.DB, Code) then
Self.State := No_More_Rows;
else
Self.State := Has_Row;
-- validate not null string columns
for J in 1 .. Self.Column_Count loop
if Self.Columns (J).Column_Type = String_Column
and Self.Columns (J).Is_Null = 0
then
Matreshka.Internals.Strings.C.Validate_And_Fixup
(Self.Columns (J).String, Ok);
end if;
end loop;
end if;
return Self.State = Has_Row;
end Next;
-----------------------
-- OCICallbackInBind --
-----------------------
function OCICallbackInBind
(ictxp : Bound_Value_Access;
bindp : Oracle.Bind;
iter : Ub4;
index : Ub4;
bufpp : access Utf16_Code_Unit_Access;
alenp : access Ub4;
piecep : access Ub1;
indp : access Sb2_Ptr)
return Error_Code
is
pragma Unreferenced (bindp);
pragma Unreferenced (iter);
pragma Unreferenced (index);
begin
piecep.all := OCI_ONE_PIECE;
indp.all := ictxp.Is_Null'Access;
if ictxp.Is_Null = -1 then
bufpp.all := null;
alenp.all := 0;
return OCI_CONTINUE;
end if;
alenp.all :=
Ub4
(League.Strings.Internals.Internal
(League.Holders.Element (ictxp.Value)).Unused) * 2 + 2;
bufpp.all := League.Strings.Internals.Internal
(League.Holders.Element (ictxp.Value)).Value (0)'Access;
return OCI_CONTINUE;
end OCICallbackInBind;
------------------------
-- OCICallbackOutBind --
------------------------
function OCICallbackOutBind
(octxp : Bound_Value_Access;
bindp : Oracle.Bind;
iter : Ub4;
index : Ub4;
bufpp : access Utf16_Code_Unit_Access;
alenp : access Ub4_Ptr;
piecep : access Ub1;
indp : access Sb2_Ptr;
rcodepp : access Sb2_Ptr)
return Error_Code
is
pragma Unreferenced (bindp);
pragma Unreferenced (iter);
pragma Unreferenced (index);
pragma Unreferenced (Rcodepp);
use Matreshka.Internals.Strings;
use type Ub1;
use type Matreshka.Internals.Utf16.Utf16_String_Index;
begin
if piecep.all = OCI_ONE_PIECE then
piecep.all := OCI_FIRST_PIECE;
if not League.Holders.Is_Empty (octxp.Value) then
octxp.String := League.Strings.Internals.Internal
(League.Holders.Element (octxp.Value));
else
octxp.String := null;
end if;
if octxp.String /= null
and then Can_Be_Reused (octxp.String, octxp.String.Capacity - 1)
then
Reference (octxp.String);
League.Holders.Replace_Element
(octxp.Value, League.Strings.Empty_Universal_String);
else
octxp.String := Allocate (64); -- Some initial size
end if;
octxp.String.Unused := 0;
else
piecep.all := OCI_NEXT_PIECE;
octxp.String.Unused := octxp.String.Unused + octxp.String_Size;
Mutate (octxp.String, 8 * octxp.String.Capacity);
end if;
octxp.String_Size := Ub4
((octxp.String.Capacity - octxp.String.Unused) * 2);
bufpp.all := octxp.String.Value (octxp.String.Unused)'Access;
alenp.all := octxp.String_Size'Access;
indp.all := octxp.Is_Null'Access;
return OCI_CONTINUE;
end OCICallbackOutBind;
-------------
-- Prepare --
-------------
overriding function Prepare
(Self : not null access OCI_Query;
Query : League.Strings.Universal_String) return Boolean
is
Kind : aliased Ub2;
Code : Error_Code;
begin
if Self.Handle = null then
Code :=
OCIHandleAlloc (Databases.Env, Self.Handle'Access, OCI_HTYPE_STMT);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
end if;
Code :=
OCIStmtPrepare
(Self.Handle,
Self.DB.Error,
League.Strings.Internals.Internal (Query).Value,
Ub4 (League.Strings.Internals.Internal (Query).Unused) * 2);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Code :=
OCIAttrGet
(Target => Self.Handle,
Target_Type => OCI_HTYPE_STMT,
Buffer => Kind'Address,
Length => null,
Attr => OCI_ATTR_STMT_TYPE,
Error => Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Self.Is_Described := False;
Self.Is_Select := Kind = OCI_STMT_SELECT;
Self.State := Prepared;
return True;
end Prepare;
-----------
-- Value --
-----------
overriding function Value
(Self : not null access OCI_Query;
Index : Positive) return League.Holders.Holder
is
Value : League.Holders.Holder;
begin
if Self.State /= Has_Row or else Index > Self.Column_Count then
return Value;
elsif Self.Columns (Index).Plugin /= null then
if Self.Columns (Index).Is_Null = 0 then
Self.Columns (Index).Plugin.Decode
(Value, Self.Columns (Index).Extra
(1 .. Self.Columns (Index).Extra_Size));
end if;
elsif Self.Columns (Index).Column_Type = String_Column then
League.Holders.Set_Tag (Value, League.Holders.Universal_String_Tag);
if Self.Columns (Index).Is_Null = 0 then
League.Holders.Replace_Element
(Value,
League.Strings.Internals.Create (Self.Columns (Index).String));
end if;
elsif Self.Columns (Index).Column_Type = Integer_Column then
League.Holders.Set_Tag (Value, League.Holders.Universal_Integer_Tag);
if Self.Columns (Index).Is_Null = 0 then
League.Holders.Replace_Element
(Value, Self.Columns (Index).Int);
end if;
elsif Self.Columns (Index).Column_Type = Float_Column then
League.Holders.Set_Tag (Value, League.Holders.Universal_Float_Tag);
if Self.Columns (Index).Is_Null = 0 then
League.Holders.Replace_Element (Value, Self.Columns (Index).Float);
end if;
elsif Self.Columns (Index).Column_Type = Date_Column then
League.Holders.Set_Tag (Value, League.Holders.Date_Tag);
if Self.Columns (Index).Is_Null = 0 then
League.Holders.Replace_Element
(Value, Utils.Decode_Date (Self.Columns (Index).Date));
end if;
elsif Self.Columns (Index).Column_Type = Time_Column then
League.Holders.Set_Tag (Value, League.Holders.Date_Time_Tag);
if Self.Columns (Index).Is_Null = 0 then
declare
Aux : League.Calendars.Date_Time;
Code : Error_Code;
Year : aliased Sb2;
Month : aliased Ub1;
Day : aliased Ub1;
Hour : aliased Ub1;
Min : aliased Ub1;
Sec : aliased Ub1;
Fract : aliased Ub4;
begin
Code :=
OCIDateTimeGetDate
(Env => Databases.Env,
Error => Self.DB.Error,
Date => Self.Columns (Index).Timestamp,
Year => Year'Access,
Month => Month'Access,
Day => Day'Access);
if Databases.Check_Error (Self.DB, Code) then
return Value;
end if;
Code :=
OCIDateTimeGetTime
(Env => Databases.Env,
Error => Self.DB.Error,
Date => Self.Columns (Index).Timestamp,
Hour => Hour'Access,
Min => Min'Access,
Sec => Sec'Access,
Fract => Fract'Access);
if Databases.Check_Error (Self.DB, Code) then
return Value;
end if;
Aux := League.Calendars.ISO_8601.Create
(League.Calendars.ISO_8601.Year_Number (Year),
League.Calendars.ISO_8601.Month_Number (Month),
League.Calendars.ISO_8601.Day_Number (Day),
League.Calendars.ISO_8601.Hour_Number (Hour),
League.Calendars.ISO_8601.Minute_Number (Min),
League.Calendars.ISO_8601.Second_Number (Sec),
League.Calendars.ISO_8601.Nanosecond_100_Number
(Fract / 100));
-- ??? where timezone should go???
League.Holders.Replace_Element (Value, Aux);
end;
end if;
end if;
return Value;
end Value;
end Matreshka.Internals.SQL_Drivers.Oracle.Queries;
| 22414 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- SQL Database Access --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2014, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with League.Calendars.ISO_8601;
with League.Strings.Internals;
with Matreshka.Internals.Utf16;
with Matreshka.Internals.Strings.C;
with Matreshka.Internals.SQL_Drivers.Oracle.Plug_In;
package body Matreshka.Internals.SQL_Drivers.Oracle.Queries is
use type Interfaces.Unsigned_32;
use type Interfaces.Unsigned_16;
use type Interfaces.Integer_8;
use type Sb2;
use type SQL.Parameter_Directions;
use type Plug_In.Control_Side;
use type System.Storage_Elements.Storage_Count;
procedure Free is
new Ada.Unchecked_Deallocation (Bound_Value_Node, Bound_Value_Access);
procedure Free is
new Ada.Unchecked_Deallocation
(Defined_Value_Array, Defined_Value_Array_Access);
procedure Free is
new Ada.Unchecked_Deallocation
(System.Storage_Elements.Storage_Array, Storage_Array_Access);
type Utf16_Code_Unit_Access is
access all Matreshka.Internals.Utf16.Utf16_Code_Unit;
function OCICallbackInBind
(ictxp : Bound_Value_Access;
bindp : Oracle.Bind;
iter : Ub4;
index : Ub4;
bufpp : access Utf16_Code_Unit_Access;
alenp : access Ub4;
piecep : access Ub1;
indp : access Sb2_Ptr)
return Error_Code;
pragma Convention (C, OCICallbackInBind);
function OCICallbackOutBind
(octxp : Bound_Value_Access;
bindp : Oracle.Bind;
iter : Ub4;
index : Ub4;
bufpp : access Utf16_Code_Unit_Access;
alenp : access Ub4_Ptr;
piecep : access Ub1;
indp : access Sb2_Ptr;
rcodepp : access Sb2_Ptr)
return Error_Code;
pragma Convention (C, OCICallbackOutBind);
function "+"
(Left : Matreshka.Internals.Utf16.Utf16_String_Index;
Right : Ub4) return Matreshka.Internals.Utf16.Utf16_String_Index;
UTC_TZ : constant Wide_String := "+00:00";
---------
-- "+" --
---------
function "+"
(Left : Matreshka.Internals.Utf16.Utf16_String_Index;
Right : Ub4) return Matreshka.Internals.Utf16.Utf16_String_Index
is
use type Matreshka.Internals.Utf16.Utf16_String_Index;
begin
return Left + Matreshka.Internals.Utf16.Utf16_String_Index (Right) / 2;
end "+";
----------------
-- Bind_Value --
----------------
overriding procedure Bind_Value
(Self : not null access OCI_Query;
Name : League.Strings.Universal_String;
Value : League.Holders.Holder;
Direction : SQL.Parameter_Directions)
is
Code : Error_Code;
Pos : Parameter_Maps.Cursor;
Ok : Boolean;
procedure Bind
(Name : League.Strings.Universal_String;
Item : in out Bound_Value_Access);
----------
-- Bind --
----------
procedure Bind
(Name : League.Strings.Universal_String;
Item : in out Bound_Value_Access)
is
Length : Ub4;
Plugin : Plug_In_Access := Plug_In_Access (Self.DB.Plugins);
Control : Plug_In.Control_Side := Plug_In.Driver;
Extra_Type : Data_Type;
Extra_Size : System.Storage_Elements.Storage_Count := 0;
begin
while Plugin /= null loop
Plugin.Check_Parameter
(Value,
Control,
Extra_Type,
Extra_Size);
exit when Control = Plug_In.Plug_In;
Plugin := Plugin.Next;
end loop;
if Item /= null and then Item.Length < Extra_Size then
Free (Item);
end if;
if Item = null then
Item := new Bound_Value_Node (Extra_Size);
end if;
Item.Value := Value;
Item.Direction := Direction;
Item.Plugin := Plugin;
Item.Extra_Type := Extra_Type;
Item.Extra_Size := Extra_Size;
if Item.Plugin /= null then
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Extra (1)'Address,
Ub4 (Item.Extra_Size),
Item.Extra_Type,
Item.Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
Free (Item);
return; -- How to report errors?
end if;
Item.Plugin.Encode (Value, Item.Extra (1 .. Item.Extra_Size));
elsif League.Holders.Is_Universal_String (Value) then
Length := 64 * 1024; -- 64kbyte max length of out string param
if Direction = SQL.In_Parameter then
if League.Holders.Is_Empty (Value) then
Length := 2;
else
Length :=
Ub4
(League.Strings.Internals.Internal
(League.Holders.Element (Value)).Unused) * 2 + 2;
end if;
end if;
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Value_Length => Length,
Value_Type => SQLT_STR,
Mode => OCI_DATA_AT_EXEC);
if Databases.Check_Error (Self.DB, Code) then
Free (Item);
return; -- How to report errors?
end if;
Code :=
OCIBindDynamic
(Item.Bind,
Self.DB.Error,
Item.all'Address,
OCICallbackInBind'Address,
Item.all'Address,
OCICallbackOutBind'Address);
Item.String_Size := 0;
elsif League.Holders.Is_Abstract_Integer (Value) then
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Int'Address,
Item.Int'Size / 8,
SQLT_INT,
Item.Is_Null'Access);
if not League.Holders.Is_Empty (Value) then
Item.Int := League.Holders.Element (Value);
end if;
elsif League.Holders.Is_Abstract_Float (Value) then
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Float'Address,
Item.Float'Size / 8,
SQLT_FLT,
Item.Is_Null'Access);
if not League.Holders.Is_Empty (Value) then
Item.Float := League.Holders.Element (Value);
end if;
elsif League.Holders.Is_Date (Value) then
declare
Aux : League.Calendars.Date;
begin
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Date'Address,
Item.Date'Size / 8,
SQLT_ODT,
Item.Is_Null'Access);
if not League.Holders.Is_Empty (Value) then
Aux := League.Holders.Element (Value);
Item.Date := Utils.Encode_Date (Aux);
end if;
end;
elsif League.Holders.Is_Date_Time (Value) then
if Item.Timestamp = null then
Code := OCIDescriptorAlloc
(Databases.Env,
Item.Timestamp'Access,
OCI_DTYPE_TIMESTAMP_TZ);
end if;
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Timestamp'Address,
Item.Timestamp'Size / 8,
SQLT_TIMESTAMP_TZ,
Item.Is_Null'Access);
if not League.Holders.Is_Empty (Value) then
declare
use type Size_T;
Aux : constant League.Calendars.Date_Time :=
League.Holders.Element (Value);
Year : League.Calendars.ISO_8601.Year_Number;
Month : League.Calendars.ISO_8601.Month_Number;
Day : League.Calendars.ISO_8601.Day_Number;
Hour : League.Calendars.ISO_8601.Hour_Number;
Minute : League.Calendars.ISO_8601.Minute_Number;
Second : League.Calendars.ISO_8601.Second_Number;
Fraction : League.Calendars.ISO_8601.Nanosecond_100_Number;
begin
League.Calendars.ISO_8601.Split
(Aux, Year, Month, Day, Hour, Minute, Second, Fraction);
Code := OCIDateTimeConstruct
(Env => Databases.Env,
Error => Self.DB.Error,
Date => Item.Timestamp,
Year => Sb2 (Year),
Month => Ub1 (Month),
Day => Ub1 (Day),
Hour => Ub1 (Hour),
Min => Ub1 (Minute),
Sec => Ub1 (Second),
Fract => Ub4 (Fraction) * 100,
TZ => UTC_TZ (UTC_TZ'First)'Address,
TZ_Len => UTC_TZ'Length * 2);
end;
end if;
elsif League.Holders.Is_Empty (Value) then
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Int'Address,
Item.Int'Size / 8,
SQLT_INT,
Item.Is_Null'Access);
else
Free (Item);
return;
end if;
if Databases.Check_Error (Self.DB, Code) then
Free (Item);
return; -- How to report errors?
end if;
Item.Is_Null := -Boolean'Pos
(League.Holders.Is_Empty (Value) or Direction = SQL.Out_Parameter);
end Bind;
begin
if Self.State = Prepared then
Self.Parameters.Insert (Name, null, Pos, Ok);
Self.Parameters.Update_Element (Pos, Bind'Access);
end if;
end Bind_Value;
-----------------
-- Bound_Value --
-----------------
overriding function Bound_Value
(Self : not null access OCI_Query;
Name : League.Strings.Universal_String)
return League.Holders.Holder
is
Empty : League.Holders.Holder;
Pos : constant Parameter_Maps.Cursor := Self.Parameters.Find (Name);
Item : Bound_Value_Access;
begin
if Parameter_Maps.Has_Element (Pos) then
Item := Parameter_Maps.Element (Pos);
end if;
if Item = null then
return Empty;
else
return Item.Value;
end if;
end Bound_Value;
-------------------
-- Error_Message --
-------------------
overriding function Error_Message
(Self : not null access OCI_Query)
return League.Strings.Universal_String is
begin
return Self.DB.Error_Message;
end Error_Message;
-------------
-- Execute --
-------------
overriding function Execute
(Self : not null access OCI_Query) return Boolean
is
procedure Fixup_Parameter (Position : Parameter_Maps.Cursor);
---------------------
-- Fixup_Parameter --
---------------------
procedure Fixup_Parameter (Position : Parameter_Maps.Cursor) is
use type Matreshka.Internals.Strings.Shared_String_Access;
Ok : Boolean;
Item : constant Bound_Value_Access :=
Parameter_Maps.Element (Position);
begin
if Item = null or else Item.Direction = SQL.In_Parameter then
return;
elsif Item.String /= null then
Item.String.Unused := Item.String.Unused + Item.String_Size;
Matreshka.Internals.Strings.C.Validate_And_Fixup
(Item.String, Item.String.Unused, Ok);
League.Holders.Replace_Element
(Item.Value,
League.Strings.Internals.Wrap (Item.String));
Item.String := null;
Item.String_Size := 0;
if Item.Is_Null = -1 then
League.Holders.Clear (Item.Value);
end if;
elsif League.Holders.Is_Abstract_Integer (Item.Value) then
if Item.Is_Null = 0 then
League.Holders.Replace_Element (Item.Value, Item.Int);
else
League.Holders.Clear (Item.Value);
end if;
elsif League.Holders.Is_Abstract_Float (Item.Value) then
if Item.Is_Null = 0 then
League.Holders.Replace_Element (Item.Value, Item.Float);
else
League.Holders.Clear (Item.Value);
end if;
elsif Item.Is_Null /= 0 then
League.Holders.Clear (Item.Value);
end if;
end Fixup_Parameter;
Count : aliased Ub4;
Code : Error_Code;
begin -- Execute
if Self.State not in Ready then
return False;
end if;
Code :=
OCIStmtExecute
(Self.DB.Service,
Self.Handle,
Self.DB.Error,
Iters => Boolean'Pos (not Self.Is_Select));
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Self.Parameters.Iterate (Fixup_Parameter'Access);
if Self.Is_Select and not Self.Is_Described then
Self.Is_Described := True;
Self.Column_Count := 0;
Code :=
OCIAttrGet
(Target => Self.Handle,
Target_Type => OCI_HTYPE_STMT,
Buffer => Count'Address,
Length => null,
Attr => OCI_ATTR_PARAM_COUNT,
Error => Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
if Self.Columns /= null and then Self.Columns'Length < Count then
Free (Self.Columns);
end if;
if Self.Columns = null and Count > 0 then
Self.Columns := new Defined_Value_Array (1 .. Positive (Count));
end if;
for J in 1 .. Natural (Count) loop
declare
Param : aliased Parameter;
Column : Plug_In.Column_Description;
Plugin : Plug_In_Access := Plug_In_Access (Self.DB.Plugins);
Control : Plug_In.Control_Side := Plug_In.Driver;
begin
Code :=
OCIParamGet
(Self.Handle,
OCI_HTYPE_STMT,
Self.DB.Error,
Param'Access,
Ub4 (J));
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Code :=
OCIAttrGet
(Param,
OCI_DTYPE_PARAM,
Column.Column_Type'Address,
null,
OCI_ATTR_DATA_TYPE,
Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Code :=
OCIAttrGet
(Param,
OCI_DTYPE_PARAM,
Column.Size'Address,
null,
OCI_ATTR_DATA_SIZE,
Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Code :=
OCIAttrGet
(Param,
OCI_DTYPE_PARAM,
Column.Precision'Address,
null,
OCI_ATTR_PRECISION,
Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Code :=
OCIAttrGet
(Param,
OCI_DTYPE_PARAM,
Column.Scale'Address,
null,
OCI_ATTR_SCALE,
Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
-- Look for plugin
while Plugin /= null loop
Plugin.Check_Column
(Column,
Control,
Self.Columns (J).Extra_Type,
Self.Columns (J).Extra_Size);
exit when Control = Plug_In.Plug_In;
Plugin := Plugin.Next;
end loop;
Self.Columns (J).Plugin := Plugin;
if Plugin /= null then
-- Drop insufficient Extra space
if Self.Columns (J).Extra /= null and then
Self.Columns (J).Extra'Length < Self.Columns (J).Extra_Size
then
Free (Self.Columns (J).Extra);
end if;
-- Allocate Extra space
if Self.Columns (J).Extra = null then
Self.Columns (J).Extra := new
System.Storage_Elements.Storage_Array
(1 .. Self.Columns (J).Extra_Size);
end if;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).Extra (1)'Address,
Value_Length => Ub4 (Self.Columns (J).Extra_Size),
Value_Type => Self.Columns (J).Extra_Type,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
elsif Column.Column_Type in SQLT_CHR | SQLT_AFC then
Self.Columns (J).Column_Type := String_Column;
Self.Columns (J).Size :=
Utf16.Utf16_String_Index (Column.Size + 1);
declare
use Matreshka.Internals.Strings;
Ptr : Shared_String_Access
renames Self.Columns (J).String;
begin
if Ptr = null then
Ptr := Allocate (Self.Columns (J).Size);
elsif not Can_Be_Reused (Ptr, Self.Columns (J).Size) then
Dereference (Ptr);
Ptr := Allocate (Self.Columns (J).Size);
end if;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Ptr.Value (0)'Address,
Value_Length => Ptr.Value'Length * 2,
Value_Type => SQLT_STR,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
end;
elsif Column.Column_Type in
SQLT_NUM | SQLT_IBFLOAT | SQLT_IBDOUBLE
then
if Column.Column_Type = SQLT_NUM and Column.Scale = 0 then
Self.Columns (J).Column_Type := Integer_Column;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).Int'Address,
Value_Length => Self.Columns (J).Int'Size / 8,
Value_Type => SQLT_INT,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
else
Self.Columns (J).Column_Type := Float_Column;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).Float'Address,
Value_Length => Self.Columns (J).Float'Size / 8,
Value_Type => SQLT_FLT,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
end if;
elsif Column.Column_Type in SQLT_DAT then
Self.Columns (J).Column_Type := Date_Column;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).Date'Address,
Value_Length => Self.Columns (J).Date'Size / 8,
Value_Type => SQLT_ODT,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
elsif Column.Column_Type in
SQLT_TIMESTAMP | SQLT_TIMESTAMP_TZ | SQLT_TIMESTAMP_LTZ
then
if Self.Columns (J).Timestamp = null then
Code := OCIDescriptorAlloc
(Databases.Env,
Self.Columns (J).Timestamp'Access,
OCI_DTYPE_TIMESTAMP_TZ);
end if;
Self.Columns (J).Column_Type := Time_Column;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).Timestamp'Address,
Value_Length => Self.Columns (J).Timestamp'Size / 8,
Value_Type => SQLT_TIMESTAMP_TZ,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
else
exit;
-- raise Constraint_Error with "Unsupported type";
end if;
Code := OCIDescriptorFree (Param, OCI_DTYPE_PARAM);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
end;
Self.Column_Count := J;
end loop;
end if;
if Self.Is_Select then
Self.State := Executed;
else
Self.State := No_More_Rows;
end if;
return True;
end Execute;
------------
-- Finish --
------------
overriding procedure Finish (Self : not null access OCI_Query) is
Code : Error_Code;
begin
if Self.State in Active then
if Self.State in Fetching then
-- Cancel cursor by fetching no rows
Code := OCIStmtFetch2 (Self.Handle, Self.DB.Error, Rows => 0);
if Databases.Check_Error (Self.DB, Code) then
null; -- How to report errors?
end if;
end if;
Self.State := Prepared;
end if;
end Finish;
----------------
-- Invalidate --
----------------
overriding procedure Invalidate (Self : not null access OCI_Query) is
procedure Drop (Pos : Parameter_Maps.Cursor);
----------
-- Drop --
----------
procedure Drop (Pos : Parameter_Maps.Cursor) is
Code : Error_Code;
Item : Bound_Value_Access := Parameter_Maps.Element (Pos);
begin
if Item /= null and then Item.Timestamp /= null then
Code := OCIHandleFree
(Item.Timestamp, OCI_DTYPE_TIMESTAMP_TZ);
if Databases.Check_Error (Self.DB, Code) then
null; -- How to report errors?
end if;
Item.Timestamp := null;
end if;
Free (Item);
Self.Parameters.Replace_Element (Pos, null);
end Drop;
Code : Error_Code;
begin
if Self.Handle /= null then
Code := OCIHandleFree (Self.Handle, OCI_HTYPE_STMT);
if Databases.Check_Error (Self.DB, Code) then
null; -- How to report errors?
end if;
Self.Handle := null;
end if;
Self.Parameters.Iterate (Drop'Access);
if Self.Columns /= null then
declare
use Matreshka.Internals.Strings;
begin
for J in Self.Columns'Range loop
if Self.Columns (J).String /= null then
Dereference (Self.Columns (J).String);
elsif Self.Columns (J).Timestamp /= null then
Code := OCIHandleFree
(Self.Columns (J).Timestamp, OCI_DTYPE_TIMESTAMP_TZ);
Self.Columns (J).Timestamp := null;
end if;
end loop;
Free (Self.Columns);
end;
end if;
-- Call Invalidate of parent tagged type.
Abstract_Query (Self.all).Invalidate;
end Invalidate;
---------------
-- Is_Active --
---------------
overriding function Is_Active
(Self : not null access OCI_Query) return Boolean is
begin
return Self.State in Active;
end Is_Active;
--------------
-- Is_Valid --
--------------
overriding function Is_Valid
(Self : not null access OCI_Query) return Boolean is
begin
return Self.State = Has_Row;
end Is_Valid;
----------
-- Next --
----------
overriding function Next
(Self : not null access OCI_Query) return Boolean
is
use Matreshka.Internals.Strings;
Ok : Boolean;
Code : Error_Code;
begin
if Self.State not in Fetching then
return False;
end if;
-- Rebind used strings columns
for J in 1 .. Self.Column_Count loop
if Self.Columns (J).Plugin = null
and then Self.Columns (J).Column_Type = String_Column
and then not Can_Be_Reused
(Self.Columns (J).String, Self.Columns (J).Size)
then
Dereference (Self.Columns (J).String);
Self.Columns (J).String := Allocate (Self.Columns (J).Size);
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).String.Value (0)'Address,
Value_Length => Self.Columns (J).String.Value'Length * 2,
Value_Type => SQLT_STR,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
Self.State := No_More_Rows;
return False;
end if;
end if;
end loop;
Code := OCIStmtFetch2 (Self.Handle, Self.DB.Error);
if Code = OCI_NO_DATA or else Databases.Check_Error (Self.DB, Code) then
Self.State := No_More_Rows;
else
Self.State := Has_Row;
-- validate not null string columns
for J in 1 .. Self.Column_Count loop
if Self.Columns (J).Column_Type = String_Column
and Self.Columns (J).Is_Null = 0
then
Matreshka.Internals.Strings.C.Validate_And_Fixup
(Self.Columns (J).String, Ok);
end if;
end loop;
end if;
return Self.State = Has_Row;
end Next;
-----------------------
-- OCICallbackInBind --
-----------------------
function OCICallbackInBind
(ictxp : Bound_Value_Access;
bindp : Oracle.Bind;
iter : Ub4;
index : Ub4;
bufpp : access Utf16_Code_Unit_Access;
alenp : access Ub4;
piecep : access Ub1;
indp : access Sb2_Ptr)
return Error_Code
is
pragma Unreferenced (bindp);
pragma Unreferenced (iter);
pragma Unreferenced (index);
begin
piecep.all := OCI_ONE_PIECE;
indp.all := ictxp.Is_Null'Access;
if ictxp.Is_Null = -1 then
bufpp.all := null;
alenp.all := 0;
return OCI_CONTINUE;
end if;
alenp.all :=
Ub4
(League.Strings.Internals.Internal
(League.Holders.Element (ictxp.Value)).Unused) * 2 + 2;
bufpp.all := League.Strings.Internals.Internal
(League.Holders.Element (ictxp.Value)).Value (0)'Access;
return OCI_CONTINUE;
end OCICallbackInBind;
------------------------
-- OCICallbackOutBind --
------------------------
function OCICallbackOutBind
(octxp : Bound_Value_Access;
bindp : Oracle.Bind;
iter : Ub4;
index : Ub4;
bufpp : access Utf16_Code_Unit_Access;
alenp : access Ub4_Ptr;
piecep : access Ub1;
indp : access Sb2_Ptr;
rcodepp : access Sb2_Ptr)
return Error_Code
is
pragma Unreferenced (bindp);
pragma Unreferenced (iter);
pragma Unreferenced (index);
pragma Unreferenced (Rcodepp);
use Matreshka.Internals.Strings;
use type Ub1;
use type Matreshka.Internals.Utf16.Utf16_String_Index;
begin
if piecep.all = OCI_ONE_PIECE then
piecep.all := OCI_FIRST_PIECE;
if not League.Holders.Is_Empty (octxp.Value) then
octxp.String := League.Strings.Internals.Internal
(League.Holders.Element (octxp.Value));
else
octxp.String := null;
end if;
if octxp.String /= null
and then Can_Be_Reused (octxp.String, octxp.String.Capacity - 1)
then
Reference (octxp.String);
League.Holders.Replace_Element
(octxp.Value, League.Strings.Empty_Universal_String);
else
octxp.String := Allocate (64); -- Some initial size
end if;
octxp.String.Unused := 0;
else
piecep.all := OCI_NEXT_PIECE;
octxp.String.Unused := octxp.String.Unused + octxp.String_Size;
Mutate (octxp.String, 8 * octxp.String.Capacity);
end if;
octxp.String_Size := Ub4
((octxp.String.Capacity - octxp.String.Unused) * 2);
bufpp.all := octxp.String.Value (octxp.String.Unused)'Access;
alenp.all := octxp.String_Size'Access;
indp.all := octxp.Is_Null'Access;
return OCI_CONTINUE;
end OCICallbackOutBind;
-------------
-- Prepare --
-------------
overriding function Prepare
(Self : not null access OCI_Query;
Query : League.Strings.Universal_String) return Boolean
is
Kind : aliased Ub2;
Code : Error_Code;
begin
if Self.Handle = null then
Code :=
OCIHandleAlloc (Databases.Env, Self.Handle'Access, OCI_HTYPE_STMT);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
end if;
Code :=
OCIStmtPrepare
(Self.Handle,
Self.DB.Error,
League.Strings.Internals.Internal (Query).Value,
Ub4 (League.Strings.Internals.Internal (Query).Unused) * 2);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Code :=
OCIAttrGet
(Target => Self.Handle,
Target_Type => OCI_HTYPE_STMT,
Buffer => Kind'Address,
Length => null,
Attr => OCI_ATTR_STMT_TYPE,
Error => Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Self.Is_Described := False;
Self.Is_Select := Kind = OCI_STMT_SELECT;
Self.State := Prepared;
return True;
end Prepare;
-----------
-- Value --
-----------
overriding function Value
(Self : not null access OCI_Query;
Index : Positive) return League.Holders.Holder
is
Value : League.Holders.Holder;
begin
if Self.State /= Has_Row or else Index > Self.Column_Count then
return Value;
elsif Self.Columns (Index).Plugin /= null then
if Self.Columns (Index).Is_Null = 0 then
Self.Columns (Index).Plugin.Decode
(Value, Self.Columns (Index).Extra
(1 .. Self.Columns (Index).Extra_Size));
end if;
elsif Self.Columns (Index).Column_Type = String_Column then
League.Holders.Set_Tag (Value, League.Holders.Universal_String_Tag);
if Self.Columns (Index).Is_Null = 0 then
League.Holders.Replace_Element
(Value,
League.Strings.Internals.Create (Self.Columns (Index).String));
end if;
elsif Self.Columns (Index).Column_Type = Integer_Column then
League.Holders.Set_Tag (Value, League.Holders.Universal_Integer_Tag);
if Self.Columns (Index).Is_Null = 0 then
League.Holders.Replace_Element
(Value, Self.Columns (Index).Int);
end if;
elsif Self.Columns (Index).Column_Type = Float_Column then
League.Holders.Set_Tag (Value, League.Holders.Universal_Float_Tag);
if Self.Columns (Index).Is_Null = 0 then
League.Holders.Replace_Element (Value, Self.Columns (Index).Float);
end if;
elsif Self.Columns (Index).Column_Type = Date_Column then
League.Holders.Set_Tag (Value, League.Holders.Date_Tag);
if Self.Columns (Index).Is_Null = 0 then
League.Holders.Replace_Element
(Value, Utils.Decode_Date (Self.Columns (Index).Date));
end if;
elsif Self.Columns (Index).Column_Type = Time_Column then
League.Holders.Set_Tag (Value, League.Holders.Date_Time_Tag);
if Self.Columns (Index).Is_Null = 0 then
declare
Aux : League.Calendars.Date_Time;
Code : Error_Code;
Year : aliased Sb2;
Month : aliased Ub1;
Day : aliased Ub1;
Hour : aliased Ub1;
Min : aliased Ub1;
Sec : aliased Ub1;
Fract : aliased Ub4;
begin
Code :=
OCIDateTimeGetDate
(Env => Databases.Env,
Error => Self.DB.Error,
Date => Self.Columns (Index).Timestamp,
Year => Year'Access,
Month => Month'Access,
Day => Day'Access);
if Databases.Check_Error (Self.DB, Code) then
return Value;
end if;
Code :=
OCIDateTimeGetTime
(Env => Databases.Env,
Error => Self.DB.Error,
Date => Self.Columns (Index).Timestamp,
Hour => Hour'Access,
Min => Min'Access,
Sec => Sec'Access,
Fract => Fract'Access);
if Databases.Check_Error (Self.DB, Code) then
return Value;
end if;
Aux := League.Calendars.ISO_8601.Create
(League.Calendars.ISO_8601.Year_Number (Year),
League.Calendars.ISO_8601.Month_Number (Month),
League.Calendars.ISO_8601.Day_Number (Day),
League.Calendars.ISO_8601.Hour_Number (Hour),
League.Calendars.ISO_8601.Minute_Number (Min),
League.Calendars.ISO_8601.Second_Number (Sec),
League.Calendars.ISO_8601.Nanosecond_100_Number
(Fract / 100));
-- ??? where timezone should go???
League.Holders.Replace_Element (Value, Aux);
end;
end if;
end if;
return Value;
end Value;
end Matreshka.Internals.SQL_Drivers.Oracle.Queries;
| true | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- SQL Database Access --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2014, PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> --
-- 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.Unchecked_Deallocation;
with League.Calendars.ISO_8601;
with League.Strings.Internals;
with Matreshka.Internals.Utf16;
with Matreshka.Internals.Strings.C;
with Matreshka.Internals.SQL_Drivers.Oracle.Plug_In;
package body Matreshka.Internals.SQL_Drivers.Oracle.Queries is
use type Interfaces.Unsigned_32;
use type Interfaces.Unsigned_16;
use type Interfaces.Integer_8;
use type Sb2;
use type SQL.Parameter_Directions;
use type Plug_In.Control_Side;
use type System.Storage_Elements.Storage_Count;
procedure Free is
new Ada.Unchecked_Deallocation (Bound_Value_Node, Bound_Value_Access);
procedure Free is
new Ada.Unchecked_Deallocation
(Defined_Value_Array, Defined_Value_Array_Access);
procedure Free is
new Ada.Unchecked_Deallocation
(System.Storage_Elements.Storage_Array, Storage_Array_Access);
type Utf16_Code_Unit_Access is
access all Matreshka.Internals.Utf16.Utf16_Code_Unit;
function OCICallbackInBind
(ictxp : Bound_Value_Access;
bindp : Oracle.Bind;
iter : Ub4;
index : Ub4;
bufpp : access Utf16_Code_Unit_Access;
alenp : access Ub4;
piecep : access Ub1;
indp : access Sb2_Ptr)
return Error_Code;
pragma Convention (C, OCICallbackInBind);
function OCICallbackOutBind
(octxp : Bound_Value_Access;
bindp : Oracle.Bind;
iter : Ub4;
index : Ub4;
bufpp : access Utf16_Code_Unit_Access;
alenp : access Ub4_Ptr;
piecep : access Ub1;
indp : access Sb2_Ptr;
rcodepp : access Sb2_Ptr)
return Error_Code;
pragma Convention (C, OCICallbackOutBind);
function "+"
(Left : Matreshka.Internals.Utf16.Utf16_String_Index;
Right : Ub4) return Matreshka.Internals.Utf16.Utf16_String_Index;
UTC_TZ : constant Wide_String := "+00:00";
---------
-- "+" --
---------
function "+"
(Left : Matreshka.Internals.Utf16.Utf16_String_Index;
Right : Ub4) return Matreshka.Internals.Utf16.Utf16_String_Index
is
use type Matreshka.Internals.Utf16.Utf16_String_Index;
begin
return Left + Matreshka.Internals.Utf16.Utf16_String_Index (Right) / 2;
end "+";
----------------
-- Bind_Value --
----------------
overriding procedure Bind_Value
(Self : not null access OCI_Query;
Name : League.Strings.Universal_String;
Value : League.Holders.Holder;
Direction : SQL.Parameter_Directions)
is
Code : Error_Code;
Pos : Parameter_Maps.Cursor;
Ok : Boolean;
procedure Bind
(Name : League.Strings.Universal_String;
Item : in out Bound_Value_Access);
----------
-- Bind --
----------
procedure Bind
(Name : League.Strings.Universal_String;
Item : in out Bound_Value_Access)
is
Length : Ub4;
Plugin : Plug_In_Access := Plug_In_Access (Self.DB.Plugins);
Control : Plug_In.Control_Side := Plug_In.Driver;
Extra_Type : Data_Type;
Extra_Size : System.Storage_Elements.Storage_Count := 0;
begin
while Plugin /= null loop
Plugin.Check_Parameter
(Value,
Control,
Extra_Type,
Extra_Size);
exit when Control = Plug_In.Plug_In;
Plugin := Plugin.Next;
end loop;
if Item /= null and then Item.Length < Extra_Size then
Free (Item);
end if;
if Item = null then
Item := new Bound_Value_Node (Extra_Size);
end if;
Item.Value := Value;
Item.Direction := Direction;
Item.Plugin := Plugin;
Item.Extra_Type := Extra_Type;
Item.Extra_Size := Extra_Size;
if Item.Plugin /= null then
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Extra (1)'Address,
Ub4 (Item.Extra_Size),
Item.Extra_Type,
Item.Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
Free (Item);
return; -- How to report errors?
end if;
Item.Plugin.Encode (Value, Item.Extra (1 .. Item.Extra_Size));
elsif League.Holders.Is_Universal_String (Value) then
Length := 64 * 1024; -- 64kbyte max length of out string param
if Direction = SQL.In_Parameter then
if League.Holders.Is_Empty (Value) then
Length := 2;
else
Length :=
Ub4
(League.Strings.Internals.Internal
(League.Holders.Element (Value)).Unused) * 2 + 2;
end if;
end if;
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Value_Length => Length,
Value_Type => SQLT_STR,
Mode => OCI_DATA_AT_EXEC);
if Databases.Check_Error (Self.DB, Code) then
Free (Item);
return; -- How to report errors?
end if;
Code :=
OCIBindDynamic
(Item.Bind,
Self.DB.Error,
Item.all'Address,
OCICallbackInBind'Address,
Item.all'Address,
OCICallbackOutBind'Address);
Item.String_Size := 0;
elsif League.Holders.Is_Abstract_Integer (Value) then
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Int'Address,
Item.Int'Size / 8,
SQLT_INT,
Item.Is_Null'Access);
if not League.Holders.Is_Empty (Value) then
Item.Int := League.Holders.Element (Value);
end if;
elsif League.Holders.Is_Abstract_Float (Value) then
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Float'Address,
Item.Float'Size / 8,
SQLT_FLT,
Item.Is_Null'Access);
if not League.Holders.Is_Empty (Value) then
Item.Float := League.Holders.Element (Value);
end if;
elsif League.Holders.Is_Date (Value) then
declare
Aux : League.Calendars.Date;
begin
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Date'Address,
Item.Date'Size / 8,
SQLT_ODT,
Item.Is_Null'Access);
if not League.Holders.Is_Empty (Value) then
Aux := League.Holders.Element (Value);
Item.Date := Utils.Encode_Date (Aux);
end if;
end;
elsif League.Holders.Is_Date_Time (Value) then
if Item.Timestamp = null then
Code := OCIDescriptorAlloc
(Databases.Env,
Item.Timestamp'Access,
OCI_DTYPE_TIMESTAMP_TZ);
end if;
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Timestamp'Address,
Item.Timestamp'Size / 8,
SQLT_TIMESTAMP_TZ,
Item.Is_Null'Access);
if not League.Holders.Is_Empty (Value) then
declare
use type Size_T;
Aux : constant League.Calendars.Date_Time :=
League.Holders.Element (Value);
Year : League.Calendars.ISO_8601.Year_Number;
Month : League.Calendars.ISO_8601.Month_Number;
Day : League.Calendars.ISO_8601.Day_Number;
Hour : League.Calendars.ISO_8601.Hour_Number;
Minute : League.Calendars.ISO_8601.Minute_Number;
Second : League.Calendars.ISO_8601.Second_Number;
Fraction : League.Calendars.ISO_8601.Nanosecond_100_Number;
begin
League.Calendars.ISO_8601.Split
(Aux, Year, Month, Day, Hour, Minute, Second, Fraction);
Code := OCIDateTimeConstruct
(Env => Databases.Env,
Error => Self.DB.Error,
Date => Item.Timestamp,
Year => Sb2 (Year),
Month => Ub1 (Month),
Day => Ub1 (Day),
Hour => Ub1 (Hour),
Min => Ub1 (Minute),
Sec => Ub1 (Second),
Fract => Ub4 (Fraction) * 100,
TZ => UTC_TZ (UTC_TZ'First)'Address,
TZ_Len => UTC_TZ'Length * 2);
end;
end if;
elsif League.Holders.Is_Empty (Value) then
Code :=
OCIBindByName
(Self.Handle,
Item.Bind'Access,
Self.DB.Error,
League.Strings.Internals.Internal (Name).Value,
Ub4 (League.Strings.Internals.Internal (Name).Unused) * 2,
Item.Int'Address,
Item.Int'Size / 8,
SQLT_INT,
Item.Is_Null'Access);
else
Free (Item);
return;
end if;
if Databases.Check_Error (Self.DB, Code) then
Free (Item);
return; -- How to report errors?
end if;
Item.Is_Null := -Boolean'Pos
(League.Holders.Is_Empty (Value) or Direction = SQL.Out_Parameter);
end Bind;
begin
if Self.State = Prepared then
Self.Parameters.Insert (Name, null, Pos, Ok);
Self.Parameters.Update_Element (Pos, Bind'Access);
end if;
end Bind_Value;
-----------------
-- Bound_Value --
-----------------
overriding function Bound_Value
(Self : not null access OCI_Query;
Name : League.Strings.Universal_String)
return League.Holders.Holder
is
Empty : League.Holders.Holder;
Pos : constant Parameter_Maps.Cursor := Self.Parameters.Find (Name);
Item : Bound_Value_Access;
begin
if Parameter_Maps.Has_Element (Pos) then
Item := Parameter_Maps.Element (Pos);
end if;
if Item = null then
return Empty;
else
return Item.Value;
end if;
end Bound_Value;
-------------------
-- Error_Message --
-------------------
overriding function Error_Message
(Self : not null access OCI_Query)
return League.Strings.Universal_String is
begin
return Self.DB.Error_Message;
end Error_Message;
-------------
-- Execute --
-------------
overriding function Execute
(Self : not null access OCI_Query) return Boolean
is
procedure Fixup_Parameter (Position : Parameter_Maps.Cursor);
---------------------
-- Fixup_Parameter --
---------------------
procedure Fixup_Parameter (Position : Parameter_Maps.Cursor) is
use type Matreshka.Internals.Strings.Shared_String_Access;
Ok : Boolean;
Item : constant Bound_Value_Access :=
Parameter_Maps.Element (Position);
begin
if Item = null or else Item.Direction = SQL.In_Parameter then
return;
elsif Item.String /= null then
Item.String.Unused := Item.String.Unused + Item.String_Size;
Matreshka.Internals.Strings.C.Validate_And_Fixup
(Item.String, Item.String.Unused, Ok);
League.Holders.Replace_Element
(Item.Value,
League.Strings.Internals.Wrap (Item.String));
Item.String := null;
Item.String_Size := 0;
if Item.Is_Null = -1 then
League.Holders.Clear (Item.Value);
end if;
elsif League.Holders.Is_Abstract_Integer (Item.Value) then
if Item.Is_Null = 0 then
League.Holders.Replace_Element (Item.Value, Item.Int);
else
League.Holders.Clear (Item.Value);
end if;
elsif League.Holders.Is_Abstract_Float (Item.Value) then
if Item.Is_Null = 0 then
League.Holders.Replace_Element (Item.Value, Item.Float);
else
League.Holders.Clear (Item.Value);
end if;
elsif Item.Is_Null /= 0 then
League.Holders.Clear (Item.Value);
end if;
end Fixup_Parameter;
Count : aliased Ub4;
Code : Error_Code;
begin -- Execute
if Self.State not in Ready then
return False;
end if;
Code :=
OCIStmtExecute
(Self.DB.Service,
Self.Handle,
Self.DB.Error,
Iters => Boolean'Pos (not Self.Is_Select));
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Self.Parameters.Iterate (Fixup_Parameter'Access);
if Self.Is_Select and not Self.Is_Described then
Self.Is_Described := True;
Self.Column_Count := 0;
Code :=
OCIAttrGet
(Target => Self.Handle,
Target_Type => OCI_HTYPE_STMT,
Buffer => Count'Address,
Length => null,
Attr => OCI_ATTR_PARAM_COUNT,
Error => Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
if Self.Columns /= null and then Self.Columns'Length < Count then
Free (Self.Columns);
end if;
if Self.Columns = null and Count > 0 then
Self.Columns := new Defined_Value_Array (1 .. Positive (Count));
end if;
for J in 1 .. Natural (Count) loop
declare
Param : aliased Parameter;
Column : Plug_In.Column_Description;
Plugin : Plug_In_Access := Plug_In_Access (Self.DB.Plugins);
Control : Plug_In.Control_Side := Plug_In.Driver;
begin
Code :=
OCIParamGet
(Self.Handle,
OCI_HTYPE_STMT,
Self.DB.Error,
Param'Access,
Ub4 (J));
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Code :=
OCIAttrGet
(Param,
OCI_DTYPE_PARAM,
Column.Column_Type'Address,
null,
OCI_ATTR_DATA_TYPE,
Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Code :=
OCIAttrGet
(Param,
OCI_DTYPE_PARAM,
Column.Size'Address,
null,
OCI_ATTR_DATA_SIZE,
Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Code :=
OCIAttrGet
(Param,
OCI_DTYPE_PARAM,
Column.Precision'Address,
null,
OCI_ATTR_PRECISION,
Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Code :=
OCIAttrGet
(Param,
OCI_DTYPE_PARAM,
Column.Scale'Address,
null,
OCI_ATTR_SCALE,
Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
-- Look for plugin
while Plugin /= null loop
Plugin.Check_Column
(Column,
Control,
Self.Columns (J).Extra_Type,
Self.Columns (J).Extra_Size);
exit when Control = Plug_In.Plug_In;
Plugin := Plugin.Next;
end loop;
Self.Columns (J).Plugin := Plugin;
if Plugin /= null then
-- Drop insufficient Extra space
if Self.Columns (J).Extra /= null and then
Self.Columns (J).Extra'Length < Self.Columns (J).Extra_Size
then
Free (Self.Columns (J).Extra);
end if;
-- Allocate Extra space
if Self.Columns (J).Extra = null then
Self.Columns (J).Extra := new
System.Storage_Elements.Storage_Array
(1 .. Self.Columns (J).Extra_Size);
end if;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).Extra (1)'Address,
Value_Length => Ub4 (Self.Columns (J).Extra_Size),
Value_Type => Self.Columns (J).Extra_Type,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
elsif Column.Column_Type in SQLT_CHR | SQLT_AFC then
Self.Columns (J).Column_Type := String_Column;
Self.Columns (J).Size :=
Utf16.Utf16_String_Index (Column.Size + 1);
declare
use Matreshka.Internals.Strings;
Ptr : Shared_String_Access
renames Self.Columns (J).String;
begin
if Ptr = null then
Ptr := Allocate (Self.Columns (J).Size);
elsif not Can_Be_Reused (Ptr, Self.Columns (J).Size) then
Dereference (Ptr);
Ptr := Allocate (Self.Columns (J).Size);
end if;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Ptr.Value (0)'Address,
Value_Length => Ptr.Value'Length * 2,
Value_Type => SQLT_STR,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
end;
elsif Column.Column_Type in
SQLT_NUM | SQLT_IBFLOAT | SQLT_IBDOUBLE
then
if Column.Column_Type = SQLT_NUM and Column.Scale = 0 then
Self.Columns (J).Column_Type := Integer_Column;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).Int'Address,
Value_Length => Self.Columns (J).Int'Size / 8,
Value_Type => SQLT_INT,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
else
Self.Columns (J).Column_Type := Float_Column;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).Float'Address,
Value_Length => Self.Columns (J).Float'Size / 8,
Value_Type => SQLT_FLT,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
end if;
elsif Column.Column_Type in SQLT_DAT then
Self.Columns (J).Column_Type := Date_Column;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).Date'Address,
Value_Length => Self.Columns (J).Date'Size / 8,
Value_Type => SQLT_ODT,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
elsif Column.Column_Type in
SQLT_TIMESTAMP | SQLT_TIMESTAMP_TZ | SQLT_TIMESTAMP_LTZ
then
if Self.Columns (J).Timestamp = null then
Code := OCIDescriptorAlloc
(Databases.Env,
Self.Columns (J).Timestamp'Access,
OCI_DTYPE_TIMESTAMP_TZ);
end if;
Self.Columns (J).Column_Type := Time_Column;
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).Timestamp'Address,
Value_Length => Self.Columns (J).Timestamp'Size / 8,
Value_Type => SQLT_TIMESTAMP_TZ,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
else
exit;
-- raise Constraint_Error with "Unsupported type";
end if;
Code := OCIDescriptorFree (Param, OCI_DTYPE_PARAM);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
end;
Self.Column_Count := J;
end loop;
end if;
if Self.Is_Select then
Self.State := Executed;
else
Self.State := No_More_Rows;
end if;
return True;
end Execute;
------------
-- Finish --
------------
overriding procedure Finish (Self : not null access OCI_Query) is
Code : Error_Code;
begin
if Self.State in Active then
if Self.State in Fetching then
-- Cancel cursor by fetching no rows
Code := OCIStmtFetch2 (Self.Handle, Self.DB.Error, Rows => 0);
if Databases.Check_Error (Self.DB, Code) then
null; -- How to report errors?
end if;
end if;
Self.State := Prepared;
end if;
end Finish;
----------------
-- Invalidate --
----------------
overriding procedure Invalidate (Self : not null access OCI_Query) is
procedure Drop (Pos : Parameter_Maps.Cursor);
----------
-- Drop --
----------
procedure Drop (Pos : Parameter_Maps.Cursor) is
Code : Error_Code;
Item : Bound_Value_Access := Parameter_Maps.Element (Pos);
begin
if Item /= null and then Item.Timestamp /= null then
Code := OCIHandleFree
(Item.Timestamp, OCI_DTYPE_TIMESTAMP_TZ);
if Databases.Check_Error (Self.DB, Code) then
null; -- How to report errors?
end if;
Item.Timestamp := null;
end if;
Free (Item);
Self.Parameters.Replace_Element (Pos, null);
end Drop;
Code : Error_Code;
begin
if Self.Handle /= null then
Code := OCIHandleFree (Self.Handle, OCI_HTYPE_STMT);
if Databases.Check_Error (Self.DB, Code) then
null; -- How to report errors?
end if;
Self.Handle := null;
end if;
Self.Parameters.Iterate (Drop'Access);
if Self.Columns /= null then
declare
use Matreshka.Internals.Strings;
begin
for J in Self.Columns'Range loop
if Self.Columns (J).String /= null then
Dereference (Self.Columns (J).String);
elsif Self.Columns (J).Timestamp /= null then
Code := OCIHandleFree
(Self.Columns (J).Timestamp, OCI_DTYPE_TIMESTAMP_TZ);
Self.Columns (J).Timestamp := null;
end if;
end loop;
Free (Self.Columns);
end;
end if;
-- Call Invalidate of parent tagged type.
Abstract_Query (Self.all).Invalidate;
end Invalidate;
---------------
-- Is_Active --
---------------
overriding function Is_Active
(Self : not null access OCI_Query) return Boolean is
begin
return Self.State in Active;
end Is_Active;
--------------
-- Is_Valid --
--------------
overriding function Is_Valid
(Self : not null access OCI_Query) return Boolean is
begin
return Self.State = Has_Row;
end Is_Valid;
----------
-- Next --
----------
overriding function Next
(Self : not null access OCI_Query) return Boolean
is
use Matreshka.Internals.Strings;
Ok : Boolean;
Code : Error_Code;
begin
if Self.State not in Fetching then
return False;
end if;
-- Rebind used strings columns
for J in 1 .. Self.Column_Count loop
if Self.Columns (J).Plugin = null
and then Self.Columns (J).Column_Type = String_Column
and then not Can_Be_Reused
(Self.Columns (J).String, Self.Columns (J).Size)
then
Dereference (Self.Columns (J).String);
Self.Columns (J).String := Allocate (Self.Columns (J).Size);
Code :=
OCIDefineByPos
(Stmt => Self.Handle,
Target => Self.Columns (J).Define'Access,
Error => Self.DB.Error,
Position => Ub4 (J),
Value => Self.Columns (J).String.Value (0)'Address,
Value_Length => Self.Columns (J).String.Value'Length * 2,
Value_Type => SQLT_STR,
Indicator => Self.Columns (J).Is_Null'Access);
if Databases.Check_Error (Self.DB, Code) then
Self.State := No_More_Rows;
return False;
end if;
end if;
end loop;
Code := OCIStmtFetch2 (Self.Handle, Self.DB.Error);
if Code = OCI_NO_DATA or else Databases.Check_Error (Self.DB, Code) then
Self.State := No_More_Rows;
else
Self.State := Has_Row;
-- validate not null string columns
for J in 1 .. Self.Column_Count loop
if Self.Columns (J).Column_Type = String_Column
and Self.Columns (J).Is_Null = 0
then
Matreshka.Internals.Strings.C.Validate_And_Fixup
(Self.Columns (J).String, Ok);
end if;
end loop;
end if;
return Self.State = Has_Row;
end Next;
-----------------------
-- OCICallbackInBind --
-----------------------
function OCICallbackInBind
(ictxp : Bound_Value_Access;
bindp : Oracle.Bind;
iter : Ub4;
index : Ub4;
bufpp : access Utf16_Code_Unit_Access;
alenp : access Ub4;
piecep : access Ub1;
indp : access Sb2_Ptr)
return Error_Code
is
pragma Unreferenced (bindp);
pragma Unreferenced (iter);
pragma Unreferenced (index);
begin
piecep.all := OCI_ONE_PIECE;
indp.all := ictxp.Is_Null'Access;
if ictxp.Is_Null = -1 then
bufpp.all := null;
alenp.all := 0;
return OCI_CONTINUE;
end if;
alenp.all :=
Ub4
(League.Strings.Internals.Internal
(League.Holders.Element (ictxp.Value)).Unused) * 2 + 2;
bufpp.all := League.Strings.Internals.Internal
(League.Holders.Element (ictxp.Value)).Value (0)'Access;
return OCI_CONTINUE;
end OCICallbackInBind;
------------------------
-- OCICallbackOutBind --
------------------------
function OCICallbackOutBind
(octxp : Bound_Value_Access;
bindp : Oracle.Bind;
iter : Ub4;
index : Ub4;
bufpp : access Utf16_Code_Unit_Access;
alenp : access Ub4_Ptr;
piecep : access Ub1;
indp : access Sb2_Ptr;
rcodepp : access Sb2_Ptr)
return Error_Code
is
pragma Unreferenced (bindp);
pragma Unreferenced (iter);
pragma Unreferenced (index);
pragma Unreferenced (Rcodepp);
use Matreshka.Internals.Strings;
use type Ub1;
use type Matreshka.Internals.Utf16.Utf16_String_Index;
begin
if piecep.all = OCI_ONE_PIECE then
piecep.all := OCI_FIRST_PIECE;
if not League.Holders.Is_Empty (octxp.Value) then
octxp.String := League.Strings.Internals.Internal
(League.Holders.Element (octxp.Value));
else
octxp.String := null;
end if;
if octxp.String /= null
and then Can_Be_Reused (octxp.String, octxp.String.Capacity - 1)
then
Reference (octxp.String);
League.Holders.Replace_Element
(octxp.Value, League.Strings.Empty_Universal_String);
else
octxp.String := Allocate (64); -- Some initial size
end if;
octxp.String.Unused := 0;
else
piecep.all := OCI_NEXT_PIECE;
octxp.String.Unused := octxp.String.Unused + octxp.String_Size;
Mutate (octxp.String, 8 * octxp.String.Capacity);
end if;
octxp.String_Size := Ub4
((octxp.String.Capacity - octxp.String.Unused) * 2);
bufpp.all := octxp.String.Value (octxp.String.Unused)'Access;
alenp.all := octxp.String_Size'Access;
indp.all := octxp.Is_Null'Access;
return OCI_CONTINUE;
end OCICallbackOutBind;
-------------
-- Prepare --
-------------
overriding function Prepare
(Self : not null access OCI_Query;
Query : League.Strings.Universal_String) return Boolean
is
Kind : aliased Ub2;
Code : Error_Code;
begin
if Self.Handle = null then
Code :=
OCIHandleAlloc (Databases.Env, Self.Handle'Access, OCI_HTYPE_STMT);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
end if;
Code :=
OCIStmtPrepare
(Self.Handle,
Self.DB.Error,
League.Strings.Internals.Internal (Query).Value,
Ub4 (League.Strings.Internals.Internal (Query).Unused) * 2);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Code :=
OCIAttrGet
(Target => Self.Handle,
Target_Type => OCI_HTYPE_STMT,
Buffer => Kind'Address,
Length => null,
Attr => OCI_ATTR_STMT_TYPE,
Error => Self.DB.Error);
if Databases.Check_Error (Self.DB, Code) then
return False;
end if;
Self.Is_Described := False;
Self.Is_Select := Kind = OCI_STMT_SELECT;
Self.State := Prepared;
return True;
end Prepare;
-----------
-- Value --
-----------
overriding function Value
(Self : not null access OCI_Query;
Index : Positive) return League.Holders.Holder
is
Value : League.Holders.Holder;
begin
if Self.State /= Has_Row or else Index > Self.Column_Count then
return Value;
elsif Self.Columns (Index).Plugin /= null then
if Self.Columns (Index).Is_Null = 0 then
Self.Columns (Index).Plugin.Decode
(Value, Self.Columns (Index).Extra
(1 .. Self.Columns (Index).Extra_Size));
end if;
elsif Self.Columns (Index).Column_Type = String_Column then
League.Holders.Set_Tag (Value, League.Holders.Universal_String_Tag);
if Self.Columns (Index).Is_Null = 0 then
League.Holders.Replace_Element
(Value,
League.Strings.Internals.Create (Self.Columns (Index).String));
end if;
elsif Self.Columns (Index).Column_Type = Integer_Column then
League.Holders.Set_Tag (Value, League.Holders.Universal_Integer_Tag);
if Self.Columns (Index).Is_Null = 0 then
League.Holders.Replace_Element
(Value, Self.Columns (Index).Int);
end if;
elsif Self.Columns (Index).Column_Type = Float_Column then
League.Holders.Set_Tag (Value, League.Holders.Universal_Float_Tag);
if Self.Columns (Index).Is_Null = 0 then
League.Holders.Replace_Element (Value, Self.Columns (Index).Float);
end if;
elsif Self.Columns (Index).Column_Type = Date_Column then
League.Holders.Set_Tag (Value, League.Holders.Date_Tag);
if Self.Columns (Index).Is_Null = 0 then
League.Holders.Replace_Element
(Value, Utils.Decode_Date (Self.Columns (Index).Date));
end if;
elsif Self.Columns (Index).Column_Type = Time_Column then
League.Holders.Set_Tag (Value, League.Holders.Date_Time_Tag);
if Self.Columns (Index).Is_Null = 0 then
declare
Aux : League.Calendars.Date_Time;
Code : Error_Code;
Year : aliased Sb2;
Month : aliased Ub1;
Day : aliased Ub1;
Hour : aliased Ub1;
Min : aliased Ub1;
Sec : aliased Ub1;
Fract : aliased Ub4;
begin
Code :=
OCIDateTimeGetDate
(Env => Databases.Env,
Error => Self.DB.Error,
Date => Self.Columns (Index).Timestamp,
Year => Year'Access,
Month => Month'Access,
Day => Day'Access);
if Databases.Check_Error (Self.DB, Code) then
return Value;
end if;
Code :=
OCIDateTimeGetTime
(Env => Databases.Env,
Error => Self.DB.Error,
Date => Self.Columns (Index).Timestamp,
Hour => Hour'Access,
Min => Min'Access,
Sec => Sec'Access,
Fract => Fract'Access);
if Databases.Check_Error (Self.DB, Code) then
return Value;
end if;
Aux := League.Calendars.ISO_8601.Create
(League.Calendars.ISO_8601.Year_Number (Year),
League.Calendars.ISO_8601.Month_Number (Month),
League.Calendars.ISO_8601.Day_Number (Day),
League.Calendars.ISO_8601.Hour_Number (Hour),
League.Calendars.ISO_8601.Minute_Number (Min),
League.Calendars.ISO_8601.Second_Number (Sec),
League.Calendars.ISO_8601.Nanosecond_100_Number
(Fract / 100));
-- ??? where timezone should go???
League.Holders.Replace_Element (Value, Aux);
end;
end if;
end if;
return Value;
end Value;
end Matreshka.Internals.SQL_Drivers.Oracle.Queries;
|
[
{
"context": " --\n-- This unit was originally developed by Matthew J Heaney. --\n----------------------------",
"end": 2111,
"score": 0.9997861385345459,
"start": 2095,
"tag": "NAME",
"value": "Matthew J Heaney"
}
] | gcc-gcc-7_3_0-release/gcc/ada/a-cbhama.adb | best08618/asylo | 7 | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- A D A . C O N T A I N E R S . B O U N D E D _ H A S H E D _ M A P S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2004-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
with Ada.Containers.Hash_Tables.Generic_Bounded_Operations;
pragma Elaborate_All (Ada.Containers.Hash_Tables.Generic_Bounded_Operations);
with Ada.Containers.Hash_Tables.Generic_Bounded_Keys;
pragma Elaborate_All (Ada.Containers.Hash_Tables.Generic_Bounded_Keys);
with Ada.Containers.Helpers; use Ada.Containers.Helpers;
with Ada.Containers.Prime_Numbers; use Ada.Containers.Prime_Numbers;
with System; use type System.Address;
package body Ada.Containers.Bounded_Hashed_Maps is
pragma Warnings (Off, "variable ""Busy*"" is not referenced");
pragma Warnings (Off, "variable ""Lock*"" is not referenced");
-- See comment in Ada.Containers.Helpers
-----------------------
-- Local Subprograms --
-----------------------
function Equivalent_Key_Node
(Key : Key_Type;
Node : Node_Type) return Boolean;
pragma Inline (Equivalent_Key_Node);
function Hash_Node (Node : Node_Type) return Hash_Type;
pragma Inline (Hash_Node);
function Next (Node : Node_Type) return Count_Type;
pragma Inline (Next);
procedure Set_Next (Node : in out Node_Type; Next : Count_Type);
pragma Inline (Set_Next);
function Vet (Position : Cursor) return Boolean;
--------------------------
-- Local Instantiations --
--------------------------
package HT_Ops is new Hash_Tables.Generic_Bounded_Operations
(HT_Types => HT_Types,
Hash_Node => Hash_Node,
Next => Next,
Set_Next => Set_Next);
package Key_Ops is new Hash_Tables.Generic_Bounded_Keys
(HT_Types => HT_Types,
Next => Next,
Set_Next => Set_Next,
Key_Type => Key_Type,
Hash => Hash,
Equivalent_Keys => Equivalent_Key_Node);
---------
-- "=" --
---------
function "=" (Left, Right : Map) return Boolean is
function Find_Equal_Key
(R_HT : Hash_Table_Type'Class;
L_Node : Node_Type) return Boolean;
function Is_Equal is new HT_Ops.Generic_Equal (Find_Equal_Key);
--------------------
-- Find_Equal_Key --
--------------------
function Find_Equal_Key
(R_HT : Hash_Table_Type'Class;
L_Node : Node_Type) return Boolean
is
R_Index : constant Hash_Type := Key_Ops.Index (R_HT, L_Node.Key);
R_Node : Count_Type := R_HT.Buckets (R_Index);
begin
while R_Node /= 0 loop
if Equivalent_Keys (L_Node.Key, R_HT.Nodes (R_Node).Key) then
return L_Node.Element = R_HT.Nodes (R_Node).Element;
end if;
R_Node := R_HT.Nodes (R_Node).Next;
end loop;
return False;
end Find_Equal_Key;
-- Start of processing for "="
begin
return Is_Equal (Left, Right);
end "=";
------------
-- Assign --
------------
procedure Assign (Target : in out Map; Source : Map) is
procedure Insert_Element (Source_Node : Count_Type);
procedure Insert_Elements is
new HT_Ops.Generic_Iteration (Insert_Element);
--------------------
-- Insert_Element --
--------------------
procedure Insert_Element (Source_Node : Count_Type) is
N : Node_Type renames Source.Nodes (Source_Node);
C : Cursor;
B : Boolean;
begin
Insert (Target, N.Key, N.Element, C, B);
pragma Assert (B);
end Insert_Element;
-- Start of processing for Assign
begin
if Target'Address = Source'Address then
return;
end if;
if Checks and then Target.Capacity < Source.Length then
raise Capacity_Error
with "Target capacity is less than Source length";
end if;
HT_Ops.Clear (Target);
Insert_Elements (Source);
end Assign;
--------------
-- Capacity --
--------------
function Capacity (Container : Map) return Count_Type is
begin
return Container.Capacity;
end Capacity;
-----------
-- Clear --
-----------
procedure Clear (Container : in out Map) is
begin
HT_Ops.Clear (Container);
end Clear;
------------------------
-- Constant_Reference --
------------------------
function Constant_Reference
(Container : aliased Map;
Position : Cursor) return Constant_Reference_Type
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with
"Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor designates wrong map";
end if;
pragma Assert (Vet (Position),
"Position cursor in Constant_Reference is bad");
declare
N : Node_Type renames Container.Nodes (Position.Node);
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Constant_Reference_Type :=
(Element => N.Element'Access,
Control => (Controlled with TC))
do
Lock (TC.all);
end return;
end;
end Constant_Reference;
function Constant_Reference
(Container : aliased Map;
Key : Key_Type) return Constant_Reference_Type
is
Node : constant Count_Type :=
Key_Ops.Find (Container'Unrestricted_Access.all, Key);
begin
if Checks and then Node = 0 then
raise Constraint_Error with "key not in map";
end if;
declare
N : Node_Type renames Container.Nodes (Node);
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Constant_Reference_Type :=
(Element => N.Element'Access,
Control => (Controlled with TC))
do
Lock (TC.all);
end return;
end;
end Constant_Reference;
--------------
-- Contains --
--------------
function Contains (Container : Map; Key : Key_Type) return Boolean is
begin
return Find (Container, Key) /= No_Element;
end Contains;
----------
-- Copy --
----------
function Copy
(Source : Map;
Capacity : Count_Type := 0;
Modulus : Hash_Type := 0) return Map
is
C : Count_Type;
M : Hash_Type;
begin
if Capacity = 0 then
C := Source.Length;
elsif Capacity >= Source.Length then
C := Capacity;
elsif Checks then
raise Capacity_Error with "Capacity value too small";
end if;
if Modulus = 0 then
M := Default_Modulus (C);
else
M := Modulus;
end if;
return Target : Map (Capacity => C, Modulus => M) do
Assign (Target => Target, Source => Source);
end return;
end Copy;
---------------------
-- Default_Modulus --
---------------------
function Default_Modulus (Capacity : Count_Type) return Hash_Type is
begin
return To_Prime (Capacity);
end Default_Modulus;
------------
-- Delete --
------------
procedure Delete (Container : in out Map; Key : Key_Type) is
X : Count_Type;
begin
Key_Ops.Delete_Key_Sans_Free (Container, Key, X);
if Checks and then X = 0 then
raise Constraint_Error with "attempt to delete key not in map";
end if;
HT_Ops.Free (Container, X);
end Delete;
procedure Delete (Container : in out Map; Position : in out Cursor) is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of Delete equals No_Element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor of Delete designates wrong map";
end if;
TC_Check (Container.TC);
pragma Assert (Vet (Position), "bad cursor in Delete");
HT_Ops.Delete_Node_Sans_Free (Container, Position.Node);
HT_Ops.Free (Container, Position.Node);
Position := No_Element;
end Delete;
-------------
-- Element --
-------------
function Element (Container : Map; Key : Key_Type) return Element_Type is
Node : constant Count_Type :=
Key_Ops.Find (Container'Unrestricted_Access.all, Key);
begin
if Checks and then Node = 0 then
raise Constraint_Error with
"no element available because key not in map";
end if;
return Container.Nodes (Node).Element;
end Element;
function Element (Position : Cursor) return Element_Type is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of function Element equals No_Element";
end if;
pragma Assert (Vet (Position), "bad cursor in function Element");
return Position.Container.Nodes (Position.Node).Element;
end Element;
-------------------------
-- Equivalent_Key_Node --
-------------------------
function Equivalent_Key_Node
(Key : Key_Type;
Node : Node_Type) return Boolean is
begin
return Equivalent_Keys (Key, Node.Key);
end Equivalent_Key_Node;
---------------------
-- Equivalent_Keys --
---------------------
function Equivalent_Keys (Left, Right : Cursor)
return Boolean is
begin
if Checks and then Left.Node = 0 then
raise Constraint_Error with
"Left cursor of Equivalent_Keys equals No_Element";
end if;
if Checks and then Right.Node = 0 then
raise Constraint_Error with
"Right cursor of Equivalent_Keys equals No_Element";
end if;
pragma Assert (Vet (Left), "Left cursor of Equivalent_Keys is bad");
pragma Assert (Vet (Right), "Right cursor of Equivalent_Keys is bad");
declare
LN : Node_Type renames Left.Container.Nodes (Left.Node);
RN : Node_Type renames Right.Container.Nodes (Right.Node);
begin
return Equivalent_Keys (LN.Key, RN.Key);
end;
end Equivalent_Keys;
function Equivalent_Keys (Left : Cursor; Right : Key_Type) return Boolean is
begin
if Checks and then Left.Node = 0 then
raise Constraint_Error with
"Left cursor of Equivalent_Keys equals No_Element";
end if;
pragma Assert (Vet (Left), "Left cursor in Equivalent_Keys is bad");
declare
LN : Node_Type renames Left.Container.Nodes (Left.Node);
begin
return Equivalent_Keys (LN.Key, Right);
end;
end Equivalent_Keys;
function Equivalent_Keys (Left : Key_Type; Right : Cursor) return Boolean is
begin
if Checks and then Right.Node = 0 then
raise Constraint_Error with
"Right cursor of Equivalent_Keys equals No_Element";
end if;
pragma Assert (Vet (Right), "Right cursor of Equivalent_Keys is bad");
declare
RN : Node_Type renames Right.Container.Nodes (Right.Node);
begin
return Equivalent_Keys (Left, RN.Key);
end;
end Equivalent_Keys;
-------------
-- Exclude --
-------------
procedure Exclude (Container : in out Map; Key : Key_Type) is
X : Count_Type;
begin
Key_Ops.Delete_Key_Sans_Free (Container, Key, X);
HT_Ops.Free (Container, X);
end Exclude;
--------------
-- Finalize --
--------------
procedure Finalize (Object : in out Iterator) is
begin
if Object.Container /= null then
Unbusy (Object.Container.TC);
end if;
end Finalize;
----------
-- Find --
----------
function Find (Container : Map; Key : Key_Type) return Cursor is
Node : constant Count_Type :=
Key_Ops.Find (Container'Unrestricted_Access.all, Key);
begin
if Node = 0 then
return No_Element;
else
return Cursor'(Container'Unrestricted_Access, Node);
end if;
end Find;
-----------
-- First --
-----------
function First (Container : Map) return Cursor is
Node : constant Count_Type := HT_Ops.First (Container);
begin
if Node = 0 then
return No_Element;
else
return Cursor'(Container'Unrestricted_Access, Node);
end if;
end First;
function First (Object : Iterator) return Cursor is
begin
return Object.Container.First;
end First;
------------------------
-- Get_Element_Access --
------------------------
function Get_Element_Access
(Position : Cursor) return not null Element_Access is
begin
return Position.Container.Nodes (Position.Node).Element'Access;
end Get_Element_Access;
-----------------
-- Has_Element --
-----------------
function Has_Element (Position : Cursor) return Boolean is
begin
pragma Assert (Vet (Position), "bad cursor in Has_Element");
return Position.Node /= 0;
end Has_Element;
---------------
-- Hash_Node --
---------------
function Hash_Node (Node : Node_Type) return Hash_Type is
begin
return Hash (Node.Key);
end Hash_Node;
-------------
-- Include --
-------------
procedure Include
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type)
is
Position : Cursor;
Inserted : Boolean;
begin
Insert (Container, Key, New_Item, Position, Inserted);
if not Inserted then
TE_Check (Container.TC);
declare
N : Node_Type renames Container.Nodes (Position.Node);
begin
N.Key := Key;
N.Element := New_Item;
end;
end if;
end Include;
------------
-- Insert --
------------
procedure Insert
(Container : in out Map;
Key : Key_Type;
Position : out Cursor;
Inserted : out Boolean)
is
procedure Assign_Key (Node : in out Node_Type);
pragma Inline (Assign_Key);
function New_Node return Count_Type;
pragma Inline (New_Node);
procedure Local_Insert is
new Key_Ops.Generic_Conditional_Insert (New_Node);
procedure Allocate is
new HT_Ops.Generic_Allocate (Assign_Key);
-----------------
-- Assign_Key --
-----------------
procedure Assign_Key (Node : in out Node_Type) is
New_Item : Element_Type;
pragma Unmodified (New_Item);
-- Default-initialized element (ok to reference, see below)
begin
Node.Key := Key;
-- There is no explicit element provided, but in an instance the
-- element type may be a scalar with a Default_Value aspect, or a
-- composite type with such a scalar component, or components with
-- default initialization, so insert a possibly initialized element
-- under the given key.
Node.Element := New_Item;
end Assign_Key;
--------------
-- New_Node --
--------------
function New_Node return Count_Type is
Result : Count_Type;
begin
Allocate (Container, Result);
return Result;
end New_Node;
-- Start of processing for Insert
begin
-- The buckets array length is specified by the user as a discriminant
-- of the container type, so it is possible for the buckets array to
-- have a length of zero. We must check for this case specifically, in
-- order to prevent divide-by-zero errors later, when we compute the
-- buckets array index value for a key, given its hash value.
if Checks and then Container.Buckets'Length = 0 then
raise Capacity_Error with "No capacity for insertion";
end if;
Local_Insert (Container, Key, Position.Node, Inserted);
Position.Container := Container'Unchecked_Access;
end Insert;
procedure Insert
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type;
Position : out Cursor;
Inserted : out Boolean)
is
procedure Assign_Key (Node : in out Node_Type);
pragma Inline (Assign_Key);
function New_Node return Count_Type;
pragma Inline (New_Node);
procedure Local_Insert is
new Key_Ops.Generic_Conditional_Insert (New_Node);
procedure Allocate is
new HT_Ops.Generic_Allocate (Assign_Key);
-----------------
-- Assign_Key --
-----------------
procedure Assign_Key (Node : in out Node_Type) is
begin
Node.Key := Key;
Node.Element := New_Item;
end Assign_Key;
--------------
-- New_Node --
--------------
function New_Node return Count_Type is
Result : Count_Type;
begin
Allocate (Container, Result);
return Result;
end New_Node;
-- Start of processing for Insert
begin
-- The buckets array length is specified by the user as a discriminant
-- of the container type, so it is possible for the buckets array to
-- have a length of zero. We must check for this case specifically, in
-- order to prevent divide-by-zero errors later, when we compute the
-- buckets array index value for a key, given its hash value.
if Checks and then Container.Buckets'Length = 0 then
raise Capacity_Error with "No capacity for insertion";
end if;
Local_Insert (Container, Key, Position.Node, Inserted);
Position.Container := Container'Unchecked_Access;
end Insert;
procedure Insert
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type)
is
Position : Cursor;
pragma Unreferenced (Position);
Inserted : Boolean;
begin
Insert (Container, Key, New_Item, Position, Inserted);
if Checks and then not Inserted then
raise Constraint_Error with
"attempt to insert key already in map";
end if;
end Insert;
--------------
-- Is_Empty --
--------------
function Is_Empty (Container : Map) return Boolean is
begin
return Container.Length = 0;
end Is_Empty;
-------------
-- Iterate --
-------------
procedure Iterate
(Container : Map;
Process : not null access procedure (Position : Cursor))
is
procedure Process_Node (Node : Count_Type);
pragma Inline (Process_Node);
procedure Local_Iterate is new HT_Ops.Generic_Iteration (Process_Node);
------------------
-- Process_Node --
------------------
procedure Process_Node (Node : Count_Type) is
begin
Process (Cursor'(Container'Unrestricted_Access, Node));
end Process_Node;
Busy : With_Busy (Container.TC'Unrestricted_Access);
-- Start of processing for Iterate
begin
Local_Iterate (Container);
end Iterate;
function Iterate
(Container : Map) return Map_Iterator_Interfaces.Forward_Iterator'Class
is
begin
return It : constant Iterator :=
(Limited_Controlled with
Container => Container'Unrestricted_Access)
do
Busy (Container.TC'Unrestricted_Access.all);
end return;
end Iterate;
---------
-- Key --
---------
function Key (Position : Cursor) return Key_Type is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of function Key equals No_Element";
end if;
pragma Assert (Vet (Position), "bad cursor in function Key");
return Position.Container.Nodes (Position.Node).Key;
end Key;
------------
-- Length --
------------
function Length (Container : Map) return Count_Type is
begin
return Container.Length;
end Length;
----------
-- Move --
----------
procedure Move
(Target : in out Map;
Source : in out Map)
is
begin
if Target'Address = Source'Address then
return;
end if;
TC_Check (Source.TC);
Target.Assign (Source);
Source.Clear;
end Move;
----------
-- Next --
----------
function Next (Node : Node_Type) return Count_Type is
begin
return Node.Next;
end Next;
function Next (Position : Cursor) return Cursor is
begin
if Position.Node = 0 then
return No_Element;
end if;
pragma Assert (Vet (Position), "bad cursor in function Next");
declare
M : Map renames Position.Container.all;
Node : constant Count_Type := HT_Ops.Next (M, Position.Node);
begin
if Node = 0 then
return No_Element;
else
return Cursor'(Position.Container, Node);
end if;
end;
end Next;
procedure Next (Position : in out Cursor) is
begin
Position := Next (Position);
end Next;
function Next
(Object : Iterator;
Position : Cursor) return Cursor
is
begin
if Position.Container = null then
return No_Element;
end if;
if Checks and then Position.Container /= Object.Container then
raise Program_Error with
"Position cursor of Next designates wrong map";
end if;
return Next (Position);
end Next;
----------------------
-- Pseudo_Reference --
----------------------
function Pseudo_Reference
(Container : aliased Map'Class) return Reference_Control_Type
is
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Reference_Control_Type := (Controlled with TC) do
Lock (TC.all);
end return;
end Pseudo_Reference;
-------------------
-- Query_Element --
-------------------
procedure Query_Element
(Position : Cursor;
Process : not null access
procedure (Key : Key_Type; Element : Element_Type))
is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of Query_Element equals No_Element";
end if;
pragma Assert (Vet (Position), "bad cursor in Query_Element");
declare
M : Map renames Position.Container.all;
N : Node_Type renames M.Nodes (Position.Node);
Lock : With_Lock (M.TC'Unrestricted_Access);
begin
Process (N.Key, N.Element);
end;
end Query_Element;
----------
-- Read --
----------
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Container : out Map)
is
function Read_Node
(Stream : not null access Root_Stream_Type'Class) return Count_Type;
-- pragma Inline (Read_Node); ???
procedure Read_Nodes is new HT_Ops.Generic_Read (Read_Node);
---------------
-- Read_Node --
---------------
function Read_Node
(Stream : not null access Root_Stream_Type'Class) return Count_Type
is
procedure Read_Element (Node : in out Node_Type);
-- pragma Inline (Read_Element); ???
procedure Allocate is
new HT_Ops.Generic_Allocate (Read_Element);
procedure Read_Element (Node : in out Node_Type) is
begin
Key_Type'Read (Stream, Node.Key);
Element_Type'Read (Stream, Node.Element);
end Read_Element;
Node : Count_Type;
-- Start of processing for Read_Node
begin
Allocate (Container, Node);
return Node;
end Read_Node;
-- Start of processing for Read
begin
Read_Nodes (Stream, Container);
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Cursor)
is
begin
raise Program_Error with "attempt to stream map cursor";
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Constant_Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Read;
---------------
-- Reference --
---------------
function Reference
(Container : aliased in out Map;
Position : Cursor) return Reference_Type
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with
"Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor designates wrong map";
end if;
pragma Assert (Vet (Position),
"Position cursor in function Reference is bad");
declare
N : Node_Type renames Container.Nodes (Position.Node);
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Reference_Type :=
(Element => N.Element'Access,
Control => (Controlled with TC))
do
Lock (TC.all);
end return;
end;
end Reference;
function Reference
(Container : aliased in out Map;
Key : Key_Type) return Reference_Type
is
Node : constant Count_Type := Key_Ops.Find (Container, Key);
begin
if Checks and then Node = 0 then
raise Constraint_Error with "key not in map";
end if;
declare
N : Node_Type renames Container.Nodes (Node);
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Reference_Type :=
(Element => N.Element'Access,
Control => (Controlled with TC))
do
Lock (TC.all);
end return;
end;
end Reference;
-------------
-- Replace --
-------------
procedure Replace
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type)
is
Node : constant Count_Type := Key_Ops.Find (Container, Key);
begin
if Checks and then Node = 0 then
raise Constraint_Error with
"attempt to replace key not in map";
end if;
TE_Check (Container.TC);
declare
N : Node_Type renames Container.Nodes (Node);
begin
N.Key := Key;
N.Element := New_Item;
end;
end Replace;
---------------------
-- Replace_Element --
---------------------
procedure Replace_Element
(Container : in out Map;
Position : Cursor;
New_Item : Element_Type)
is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of Replace_Element equals No_Element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor of Replace_Element designates wrong map";
end if;
TE_Check (Position.Container.TC);
pragma Assert (Vet (Position), "bad cursor in Replace_Element");
Container.Nodes (Position.Node).Element := New_Item;
end Replace_Element;
----------------------
-- Reserve_Capacity --
----------------------
procedure Reserve_Capacity
(Container : in out Map;
Capacity : Count_Type)
is
begin
if Checks and then Capacity > Container.Capacity then
raise Capacity_Error with "requested capacity is too large";
end if;
end Reserve_Capacity;
--------------
-- Set_Next --
--------------
procedure Set_Next (Node : in out Node_Type; Next : Count_Type) is
begin
Node.Next := Next;
end Set_Next;
--------------------
-- Update_Element --
--------------------
procedure Update_Element
(Container : in out Map;
Position : Cursor;
Process : not null access procedure (Key : Key_Type;
Element : in out Element_Type))
is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of Update_Element equals No_Element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor of Update_Element designates wrong map";
end if;
pragma Assert (Vet (Position), "bad cursor in Update_Element");
declare
N : Node_Type renames Container.Nodes (Position.Node);
Lock : With_Lock (Container.TC'Unrestricted_Access);
begin
Process (N.Key, N.Element);
end;
end Update_Element;
---------
-- Vet --
---------
function Vet (Position : Cursor) return Boolean is
begin
if Position.Node = 0 then
return Position.Container = null;
end if;
if Position.Container = null then
return False;
end if;
declare
M : Map renames Position.Container.all;
X : Count_Type;
begin
if M.Length = 0 then
return False;
end if;
if M.Capacity = 0 then
return False;
end if;
if M.Buckets'Length = 0 then
return False;
end if;
if Position.Node > M.Capacity then
return False;
end if;
if M.Nodes (Position.Node).Next = Position.Node then
return False;
end if;
X := M.Buckets (Key_Ops.Checked_Index
(M, M.Nodes (Position.Node).Key));
for J in 1 .. M.Length loop
if X = Position.Node then
return True;
end if;
if X = 0 then
return False;
end if;
if X = M.Nodes (X).Next then -- to prevent unnecessary looping
return False;
end if;
X := M.Nodes (X).Next;
end loop;
return False;
end;
end Vet;
-----------
-- Write --
-----------
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Container : Map)
is
procedure Write_Node
(Stream : not null access Root_Stream_Type'Class;
Node : Node_Type);
pragma Inline (Write_Node);
procedure Write_Nodes is new HT_Ops.Generic_Write (Write_Node);
----------------
-- Write_Node --
----------------
procedure Write_Node
(Stream : not null access Root_Stream_Type'Class;
Node : Node_Type)
is
begin
Key_Type'Write (Stream, Node.Key);
Element_Type'Write (Stream, Node.Element);
end Write_Node;
-- Start of processing for Write
begin
Write_Nodes (Stream, Container);
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Cursor)
is
begin
raise Program_Error with "attempt to stream map cursor";
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Constant_Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Write;
end Ada.Containers.Bounded_Hashed_Maps;
| 16278 | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- A D A . C O N T A I N E R S . B O U N D E D _ H A S H E D _ M A P S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2004-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- This unit was originally developed by <NAME>. --
------------------------------------------------------------------------------
with Ada.Containers.Hash_Tables.Generic_Bounded_Operations;
pragma Elaborate_All (Ada.Containers.Hash_Tables.Generic_Bounded_Operations);
with Ada.Containers.Hash_Tables.Generic_Bounded_Keys;
pragma Elaborate_All (Ada.Containers.Hash_Tables.Generic_Bounded_Keys);
with Ada.Containers.Helpers; use Ada.Containers.Helpers;
with Ada.Containers.Prime_Numbers; use Ada.Containers.Prime_Numbers;
with System; use type System.Address;
package body Ada.Containers.Bounded_Hashed_Maps is
pragma Warnings (Off, "variable ""Busy*"" is not referenced");
pragma Warnings (Off, "variable ""Lock*"" is not referenced");
-- See comment in Ada.Containers.Helpers
-----------------------
-- Local Subprograms --
-----------------------
function Equivalent_Key_Node
(Key : Key_Type;
Node : Node_Type) return Boolean;
pragma Inline (Equivalent_Key_Node);
function Hash_Node (Node : Node_Type) return Hash_Type;
pragma Inline (Hash_Node);
function Next (Node : Node_Type) return Count_Type;
pragma Inline (Next);
procedure Set_Next (Node : in out Node_Type; Next : Count_Type);
pragma Inline (Set_Next);
function Vet (Position : Cursor) return Boolean;
--------------------------
-- Local Instantiations --
--------------------------
package HT_Ops is new Hash_Tables.Generic_Bounded_Operations
(HT_Types => HT_Types,
Hash_Node => Hash_Node,
Next => Next,
Set_Next => Set_Next);
package Key_Ops is new Hash_Tables.Generic_Bounded_Keys
(HT_Types => HT_Types,
Next => Next,
Set_Next => Set_Next,
Key_Type => Key_Type,
Hash => Hash,
Equivalent_Keys => Equivalent_Key_Node);
---------
-- "=" --
---------
function "=" (Left, Right : Map) return Boolean is
function Find_Equal_Key
(R_HT : Hash_Table_Type'Class;
L_Node : Node_Type) return Boolean;
function Is_Equal is new HT_Ops.Generic_Equal (Find_Equal_Key);
--------------------
-- Find_Equal_Key --
--------------------
function Find_Equal_Key
(R_HT : Hash_Table_Type'Class;
L_Node : Node_Type) return Boolean
is
R_Index : constant Hash_Type := Key_Ops.Index (R_HT, L_Node.Key);
R_Node : Count_Type := R_HT.Buckets (R_Index);
begin
while R_Node /= 0 loop
if Equivalent_Keys (L_Node.Key, R_HT.Nodes (R_Node).Key) then
return L_Node.Element = R_HT.Nodes (R_Node).Element;
end if;
R_Node := R_HT.Nodes (R_Node).Next;
end loop;
return False;
end Find_Equal_Key;
-- Start of processing for "="
begin
return Is_Equal (Left, Right);
end "=";
------------
-- Assign --
------------
procedure Assign (Target : in out Map; Source : Map) is
procedure Insert_Element (Source_Node : Count_Type);
procedure Insert_Elements is
new HT_Ops.Generic_Iteration (Insert_Element);
--------------------
-- Insert_Element --
--------------------
procedure Insert_Element (Source_Node : Count_Type) is
N : Node_Type renames Source.Nodes (Source_Node);
C : Cursor;
B : Boolean;
begin
Insert (Target, N.Key, N.Element, C, B);
pragma Assert (B);
end Insert_Element;
-- Start of processing for Assign
begin
if Target'Address = Source'Address then
return;
end if;
if Checks and then Target.Capacity < Source.Length then
raise Capacity_Error
with "Target capacity is less than Source length";
end if;
HT_Ops.Clear (Target);
Insert_Elements (Source);
end Assign;
--------------
-- Capacity --
--------------
function Capacity (Container : Map) return Count_Type is
begin
return Container.Capacity;
end Capacity;
-----------
-- Clear --
-----------
procedure Clear (Container : in out Map) is
begin
HT_Ops.Clear (Container);
end Clear;
------------------------
-- Constant_Reference --
------------------------
function Constant_Reference
(Container : aliased Map;
Position : Cursor) return Constant_Reference_Type
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with
"Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor designates wrong map";
end if;
pragma Assert (Vet (Position),
"Position cursor in Constant_Reference is bad");
declare
N : Node_Type renames Container.Nodes (Position.Node);
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Constant_Reference_Type :=
(Element => N.Element'Access,
Control => (Controlled with TC))
do
Lock (TC.all);
end return;
end;
end Constant_Reference;
function Constant_Reference
(Container : aliased Map;
Key : Key_Type) return Constant_Reference_Type
is
Node : constant Count_Type :=
Key_Ops.Find (Container'Unrestricted_Access.all, Key);
begin
if Checks and then Node = 0 then
raise Constraint_Error with "key not in map";
end if;
declare
N : Node_Type renames Container.Nodes (Node);
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Constant_Reference_Type :=
(Element => N.Element'Access,
Control => (Controlled with TC))
do
Lock (TC.all);
end return;
end;
end Constant_Reference;
--------------
-- Contains --
--------------
function Contains (Container : Map; Key : Key_Type) return Boolean is
begin
return Find (Container, Key) /= No_Element;
end Contains;
----------
-- Copy --
----------
function Copy
(Source : Map;
Capacity : Count_Type := 0;
Modulus : Hash_Type := 0) return Map
is
C : Count_Type;
M : Hash_Type;
begin
if Capacity = 0 then
C := Source.Length;
elsif Capacity >= Source.Length then
C := Capacity;
elsif Checks then
raise Capacity_Error with "Capacity value too small";
end if;
if Modulus = 0 then
M := Default_Modulus (C);
else
M := Modulus;
end if;
return Target : Map (Capacity => C, Modulus => M) do
Assign (Target => Target, Source => Source);
end return;
end Copy;
---------------------
-- Default_Modulus --
---------------------
function Default_Modulus (Capacity : Count_Type) return Hash_Type is
begin
return To_Prime (Capacity);
end Default_Modulus;
------------
-- Delete --
------------
procedure Delete (Container : in out Map; Key : Key_Type) is
X : Count_Type;
begin
Key_Ops.Delete_Key_Sans_Free (Container, Key, X);
if Checks and then X = 0 then
raise Constraint_Error with "attempt to delete key not in map";
end if;
HT_Ops.Free (Container, X);
end Delete;
procedure Delete (Container : in out Map; Position : in out Cursor) is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of Delete equals No_Element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor of Delete designates wrong map";
end if;
TC_Check (Container.TC);
pragma Assert (Vet (Position), "bad cursor in Delete");
HT_Ops.Delete_Node_Sans_Free (Container, Position.Node);
HT_Ops.Free (Container, Position.Node);
Position := No_Element;
end Delete;
-------------
-- Element --
-------------
function Element (Container : Map; Key : Key_Type) return Element_Type is
Node : constant Count_Type :=
Key_Ops.Find (Container'Unrestricted_Access.all, Key);
begin
if Checks and then Node = 0 then
raise Constraint_Error with
"no element available because key not in map";
end if;
return Container.Nodes (Node).Element;
end Element;
function Element (Position : Cursor) return Element_Type is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of function Element equals No_Element";
end if;
pragma Assert (Vet (Position), "bad cursor in function Element");
return Position.Container.Nodes (Position.Node).Element;
end Element;
-------------------------
-- Equivalent_Key_Node --
-------------------------
function Equivalent_Key_Node
(Key : Key_Type;
Node : Node_Type) return Boolean is
begin
return Equivalent_Keys (Key, Node.Key);
end Equivalent_Key_Node;
---------------------
-- Equivalent_Keys --
---------------------
function Equivalent_Keys (Left, Right : Cursor)
return Boolean is
begin
if Checks and then Left.Node = 0 then
raise Constraint_Error with
"Left cursor of Equivalent_Keys equals No_Element";
end if;
if Checks and then Right.Node = 0 then
raise Constraint_Error with
"Right cursor of Equivalent_Keys equals No_Element";
end if;
pragma Assert (Vet (Left), "Left cursor of Equivalent_Keys is bad");
pragma Assert (Vet (Right), "Right cursor of Equivalent_Keys is bad");
declare
LN : Node_Type renames Left.Container.Nodes (Left.Node);
RN : Node_Type renames Right.Container.Nodes (Right.Node);
begin
return Equivalent_Keys (LN.Key, RN.Key);
end;
end Equivalent_Keys;
function Equivalent_Keys (Left : Cursor; Right : Key_Type) return Boolean is
begin
if Checks and then Left.Node = 0 then
raise Constraint_Error with
"Left cursor of Equivalent_Keys equals No_Element";
end if;
pragma Assert (Vet (Left), "Left cursor in Equivalent_Keys is bad");
declare
LN : Node_Type renames Left.Container.Nodes (Left.Node);
begin
return Equivalent_Keys (LN.Key, Right);
end;
end Equivalent_Keys;
function Equivalent_Keys (Left : Key_Type; Right : Cursor) return Boolean is
begin
if Checks and then Right.Node = 0 then
raise Constraint_Error with
"Right cursor of Equivalent_Keys equals No_Element";
end if;
pragma Assert (Vet (Right), "Right cursor of Equivalent_Keys is bad");
declare
RN : Node_Type renames Right.Container.Nodes (Right.Node);
begin
return Equivalent_Keys (Left, RN.Key);
end;
end Equivalent_Keys;
-------------
-- Exclude --
-------------
procedure Exclude (Container : in out Map; Key : Key_Type) is
X : Count_Type;
begin
Key_Ops.Delete_Key_Sans_Free (Container, Key, X);
HT_Ops.Free (Container, X);
end Exclude;
--------------
-- Finalize --
--------------
procedure Finalize (Object : in out Iterator) is
begin
if Object.Container /= null then
Unbusy (Object.Container.TC);
end if;
end Finalize;
----------
-- Find --
----------
function Find (Container : Map; Key : Key_Type) return Cursor is
Node : constant Count_Type :=
Key_Ops.Find (Container'Unrestricted_Access.all, Key);
begin
if Node = 0 then
return No_Element;
else
return Cursor'(Container'Unrestricted_Access, Node);
end if;
end Find;
-----------
-- First --
-----------
function First (Container : Map) return Cursor is
Node : constant Count_Type := HT_Ops.First (Container);
begin
if Node = 0 then
return No_Element;
else
return Cursor'(Container'Unrestricted_Access, Node);
end if;
end First;
function First (Object : Iterator) return Cursor is
begin
return Object.Container.First;
end First;
------------------------
-- Get_Element_Access --
------------------------
function Get_Element_Access
(Position : Cursor) return not null Element_Access is
begin
return Position.Container.Nodes (Position.Node).Element'Access;
end Get_Element_Access;
-----------------
-- Has_Element --
-----------------
function Has_Element (Position : Cursor) return Boolean is
begin
pragma Assert (Vet (Position), "bad cursor in Has_Element");
return Position.Node /= 0;
end Has_Element;
---------------
-- Hash_Node --
---------------
function Hash_Node (Node : Node_Type) return Hash_Type is
begin
return Hash (Node.Key);
end Hash_Node;
-------------
-- Include --
-------------
procedure Include
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type)
is
Position : Cursor;
Inserted : Boolean;
begin
Insert (Container, Key, New_Item, Position, Inserted);
if not Inserted then
TE_Check (Container.TC);
declare
N : Node_Type renames Container.Nodes (Position.Node);
begin
N.Key := Key;
N.Element := New_Item;
end;
end if;
end Include;
------------
-- Insert --
------------
procedure Insert
(Container : in out Map;
Key : Key_Type;
Position : out Cursor;
Inserted : out Boolean)
is
procedure Assign_Key (Node : in out Node_Type);
pragma Inline (Assign_Key);
function New_Node return Count_Type;
pragma Inline (New_Node);
procedure Local_Insert is
new Key_Ops.Generic_Conditional_Insert (New_Node);
procedure Allocate is
new HT_Ops.Generic_Allocate (Assign_Key);
-----------------
-- Assign_Key --
-----------------
procedure Assign_Key (Node : in out Node_Type) is
New_Item : Element_Type;
pragma Unmodified (New_Item);
-- Default-initialized element (ok to reference, see below)
begin
Node.Key := Key;
-- There is no explicit element provided, but in an instance the
-- element type may be a scalar with a Default_Value aspect, or a
-- composite type with such a scalar component, or components with
-- default initialization, so insert a possibly initialized element
-- under the given key.
Node.Element := New_Item;
end Assign_Key;
--------------
-- New_Node --
--------------
function New_Node return Count_Type is
Result : Count_Type;
begin
Allocate (Container, Result);
return Result;
end New_Node;
-- Start of processing for Insert
begin
-- The buckets array length is specified by the user as a discriminant
-- of the container type, so it is possible for the buckets array to
-- have a length of zero. We must check for this case specifically, in
-- order to prevent divide-by-zero errors later, when we compute the
-- buckets array index value for a key, given its hash value.
if Checks and then Container.Buckets'Length = 0 then
raise Capacity_Error with "No capacity for insertion";
end if;
Local_Insert (Container, Key, Position.Node, Inserted);
Position.Container := Container'Unchecked_Access;
end Insert;
procedure Insert
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type;
Position : out Cursor;
Inserted : out Boolean)
is
procedure Assign_Key (Node : in out Node_Type);
pragma Inline (Assign_Key);
function New_Node return Count_Type;
pragma Inline (New_Node);
procedure Local_Insert is
new Key_Ops.Generic_Conditional_Insert (New_Node);
procedure Allocate is
new HT_Ops.Generic_Allocate (Assign_Key);
-----------------
-- Assign_Key --
-----------------
procedure Assign_Key (Node : in out Node_Type) is
begin
Node.Key := Key;
Node.Element := New_Item;
end Assign_Key;
--------------
-- New_Node --
--------------
function New_Node return Count_Type is
Result : Count_Type;
begin
Allocate (Container, Result);
return Result;
end New_Node;
-- Start of processing for Insert
begin
-- The buckets array length is specified by the user as a discriminant
-- of the container type, so it is possible for the buckets array to
-- have a length of zero. We must check for this case specifically, in
-- order to prevent divide-by-zero errors later, when we compute the
-- buckets array index value for a key, given its hash value.
if Checks and then Container.Buckets'Length = 0 then
raise Capacity_Error with "No capacity for insertion";
end if;
Local_Insert (Container, Key, Position.Node, Inserted);
Position.Container := Container'Unchecked_Access;
end Insert;
procedure Insert
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type)
is
Position : Cursor;
pragma Unreferenced (Position);
Inserted : Boolean;
begin
Insert (Container, Key, New_Item, Position, Inserted);
if Checks and then not Inserted then
raise Constraint_Error with
"attempt to insert key already in map";
end if;
end Insert;
--------------
-- Is_Empty --
--------------
function Is_Empty (Container : Map) return Boolean is
begin
return Container.Length = 0;
end Is_Empty;
-------------
-- Iterate --
-------------
procedure Iterate
(Container : Map;
Process : not null access procedure (Position : Cursor))
is
procedure Process_Node (Node : Count_Type);
pragma Inline (Process_Node);
procedure Local_Iterate is new HT_Ops.Generic_Iteration (Process_Node);
------------------
-- Process_Node --
------------------
procedure Process_Node (Node : Count_Type) is
begin
Process (Cursor'(Container'Unrestricted_Access, Node));
end Process_Node;
Busy : With_Busy (Container.TC'Unrestricted_Access);
-- Start of processing for Iterate
begin
Local_Iterate (Container);
end Iterate;
function Iterate
(Container : Map) return Map_Iterator_Interfaces.Forward_Iterator'Class
is
begin
return It : constant Iterator :=
(Limited_Controlled with
Container => Container'Unrestricted_Access)
do
Busy (Container.TC'Unrestricted_Access.all);
end return;
end Iterate;
---------
-- Key --
---------
function Key (Position : Cursor) return Key_Type is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of function Key equals No_Element";
end if;
pragma Assert (Vet (Position), "bad cursor in function Key");
return Position.Container.Nodes (Position.Node).Key;
end Key;
------------
-- Length --
------------
function Length (Container : Map) return Count_Type is
begin
return Container.Length;
end Length;
----------
-- Move --
----------
procedure Move
(Target : in out Map;
Source : in out Map)
is
begin
if Target'Address = Source'Address then
return;
end if;
TC_Check (Source.TC);
Target.Assign (Source);
Source.Clear;
end Move;
----------
-- Next --
----------
function Next (Node : Node_Type) return Count_Type is
begin
return Node.Next;
end Next;
function Next (Position : Cursor) return Cursor is
begin
if Position.Node = 0 then
return No_Element;
end if;
pragma Assert (Vet (Position), "bad cursor in function Next");
declare
M : Map renames Position.Container.all;
Node : constant Count_Type := HT_Ops.Next (M, Position.Node);
begin
if Node = 0 then
return No_Element;
else
return Cursor'(Position.Container, Node);
end if;
end;
end Next;
procedure Next (Position : in out Cursor) is
begin
Position := Next (Position);
end Next;
function Next
(Object : Iterator;
Position : Cursor) return Cursor
is
begin
if Position.Container = null then
return No_Element;
end if;
if Checks and then Position.Container /= Object.Container then
raise Program_Error with
"Position cursor of Next designates wrong map";
end if;
return Next (Position);
end Next;
----------------------
-- Pseudo_Reference --
----------------------
function Pseudo_Reference
(Container : aliased Map'Class) return Reference_Control_Type
is
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Reference_Control_Type := (Controlled with TC) do
Lock (TC.all);
end return;
end Pseudo_Reference;
-------------------
-- Query_Element --
-------------------
procedure Query_Element
(Position : Cursor;
Process : not null access
procedure (Key : Key_Type; Element : Element_Type))
is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of Query_Element equals No_Element";
end if;
pragma Assert (Vet (Position), "bad cursor in Query_Element");
declare
M : Map renames Position.Container.all;
N : Node_Type renames M.Nodes (Position.Node);
Lock : With_Lock (M.TC'Unrestricted_Access);
begin
Process (N.Key, N.Element);
end;
end Query_Element;
----------
-- Read --
----------
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Container : out Map)
is
function Read_Node
(Stream : not null access Root_Stream_Type'Class) return Count_Type;
-- pragma Inline (Read_Node); ???
procedure Read_Nodes is new HT_Ops.Generic_Read (Read_Node);
---------------
-- Read_Node --
---------------
function Read_Node
(Stream : not null access Root_Stream_Type'Class) return Count_Type
is
procedure Read_Element (Node : in out Node_Type);
-- pragma Inline (Read_Element); ???
procedure Allocate is
new HT_Ops.Generic_Allocate (Read_Element);
procedure Read_Element (Node : in out Node_Type) is
begin
Key_Type'Read (Stream, Node.Key);
Element_Type'Read (Stream, Node.Element);
end Read_Element;
Node : Count_Type;
-- Start of processing for Read_Node
begin
Allocate (Container, Node);
return Node;
end Read_Node;
-- Start of processing for Read
begin
Read_Nodes (Stream, Container);
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Cursor)
is
begin
raise Program_Error with "attempt to stream map cursor";
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Constant_Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Read;
---------------
-- Reference --
---------------
function Reference
(Container : aliased in out Map;
Position : Cursor) return Reference_Type
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with
"Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor designates wrong map";
end if;
pragma Assert (Vet (Position),
"Position cursor in function Reference is bad");
declare
N : Node_Type renames Container.Nodes (Position.Node);
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Reference_Type :=
(Element => N.Element'Access,
Control => (Controlled with TC))
do
Lock (TC.all);
end return;
end;
end Reference;
function Reference
(Container : aliased in out Map;
Key : Key_Type) return Reference_Type
is
Node : constant Count_Type := Key_Ops.Find (Container, Key);
begin
if Checks and then Node = 0 then
raise Constraint_Error with "key not in map";
end if;
declare
N : Node_Type renames Container.Nodes (Node);
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Reference_Type :=
(Element => N.Element'Access,
Control => (Controlled with TC))
do
Lock (TC.all);
end return;
end;
end Reference;
-------------
-- Replace --
-------------
procedure Replace
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type)
is
Node : constant Count_Type := Key_Ops.Find (Container, Key);
begin
if Checks and then Node = 0 then
raise Constraint_Error with
"attempt to replace key not in map";
end if;
TE_Check (Container.TC);
declare
N : Node_Type renames Container.Nodes (Node);
begin
N.Key := Key;
N.Element := New_Item;
end;
end Replace;
---------------------
-- Replace_Element --
---------------------
procedure Replace_Element
(Container : in out Map;
Position : Cursor;
New_Item : Element_Type)
is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of Replace_Element equals No_Element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor of Replace_Element designates wrong map";
end if;
TE_Check (Position.Container.TC);
pragma Assert (Vet (Position), "bad cursor in Replace_Element");
Container.Nodes (Position.Node).Element := New_Item;
end Replace_Element;
----------------------
-- Reserve_Capacity --
----------------------
procedure Reserve_Capacity
(Container : in out Map;
Capacity : Count_Type)
is
begin
if Checks and then Capacity > Container.Capacity then
raise Capacity_Error with "requested capacity is too large";
end if;
end Reserve_Capacity;
--------------
-- Set_Next --
--------------
procedure Set_Next (Node : in out Node_Type; Next : Count_Type) is
begin
Node.Next := Next;
end Set_Next;
--------------------
-- Update_Element --
--------------------
procedure Update_Element
(Container : in out Map;
Position : Cursor;
Process : not null access procedure (Key : Key_Type;
Element : in out Element_Type))
is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of Update_Element equals No_Element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor of Update_Element designates wrong map";
end if;
pragma Assert (Vet (Position), "bad cursor in Update_Element");
declare
N : Node_Type renames Container.Nodes (Position.Node);
Lock : With_Lock (Container.TC'Unrestricted_Access);
begin
Process (N.Key, N.Element);
end;
end Update_Element;
---------
-- Vet --
---------
function Vet (Position : Cursor) return Boolean is
begin
if Position.Node = 0 then
return Position.Container = null;
end if;
if Position.Container = null then
return False;
end if;
declare
M : Map renames Position.Container.all;
X : Count_Type;
begin
if M.Length = 0 then
return False;
end if;
if M.Capacity = 0 then
return False;
end if;
if M.Buckets'Length = 0 then
return False;
end if;
if Position.Node > M.Capacity then
return False;
end if;
if M.Nodes (Position.Node).Next = Position.Node then
return False;
end if;
X := M.Buckets (Key_Ops.Checked_Index
(M, M.Nodes (Position.Node).Key));
for J in 1 .. M.Length loop
if X = Position.Node then
return True;
end if;
if X = 0 then
return False;
end if;
if X = M.Nodes (X).Next then -- to prevent unnecessary looping
return False;
end if;
X := M.Nodes (X).Next;
end loop;
return False;
end;
end Vet;
-----------
-- Write --
-----------
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Container : Map)
is
procedure Write_Node
(Stream : not null access Root_Stream_Type'Class;
Node : Node_Type);
pragma Inline (Write_Node);
procedure Write_Nodes is new HT_Ops.Generic_Write (Write_Node);
----------------
-- Write_Node --
----------------
procedure Write_Node
(Stream : not null access Root_Stream_Type'Class;
Node : Node_Type)
is
begin
Key_Type'Write (Stream, Node.Key);
Element_Type'Write (Stream, Node.Element);
end Write_Node;
-- Start of processing for Write
begin
Write_Nodes (Stream, Container);
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Cursor)
is
begin
raise Program_Error with "attempt to stream map cursor";
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Constant_Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Write;
end Ada.Containers.Bounded_Hashed_Maps;
| true | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- A D A . C O N T A I N E R S . B O U N D E D _ H A S H E D _ M A P S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2004-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- This unit was originally developed by PI:NAME:<NAME>END_PI. --
------------------------------------------------------------------------------
with Ada.Containers.Hash_Tables.Generic_Bounded_Operations;
pragma Elaborate_All (Ada.Containers.Hash_Tables.Generic_Bounded_Operations);
with Ada.Containers.Hash_Tables.Generic_Bounded_Keys;
pragma Elaborate_All (Ada.Containers.Hash_Tables.Generic_Bounded_Keys);
with Ada.Containers.Helpers; use Ada.Containers.Helpers;
with Ada.Containers.Prime_Numbers; use Ada.Containers.Prime_Numbers;
with System; use type System.Address;
package body Ada.Containers.Bounded_Hashed_Maps is
pragma Warnings (Off, "variable ""Busy*"" is not referenced");
pragma Warnings (Off, "variable ""Lock*"" is not referenced");
-- See comment in Ada.Containers.Helpers
-----------------------
-- Local Subprograms --
-----------------------
function Equivalent_Key_Node
(Key : Key_Type;
Node : Node_Type) return Boolean;
pragma Inline (Equivalent_Key_Node);
function Hash_Node (Node : Node_Type) return Hash_Type;
pragma Inline (Hash_Node);
function Next (Node : Node_Type) return Count_Type;
pragma Inline (Next);
procedure Set_Next (Node : in out Node_Type; Next : Count_Type);
pragma Inline (Set_Next);
function Vet (Position : Cursor) return Boolean;
--------------------------
-- Local Instantiations --
--------------------------
package HT_Ops is new Hash_Tables.Generic_Bounded_Operations
(HT_Types => HT_Types,
Hash_Node => Hash_Node,
Next => Next,
Set_Next => Set_Next);
package Key_Ops is new Hash_Tables.Generic_Bounded_Keys
(HT_Types => HT_Types,
Next => Next,
Set_Next => Set_Next,
Key_Type => Key_Type,
Hash => Hash,
Equivalent_Keys => Equivalent_Key_Node);
---------
-- "=" --
---------
function "=" (Left, Right : Map) return Boolean is
function Find_Equal_Key
(R_HT : Hash_Table_Type'Class;
L_Node : Node_Type) return Boolean;
function Is_Equal is new HT_Ops.Generic_Equal (Find_Equal_Key);
--------------------
-- Find_Equal_Key --
--------------------
function Find_Equal_Key
(R_HT : Hash_Table_Type'Class;
L_Node : Node_Type) return Boolean
is
R_Index : constant Hash_Type := Key_Ops.Index (R_HT, L_Node.Key);
R_Node : Count_Type := R_HT.Buckets (R_Index);
begin
while R_Node /= 0 loop
if Equivalent_Keys (L_Node.Key, R_HT.Nodes (R_Node).Key) then
return L_Node.Element = R_HT.Nodes (R_Node).Element;
end if;
R_Node := R_HT.Nodes (R_Node).Next;
end loop;
return False;
end Find_Equal_Key;
-- Start of processing for "="
begin
return Is_Equal (Left, Right);
end "=";
------------
-- Assign --
------------
procedure Assign (Target : in out Map; Source : Map) is
procedure Insert_Element (Source_Node : Count_Type);
procedure Insert_Elements is
new HT_Ops.Generic_Iteration (Insert_Element);
--------------------
-- Insert_Element --
--------------------
procedure Insert_Element (Source_Node : Count_Type) is
N : Node_Type renames Source.Nodes (Source_Node);
C : Cursor;
B : Boolean;
begin
Insert (Target, N.Key, N.Element, C, B);
pragma Assert (B);
end Insert_Element;
-- Start of processing for Assign
begin
if Target'Address = Source'Address then
return;
end if;
if Checks and then Target.Capacity < Source.Length then
raise Capacity_Error
with "Target capacity is less than Source length";
end if;
HT_Ops.Clear (Target);
Insert_Elements (Source);
end Assign;
--------------
-- Capacity --
--------------
function Capacity (Container : Map) return Count_Type is
begin
return Container.Capacity;
end Capacity;
-----------
-- Clear --
-----------
procedure Clear (Container : in out Map) is
begin
HT_Ops.Clear (Container);
end Clear;
------------------------
-- Constant_Reference --
------------------------
function Constant_Reference
(Container : aliased Map;
Position : Cursor) return Constant_Reference_Type
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with
"Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor designates wrong map";
end if;
pragma Assert (Vet (Position),
"Position cursor in Constant_Reference is bad");
declare
N : Node_Type renames Container.Nodes (Position.Node);
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Constant_Reference_Type :=
(Element => N.Element'Access,
Control => (Controlled with TC))
do
Lock (TC.all);
end return;
end;
end Constant_Reference;
function Constant_Reference
(Container : aliased Map;
Key : Key_Type) return Constant_Reference_Type
is
Node : constant Count_Type :=
Key_Ops.Find (Container'Unrestricted_Access.all, Key);
begin
if Checks and then Node = 0 then
raise Constraint_Error with "key not in map";
end if;
declare
N : Node_Type renames Container.Nodes (Node);
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Constant_Reference_Type :=
(Element => N.Element'Access,
Control => (Controlled with TC))
do
Lock (TC.all);
end return;
end;
end Constant_Reference;
--------------
-- Contains --
--------------
function Contains (Container : Map; Key : Key_Type) return Boolean is
begin
return Find (Container, Key) /= No_Element;
end Contains;
----------
-- Copy --
----------
function Copy
(Source : Map;
Capacity : Count_Type := 0;
Modulus : Hash_Type := 0) return Map
is
C : Count_Type;
M : Hash_Type;
begin
if Capacity = 0 then
C := Source.Length;
elsif Capacity >= Source.Length then
C := Capacity;
elsif Checks then
raise Capacity_Error with "Capacity value too small";
end if;
if Modulus = 0 then
M := Default_Modulus (C);
else
M := Modulus;
end if;
return Target : Map (Capacity => C, Modulus => M) do
Assign (Target => Target, Source => Source);
end return;
end Copy;
---------------------
-- Default_Modulus --
---------------------
function Default_Modulus (Capacity : Count_Type) return Hash_Type is
begin
return To_Prime (Capacity);
end Default_Modulus;
------------
-- Delete --
------------
procedure Delete (Container : in out Map; Key : Key_Type) is
X : Count_Type;
begin
Key_Ops.Delete_Key_Sans_Free (Container, Key, X);
if Checks and then X = 0 then
raise Constraint_Error with "attempt to delete key not in map";
end if;
HT_Ops.Free (Container, X);
end Delete;
procedure Delete (Container : in out Map; Position : in out Cursor) is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of Delete equals No_Element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor of Delete designates wrong map";
end if;
TC_Check (Container.TC);
pragma Assert (Vet (Position), "bad cursor in Delete");
HT_Ops.Delete_Node_Sans_Free (Container, Position.Node);
HT_Ops.Free (Container, Position.Node);
Position := No_Element;
end Delete;
-------------
-- Element --
-------------
function Element (Container : Map; Key : Key_Type) return Element_Type is
Node : constant Count_Type :=
Key_Ops.Find (Container'Unrestricted_Access.all, Key);
begin
if Checks and then Node = 0 then
raise Constraint_Error with
"no element available because key not in map";
end if;
return Container.Nodes (Node).Element;
end Element;
function Element (Position : Cursor) return Element_Type is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of function Element equals No_Element";
end if;
pragma Assert (Vet (Position), "bad cursor in function Element");
return Position.Container.Nodes (Position.Node).Element;
end Element;
-------------------------
-- Equivalent_Key_Node --
-------------------------
function Equivalent_Key_Node
(Key : Key_Type;
Node : Node_Type) return Boolean is
begin
return Equivalent_Keys (Key, Node.Key);
end Equivalent_Key_Node;
---------------------
-- Equivalent_Keys --
---------------------
function Equivalent_Keys (Left, Right : Cursor)
return Boolean is
begin
if Checks and then Left.Node = 0 then
raise Constraint_Error with
"Left cursor of Equivalent_Keys equals No_Element";
end if;
if Checks and then Right.Node = 0 then
raise Constraint_Error with
"Right cursor of Equivalent_Keys equals No_Element";
end if;
pragma Assert (Vet (Left), "Left cursor of Equivalent_Keys is bad");
pragma Assert (Vet (Right), "Right cursor of Equivalent_Keys is bad");
declare
LN : Node_Type renames Left.Container.Nodes (Left.Node);
RN : Node_Type renames Right.Container.Nodes (Right.Node);
begin
return Equivalent_Keys (LN.Key, RN.Key);
end;
end Equivalent_Keys;
function Equivalent_Keys (Left : Cursor; Right : Key_Type) return Boolean is
begin
if Checks and then Left.Node = 0 then
raise Constraint_Error with
"Left cursor of Equivalent_Keys equals No_Element";
end if;
pragma Assert (Vet (Left), "Left cursor in Equivalent_Keys is bad");
declare
LN : Node_Type renames Left.Container.Nodes (Left.Node);
begin
return Equivalent_Keys (LN.Key, Right);
end;
end Equivalent_Keys;
function Equivalent_Keys (Left : Key_Type; Right : Cursor) return Boolean is
begin
if Checks and then Right.Node = 0 then
raise Constraint_Error with
"Right cursor of Equivalent_Keys equals No_Element";
end if;
pragma Assert (Vet (Right), "Right cursor of Equivalent_Keys is bad");
declare
RN : Node_Type renames Right.Container.Nodes (Right.Node);
begin
return Equivalent_Keys (Left, RN.Key);
end;
end Equivalent_Keys;
-------------
-- Exclude --
-------------
procedure Exclude (Container : in out Map; Key : Key_Type) is
X : Count_Type;
begin
Key_Ops.Delete_Key_Sans_Free (Container, Key, X);
HT_Ops.Free (Container, X);
end Exclude;
--------------
-- Finalize --
--------------
procedure Finalize (Object : in out Iterator) is
begin
if Object.Container /= null then
Unbusy (Object.Container.TC);
end if;
end Finalize;
----------
-- Find --
----------
function Find (Container : Map; Key : Key_Type) return Cursor is
Node : constant Count_Type :=
Key_Ops.Find (Container'Unrestricted_Access.all, Key);
begin
if Node = 0 then
return No_Element;
else
return Cursor'(Container'Unrestricted_Access, Node);
end if;
end Find;
-----------
-- First --
-----------
function First (Container : Map) return Cursor is
Node : constant Count_Type := HT_Ops.First (Container);
begin
if Node = 0 then
return No_Element;
else
return Cursor'(Container'Unrestricted_Access, Node);
end if;
end First;
function First (Object : Iterator) return Cursor is
begin
return Object.Container.First;
end First;
------------------------
-- Get_Element_Access --
------------------------
function Get_Element_Access
(Position : Cursor) return not null Element_Access is
begin
return Position.Container.Nodes (Position.Node).Element'Access;
end Get_Element_Access;
-----------------
-- Has_Element --
-----------------
function Has_Element (Position : Cursor) return Boolean is
begin
pragma Assert (Vet (Position), "bad cursor in Has_Element");
return Position.Node /= 0;
end Has_Element;
---------------
-- Hash_Node --
---------------
function Hash_Node (Node : Node_Type) return Hash_Type is
begin
return Hash (Node.Key);
end Hash_Node;
-------------
-- Include --
-------------
procedure Include
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type)
is
Position : Cursor;
Inserted : Boolean;
begin
Insert (Container, Key, New_Item, Position, Inserted);
if not Inserted then
TE_Check (Container.TC);
declare
N : Node_Type renames Container.Nodes (Position.Node);
begin
N.Key := Key;
N.Element := New_Item;
end;
end if;
end Include;
------------
-- Insert --
------------
procedure Insert
(Container : in out Map;
Key : Key_Type;
Position : out Cursor;
Inserted : out Boolean)
is
procedure Assign_Key (Node : in out Node_Type);
pragma Inline (Assign_Key);
function New_Node return Count_Type;
pragma Inline (New_Node);
procedure Local_Insert is
new Key_Ops.Generic_Conditional_Insert (New_Node);
procedure Allocate is
new HT_Ops.Generic_Allocate (Assign_Key);
-----------------
-- Assign_Key --
-----------------
procedure Assign_Key (Node : in out Node_Type) is
New_Item : Element_Type;
pragma Unmodified (New_Item);
-- Default-initialized element (ok to reference, see below)
begin
Node.Key := Key;
-- There is no explicit element provided, but in an instance the
-- element type may be a scalar with a Default_Value aspect, or a
-- composite type with such a scalar component, or components with
-- default initialization, so insert a possibly initialized element
-- under the given key.
Node.Element := New_Item;
end Assign_Key;
--------------
-- New_Node --
--------------
function New_Node return Count_Type is
Result : Count_Type;
begin
Allocate (Container, Result);
return Result;
end New_Node;
-- Start of processing for Insert
begin
-- The buckets array length is specified by the user as a discriminant
-- of the container type, so it is possible for the buckets array to
-- have a length of zero. We must check for this case specifically, in
-- order to prevent divide-by-zero errors later, when we compute the
-- buckets array index value for a key, given its hash value.
if Checks and then Container.Buckets'Length = 0 then
raise Capacity_Error with "No capacity for insertion";
end if;
Local_Insert (Container, Key, Position.Node, Inserted);
Position.Container := Container'Unchecked_Access;
end Insert;
procedure Insert
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type;
Position : out Cursor;
Inserted : out Boolean)
is
procedure Assign_Key (Node : in out Node_Type);
pragma Inline (Assign_Key);
function New_Node return Count_Type;
pragma Inline (New_Node);
procedure Local_Insert is
new Key_Ops.Generic_Conditional_Insert (New_Node);
procedure Allocate is
new HT_Ops.Generic_Allocate (Assign_Key);
-----------------
-- Assign_Key --
-----------------
procedure Assign_Key (Node : in out Node_Type) is
begin
Node.Key := Key;
Node.Element := New_Item;
end Assign_Key;
--------------
-- New_Node --
--------------
function New_Node return Count_Type is
Result : Count_Type;
begin
Allocate (Container, Result);
return Result;
end New_Node;
-- Start of processing for Insert
begin
-- The buckets array length is specified by the user as a discriminant
-- of the container type, so it is possible for the buckets array to
-- have a length of zero. We must check for this case specifically, in
-- order to prevent divide-by-zero errors later, when we compute the
-- buckets array index value for a key, given its hash value.
if Checks and then Container.Buckets'Length = 0 then
raise Capacity_Error with "No capacity for insertion";
end if;
Local_Insert (Container, Key, Position.Node, Inserted);
Position.Container := Container'Unchecked_Access;
end Insert;
procedure Insert
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type)
is
Position : Cursor;
pragma Unreferenced (Position);
Inserted : Boolean;
begin
Insert (Container, Key, New_Item, Position, Inserted);
if Checks and then not Inserted then
raise Constraint_Error with
"attempt to insert key already in map";
end if;
end Insert;
--------------
-- Is_Empty --
--------------
function Is_Empty (Container : Map) return Boolean is
begin
return Container.Length = 0;
end Is_Empty;
-------------
-- Iterate --
-------------
procedure Iterate
(Container : Map;
Process : not null access procedure (Position : Cursor))
is
procedure Process_Node (Node : Count_Type);
pragma Inline (Process_Node);
procedure Local_Iterate is new HT_Ops.Generic_Iteration (Process_Node);
------------------
-- Process_Node --
------------------
procedure Process_Node (Node : Count_Type) is
begin
Process (Cursor'(Container'Unrestricted_Access, Node));
end Process_Node;
Busy : With_Busy (Container.TC'Unrestricted_Access);
-- Start of processing for Iterate
begin
Local_Iterate (Container);
end Iterate;
function Iterate
(Container : Map) return Map_Iterator_Interfaces.Forward_Iterator'Class
is
begin
return It : constant Iterator :=
(Limited_Controlled with
Container => Container'Unrestricted_Access)
do
Busy (Container.TC'Unrestricted_Access.all);
end return;
end Iterate;
---------
-- Key --
---------
function Key (Position : Cursor) return Key_Type is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of function Key equals No_Element";
end if;
pragma Assert (Vet (Position), "bad cursor in function Key");
return Position.Container.Nodes (Position.Node).Key;
end Key;
------------
-- Length --
------------
function Length (Container : Map) return Count_Type is
begin
return Container.Length;
end Length;
----------
-- Move --
----------
procedure Move
(Target : in out Map;
Source : in out Map)
is
begin
if Target'Address = Source'Address then
return;
end if;
TC_Check (Source.TC);
Target.Assign (Source);
Source.Clear;
end Move;
----------
-- Next --
----------
function Next (Node : Node_Type) return Count_Type is
begin
return Node.Next;
end Next;
function Next (Position : Cursor) return Cursor is
begin
if Position.Node = 0 then
return No_Element;
end if;
pragma Assert (Vet (Position), "bad cursor in function Next");
declare
M : Map renames Position.Container.all;
Node : constant Count_Type := HT_Ops.Next (M, Position.Node);
begin
if Node = 0 then
return No_Element;
else
return Cursor'(Position.Container, Node);
end if;
end;
end Next;
procedure Next (Position : in out Cursor) is
begin
Position := Next (Position);
end Next;
function Next
(Object : Iterator;
Position : Cursor) return Cursor
is
begin
if Position.Container = null then
return No_Element;
end if;
if Checks and then Position.Container /= Object.Container then
raise Program_Error with
"Position cursor of Next designates wrong map";
end if;
return Next (Position);
end Next;
----------------------
-- Pseudo_Reference --
----------------------
function Pseudo_Reference
(Container : aliased Map'Class) return Reference_Control_Type
is
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Reference_Control_Type := (Controlled with TC) do
Lock (TC.all);
end return;
end Pseudo_Reference;
-------------------
-- Query_Element --
-------------------
procedure Query_Element
(Position : Cursor;
Process : not null access
procedure (Key : Key_Type; Element : Element_Type))
is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of Query_Element equals No_Element";
end if;
pragma Assert (Vet (Position), "bad cursor in Query_Element");
declare
M : Map renames Position.Container.all;
N : Node_Type renames M.Nodes (Position.Node);
Lock : With_Lock (M.TC'Unrestricted_Access);
begin
Process (N.Key, N.Element);
end;
end Query_Element;
----------
-- Read --
----------
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Container : out Map)
is
function Read_Node
(Stream : not null access Root_Stream_Type'Class) return Count_Type;
-- pragma Inline (Read_Node); ???
procedure Read_Nodes is new HT_Ops.Generic_Read (Read_Node);
---------------
-- Read_Node --
---------------
function Read_Node
(Stream : not null access Root_Stream_Type'Class) return Count_Type
is
procedure Read_Element (Node : in out Node_Type);
-- pragma Inline (Read_Element); ???
procedure Allocate is
new HT_Ops.Generic_Allocate (Read_Element);
procedure Read_Element (Node : in out Node_Type) is
begin
Key_Type'Read (Stream, Node.Key);
Element_Type'Read (Stream, Node.Element);
end Read_Element;
Node : Count_Type;
-- Start of processing for Read_Node
begin
Allocate (Container, Node);
return Node;
end Read_Node;
-- Start of processing for Read
begin
Read_Nodes (Stream, Container);
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Cursor)
is
begin
raise Program_Error with "attempt to stream map cursor";
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Constant_Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Read;
---------------
-- Reference --
---------------
function Reference
(Container : aliased in out Map;
Position : Cursor) return Reference_Type
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with
"Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor designates wrong map";
end if;
pragma Assert (Vet (Position),
"Position cursor in function Reference is bad");
declare
N : Node_Type renames Container.Nodes (Position.Node);
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Reference_Type :=
(Element => N.Element'Access,
Control => (Controlled with TC))
do
Lock (TC.all);
end return;
end;
end Reference;
function Reference
(Container : aliased in out Map;
Key : Key_Type) return Reference_Type
is
Node : constant Count_Type := Key_Ops.Find (Container, Key);
begin
if Checks and then Node = 0 then
raise Constraint_Error with "key not in map";
end if;
declare
N : Node_Type renames Container.Nodes (Node);
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Reference_Type :=
(Element => N.Element'Access,
Control => (Controlled with TC))
do
Lock (TC.all);
end return;
end;
end Reference;
-------------
-- Replace --
-------------
procedure Replace
(Container : in out Map;
Key : Key_Type;
New_Item : Element_Type)
is
Node : constant Count_Type := Key_Ops.Find (Container, Key);
begin
if Checks and then Node = 0 then
raise Constraint_Error with
"attempt to replace key not in map";
end if;
TE_Check (Container.TC);
declare
N : Node_Type renames Container.Nodes (Node);
begin
N.Key := Key;
N.Element := New_Item;
end;
end Replace;
---------------------
-- Replace_Element --
---------------------
procedure Replace_Element
(Container : in out Map;
Position : Cursor;
New_Item : Element_Type)
is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of Replace_Element equals No_Element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor of Replace_Element designates wrong map";
end if;
TE_Check (Position.Container.TC);
pragma Assert (Vet (Position), "bad cursor in Replace_Element");
Container.Nodes (Position.Node).Element := New_Item;
end Replace_Element;
----------------------
-- Reserve_Capacity --
----------------------
procedure Reserve_Capacity
(Container : in out Map;
Capacity : Count_Type)
is
begin
if Checks and then Capacity > Container.Capacity then
raise Capacity_Error with "requested capacity is too large";
end if;
end Reserve_Capacity;
--------------
-- Set_Next --
--------------
procedure Set_Next (Node : in out Node_Type; Next : Count_Type) is
begin
Node.Next := Next;
end Set_Next;
--------------------
-- Update_Element --
--------------------
procedure Update_Element
(Container : in out Map;
Position : Cursor;
Process : not null access procedure (Key : Key_Type;
Element : in out Element_Type))
is
begin
if Checks and then Position.Node = 0 then
raise Constraint_Error with
"Position cursor of Update_Element equals No_Element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with
"Position cursor of Update_Element designates wrong map";
end if;
pragma Assert (Vet (Position), "bad cursor in Update_Element");
declare
N : Node_Type renames Container.Nodes (Position.Node);
Lock : With_Lock (Container.TC'Unrestricted_Access);
begin
Process (N.Key, N.Element);
end;
end Update_Element;
---------
-- Vet --
---------
function Vet (Position : Cursor) return Boolean is
begin
if Position.Node = 0 then
return Position.Container = null;
end if;
if Position.Container = null then
return False;
end if;
declare
M : Map renames Position.Container.all;
X : Count_Type;
begin
if M.Length = 0 then
return False;
end if;
if M.Capacity = 0 then
return False;
end if;
if M.Buckets'Length = 0 then
return False;
end if;
if Position.Node > M.Capacity then
return False;
end if;
if M.Nodes (Position.Node).Next = Position.Node then
return False;
end if;
X := M.Buckets (Key_Ops.Checked_Index
(M, M.Nodes (Position.Node).Key));
for J in 1 .. M.Length loop
if X = Position.Node then
return True;
end if;
if X = 0 then
return False;
end if;
if X = M.Nodes (X).Next then -- to prevent unnecessary looping
return False;
end if;
X := M.Nodes (X).Next;
end loop;
return False;
end;
end Vet;
-----------
-- Write --
-----------
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Container : Map)
is
procedure Write_Node
(Stream : not null access Root_Stream_Type'Class;
Node : Node_Type);
pragma Inline (Write_Node);
procedure Write_Nodes is new HT_Ops.Generic_Write (Write_Node);
----------------
-- Write_Node --
----------------
procedure Write_Node
(Stream : not null access Root_Stream_Type'Class;
Node : Node_Type)
is
begin
Key_Type'Write (Stream, Node.Key);
Element_Type'Write (Stream, Node.Element);
end Write_Node;
-- Start of processing for Write
begin
Write_Nodes (Stream, Container);
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Cursor)
is
begin
raise Program_Error with "attempt to stream map cursor";
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Constant_Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Write;
end Ada.Containers.Bounded_Hashed_Maps;
|
[
{
"context": "e-Identifier: Apache-2.0\n--\n-- Copyright (c) 2012 Felix Krause <contact@flyx.org>\n--\n-- Licensed under the Apac",
"end": 78,
"score": 0.9998487234115601,
"start": 66,
"tag": "NAME",
"value": "Felix Krause"
},
{
"context": "pache-2.0\n--\n-- Copyright (c) 2012 Felix Krause <contact@flyx.org>\n--\n-- Licensed under the Apache License, Versio",
"end": 96,
"score": 0.9999311566352844,
"start": 80,
"tag": "EMAIL",
"value": "contact@flyx.org"
}
] | orka/src/gl/implementation/gl-enums-getter.ads | onox/orka | 52 | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2012 Felix Krause <contact@flyx.org>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package GL.Enums.Getter is
pragma Preelaborate;
type Parameter is
(Line_Smooth,
Polygon_Mode,
Polygon_Smooth,
Cull_Face,
Cull_Face_Mode,
Front_Face,
Depth_Range,
Depth_Test,
Depth_Writemask,
Depth_Clear_Value,
Depth_Func,
Stencil_Test,
Stencil_Clear_Value,
Stencil_Func,
Stencil_Value_Mask,
Stencil_Fail,
Stencil_Pass_Depth_Fail,
Stencil_Pass_Depth_Pass,
Stencil_Ref,
Stencil_Writemask,
Viewport,
Dither,
Blend_Dst,
Blend_Src,
Blend,
Logic_Op_Mode,
Color_Logic_Op,
Draw_Buffer,
Read_Buffer,
Scissor_Box,
Scissor_Test,
Color_Clear_Value,
Color_Writemask,
Doublebuffer,
Stereo,
Line_Smooth_Hint,
Polygon_Smooth_Hint,
Unpack_Alignment,
Pack_Alignment,
Max_Clip_Distances,
Max_Texture_Size,
Max_Viewport_Dims,
Subpixel_Bits,
Texture_1D,
Texture_2D,
Polygon_Offset_Units,
Blend_Color,
Blend_Equation_RGB,
Polygon_Offset_Factor,
Blend_Dst_RGB,
Blend_Src_RGB,
Blend_Dst_Alpha,
Blend_Src_Alpha,
Major_Version,
Minor_Version,
Num_Extensions,
Context_Flags,
Context_Reset_Notification,
Max_Viewports,
Viewport_Subpixel_Bits,
Viewport_Bounds_Range,
Max_Compute_Shared_Memory_Size,
Num_Shading_Language_Versions,
Context_Release_Behavior,
Active_Texture,
Max_Texture_Max_Anisotropy,
Stencil_Back_Func,
Stencil_Back_Fail,
Stencil_Back_Pass_Depth_Fail,
Stencil_Back_Pass_Depth_Pass,
Blend_Equation_Alpha,
Max_Texture_Image_Units,
Max_Vertex_Texture_Image_Units,
Max_Combined_Texture_Image_Units,
Max_Geometry_Texture_Image_Units,
Min_Sample_Shading_Value,
Stencil_Back_Ref,
Stencil_Back_Value_Mask,
Stencil_Back_Writemask,
Polygon_Offset_Clamp,
Timestamp,
Max_Tess_Control_Texture_Image_Units,
Max_Tess_Evaluation_Texture_Image_Units,
Min_Map_Buffer_Alignment,
Max_Compute_Work_Group_Invocations,
Unpack_Compressed_Block_Width,
Unpack_Compressed_Block_Height,
Unpack_Compressed_Block_Depth,
Unpack_Compressed_Block_Size,
Pack_Compressed_Block_Width,
Pack_Compressed_Block_Height,
Pack_Compressed_Block_Depth,
Pack_Compressed_Block_Size,
Max_Debug_Message_Length,
Debug_Logged_Messages,
Max_Compute_Texture_Image_Units,
Max_Compute_Work_Group_Count,
Max_Compute_Work_Group_Size,
Max_Framebuffer_Width,
Max_Framebuffer_Height,
Max_Framebuffer_Layers,
Max_Framebuffer_Samples,
Clip_Origin,
Clip_Depth_Mode);
type String_Parameter is
(Vendor, Renderer, Version, Extensions, Shading_Language_Version);
private
for Parameter use
(Line_Smooth => 16#0B20#,
Polygon_Mode => 16#0B40#,
Polygon_Smooth => 16#0B41#,
Cull_Face => 16#0B44#,
Cull_Face_Mode => 16#0B45#,
Front_Face => 16#0B46#,
Depth_Range => 16#0B70#,
Depth_Test => 16#0B71#,
Depth_Writemask => 16#0B72#,
Depth_Clear_Value => 16#0B73#,
Depth_Func => 16#0B74#,
Stencil_Test => 16#0B90#,
Stencil_Clear_Value => 16#0B91#,
Stencil_Func => 16#0B92#,
Stencil_Value_Mask => 16#0B93#,
Stencil_Fail => 16#0B94#,
Stencil_Pass_Depth_Fail => 16#0B95#,
Stencil_Pass_Depth_Pass => 16#0B96#,
Stencil_Ref => 16#0B97#,
Stencil_Writemask => 16#0B98#,
Viewport => 16#0BA2#,
Dither => 16#0BD0#,
Blend_Dst => 16#0BE0#,
Blend_Src => 16#0BE1#,
Blend => 16#0BE2#,
Logic_Op_Mode => 16#0BF0#,
Color_Logic_Op => 16#0BF2#,
Draw_Buffer => 16#0C01#,
Read_Buffer => 16#0C02#,
Scissor_Box => 16#0C10#,
Scissor_Test => 16#0C11#,
Color_Clear_Value => 16#0C22#,
Color_Writemask => 16#0C23#,
Doublebuffer => 16#0C32#,
Stereo => 16#0C33#,
Line_Smooth_Hint => 16#0C52#,
Polygon_Smooth_Hint => 16#0C53#,
Unpack_Alignment => 16#0CF5#,
Pack_Alignment => 16#0D05#,
Max_Clip_Distances => 16#0D32#,
Max_Texture_Size => 16#0D33#,
Max_Viewport_Dims => 16#0D3A#,
Subpixel_Bits => 16#0D50#,
Texture_1D => 16#0DE0#,
Texture_2D => 16#0DE1#,
Polygon_Offset_Units => 16#2A00#,
Blend_Color => 16#8005#,
Blend_Equation_RGB => 16#8009#,
Polygon_Offset_Factor => 16#8038#,
Blend_Dst_RGB => 16#80C8#,
Blend_Src_RGB => 16#80C9#,
Blend_Dst_Alpha => 16#80CA#,
Blend_Src_Alpha => 16#80CB#,
Major_Version => 16#821B#,
Minor_Version => 16#821C#,
Num_Extensions => 16#821D#,
Context_Flags => 16#821E#,
Context_Reset_Notification => 16#8256#,
Max_Viewports => 16#825B#,
Viewport_Subpixel_Bits => 16#825C#,
Viewport_Bounds_Range => 16#825D#,
Max_Compute_Shared_Memory_Size => 16#8262#,
Num_Shading_Language_Versions => 16#82E9#,
Context_Release_Behavior => 16#82FB#,
Active_Texture => 16#84E0#,
Max_Texture_Max_Anisotropy => 16#84FF#,
Stencil_Back_Func => 16#8800#,
Stencil_Back_Fail => 16#8801#,
Stencil_Back_Pass_Depth_Fail => 16#8802#,
Stencil_Back_Pass_Depth_Pass => 16#8803#,
Blend_Equation_Alpha => 16#883D#,
Max_Texture_Image_Units => 16#8872#,
Max_Vertex_Texture_Image_Units => 16#8B4C#,
Max_Combined_Texture_Image_Units => 16#8B4D#,
Max_Geometry_Texture_Image_Units => 16#8C29#,
Min_Sample_Shading_Value => 16#8C37#,
Stencil_Back_Ref => 16#8CA3#,
Stencil_Back_Value_Mask => 16#8CA4#,
Stencil_Back_Writemask => 16#8CA5#,
Polygon_Offset_Clamp => 16#8E1B#,
Timestamp => 16#8E28#,
Max_Tess_Control_Texture_Image_Units => 16#8E81#,
Max_Tess_Evaluation_Texture_Image_Units => 16#8E82#,
Min_Map_Buffer_Alignment => 16#90BC#,
Max_Compute_Work_Group_Invocations => 16#90EB#,
Unpack_Compressed_Block_Width => 16#9127#,
Unpack_Compressed_Block_Height => 16#9128#,
Unpack_Compressed_Block_Depth => 16#9129#,
Unpack_Compressed_Block_Size => 16#912A#,
Pack_Compressed_Block_Width => 16#912B#,
Pack_Compressed_Block_Height => 16#912C#,
Pack_Compressed_Block_Depth => 16#912D#,
Pack_Compressed_Block_Size => 16#912E#,
Max_Debug_Message_Length => 16#9143#,
Debug_Logged_Messages => 16#9145#,
Max_Compute_Texture_Image_Units => 16#91BC#,
Max_Compute_Work_Group_Count => 16#91BE#,
Max_Compute_Work_Group_Size => 16#91BF#,
Max_Framebuffer_Width => 16#9315#,
Max_Framebuffer_Height => 16#9316#,
Max_Framebuffer_Layers => 16#9317#,
Max_Framebuffer_Samples => 16#9318#,
Clip_Origin => 16#935C#,
Clip_Depth_Mode => 16#935D#);
for Parameter'Size use Low_Level.Enum'Size;
for String_Parameter use
(Vendor => 16#1F00#,
Renderer => 16#1F01#,
Version => 16#1F02#,
Extensions => 16#1F03#,
Shading_Language_Version => 16#8B8C#);
for String_Parameter'Size use Low_Level.Enum'Size;
end GL.Enums.Getter;
| 28389 | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2012 <NAME> <<EMAIL>>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package GL.Enums.Getter is
pragma Preelaborate;
type Parameter is
(Line_Smooth,
Polygon_Mode,
Polygon_Smooth,
Cull_Face,
Cull_Face_Mode,
Front_Face,
Depth_Range,
Depth_Test,
Depth_Writemask,
Depth_Clear_Value,
Depth_Func,
Stencil_Test,
Stencil_Clear_Value,
Stencil_Func,
Stencil_Value_Mask,
Stencil_Fail,
Stencil_Pass_Depth_Fail,
Stencil_Pass_Depth_Pass,
Stencil_Ref,
Stencil_Writemask,
Viewport,
Dither,
Blend_Dst,
Blend_Src,
Blend,
Logic_Op_Mode,
Color_Logic_Op,
Draw_Buffer,
Read_Buffer,
Scissor_Box,
Scissor_Test,
Color_Clear_Value,
Color_Writemask,
Doublebuffer,
Stereo,
Line_Smooth_Hint,
Polygon_Smooth_Hint,
Unpack_Alignment,
Pack_Alignment,
Max_Clip_Distances,
Max_Texture_Size,
Max_Viewport_Dims,
Subpixel_Bits,
Texture_1D,
Texture_2D,
Polygon_Offset_Units,
Blend_Color,
Blend_Equation_RGB,
Polygon_Offset_Factor,
Blend_Dst_RGB,
Blend_Src_RGB,
Blend_Dst_Alpha,
Blend_Src_Alpha,
Major_Version,
Minor_Version,
Num_Extensions,
Context_Flags,
Context_Reset_Notification,
Max_Viewports,
Viewport_Subpixel_Bits,
Viewport_Bounds_Range,
Max_Compute_Shared_Memory_Size,
Num_Shading_Language_Versions,
Context_Release_Behavior,
Active_Texture,
Max_Texture_Max_Anisotropy,
Stencil_Back_Func,
Stencil_Back_Fail,
Stencil_Back_Pass_Depth_Fail,
Stencil_Back_Pass_Depth_Pass,
Blend_Equation_Alpha,
Max_Texture_Image_Units,
Max_Vertex_Texture_Image_Units,
Max_Combined_Texture_Image_Units,
Max_Geometry_Texture_Image_Units,
Min_Sample_Shading_Value,
Stencil_Back_Ref,
Stencil_Back_Value_Mask,
Stencil_Back_Writemask,
Polygon_Offset_Clamp,
Timestamp,
Max_Tess_Control_Texture_Image_Units,
Max_Tess_Evaluation_Texture_Image_Units,
Min_Map_Buffer_Alignment,
Max_Compute_Work_Group_Invocations,
Unpack_Compressed_Block_Width,
Unpack_Compressed_Block_Height,
Unpack_Compressed_Block_Depth,
Unpack_Compressed_Block_Size,
Pack_Compressed_Block_Width,
Pack_Compressed_Block_Height,
Pack_Compressed_Block_Depth,
Pack_Compressed_Block_Size,
Max_Debug_Message_Length,
Debug_Logged_Messages,
Max_Compute_Texture_Image_Units,
Max_Compute_Work_Group_Count,
Max_Compute_Work_Group_Size,
Max_Framebuffer_Width,
Max_Framebuffer_Height,
Max_Framebuffer_Layers,
Max_Framebuffer_Samples,
Clip_Origin,
Clip_Depth_Mode);
type String_Parameter is
(Vendor, Renderer, Version, Extensions, Shading_Language_Version);
private
for Parameter use
(Line_Smooth => 16#0B20#,
Polygon_Mode => 16#0B40#,
Polygon_Smooth => 16#0B41#,
Cull_Face => 16#0B44#,
Cull_Face_Mode => 16#0B45#,
Front_Face => 16#0B46#,
Depth_Range => 16#0B70#,
Depth_Test => 16#0B71#,
Depth_Writemask => 16#0B72#,
Depth_Clear_Value => 16#0B73#,
Depth_Func => 16#0B74#,
Stencil_Test => 16#0B90#,
Stencil_Clear_Value => 16#0B91#,
Stencil_Func => 16#0B92#,
Stencil_Value_Mask => 16#0B93#,
Stencil_Fail => 16#0B94#,
Stencil_Pass_Depth_Fail => 16#0B95#,
Stencil_Pass_Depth_Pass => 16#0B96#,
Stencil_Ref => 16#0B97#,
Stencil_Writemask => 16#0B98#,
Viewport => 16#0BA2#,
Dither => 16#0BD0#,
Blend_Dst => 16#0BE0#,
Blend_Src => 16#0BE1#,
Blend => 16#0BE2#,
Logic_Op_Mode => 16#0BF0#,
Color_Logic_Op => 16#0BF2#,
Draw_Buffer => 16#0C01#,
Read_Buffer => 16#0C02#,
Scissor_Box => 16#0C10#,
Scissor_Test => 16#0C11#,
Color_Clear_Value => 16#0C22#,
Color_Writemask => 16#0C23#,
Doublebuffer => 16#0C32#,
Stereo => 16#0C33#,
Line_Smooth_Hint => 16#0C52#,
Polygon_Smooth_Hint => 16#0C53#,
Unpack_Alignment => 16#0CF5#,
Pack_Alignment => 16#0D05#,
Max_Clip_Distances => 16#0D32#,
Max_Texture_Size => 16#0D33#,
Max_Viewport_Dims => 16#0D3A#,
Subpixel_Bits => 16#0D50#,
Texture_1D => 16#0DE0#,
Texture_2D => 16#0DE1#,
Polygon_Offset_Units => 16#2A00#,
Blend_Color => 16#8005#,
Blend_Equation_RGB => 16#8009#,
Polygon_Offset_Factor => 16#8038#,
Blend_Dst_RGB => 16#80C8#,
Blend_Src_RGB => 16#80C9#,
Blend_Dst_Alpha => 16#80CA#,
Blend_Src_Alpha => 16#80CB#,
Major_Version => 16#821B#,
Minor_Version => 16#821C#,
Num_Extensions => 16#821D#,
Context_Flags => 16#821E#,
Context_Reset_Notification => 16#8256#,
Max_Viewports => 16#825B#,
Viewport_Subpixel_Bits => 16#825C#,
Viewport_Bounds_Range => 16#825D#,
Max_Compute_Shared_Memory_Size => 16#8262#,
Num_Shading_Language_Versions => 16#82E9#,
Context_Release_Behavior => 16#82FB#,
Active_Texture => 16#84E0#,
Max_Texture_Max_Anisotropy => 16#84FF#,
Stencil_Back_Func => 16#8800#,
Stencil_Back_Fail => 16#8801#,
Stencil_Back_Pass_Depth_Fail => 16#8802#,
Stencil_Back_Pass_Depth_Pass => 16#8803#,
Blend_Equation_Alpha => 16#883D#,
Max_Texture_Image_Units => 16#8872#,
Max_Vertex_Texture_Image_Units => 16#8B4C#,
Max_Combined_Texture_Image_Units => 16#8B4D#,
Max_Geometry_Texture_Image_Units => 16#8C29#,
Min_Sample_Shading_Value => 16#8C37#,
Stencil_Back_Ref => 16#8CA3#,
Stencil_Back_Value_Mask => 16#8CA4#,
Stencil_Back_Writemask => 16#8CA5#,
Polygon_Offset_Clamp => 16#8E1B#,
Timestamp => 16#8E28#,
Max_Tess_Control_Texture_Image_Units => 16#8E81#,
Max_Tess_Evaluation_Texture_Image_Units => 16#8E82#,
Min_Map_Buffer_Alignment => 16#90BC#,
Max_Compute_Work_Group_Invocations => 16#90EB#,
Unpack_Compressed_Block_Width => 16#9127#,
Unpack_Compressed_Block_Height => 16#9128#,
Unpack_Compressed_Block_Depth => 16#9129#,
Unpack_Compressed_Block_Size => 16#912A#,
Pack_Compressed_Block_Width => 16#912B#,
Pack_Compressed_Block_Height => 16#912C#,
Pack_Compressed_Block_Depth => 16#912D#,
Pack_Compressed_Block_Size => 16#912E#,
Max_Debug_Message_Length => 16#9143#,
Debug_Logged_Messages => 16#9145#,
Max_Compute_Texture_Image_Units => 16#91BC#,
Max_Compute_Work_Group_Count => 16#91BE#,
Max_Compute_Work_Group_Size => 16#91BF#,
Max_Framebuffer_Width => 16#9315#,
Max_Framebuffer_Height => 16#9316#,
Max_Framebuffer_Layers => 16#9317#,
Max_Framebuffer_Samples => 16#9318#,
Clip_Origin => 16#935C#,
Clip_Depth_Mode => 16#935D#);
for Parameter'Size use Low_Level.Enum'Size;
for String_Parameter use
(Vendor => 16#1F00#,
Renderer => 16#1F01#,
Version => 16#1F02#,
Extensions => 16#1F03#,
Shading_Language_Version => 16#8B8C#);
for String_Parameter'Size use Low_Level.Enum'Size;
end GL.Enums.Getter;
| true | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2012 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package GL.Enums.Getter is
pragma Preelaborate;
type Parameter is
(Line_Smooth,
Polygon_Mode,
Polygon_Smooth,
Cull_Face,
Cull_Face_Mode,
Front_Face,
Depth_Range,
Depth_Test,
Depth_Writemask,
Depth_Clear_Value,
Depth_Func,
Stencil_Test,
Stencil_Clear_Value,
Stencil_Func,
Stencil_Value_Mask,
Stencil_Fail,
Stencil_Pass_Depth_Fail,
Stencil_Pass_Depth_Pass,
Stencil_Ref,
Stencil_Writemask,
Viewport,
Dither,
Blend_Dst,
Blend_Src,
Blend,
Logic_Op_Mode,
Color_Logic_Op,
Draw_Buffer,
Read_Buffer,
Scissor_Box,
Scissor_Test,
Color_Clear_Value,
Color_Writemask,
Doublebuffer,
Stereo,
Line_Smooth_Hint,
Polygon_Smooth_Hint,
Unpack_Alignment,
Pack_Alignment,
Max_Clip_Distances,
Max_Texture_Size,
Max_Viewport_Dims,
Subpixel_Bits,
Texture_1D,
Texture_2D,
Polygon_Offset_Units,
Blend_Color,
Blend_Equation_RGB,
Polygon_Offset_Factor,
Blend_Dst_RGB,
Blend_Src_RGB,
Blend_Dst_Alpha,
Blend_Src_Alpha,
Major_Version,
Minor_Version,
Num_Extensions,
Context_Flags,
Context_Reset_Notification,
Max_Viewports,
Viewport_Subpixel_Bits,
Viewport_Bounds_Range,
Max_Compute_Shared_Memory_Size,
Num_Shading_Language_Versions,
Context_Release_Behavior,
Active_Texture,
Max_Texture_Max_Anisotropy,
Stencil_Back_Func,
Stencil_Back_Fail,
Stencil_Back_Pass_Depth_Fail,
Stencil_Back_Pass_Depth_Pass,
Blend_Equation_Alpha,
Max_Texture_Image_Units,
Max_Vertex_Texture_Image_Units,
Max_Combined_Texture_Image_Units,
Max_Geometry_Texture_Image_Units,
Min_Sample_Shading_Value,
Stencil_Back_Ref,
Stencil_Back_Value_Mask,
Stencil_Back_Writemask,
Polygon_Offset_Clamp,
Timestamp,
Max_Tess_Control_Texture_Image_Units,
Max_Tess_Evaluation_Texture_Image_Units,
Min_Map_Buffer_Alignment,
Max_Compute_Work_Group_Invocations,
Unpack_Compressed_Block_Width,
Unpack_Compressed_Block_Height,
Unpack_Compressed_Block_Depth,
Unpack_Compressed_Block_Size,
Pack_Compressed_Block_Width,
Pack_Compressed_Block_Height,
Pack_Compressed_Block_Depth,
Pack_Compressed_Block_Size,
Max_Debug_Message_Length,
Debug_Logged_Messages,
Max_Compute_Texture_Image_Units,
Max_Compute_Work_Group_Count,
Max_Compute_Work_Group_Size,
Max_Framebuffer_Width,
Max_Framebuffer_Height,
Max_Framebuffer_Layers,
Max_Framebuffer_Samples,
Clip_Origin,
Clip_Depth_Mode);
type String_Parameter is
(Vendor, Renderer, Version, Extensions, Shading_Language_Version);
private
for Parameter use
(Line_Smooth => 16#0B20#,
Polygon_Mode => 16#0B40#,
Polygon_Smooth => 16#0B41#,
Cull_Face => 16#0B44#,
Cull_Face_Mode => 16#0B45#,
Front_Face => 16#0B46#,
Depth_Range => 16#0B70#,
Depth_Test => 16#0B71#,
Depth_Writemask => 16#0B72#,
Depth_Clear_Value => 16#0B73#,
Depth_Func => 16#0B74#,
Stencil_Test => 16#0B90#,
Stencil_Clear_Value => 16#0B91#,
Stencil_Func => 16#0B92#,
Stencil_Value_Mask => 16#0B93#,
Stencil_Fail => 16#0B94#,
Stencil_Pass_Depth_Fail => 16#0B95#,
Stencil_Pass_Depth_Pass => 16#0B96#,
Stencil_Ref => 16#0B97#,
Stencil_Writemask => 16#0B98#,
Viewport => 16#0BA2#,
Dither => 16#0BD0#,
Blend_Dst => 16#0BE0#,
Blend_Src => 16#0BE1#,
Blend => 16#0BE2#,
Logic_Op_Mode => 16#0BF0#,
Color_Logic_Op => 16#0BF2#,
Draw_Buffer => 16#0C01#,
Read_Buffer => 16#0C02#,
Scissor_Box => 16#0C10#,
Scissor_Test => 16#0C11#,
Color_Clear_Value => 16#0C22#,
Color_Writemask => 16#0C23#,
Doublebuffer => 16#0C32#,
Stereo => 16#0C33#,
Line_Smooth_Hint => 16#0C52#,
Polygon_Smooth_Hint => 16#0C53#,
Unpack_Alignment => 16#0CF5#,
Pack_Alignment => 16#0D05#,
Max_Clip_Distances => 16#0D32#,
Max_Texture_Size => 16#0D33#,
Max_Viewport_Dims => 16#0D3A#,
Subpixel_Bits => 16#0D50#,
Texture_1D => 16#0DE0#,
Texture_2D => 16#0DE1#,
Polygon_Offset_Units => 16#2A00#,
Blend_Color => 16#8005#,
Blend_Equation_RGB => 16#8009#,
Polygon_Offset_Factor => 16#8038#,
Blend_Dst_RGB => 16#80C8#,
Blend_Src_RGB => 16#80C9#,
Blend_Dst_Alpha => 16#80CA#,
Blend_Src_Alpha => 16#80CB#,
Major_Version => 16#821B#,
Minor_Version => 16#821C#,
Num_Extensions => 16#821D#,
Context_Flags => 16#821E#,
Context_Reset_Notification => 16#8256#,
Max_Viewports => 16#825B#,
Viewport_Subpixel_Bits => 16#825C#,
Viewport_Bounds_Range => 16#825D#,
Max_Compute_Shared_Memory_Size => 16#8262#,
Num_Shading_Language_Versions => 16#82E9#,
Context_Release_Behavior => 16#82FB#,
Active_Texture => 16#84E0#,
Max_Texture_Max_Anisotropy => 16#84FF#,
Stencil_Back_Func => 16#8800#,
Stencil_Back_Fail => 16#8801#,
Stencil_Back_Pass_Depth_Fail => 16#8802#,
Stencil_Back_Pass_Depth_Pass => 16#8803#,
Blend_Equation_Alpha => 16#883D#,
Max_Texture_Image_Units => 16#8872#,
Max_Vertex_Texture_Image_Units => 16#8B4C#,
Max_Combined_Texture_Image_Units => 16#8B4D#,
Max_Geometry_Texture_Image_Units => 16#8C29#,
Min_Sample_Shading_Value => 16#8C37#,
Stencil_Back_Ref => 16#8CA3#,
Stencil_Back_Value_Mask => 16#8CA4#,
Stencil_Back_Writemask => 16#8CA5#,
Polygon_Offset_Clamp => 16#8E1B#,
Timestamp => 16#8E28#,
Max_Tess_Control_Texture_Image_Units => 16#8E81#,
Max_Tess_Evaluation_Texture_Image_Units => 16#8E82#,
Min_Map_Buffer_Alignment => 16#90BC#,
Max_Compute_Work_Group_Invocations => 16#90EB#,
Unpack_Compressed_Block_Width => 16#9127#,
Unpack_Compressed_Block_Height => 16#9128#,
Unpack_Compressed_Block_Depth => 16#9129#,
Unpack_Compressed_Block_Size => 16#912A#,
Pack_Compressed_Block_Width => 16#912B#,
Pack_Compressed_Block_Height => 16#912C#,
Pack_Compressed_Block_Depth => 16#912D#,
Pack_Compressed_Block_Size => 16#912E#,
Max_Debug_Message_Length => 16#9143#,
Debug_Logged_Messages => 16#9145#,
Max_Compute_Texture_Image_Units => 16#91BC#,
Max_Compute_Work_Group_Count => 16#91BE#,
Max_Compute_Work_Group_Size => 16#91BF#,
Max_Framebuffer_Width => 16#9315#,
Max_Framebuffer_Height => 16#9316#,
Max_Framebuffer_Layers => 16#9317#,
Max_Framebuffer_Samples => 16#9318#,
Clip_Origin => 16#935C#,
Clip_Depth_Mode => 16#935D#);
for Parameter'Size use Low_Level.Enum'Size;
for String_Parameter use
(Vendor => 16#1F00#,
Renderer => 16#1F01#,
Version => 16#1F02#,
Extensions => 16#1F03#,
Shading_Language_Version => 16#8B8C#);
for String_Parameter'Size use Low_Level.Enum'Size;
end GL.Enums.Getter;
|
[
{
"context": "-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>\n-- MIT license. Please refer t",
"end": 36,
"score": 0.9998742938041687,
"start": 22,
"tag": "NAME",
"value": "Thierry Rascle"
},
{
"context": "-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>\n-- MIT license. Please refer to the LICENSE file",
"end": 54,
"score": 0.9999339580535889,
"start": 38,
"tag": "EMAIL",
"value": "thierr26@free.fr"
}
] | src/apsepp-test_node_class-generic_case_and_suite_run_body.ads | thierr26/ada-apsepp | 0 | -- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
generic
with procedure Work (Obj : Test_Node_Interfa'Class;
Outcome : out Test_Outcome;
Kind : Run_Kind);
procedure Apsepp.Test_Node_Class.Generic_Case_And_Suite_Run_Body
(Obj : Test_Node_Interfa'Class;
Outcome : out Test_Outcome;
Kind : Run_Kind;
Cond : not null access function return Boolean);
| 13359 | -- Copyright (C) 2019 <NAME> <<EMAIL>>
-- MIT license. Please refer to the LICENSE file.
generic
with procedure Work (Obj : Test_Node_Interfa'Class;
Outcome : out Test_Outcome;
Kind : Run_Kind);
procedure Apsepp.Test_Node_Class.Generic_Case_And_Suite_Run_Body
(Obj : Test_Node_Interfa'Class;
Outcome : out Test_Outcome;
Kind : Run_Kind;
Cond : not null access function return Boolean);
| true | -- Copyright (C) 2019 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
-- MIT license. Please refer to the LICENSE file.
generic
with procedure Work (Obj : Test_Node_Interfa'Class;
Outcome : out Test_Outcome;
Kind : Run_Kind);
procedure Apsepp.Test_Node_Class.Generic_Case_And_Suite_Run_Body
(Obj : Test_Node_Interfa'Class;
Outcome : out Test_Outcome;
Kind : Run_Kind;
Cond : not null access function return Boolean);
|
[
{
"context": "--\n-- Copyright (C) 2017 Nico Huber <nico.h@gmx.de>\n--\n-- This program is free softwa",
"end": 35,
"score": 0.9998230934143066,
"start": 25,
"tag": "NAME",
"value": "Nico Huber"
},
{
"context": "--\n-- Copyright (C) 2017 Nico Huber <nico.h@gmx.de>\n--\n-- This program is free software; you can red",
"end": 50,
"score": 0.9999345541000366,
"start": 37,
"tag": "EMAIL",
"value": "nico.h@gmx.de"
}
] | firmware/coreboot/3rdparty/libhwbase/common/hw-file.ads | fabiojna02/OpenCellular | 1 | --
-- Copyright (C) 2017 Nico Huber <nico.h@gmx.de>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 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.
--
package HW.File is
--
-- Map a file's content into our address space
--
-- If `Map_Copy` is `False`, `Len` bytes at `Offset` from the start
-- of the file given by `Path` should be mapped into the application's
-- address space using mmap().
--
-- If `Map_Copy` is `True`, anonymous memory should be mapped instead
-- and be filled with a copy of the file's content using read().
--
-- If `Len` is zero, the whole file should be mapped.
--
procedure Map
(Addr : out Word64;
Path : in String;
Len : in Natural := 0;
Offset : in Natural := 0;
Readable : in Boolean := False;
Writable : in Boolean := False;
Map_Copy : in Boolean := False;
Success : out Boolean)
with
Pre => (Readable or Writable) and
(if Map_Copy then Readable and not Writable);
-- Sets `Length` to the size of the file given by `Path` or 0 if an
-- error occurs.
procedure Size (Length : out Natural; Path : String);
end HW.File;
| 16641 | --
-- Copyright (C) 2017 <NAME> <<EMAIL>>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 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.
--
package HW.File is
--
-- Map a file's content into our address space
--
-- If `Map_Copy` is `False`, `Len` bytes at `Offset` from the start
-- of the file given by `Path` should be mapped into the application's
-- address space using mmap().
--
-- If `Map_Copy` is `True`, anonymous memory should be mapped instead
-- and be filled with a copy of the file's content using read().
--
-- If `Len` is zero, the whole file should be mapped.
--
procedure Map
(Addr : out Word64;
Path : in String;
Len : in Natural := 0;
Offset : in Natural := 0;
Readable : in Boolean := False;
Writable : in Boolean := False;
Map_Copy : in Boolean := False;
Success : out Boolean)
with
Pre => (Readable or Writable) and
(if Map_Copy then Readable and not Writable);
-- Sets `Length` to the size of the file given by `Path` or 0 if an
-- error occurs.
procedure Size (Length : out Natural; Path : String);
end HW.File;
| true | --
-- Copyright (C) 2017 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 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.
--
package HW.File is
--
-- Map a file's content into our address space
--
-- If `Map_Copy` is `False`, `Len` bytes at `Offset` from the start
-- of the file given by `Path` should be mapped into the application's
-- address space using mmap().
--
-- If `Map_Copy` is `True`, anonymous memory should be mapped instead
-- and be filled with a copy of the file's content using read().
--
-- If `Len` is zero, the whole file should be mapped.
--
procedure Map
(Addr : out Word64;
Path : in String;
Len : in Natural := 0;
Offset : in Natural := 0;
Readable : in Boolean := False;
Writable : in Boolean := False;
Map_Copy : in Boolean := False;
Success : out Boolean)
with
Pre => (Readable or Writable) and
(if Map_Copy then Readable and not Writable);
-- Sets `Length` to the size of the file given by `Path` or 0 if an
-- error occurs.
procedure Size (Length : out Natural; Path : String);
end HW.File;
|
[
{
"context": " --\n-- * Richard Wai (ANNEXI-STRAYLINE) ",
"end": 1044,
"score": 0.9997112154960632,
"start": 1033,
"tag": "NAME",
"value": "Richard Wai"
}
] | registrar-dependency_processing.ads | annexi-strayline/AURA | 13 | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Core --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This package contains specialized processing steps for the consolidation of
-- the Registrar's unit dependency maps
with Progress;
package Registrar.Dependency_Processing is
------------------------------
-- Consolidate_Dependencies --
------------------------------
procedure Consolidate_Dependencies;
Merge_Subunits_Progress: aliased Progress.Progress_Tracker;
Fan_Out_Progress : aliased Progress.Progress_Tracker;
Build_Reverse_Progress : aliased Progress.Progress_Tracker;
-- Consolidate_Dependencies ensures that the Unit/Subsystem Forward/Reverse
-- dependency maps are consolidated and coherent
--
-- Consolidate_Dependencies must be completed before any of the dependency
-- maps are consulted.
--
-- Consolidate_Dependencies executes three phases (basically a map-reduce):
--
-- 1. Merge Subunits: All forward dependencies of all explicit Subunit units
-- are unioned with the forward dependency map of their
-- Library Unit parent.
--
-- The subsystem forward dependency map is
-- opportunistically populated during this phase.
--
-- 2. Fan-out : All non-Requested units in the All_Library_Units
-- registry have themselves queued for inclusion on the
-- reverse dependency map of each forward dependency
--
-- Similarily for all non-Requested Subsystems
--
-- 3. Build Reverse : All non-Requested units in the All_Library_Units
-- registry have their reverse dependency map sets built
-- from the queued names generated in the Fan-out phase
--
-- Similarily for all non-Requested Subsystems
end Registrar.Dependency_Processing;
| 27515 | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Core --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * <NAME> (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This package contains specialized processing steps for the consolidation of
-- the Registrar's unit dependency maps
with Progress;
package Registrar.Dependency_Processing is
------------------------------
-- Consolidate_Dependencies --
------------------------------
procedure Consolidate_Dependencies;
Merge_Subunits_Progress: aliased Progress.Progress_Tracker;
Fan_Out_Progress : aliased Progress.Progress_Tracker;
Build_Reverse_Progress : aliased Progress.Progress_Tracker;
-- Consolidate_Dependencies ensures that the Unit/Subsystem Forward/Reverse
-- dependency maps are consolidated and coherent
--
-- Consolidate_Dependencies must be completed before any of the dependency
-- maps are consulted.
--
-- Consolidate_Dependencies executes three phases (basically a map-reduce):
--
-- 1. Merge Subunits: All forward dependencies of all explicit Subunit units
-- are unioned with the forward dependency map of their
-- Library Unit parent.
--
-- The subsystem forward dependency map is
-- opportunistically populated during this phase.
--
-- 2. Fan-out : All non-Requested units in the All_Library_Units
-- registry have themselves queued for inclusion on the
-- reverse dependency map of each forward dependency
--
-- Similarily for all non-Requested Subsystems
--
-- 3. Build Reverse : All non-Requested units in the All_Library_Units
-- registry have their reverse dependency map sets built
-- from the queued names generated in the Fan-out phase
--
-- Similarily for all non-Requested Subsystems
end Registrar.Dependency_Processing;
| true | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Core --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * PI:NAME:<NAME>END_PI (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This package contains specialized processing steps for the consolidation of
-- the Registrar's unit dependency maps
with Progress;
package Registrar.Dependency_Processing is
------------------------------
-- Consolidate_Dependencies --
------------------------------
procedure Consolidate_Dependencies;
Merge_Subunits_Progress: aliased Progress.Progress_Tracker;
Fan_Out_Progress : aliased Progress.Progress_Tracker;
Build_Reverse_Progress : aliased Progress.Progress_Tracker;
-- Consolidate_Dependencies ensures that the Unit/Subsystem Forward/Reverse
-- dependency maps are consolidated and coherent
--
-- Consolidate_Dependencies must be completed before any of the dependency
-- maps are consulted.
--
-- Consolidate_Dependencies executes three phases (basically a map-reduce):
--
-- 1. Merge Subunits: All forward dependencies of all explicit Subunit units
-- are unioned with the forward dependency map of their
-- Library Unit parent.
--
-- The subsystem forward dependency map is
-- opportunistically populated during this phase.
--
-- 2. Fan-out : All non-Requested units in the All_Library_Units
-- registry have themselves queued for inclusion on the
-- reverse dependency map of each forward dependency
--
-- Similarily for all non-Requested Subsystems
--
-- 3. Build Reverse : All non-Requested units in the All_Library_Units
-- registry have their reverse dependency map sets built
-- from the queued names generated in the Fan-out phase
--
-- Similarily for all non-Requested Subsystems
end Registrar.Dependency_Processing;
|
[
{
"context": "-- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifi",
"end": 43,
"score": 0.9998571276664734,
"start": 33,
"tag": "NAME",
"value": "Max Reznik"
},
{
"context": "-- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifier: MIT\n------------",
"end": 63,
"score": 0.9999302625656128,
"start": 45,
"tag": "EMAIL",
"value": "reznikmm@gmail.com"
}
] | source/regions/regions-entities.ads | reznikmm/declarative-regions | 0 | -- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
package Regions.Entities is
pragma Pure;
type Entity is limited interface;
function Is_Assigned (Self : access Entity'Class) return Boolean
is (Self /= null);
not overriding function Is_Package (Self : Entity) return Boolean
is abstract;
type Entity_Access is access all Entity'Class
with Storage_Size => 0;
end Regions.Entities;
| 29531 | -- SPDX-FileCopyrightText: 2021 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
package Regions.Entities is
pragma Pure;
type Entity is limited interface;
function Is_Assigned (Self : access Entity'Class) return Boolean
is (Self /= null);
not overriding function Is_Package (Self : Entity) return Boolean
is abstract;
type Entity_Access is access all Entity'Class
with Storage_Size => 0;
end Regions.Entities;
| true | -- SPDX-FileCopyrightText: 2021 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
package Regions.Entities is
pragma Pure;
type Entity is limited interface;
function Is_Assigned (Self : access Entity'Class) return Boolean
is (Self /= null);
not overriding function Is_Package (Self : Entity) return Boolean
is abstract;
type Entity_Access is access all Entity'Class
with Storage_Size => 0;
end Regions.Entities;
|
[
{
"context": "---------------------\n-- Copyright (c) 2006-2013, Maxim Reznik\n-- All rights reserved.\n--\n-- Redistribution an",
"end": 18147,
"score": 0.9998689889907837,
"start": 18135,
"tag": "NAME",
"value": "Maxim Reznik"
},
{
"context": "the distribution.\n-- * Neither the name of the Maxim Reznik, IE nor the names of its\n-- contributors ma",
"end": 18748,
"score": 0.9998337626457214,
"start": 18736,
"tag": "NAME",
"value": "Maxim Reznik"
}
] | source/asis/xasis/xasis-static.adb | faelys/gela-asis | 4 | ------------------------------------------------------------------------------
-- G E L A X A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
with Ada.Characters.Handling;
with Ada.Unchecked_Deallocation;
with Asis.Elements;
with Asis.Definitions;
with Asis.Expressions;
with Asis.Declarations;
with XASIS.Static.Iter;
with XASIS.Static.Signed;
with XASIS.Static.Discrete;
with XASIS.Static.Unsigned;
with XASIS.Static.Float;
with XASIS.Static.Fixed;
with XASIS.Utils;
pragma Elaborate (XASIS.Static.Iter);
package body XASIS.Static is
type Calculator is null record;
function Literal
(Object : access Calculator;
Element : in Asis.Expression) return Value;
function Operator
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Operator_Kinds;
Args : in Asis.Association_List) return Value;
function Attribute
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Attribute_Kinds;
Element : in Asis.Expression) return Value;
function Attribute_Call
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Attribute_Kinds;
Args : in Asis.Association_List) return Value;
function Check_Range
(Object : access Calculator;
Expr : in Asis.Expression;
Bounds : in Static_Range;
Invert : in Boolean) return Value;
function Undefined
(Object : access Calculator;
Element : in Asis.Expression) return Value;
function Range_Of_Array
(Object : access Calculator;
Decl : in Asis.Declaration;
Attr : in Asis.Expression) return Static_Range;
function Range_Of_Type
(Object : access Calculator;
Type_Def : in Asis.Definition) return Static_Range;
function String_Constant_Range
(Object : access Calculator;
Decl : in Asis.Declaration) return Static_Range;
package S is new XASIS.Static.Iter
(Value, Static_Range, Calculator,
Literal => Literal,
Operator => Operator,
Attribute => Attribute,
Attribute_Call => Attribute_Call,
Check_Range => Check_Range,
Undefined => Undefined,
Range_Of_Array => Range_Of_Array,
Range_Of_Type => Range_Of_Type,
String_Constant_Range => String_Constant_Range);
function Get_Type_Class (Info : Classes.Type_Info) return Type_Class'Class;
function "+" (Item : Asis.ASIS_Integer) return XASIS.Integers.Value;
function Check_Range
(Object : access Calculator;
Val : in Value;
Bounds : in Static_Range;
Invert : in Boolean) return Value;
---------
-- "+" --
---------
function "+" (Item : Value) return Asis.ASIS_Integer is
begin
if Item.Kind = Static_Discrete then
return Asis.ASIS_Integer'Value (XASIS.Integers.Image (Item.Pos));
else
Raise_Error (Unexpected_Type);
return 0;
end if;
end "+";
---------
-- "+" --
---------
function "+" (Item : Asis.ASIS_Integer) return XASIS.Integers.Value is
begin
return XASIS.Integers.Literal (Asis.ASIS_Integer'Image (Item));
end "+";
------------
-- Adjust --
------------
procedure Adjust (Object : in out Integer_Array_Node) is
begin
if Object.Data /= null then
Object.Data := new Integer_Array'(Object.Data.all);
end if;
end Adjust;
-------------------------------------
-- Attribute_Designator_Expression --
-------------------------------------
function Attribute_Designator_Expression
(Attr : Asis.Expression)
return Value
is
Args : constant Asis.Expression_List :=
Asis.Expressions.Attribute_Designator_Expressions (Attr);
begin
if Args'Length > 0 then
return Evaluate (Args (1));
else
return Static_One;
end if;
end Attribute_Designator_Expression;
----------------
-- Check_Zero --
----------------
procedure Check_Zero (Item : Value) is
begin
if Item = Static_Zero or Item = (Static_Float, Fractions.Zero) then
Raise_Error (Division_By_Zero);
end if;
end Check_Zero;
-----------------
-- Debug_Image --
-----------------
function Debug_Image (Item : Value) return Wide_String is
use Ada.Characters.Handling;
begin
case Item.Kind is
when Static_Discrete =>
return "Static_Discrete:" &
To_Wide_String (XASIS.Integers.Image (Item.Pos));
when Static_Undefined =>
return "Static_Undefined";
when others =>
return "";
end case;
end Debug_Image;
--------------
-- Evaluate --
--------------
function Evaluate (Element : Asis.Expression) return Value is
Object : aliased Calculator;
begin
return S.Evaluate (Object'Access, Element);
end Evaluate;
--------------
-- Finalize --
--------------
procedure Finalize (Object : in out Integer_Array_Node) is
procedure Free is
new Ada.Unchecked_Deallocation (Integer_Array, Integer_Array_Access);
begin
if Object.Data /= null then
Free (Object.Data);
end if;
end Finalize;
--------------
-- Fraction --
--------------
function Fraction (Item : Value) return XASIS.Fractions.Fraction is
begin
return Item.Fraction;
end Fraction;
-----------
-- Image --
-----------
function Image (Item : Value) return Wide_String is
use Ada.Characters.Handling;
begin
if Item.Kind /= Static_Discrete then
Raise_Error (Unexpected_Type);
end if;
return To_Wide_String (XASIS.Integers.Image (Item.Pos));
end Image;
--------------
-- In_Range --
--------------
function In_Range
(Item : Value;
Element : Asis.Definition)
return Boolean
is
Object : aliased Calculator;
Rng : constant Static_Range :=
S.Get_Discrete_Range (Object'Access, Element);
begin
return Check_Range (Object'Access, Item, Rng, False) = Static_True;
end In_Range;
-------------
-- Integer --
-------------
function Integer (Item : Value) return XASIS.Integers.Value is
begin
return Item.Pos;
end Integer;
----------------------------
-- Static_Range_Attribute --
----------------------------
function Static_Range_Attribute
(Attr : Asis.Expression)
return Static_Range
is
Object : aliased Calculator;
begin
return S.Static_Range_Attribute (Object'Access, Attr);
end Static_Range_Attribute;
--------------------
-- Get_Type_Class --
--------------------
function Get_Type_Class
(Info : Classes.Type_Info) return Type_Class'Class is
begin
if Classes.Is_Discrete (Info) then
if Classes.Is_Integer (Info) then
if Classes.Is_Modular_Integer (Info) then
return Unsigned.Type_Class'(Info => Info);
else
return Signed.Type_Class'(Info => Info);
end if;
else
return Discrete.Type_Class'(Info => Info);
end if;
elsif Classes.Is_Float_Point (Info) then
return Float.Type_Class'(Info => Info);
elsif Classes.Is_Fixed_Point (Info) then
return Fixed.Type_Class'(Info => Info);
else
Raise_Error (Not_Implemented);
return Get_Type_Class (Info);
end if;
end Get_Type_Class;
---------------
-- Undefined --
---------------
function Undefined return Value is
begin
return (Kind => Static_Undefined);
end Undefined;
---------------------------------------------
-- Static.Iter procedures inplimentation --
---------------------------------------------
-------------
-- Literal --
-------------
function Literal
(Object : access Calculator;
Element : in Asis.Expression) return Value
is
use Asis;
use Asis.Elements;
use Asis.Expressions;
Kind : constant Asis.Expression_Kinds := Expression_Kind (Element);
begin
case Kind is
when An_Integer_Literal =>
declare
Text : constant String :=
Ada.Characters.Handling.To_String (Value_Image (Element));
begin
return Discrete.I (XASIS.Integers.Literal (Text));
end;
when A_Real_Literal =>
declare
Text : constant String :=
Ada.Characters.Handling.To_String (Value_Image (Element));
begin
return Float.V (XASIS.Fractions.Value(Text));
end;
when An_Enumeration_Literal | A_Character_Literal | An_Identifier =>
declare
Decl : constant Asis.Declaration :=
XASIS.Utils.Selected_Name_Declaration (Element, False);
Name : constant Asis.Defining_Name :=
Asis.Declarations.Names (Decl) (1);
Pos : constant Wide_String :=
Asis.Declarations.Position_Number_Image (Name);
Text : constant String :=
Ada.Characters.Handling.To_String (Pos);
begin
if Is_Part_Of_Implicit (Decl) then -- impl defined character
declare
Img : constant Wide_String := Name_Image (Element);
Pos : constant Asis.ASIS_Natural :=
Wide_Character'Pos (Img (2));
begin
return Discrete.I (+Pos);
end;
else
return Discrete.I (XASIS.Integers.Literal (Text));
end if;
end;
when A_String_Literal =>
declare
use Ada.Finalization;
function Dequote (Text : Wide_String) return Wide_String is
Result : Wide_String (Text'Range);
Last : Natural := Result'First - 1;
Skip : Boolean := False;
begin
for J in Text'First + 2 .. Text'Last - 2 loop
if Skip then
Skip := False;
else
Last := Last + 1;
Result (Last) := Text (J);
Skip := Text (J) = '"';
end if;
end loop;
return Result (Result'First .. Last);
end Dequote;
Image : constant Wide_String :=
Dequote (Value_Image (Element));
Text : Integer_Array (1 .. Image'Length);
begin
for J in Image'Range loop
Text (Asis.ASIS_Positive (J)) :=
+Wide_Character'Pos (Image (J));
end loop;
return (Kind => Static_String,
Lower => XASIS.Integers.One, -- TODO
Upper => + (Text'Last),
String => (Controlled with new Integer_Array'(Text)));
end;
when others =>
Raise_Error (Internal_Error);
return Undefined;
end case;
end Literal;
--------------
-- Operator --
--------------
function Operator
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Operator_Kinds;
Args : in Asis.Association_List) return Value
is
Switch : Type_Class'Class := Get_Type_Class (Tipe);
begin
return Evaluate (Switch, Kind, Args);
end Operator;
---------------
-- Attribute --
---------------
function Attribute
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Attribute_Kinds;
Element : in Asis.Expression) return Value
is
Switch : Type_Class'Class := Get_Type_Class (Tipe);
begin
return Evaluate (Switch, Kind, Element);
end Attribute;
--------------------
-- Attribute_Call --
--------------------
function Attribute_Call
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Attribute_Kinds;
Args : in Asis.Association_List) return Value
is
Switch : Type_Class'Class := Get_Type_Class (Tipe);
begin
return Evaluate (Switch, Kind, Args);
end Attribute_Call;
-----------------
-- Check_Range --
-----------------
function Check_Range
(Object : access Calculator;
Expr : in Asis.Expression;
Bounds : in Static_Range;
Invert : in Boolean) return Value
is
Val : constant Value := S.Evaluate (Object, Expr);
begin
return Check_Range (Object, Val, Bounds, Invert);
end Check_Range;
-----------------
-- Check_Range --
-----------------
function Check_Range
(Object : access Calculator;
Val : in Value;
Bounds : in Static_Range;
Invert : in Boolean) return Value
is
use XASIS.Integers;
begin
if Discrete.Is_Discrete (Val)
and then Discrete.Is_Discrete (Bounds (Lower))
then
if Val.Pos < Bounds (Lower).Pos then
if Invert then
return Static_True;
else
return Static_False;
end if;
elsif Discrete.Is_Discrete (Bounds (Upper)) then
if Val.Pos <= Bounds (Upper).Pos xor Invert then
return Static_True;
else
return Static_False;
end if;
end if;
end if;
return Undefined;
end Check_Range;
----------------
-- Last_Error --
----------------
procedure Last_Error (Reason : out Error_Reason) is
begin
Reason := Last_Error_Reason;
end Last_Error;
---------------
-- Undefined --
---------------
function Undefined
(Object : access Calculator;
Element : in Asis.Expression) return Value
is
begin
return Undefined;
end Undefined;
-----------------
-- Raise_Error --
-----------------
procedure Raise_Error (Reason : Error_Reason) is
begin
Last_Error_Reason := Reason;
raise Evaluation_Error;
end Raise_Error;
--------------------
-- Range_Of_Array --
--------------------
function Range_Of_Array
(Object : access Calculator;
Decl : in Asis.Declaration;
Attr : in Asis.Expression) return Static_Range
is
Val : constant Value := Attribute_Designator_Expression (Attr);
Index : Asis.ASIS_Positive;
begin
if Discrete.Is_Discrete (Val) then
Index := +Val;
else
return (Undefined, Undefined);
end if;
return S.Constrained_Array_Range (Object, Decl, Index);
end Range_Of_Array;
-------------------
-- Range_Of_Type --
-------------------
function Range_Of_Type
(Object : access Calculator;
Type_Def : in Asis.Definition) return Static_Range
is
use Asis;
use Asis.Definitions;
begin
case Asis.Elements.Type_Kind (Type_Def) is
when An_Enumeration_Type_Definition =>
declare
List : constant Asis.Declaration_List :=
Enumeration_Literal_Declarations (Type_Def);
Last : constant XASIS.Integers.Value := +(List'Length - 1);
begin
return (Static_Zero, Discrete.I (Last));
end;
when A_Signed_Integer_Type_Definition =>
return (Undefined, Undefined);
when A_Modular_Type_Definition =>
declare
use XASIS.Integers;
Module : constant Asis.Expression :=
Mod_Static_Expression (Type_Def);
Val : constant Value := S.Evaluate (Object, Module);
begin
if Discrete.Is_Discrete (Val) then
return (Static_Zero, Discrete.I (Val.Pos - One));
else
return (Undefined, Undefined);
end if;
end;
when A_Floating_Point_Definition
| An_Ordinary_Fixed_Point_Definition
| A_Decimal_Fixed_Point_Definition
=>
return (Undefined, Undefined);
when others =>
Raise_Error (Internal_Error);
return (Undefined, Undefined);
end case;
end Range_Of_Type;
---------------------------
-- String_Constant_Range --
---------------------------
function String_Constant_Range
(Object : access Calculator;
Decl : in Asis.Declaration) return Static_Range
is
use XASIS.Static.Discrete;
Val : constant Value := S.Evaluate_Static_Constant (Object, Decl);
begin
if Val.Kind = Static_Undefined then
return (Undefined, Undefined);
elsif Val.Kind = Static_String then
return (I (Val.Lower), I (Val.Upper));
else
Raise_Error (Unexpected_Type);
return (Undefined, Undefined);
end if;
end String_Constant_Range;
--------------
-- To_Fixed --
--------------
function To_Fixed
(Item : Value;
Tipe : Classes.Type_Info) return XASIS.Integers.Value is
begin
return Fixed.V (Item, Tipe).Fixed;
end To_Fixed;
end XASIS.Static;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, Maxim Reznik
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the Maxim Reznik, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
| 28874 | ------------------------------------------------------------------------------
-- G E L A X A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
with Ada.Characters.Handling;
with Ada.Unchecked_Deallocation;
with Asis.Elements;
with Asis.Definitions;
with Asis.Expressions;
with Asis.Declarations;
with XASIS.Static.Iter;
with XASIS.Static.Signed;
with XASIS.Static.Discrete;
with XASIS.Static.Unsigned;
with XASIS.Static.Float;
with XASIS.Static.Fixed;
with XASIS.Utils;
pragma Elaborate (XASIS.Static.Iter);
package body XASIS.Static is
type Calculator is null record;
function Literal
(Object : access Calculator;
Element : in Asis.Expression) return Value;
function Operator
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Operator_Kinds;
Args : in Asis.Association_List) return Value;
function Attribute
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Attribute_Kinds;
Element : in Asis.Expression) return Value;
function Attribute_Call
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Attribute_Kinds;
Args : in Asis.Association_List) return Value;
function Check_Range
(Object : access Calculator;
Expr : in Asis.Expression;
Bounds : in Static_Range;
Invert : in Boolean) return Value;
function Undefined
(Object : access Calculator;
Element : in Asis.Expression) return Value;
function Range_Of_Array
(Object : access Calculator;
Decl : in Asis.Declaration;
Attr : in Asis.Expression) return Static_Range;
function Range_Of_Type
(Object : access Calculator;
Type_Def : in Asis.Definition) return Static_Range;
function String_Constant_Range
(Object : access Calculator;
Decl : in Asis.Declaration) return Static_Range;
package S is new XASIS.Static.Iter
(Value, Static_Range, Calculator,
Literal => Literal,
Operator => Operator,
Attribute => Attribute,
Attribute_Call => Attribute_Call,
Check_Range => Check_Range,
Undefined => Undefined,
Range_Of_Array => Range_Of_Array,
Range_Of_Type => Range_Of_Type,
String_Constant_Range => String_Constant_Range);
function Get_Type_Class (Info : Classes.Type_Info) return Type_Class'Class;
function "+" (Item : Asis.ASIS_Integer) return XASIS.Integers.Value;
function Check_Range
(Object : access Calculator;
Val : in Value;
Bounds : in Static_Range;
Invert : in Boolean) return Value;
---------
-- "+" --
---------
function "+" (Item : Value) return Asis.ASIS_Integer is
begin
if Item.Kind = Static_Discrete then
return Asis.ASIS_Integer'Value (XASIS.Integers.Image (Item.Pos));
else
Raise_Error (Unexpected_Type);
return 0;
end if;
end "+";
---------
-- "+" --
---------
function "+" (Item : Asis.ASIS_Integer) return XASIS.Integers.Value is
begin
return XASIS.Integers.Literal (Asis.ASIS_Integer'Image (Item));
end "+";
------------
-- Adjust --
------------
procedure Adjust (Object : in out Integer_Array_Node) is
begin
if Object.Data /= null then
Object.Data := new Integer_Array'(Object.Data.all);
end if;
end Adjust;
-------------------------------------
-- Attribute_Designator_Expression --
-------------------------------------
function Attribute_Designator_Expression
(Attr : Asis.Expression)
return Value
is
Args : constant Asis.Expression_List :=
Asis.Expressions.Attribute_Designator_Expressions (Attr);
begin
if Args'Length > 0 then
return Evaluate (Args (1));
else
return Static_One;
end if;
end Attribute_Designator_Expression;
----------------
-- Check_Zero --
----------------
procedure Check_Zero (Item : Value) is
begin
if Item = Static_Zero or Item = (Static_Float, Fractions.Zero) then
Raise_Error (Division_By_Zero);
end if;
end Check_Zero;
-----------------
-- Debug_Image --
-----------------
function Debug_Image (Item : Value) return Wide_String is
use Ada.Characters.Handling;
begin
case Item.Kind is
when Static_Discrete =>
return "Static_Discrete:" &
To_Wide_String (XASIS.Integers.Image (Item.Pos));
when Static_Undefined =>
return "Static_Undefined";
when others =>
return "";
end case;
end Debug_Image;
--------------
-- Evaluate --
--------------
function Evaluate (Element : Asis.Expression) return Value is
Object : aliased Calculator;
begin
return S.Evaluate (Object'Access, Element);
end Evaluate;
--------------
-- Finalize --
--------------
procedure Finalize (Object : in out Integer_Array_Node) is
procedure Free is
new Ada.Unchecked_Deallocation (Integer_Array, Integer_Array_Access);
begin
if Object.Data /= null then
Free (Object.Data);
end if;
end Finalize;
--------------
-- Fraction --
--------------
function Fraction (Item : Value) return XASIS.Fractions.Fraction is
begin
return Item.Fraction;
end Fraction;
-----------
-- Image --
-----------
function Image (Item : Value) return Wide_String is
use Ada.Characters.Handling;
begin
if Item.Kind /= Static_Discrete then
Raise_Error (Unexpected_Type);
end if;
return To_Wide_String (XASIS.Integers.Image (Item.Pos));
end Image;
--------------
-- In_Range --
--------------
function In_Range
(Item : Value;
Element : Asis.Definition)
return Boolean
is
Object : aliased Calculator;
Rng : constant Static_Range :=
S.Get_Discrete_Range (Object'Access, Element);
begin
return Check_Range (Object'Access, Item, Rng, False) = Static_True;
end In_Range;
-------------
-- Integer --
-------------
function Integer (Item : Value) return XASIS.Integers.Value is
begin
return Item.Pos;
end Integer;
----------------------------
-- Static_Range_Attribute --
----------------------------
function Static_Range_Attribute
(Attr : Asis.Expression)
return Static_Range
is
Object : aliased Calculator;
begin
return S.Static_Range_Attribute (Object'Access, Attr);
end Static_Range_Attribute;
--------------------
-- Get_Type_Class --
--------------------
function Get_Type_Class
(Info : Classes.Type_Info) return Type_Class'Class is
begin
if Classes.Is_Discrete (Info) then
if Classes.Is_Integer (Info) then
if Classes.Is_Modular_Integer (Info) then
return Unsigned.Type_Class'(Info => Info);
else
return Signed.Type_Class'(Info => Info);
end if;
else
return Discrete.Type_Class'(Info => Info);
end if;
elsif Classes.Is_Float_Point (Info) then
return Float.Type_Class'(Info => Info);
elsif Classes.Is_Fixed_Point (Info) then
return Fixed.Type_Class'(Info => Info);
else
Raise_Error (Not_Implemented);
return Get_Type_Class (Info);
end if;
end Get_Type_Class;
---------------
-- Undefined --
---------------
function Undefined return Value is
begin
return (Kind => Static_Undefined);
end Undefined;
---------------------------------------------
-- Static.Iter procedures inplimentation --
---------------------------------------------
-------------
-- Literal --
-------------
function Literal
(Object : access Calculator;
Element : in Asis.Expression) return Value
is
use Asis;
use Asis.Elements;
use Asis.Expressions;
Kind : constant Asis.Expression_Kinds := Expression_Kind (Element);
begin
case Kind is
when An_Integer_Literal =>
declare
Text : constant String :=
Ada.Characters.Handling.To_String (Value_Image (Element));
begin
return Discrete.I (XASIS.Integers.Literal (Text));
end;
when A_Real_Literal =>
declare
Text : constant String :=
Ada.Characters.Handling.To_String (Value_Image (Element));
begin
return Float.V (XASIS.Fractions.Value(Text));
end;
when An_Enumeration_Literal | A_Character_Literal | An_Identifier =>
declare
Decl : constant Asis.Declaration :=
XASIS.Utils.Selected_Name_Declaration (Element, False);
Name : constant Asis.Defining_Name :=
Asis.Declarations.Names (Decl) (1);
Pos : constant Wide_String :=
Asis.Declarations.Position_Number_Image (Name);
Text : constant String :=
Ada.Characters.Handling.To_String (Pos);
begin
if Is_Part_Of_Implicit (Decl) then -- impl defined character
declare
Img : constant Wide_String := Name_Image (Element);
Pos : constant Asis.ASIS_Natural :=
Wide_Character'Pos (Img (2));
begin
return Discrete.I (+Pos);
end;
else
return Discrete.I (XASIS.Integers.Literal (Text));
end if;
end;
when A_String_Literal =>
declare
use Ada.Finalization;
function Dequote (Text : Wide_String) return Wide_String is
Result : Wide_String (Text'Range);
Last : Natural := Result'First - 1;
Skip : Boolean := False;
begin
for J in Text'First + 2 .. Text'Last - 2 loop
if Skip then
Skip := False;
else
Last := Last + 1;
Result (Last) := Text (J);
Skip := Text (J) = '"';
end if;
end loop;
return Result (Result'First .. Last);
end Dequote;
Image : constant Wide_String :=
Dequote (Value_Image (Element));
Text : Integer_Array (1 .. Image'Length);
begin
for J in Image'Range loop
Text (Asis.ASIS_Positive (J)) :=
+Wide_Character'Pos (Image (J));
end loop;
return (Kind => Static_String,
Lower => XASIS.Integers.One, -- TODO
Upper => + (Text'Last),
String => (Controlled with new Integer_Array'(Text)));
end;
when others =>
Raise_Error (Internal_Error);
return Undefined;
end case;
end Literal;
--------------
-- Operator --
--------------
function Operator
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Operator_Kinds;
Args : in Asis.Association_List) return Value
is
Switch : Type_Class'Class := Get_Type_Class (Tipe);
begin
return Evaluate (Switch, Kind, Args);
end Operator;
---------------
-- Attribute --
---------------
function Attribute
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Attribute_Kinds;
Element : in Asis.Expression) return Value
is
Switch : Type_Class'Class := Get_Type_Class (Tipe);
begin
return Evaluate (Switch, Kind, Element);
end Attribute;
--------------------
-- Attribute_Call --
--------------------
function Attribute_Call
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Attribute_Kinds;
Args : in Asis.Association_List) return Value
is
Switch : Type_Class'Class := Get_Type_Class (Tipe);
begin
return Evaluate (Switch, Kind, Args);
end Attribute_Call;
-----------------
-- Check_Range --
-----------------
function Check_Range
(Object : access Calculator;
Expr : in Asis.Expression;
Bounds : in Static_Range;
Invert : in Boolean) return Value
is
Val : constant Value := S.Evaluate (Object, Expr);
begin
return Check_Range (Object, Val, Bounds, Invert);
end Check_Range;
-----------------
-- Check_Range --
-----------------
function Check_Range
(Object : access Calculator;
Val : in Value;
Bounds : in Static_Range;
Invert : in Boolean) return Value
is
use XASIS.Integers;
begin
if Discrete.Is_Discrete (Val)
and then Discrete.Is_Discrete (Bounds (Lower))
then
if Val.Pos < Bounds (Lower).Pos then
if Invert then
return Static_True;
else
return Static_False;
end if;
elsif Discrete.Is_Discrete (Bounds (Upper)) then
if Val.Pos <= Bounds (Upper).Pos xor Invert then
return Static_True;
else
return Static_False;
end if;
end if;
end if;
return Undefined;
end Check_Range;
----------------
-- Last_Error --
----------------
procedure Last_Error (Reason : out Error_Reason) is
begin
Reason := Last_Error_Reason;
end Last_Error;
---------------
-- Undefined --
---------------
function Undefined
(Object : access Calculator;
Element : in Asis.Expression) return Value
is
begin
return Undefined;
end Undefined;
-----------------
-- Raise_Error --
-----------------
procedure Raise_Error (Reason : Error_Reason) is
begin
Last_Error_Reason := Reason;
raise Evaluation_Error;
end Raise_Error;
--------------------
-- Range_Of_Array --
--------------------
function Range_Of_Array
(Object : access Calculator;
Decl : in Asis.Declaration;
Attr : in Asis.Expression) return Static_Range
is
Val : constant Value := Attribute_Designator_Expression (Attr);
Index : Asis.ASIS_Positive;
begin
if Discrete.Is_Discrete (Val) then
Index := +Val;
else
return (Undefined, Undefined);
end if;
return S.Constrained_Array_Range (Object, Decl, Index);
end Range_Of_Array;
-------------------
-- Range_Of_Type --
-------------------
function Range_Of_Type
(Object : access Calculator;
Type_Def : in Asis.Definition) return Static_Range
is
use Asis;
use Asis.Definitions;
begin
case Asis.Elements.Type_Kind (Type_Def) is
when An_Enumeration_Type_Definition =>
declare
List : constant Asis.Declaration_List :=
Enumeration_Literal_Declarations (Type_Def);
Last : constant XASIS.Integers.Value := +(List'Length - 1);
begin
return (Static_Zero, Discrete.I (Last));
end;
when A_Signed_Integer_Type_Definition =>
return (Undefined, Undefined);
when A_Modular_Type_Definition =>
declare
use XASIS.Integers;
Module : constant Asis.Expression :=
Mod_Static_Expression (Type_Def);
Val : constant Value := S.Evaluate (Object, Module);
begin
if Discrete.Is_Discrete (Val) then
return (Static_Zero, Discrete.I (Val.Pos - One));
else
return (Undefined, Undefined);
end if;
end;
when A_Floating_Point_Definition
| An_Ordinary_Fixed_Point_Definition
| A_Decimal_Fixed_Point_Definition
=>
return (Undefined, Undefined);
when others =>
Raise_Error (Internal_Error);
return (Undefined, Undefined);
end case;
end Range_Of_Type;
---------------------------
-- String_Constant_Range --
---------------------------
function String_Constant_Range
(Object : access Calculator;
Decl : in Asis.Declaration) return Static_Range
is
use XASIS.Static.Discrete;
Val : constant Value := S.Evaluate_Static_Constant (Object, Decl);
begin
if Val.Kind = Static_Undefined then
return (Undefined, Undefined);
elsif Val.Kind = Static_String then
return (I (Val.Lower), I (Val.Upper));
else
Raise_Error (Unexpected_Type);
return (Undefined, Undefined);
end if;
end String_Constant_Range;
--------------
-- To_Fixed --
--------------
function To_Fixed
(Item : Value;
Tipe : Classes.Type_Info) return XASIS.Integers.Value is
begin
return Fixed.V (Item, Tipe).Fixed;
end To_Fixed;
end XASIS.Static;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, <NAME>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the <NAME>, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
| true | ------------------------------------------------------------------------------
-- G E L A X A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
with Ada.Characters.Handling;
with Ada.Unchecked_Deallocation;
with Asis.Elements;
with Asis.Definitions;
with Asis.Expressions;
with Asis.Declarations;
with XASIS.Static.Iter;
with XASIS.Static.Signed;
with XASIS.Static.Discrete;
with XASIS.Static.Unsigned;
with XASIS.Static.Float;
with XASIS.Static.Fixed;
with XASIS.Utils;
pragma Elaborate (XASIS.Static.Iter);
package body XASIS.Static is
type Calculator is null record;
function Literal
(Object : access Calculator;
Element : in Asis.Expression) return Value;
function Operator
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Operator_Kinds;
Args : in Asis.Association_List) return Value;
function Attribute
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Attribute_Kinds;
Element : in Asis.Expression) return Value;
function Attribute_Call
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Attribute_Kinds;
Args : in Asis.Association_List) return Value;
function Check_Range
(Object : access Calculator;
Expr : in Asis.Expression;
Bounds : in Static_Range;
Invert : in Boolean) return Value;
function Undefined
(Object : access Calculator;
Element : in Asis.Expression) return Value;
function Range_Of_Array
(Object : access Calculator;
Decl : in Asis.Declaration;
Attr : in Asis.Expression) return Static_Range;
function Range_Of_Type
(Object : access Calculator;
Type_Def : in Asis.Definition) return Static_Range;
function String_Constant_Range
(Object : access Calculator;
Decl : in Asis.Declaration) return Static_Range;
package S is new XASIS.Static.Iter
(Value, Static_Range, Calculator,
Literal => Literal,
Operator => Operator,
Attribute => Attribute,
Attribute_Call => Attribute_Call,
Check_Range => Check_Range,
Undefined => Undefined,
Range_Of_Array => Range_Of_Array,
Range_Of_Type => Range_Of_Type,
String_Constant_Range => String_Constant_Range);
function Get_Type_Class (Info : Classes.Type_Info) return Type_Class'Class;
function "+" (Item : Asis.ASIS_Integer) return XASIS.Integers.Value;
function Check_Range
(Object : access Calculator;
Val : in Value;
Bounds : in Static_Range;
Invert : in Boolean) return Value;
---------
-- "+" --
---------
function "+" (Item : Value) return Asis.ASIS_Integer is
begin
if Item.Kind = Static_Discrete then
return Asis.ASIS_Integer'Value (XASIS.Integers.Image (Item.Pos));
else
Raise_Error (Unexpected_Type);
return 0;
end if;
end "+";
---------
-- "+" --
---------
function "+" (Item : Asis.ASIS_Integer) return XASIS.Integers.Value is
begin
return XASIS.Integers.Literal (Asis.ASIS_Integer'Image (Item));
end "+";
------------
-- Adjust --
------------
procedure Adjust (Object : in out Integer_Array_Node) is
begin
if Object.Data /= null then
Object.Data := new Integer_Array'(Object.Data.all);
end if;
end Adjust;
-------------------------------------
-- Attribute_Designator_Expression --
-------------------------------------
function Attribute_Designator_Expression
(Attr : Asis.Expression)
return Value
is
Args : constant Asis.Expression_List :=
Asis.Expressions.Attribute_Designator_Expressions (Attr);
begin
if Args'Length > 0 then
return Evaluate (Args (1));
else
return Static_One;
end if;
end Attribute_Designator_Expression;
----------------
-- Check_Zero --
----------------
procedure Check_Zero (Item : Value) is
begin
if Item = Static_Zero or Item = (Static_Float, Fractions.Zero) then
Raise_Error (Division_By_Zero);
end if;
end Check_Zero;
-----------------
-- Debug_Image --
-----------------
function Debug_Image (Item : Value) return Wide_String is
use Ada.Characters.Handling;
begin
case Item.Kind is
when Static_Discrete =>
return "Static_Discrete:" &
To_Wide_String (XASIS.Integers.Image (Item.Pos));
when Static_Undefined =>
return "Static_Undefined";
when others =>
return "";
end case;
end Debug_Image;
--------------
-- Evaluate --
--------------
function Evaluate (Element : Asis.Expression) return Value is
Object : aliased Calculator;
begin
return S.Evaluate (Object'Access, Element);
end Evaluate;
--------------
-- Finalize --
--------------
procedure Finalize (Object : in out Integer_Array_Node) is
procedure Free is
new Ada.Unchecked_Deallocation (Integer_Array, Integer_Array_Access);
begin
if Object.Data /= null then
Free (Object.Data);
end if;
end Finalize;
--------------
-- Fraction --
--------------
function Fraction (Item : Value) return XASIS.Fractions.Fraction is
begin
return Item.Fraction;
end Fraction;
-----------
-- Image --
-----------
function Image (Item : Value) return Wide_String is
use Ada.Characters.Handling;
begin
if Item.Kind /= Static_Discrete then
Raise_Error (Unexpected_Type);
end if;
return To_Wide_String (XASIS.Integers.Image (Item.Pos));
end Image;
--------------
-- In_Range --
--------------
function In_Range
(Item : Value;
Element : Asis.Definition)
return Boolean
is
Object : aliased Calculator;
Rng : constant Static_Range :=
S.Get_Discrete_Range (Object'Access, Element);
begin
return Check_Range (Object'Access, Item, Rng, False) = Static_True;
end In_Range;
-------------
-- Integer --
-------------
function Integer (Item : Value) return XASIS.Integers.Value is
begin
return Item.Pos;
end Integer;
----------------------------
-- Static_Range_Attribute --
----------------------------
function Static_Range_Attribute
(Attr : Asis.Expression)
return Static_Range
is
Object : aliased Calculator;
begin
return S.Static_Range_Attribute (Object'Access, Attr);
end Static_Range_Attribute;
--------------------
-- Get_Type_Class --
--------------------
function Get_Type_Class
(Info : Classes.Type_Info) return Type_Class'Class is
begin
if Classes.Is_Discrete (Info) then
if Classes.Is_Integer (Info) then
if Classes.Is_Modular_Integer (Info) then
return Unsigned.Type_Class'(Info => Info);
else
return Signed.Type_Class'(Info => Info);
end if;
else
return Discrete.Type_Class'(Info => Info);
end if;
elsif Classes.Is_Float_Point (Info) then
return Float.Type_Class'(Info => Info);
elsif Classes.Is_Fixed_Point (Info) then
return Fixed.Type_Class'(Info => Info);
else
Raise_Error (Not_Implemented);
return Get_Type_Class (Info);
end if;
end Get_Type_Class;
---------------
-- Undefined --
---------------
function Undefined return Value is
begin
return (Kind => Static_Undefined);
end Undefined;
---------------------------------------------
-- Static.Iter procedures inplimentation --
---------------------------------------------
-------------
-- Literal --
-------------
function Literal
(Object : access Calculator;
Element : in Asis.Expression) return Value
is
use Asis;
use Asis.Elements;
use Asis.Expressions;
Kind : constant Asis.Expression_Kinds := Expression_Kind (Element);
begin
case Kind is
when An_Integer_Literal =>
declare
Text : constant String :=
Ada.Characters.Handling.To_String (Value_Image (Element));
begin
return Discrete.I (XASIS.Integers.Literal (Text));
end;
when A_Real_Literal =>
declare
Text : constant String :=
Ada.Characters.Handling.To_String (Value_Image (Element));
begin
return Float.V (XASIS.Fractions.Value(Text));
end;
when An_Enumeration_Literal | A_Character_Literal | An_Identifier =>
declare
Decl : constant Asis.Declaration :=
XASIS.Utils.Selected_Name_Declaration (Element, False);
Name : constant Asis.Defining_Name :=
Asis.Declarations.Names (Decl) (1);
Pos : constant Wide_String :=
Asis.Declarations.Position_Number_Image (Name);
Text : constant String :=
Ada.Characters.Handling.To_String (Pos);
begin
if Is_Part_Of_Implicit (Decl) then -- impl defined character
declare
Img : constant Wide_String := Name_Image (Element);
Pos : constant Asis.ASIS_Natural :=
Wide_Character'Pos (Img (2));
begin
return Discrete.I (+Pos);
end;
else
return Discrete.I (XASIS.Integers.Literal (Text));
end if;
end;
when A_String_Literal =>
declare
use Ada.Finalization;
function Dequote (Text : Wide_String) return Wide_String is
Result : Wide_String (Text'Range);
Last : Natural := Result'First - 1;
Skip : Boolean := False;
begin
for J in Text'First + 2 .. Text'Last - 2 loop
if Skip then
Skip := False;
else
Last := Last + 1;
Result (Last) := Text (J);
Skip := Text (J) = '"';
end if;
end loop;
return Result (Result'First .. Last);
end Dequote;
Image : constant Wide_String :=
Dequote (Value_Image (Element));
Text : Integer_Array (1 .. Image'Length);
begin
for J in Image'Range loop
Text (Asis.ASIS_Positive (J)) :=
+Wide_Character'Pos (Image (J));
end loop;
return (Kind => Static_String,
Lower => XASIS.Integers.One, -- TODO
Upper => + (Text'Last),
String => (Controlled with new Integer_Array'(Text)));
end;
when others =>
Raise_Error (Internal_Error);
return Undefined;
end case;
end Literal;
--------------
-- Operator --
--------------
function Operator
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Operator_Kinds;
Args : in Asis.Association_List) return Value
is
Switch : Type_Class'Class := Get_Type_Class (Tipe);
begin
return Evaluate (Switch, Kind, Args);
end Operator;
---------------
-- Attribute --
---------------
function Attribute
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Attribute_Kinds;
Element : in Asis.Expression) return Value
is
Switch : Type_Class'Class := Get_Type_Class (Tipe);
begin
return Evaluate (Switch, Kind, Element);
end Attribute;
--------------------
-- Attribute_Call --
--------------------
function Attribute_Call
(Object : access Calculator;
Tipe : in Classes.Type_Info;
Kind : in Asis.Attribute_Kinds;
Args : in Asis.Association_List) return Value
is
Switch : Type_Class'Class := Get_Type_Class (Tipe);
begin
return Evaluate (Switch, Kind, Args);
end Attribute_Call;
-----------------
-- Check_Range --
-----------------
function Check_Range
(Object : access Calculator;
Expr : in Asis.Expression;
Bounds : in Static_Range;
Invert : in Boolean) return Value
is
Val : constant Value := S.Evaluate (Object, Expr);
begin
return Check_Range (Object, Val, Bounds, Invert);
end Check_Range;
-----------------
-- Check_Range --
-----------------
function Check_Range
(Object : access Calculator;
Val : in Value;
Bounds : in Static_Range;
Invert : in Boolean) return Value
is
use XASIS.Integers;
begin
if Discrete.Is_Discrete (Val)
and then Discrete.Is_Discrete (Bounds (Lower))
then
if Val.Pos < Bounds (Lower).Pos then
if Invert then
return Static_True;
else
return Static_False;
end if;
elsif Discrete.Is_Discrete (Bounds (Upper)) then
if Val.Pos <= Bounds (Upper).Pos xor Invert then
return Static_True;
else
return Static_False;
end if;
end if;
end if;
return Undefined;
end Check_Range;
----------------
-- Last_Error --
----------------
procedure Last_Error (Reason : out Error_Reason) is
begin
Reason := Last_Error_Reason;
end Last_Error;
---------------
-- Undefined --
---------------
function Undefined
(Object : access Calculator;
Element : in Asis.Expression) return Value
is
begin
return Undefined;
end Undefined;
-----------------
-- Raise_Error --
-----------------
procedure Raise_Error (Reason : Error_Reason) is
begin
Last_Error_Reason := Reason;
raise Evaluation_Error;
end Raise_Error;
--------------------
-- Range_Of_Array --
--------------------
function Range_Of_Array
(Object : access Calculator;
Decl : in Asis.Declaration;
Attr : in Asis.Expression) return Static_Range
is
Val : constant Value := Attribute_Designator_Expression (Attr);
Index : Asis.ASIS_Positive;
begin
if Discrete.Is_Discrete (Val) then
Index := +Val;
else
return (Undefined, Undefined);
end if;
return S.Constrained_Array_Range (Object, Decl, Index);
end Range_Of_Array;
-------------------
-- Range_Of_Type --
-------------------
function Range_Of_Type
(Object : access Calculator;
Type_Def : in Asis.Definition) return Static_Range
is
use Asis;
use Asis.Definitions;
begin
case Asis.Elements.Type_Kind (Type_Def) is
when An_Enumeration_Type_Definition =>
declare
List : constant Asis.Declaration_List :=
Enumeration_Literal_Declarations (Type_Def);
Last : constant XASIS.Integers.Value := +(List'Length - 1);
begin
return (Static_Zero, Discrete.I (Last));
end;
when A_Signed_Integer_Type_Definition =>
return (Undefined, Undefined);
when A_Modular_Type_Definition =>
declare
use XASIS.Integers;
Module : constant Asis.Expression :=
Mod_Static_Expression (Type_Def);
Val : constant Value := S.Evaluate (Object, Module);
begin
if Discrete.Is_Discrete (Val) then
return (Static_Zero, Discrete.I (Val.Pos - One));
else
return (Undefined, Undefined);
end if;
end;
when A_Floating_Point_Definition
| An_Ordinary_Fixed_Point_Definition
| A_Decimal_Fixed_Point_Definition
=>
return (Undefined, Undefined);
when others =>
Raise_Error (Internal_Error);
return (Undefined, Undefined);
end case;
end Range_Of_Type;
---------------------------
-- String_Constant_Range --
---------------------------
function String_Constant_Range
(Object : access Calculator;
Decl : in Asis.Declaration) return Static_Range
is
use XASIS.Static.Discrete;
Val : constant Value := S.Evaluate_Static_Constant (Object, Decl);
begin
if Val.Kind = Static_Undefined then
return (Undefined, Undefined);
elsif Val.Kind = Static_String then
return (I (Val.Lower), I (Val.Upper));
else
Raise_Error (Unexpected_Type);
return (Undefined, Undefined);
end if;
end String_Constant_Range;
--------------
-- To_Fixed --
--------------
function To_Fixed
(Item : Value;
Tipe : Classes.Type_Info) return XASIS.Integers.Value is
begin
return Fixed.V (Item, Tipe).Fixed;
end To_Fixed;
end XASIS.Static;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, PI:NAME:<NAME>END_PI
-- 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 PI:NAME:<NAME>END_PI, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
|
[
{
"context": "tests for HTTP client\n-- Copyright (C) 2012, 2020 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@g",
"end": 174,
"score": 0.9998855590820312,
"start": 159,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "ight (C) 2012, 2020 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under",
"end": 205,
"score": 0.9998871684074402,
"start": 190,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "0 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under the Apache License, Versio",
"end": 232,
"score": 0.9999281167984009,
"start": 207,
"tag": "EMAIL",
"value": "Stephane.Carrez@gmail.com"
}
] | regtests/util-http-clients-tests.ads | RREE/ada-util | 60 | -----------------------------------------------------------------------
-- util-http-clients-tests -- Unit tests for HTTP client
-- Copyright (C) 2012, 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.Strings.Unbounded;
with Util.Tests;
with Util.Tests.Servers;
with Util.Streams.Texts;
with Util.Streams.Sockets;
package Util.Http.Clients.Tests is
type Method_Type is (OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, PATCH, CONNECT, UNKNOWN);
type Test_Server is new Util.Tests.Servers.Server with record
Method : Method_Type := UNKNOWN;
Result : Ada.Strings.Unbounded.Unbounded_String;
Content_Type : Ada.Strings.Unbounded.Unbounded_String;
Length : Natural := 0;
Test_Timeout : Boolean := False;
end record;
type Test_Server_Access is access all Test_Server'Class;
-- Process the line received by the server.
overriding
procedure Process_Line (Into : in out Test_Server;
Line : in Ada.Strings.Unbounded.Unbounded_String;
Stream : in out Util.Streams.Texts.Reader_Stream'Class;
Client : in out Util.Streams.Sockets.Socket_Stream'Class);
type Test is new Util.Tests.Test with record
Server : Test_Server_Access := null;
end record;
-- Test the http Get operation.
procedure Test_Http_Get (T : in out Test);
-- Test the http HEAD operation.
procedure Test_Http_Head (T : in out Test);
-- Test the http POST operation.
procedure Test_Http_Post (T : in out Test);
-- Test the http PUT operation.
procedure Test_Http_Put (T : in out Test);
-- Test the http DELETE operation.
procedure Test_Http_Delete (T : in out Test);
-- Test the http OPTIONS operation.
procedure Test_Http_Options (T : in out Test);
-- Test the http PATCH operation.
procedure Test_Http_Patch (T : in out Test);
-- Test the http timeout.
procedure Test_Http_Timeout (T : in out Test);
overriding
procedure Set_Up (T : in out Test);
overriding
procedure Tear_Down (T : in out Test);
-- Get the test server base URI.
function Get_Uri (T : in Test) return String;
-- The <b>Http_Tests</b> package must be instantiated with one of the HTTP implementation.
-- The <b>Register</b> procedure configures the Http.Client to use the given HTTP
-- implementation before running the test.
generic
with procedure Register;
NAME : in String;
package Http_Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Http_Test is new Test with null record;
overriding
procedure Set_Up (T : in out Http_Test);
end Http_Tests;
end Util.Http.Clients.Tests;
| 6228 | -----------------------------------------------------------------------
-- util-http-clients-tests -- Unit tests for HTTP client
-- Copyright (C) 2012, 2020 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Util.Tests;
with Util.Tests.Servers;
with Util.Streams.Texts;
with Util.Streams.Sockets;
package Util.Http.Clients.Tests is
type Method_Type is (OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, PATCH, CONNECT, UNKNOWN);
type Test_Server is new Util.Tests.Servers.Server with record
Method : Method_Type := UNKNOWN;
Result : Ada.Strings.Unbounded.Unbounded_String;
Content_Type : Ada.Strings.Unbounded.Unbounded_String;
Length : Natural := 0;
Test_Timeout : Boolean := False;
end record;
type Test_Server_Access is access all Test_Server'Class;
-- Process the line received by the server.
overriding
procedure Process_Line (Into : in out Test_Server;
Line : in Ada.Strings.Unbounded.Unbounded_String;
Stream : in out Util.Streams.Texts.Reader_Stream'Class;
Client : in out Util.Streams.Sockets.Socket_Stream'Class);
type Test is new Util.Tests.Test with record
Server : Test_Server_Access := null;
end record;
-- Test the http Get operation.
procedure Test_Http_Get (T : in out Test);
-- Test the http HEAD operation.
procedure Test_Http_Head (T : in out Test);
-- Test the http POST operation.
procedure Test_Http_Post (T : in out Test);
-- Test the http PUT operation.
procedure Test_Http_Put (T : in out Test);
-- Test the http DELETE operation.
procedure Test_Http_Delete (T : in out Test);
-- Test the http OPTIONS operation.
procedure Test_Http_Options (T : in out Test);
-- Test the http PATCH operation.
procedure Test_Http_Patch (T : in out Test);
-- Test the http timeout.
procedure Test_Http_Timeout (T : in out Test);
overriding
procedure Set_Up (T : in out Test);
overriding
procedure Tear_Down (T : in out Test);
-- Get the test server base URI.
function Get_Uri (T : in Test) return String;
-- The <b>Http_Tests</b> package must be instantiated with one of the HTTP implementation.
-- The <b>Register</b> procedure configures the Http.Client to use the given HTTP
-- implementation before running the test.
generic
with procedure Register;
NAME : in String;
package Http_Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Http_Test is new Test with null record;
overriding
procedure Set_Up (T : in out Http_Test);
end Http_Tests;
end Util.Http.Clients.Tests;
| true | -----------------------------------------------------------------------
-- util-http-clients-tests -- Unit tests for HTTP client
-- Copyright (C) 2012, 2020 PI:NAME:<NAME>END_PI
-- Written by PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Util.Tests;
with Util.Tests.Servers;
with Util.Streams.Texts;
with Util.Streams.Sockets;
package Util.Http.Clients.Tests is
type Method_Type is (OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, PATCH, CONNECT, UNKNOWN);
type Test_Server is new Util.Tests.Servers.Server with record
Method : Method_Type := UNKNOWN;
Result : Ada.Strings.Unbounded.Unbounded_String;
Content_Type : Ada.Strings.Unbounded.Unbounded_String;
Length : Natural := 0;
Test_Timeout : Boolean := False;
end record;
type Test_Server_Access is access all Test_Server'Class;
-- Process the line received by the server.
overriding
procedure Process_Line (Into : in out Test_Server;
Line : in Ada.Strings.Unbounded.Unbounded_String;
Stream : in out Util.Streams.Texts.Reader_Stream'Class;
Client : in out Util.Streams.Sockets.Socket_Stream'Class);
type Test is new Util.Tests.Test with record
Server : Test_Server_Access := null;
end record;
-- Test the http Get operation.
procedure Test_Http_Get (T : in out Test);
-- Test the http HEAD operation.
procedure Test_Http_Head (T : in out Test);
-- Test the http POST operation.
procedure Test_Http_Post (T : in out Test);
-- Test the http PUT operation.
procedure Test_Http_Put (T : in out Test);
-- Test the http DELETE operation.
procedure Test_Http_Delete (T : in out Test);
-- Test the http OPTIONS operation.
procedure Test_Http_Options (T : in out Test);
-- Test the http PATCH operation.
procedure Test_Http_Patch (T : in out Test);
-- Test the http timeout.
procedure Test_Http_Timeout (T : in out Test);
overriding
procedure Set_Up (T : in out Test);
overriding
procedure Tear_Down (T : in out Test);
-- Get the test server base URI.
function Get_Uri (T : in Test) return String;
-- The <b>Http_Tests</b> package must be instantiated with one of the HTTP implementation.
-- The <b>Register</b> procedure configures the Http.Client to use the given HTTP
-- implementation before running the test.
generic
with procedure Register;
NAME : in String;
package Http_Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Http_Test is new Test with null record;
overriding
procedure Set_Up (T : in out Http_Test);
end Http_Tests;
end Util.Http.Clients.Tests;
|
[
{
"context": "t Multimedia Library\n-- // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)\n-- //\n-- // This software",
"end": 162,
"score": 0.9998847246170044,
"start": 148,
"tag": "NAME",
"value": "Laurent Gomila"
},
{
"context": "ary\n-- // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)\n-- //\n-- // This software is provided 'as-is', w",
"end": 185,
"score": 0.9999316930770874,
"start": 164,
"tag": "EMAIL",
"value": "laurent.gom@gmail.com"
},
{
"context": " : constant GLenum := 16#0702#;\n GL_LINE_RESET_TOKEN : co",
"end": 18221,
"score": 0.4466416835784912,
"start": 18219,
"tag": "PASSWORD",
"value": "70"
}
] | include/sf-window-gl.ads | danva994/ASFML-1.6 | 1 | -- ////////////////////////////////////////////////////////////
-- //
-- // SFML - Simple and Fast Multimedia Library
-- // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
-- //
-- // This software is provided 'as-is', without any express or implied warranty.
-- // In no event will the authors be held liable for any damages arising from the use of this software.
-- //
-- // Permission is granted to anyone to use this software for any purpose,
-- // including commercial applications, and to alter it and redistribute it freely,
-- // subject to the following restrictions:
-- //
-- // 1. The origin of this software must not be misrepresented;
-- // you must not claim that you wrote the original software.
-- // If you use this software in a product, an acknowledgment
-- // in the product documentation would be appreciated but is not required.
-- //
-- // 2. Altered source versions must be plainly marked as such,
-- // and must not be misrepresented as being the original software.
-- //
-- // 3. This notice may not be removed or altered from any source distribution.
-- //
-- ////////////////////////////////////////////////////////////
package Sf.Window.GL is
-- ////////////////////////////////////////////////////////////
-- // Define portable types
-- ////////////////////////////////////////////////////////////
type GLuint is mod 2 ** Integer'SIZE;
type GLuint_Ptr is access all GLuint;
type GLenum is mod 2 ** Integer'SIZE;
type GLbitfield is mod 2 ** Integer'SIZE;
type GLboolean is mod 256;
for GLboolean'SIZE use 8;
type GLvoid is null record;
type GLvoid_Ptr is access all GLvoid;
type GLbyte is range -128 .. 127;
for GLbyte'SIZE use 8;
type GLshort is new Short_Integer;
type GLint is new Integer;
type GLubyte is mod 256;
for GLubyte'SIZE use 8;
type GLubyte_Ptr is access all GLubyte;
type GLushort is mod 2 ** Short_Integer'SIZE;
type GLsizei is new Integer;
type GLfloat is new Float;
type GLclampf is new Float;
type GLdouble is new Long_Float;
type GLclampd is new Long_Float;
pragma Convention (C, GLuint);
pragma Convention (C, GLuint_Ptr);
pragma Convention (C, GLenum);
pragma Convention (C, GLbitfield);
pragma Convention (C, GLboolean);
pragma Convention (C, GLvoid);
pragma Convention (C, GLvoid_Ptr);
pragma Convention (C, GLbyte);
pragma Convention (C, GLshort);
pragma Convention (C, GLint);
pragma Convention (C, GLubyte);
pragma Convention (C, GLubyte_Ptr);
pragma Convention (C, GLushort);
pragma Convention (C, GLsizei);
pragma Convention (C, GLfloat);
pragma Convention (C, GLclampf);
pragma Convention (C, GLdouble);
pragma Convention (C, GLclampd);
-- ////////////////////////////////////////////////////////////
-- // Define constants
-- ////////////////////////////////////////////////////////////
GL_VERSION_1_1 : constant GLenum := 1;
GL_VERSION_1_2 : constant GLenum := 1;
GL_VERSION_1_3 : constant GLenum := 1;
GL_ARB_imaging : constant GLenum := 1;
GL_FALSE : constant GLboolean := 16#0#;
GL_TRUE : constant GLboolean := 16#1#;
GL_BYTE : constant GLenum := 16#1400#;
GL_UNSIGNED_BYTE : constant GLenum := 16#1401#;
GL_SHORT : constant GLenum := 16#1402#;
GL_UNSIGNED_SHORT : constant GLenum := 16#1403#;
GL_INT : constant GLenum := 16#1404#;
GL_UNSIGNED_INT : constant GLenum := 16#1405#;
GL_FLOAT : constant GLenum := 16#1406#;
GL_DOUBLE : constant GLenum := 16#140A#;
GL_2_BYTES : constant GLenum := 16#1407#;
GL_3_BYTES : constant GLenum := 16#1408#;
GL_4_BYTES : constant GLenum := 16#1409#;
GL_POINTS : constant GLenum := 16#0000#;
GL_LINES : constant GLenum := 16#0001#;
GL_LINE_LOOP : constant GLenum := 16#0002#;
GL_LINE_STRIP : constant GLenum := 16#0003#;
GL_TRIANGLES : constant GLenum := 16#0004#;
GL_TRIANGLE_STRIP : constant GLenum := 16#0005#;
GL_TRIANGLE_FAN : constant GLenum := 16#0006#;
GL_QUADS : constant GLenum := 16#0007#;
GL_QUAD_STRIP : constant GLenum := 16#0008#;
GL_POLYGON : constant GLenum := 16#0009#;
GL_VERTEX_ARRAY : constant GLenum := 16#8074#;
GL_NORMAL_ARRAY : constant GLenum := 16#8075#;
GL_COLOR_ARRAY : constant GLenum := 16#8076#;
GL_INDEX_ARRAY : constant GLenum := 16#8077#;
GL_TEXTURE_COORD_ARRAY : constant GLenum := 16#8078#;
GL_EDGE_FLAG_ARRAY : constant GLenum := 16#8079#;
GL_VERTEX_ARRAY_SIZE : constant GLenum := 16#807A#;
GL_VERTEX_ARRAY_TYPE : constant GLenum := 16#807B#;
GL_VERTEX_ARRAY_STRIDE : constant GLenum := 16#807C#;
GL_NORMAL_ARRAY_TYPE : constant GLenum := 16#807E#;
GL_NORMAL_ARRAY_STRIDE : constant GLenum := 16#807F#;
GL_COLOR_ARRAY_SIZE : constant GLenum := 16#8081#;
GL_COLOR_ARRAY_TYPE : constant GLenum := 16#8082#;
GL_COLOR_ARRAY_STRIDE : constant GLenum := 16#8083#;
GL_INDEX_ARRAY_TYPE : constant GLenum := 16#8085#;
GL_INDEX_ARRAY_STRIDE : constant GLenum := 16#8086#;
GL_TEXTURE_COORD_ARRAY_SIZE : constant GLenum := 16#8088#;
GL_TEXTURE_COORD_ARRAY_TYPE : constant GLenum := 16#8089#;
GL_TEXTURE_COORD_ARRAY_STRIDE : constant GLenum := 16#808A#;
GL_EDGE_FLAG_ARRAY_STRIDE : constant GLenum := 16#808C#;
GL_VERTEX_ARRAY_POINTER : constant GLenum := 16#808E#;
GL_NORMAL_ARRAY_POINTER : constant GLenum := 16#808F#;
GL_COLOR_ARRAY_POINTER : constant GLenum := 16#8090#;
GL_INDEX_ARRAY_POINTER : constant GLenum := 16#8091#;
GL_TEXTURE_COORD_ARRAY_POINTER : constant GLenum := 16#8092#;
GL_EDGE_FLAG_ARRAY_POINTER : constant GLenum := 16#8093#;
GL_V2F : constant GLenum := 16#2A20#;
GL_V3F : constant GLenum := 16#2A21#;
GL_C4UB_V2F : constant GLenum := 16#2A22#;
GL_C4UB_V3F : constant GLenum := 16#2A23#;
GL_C3F_V3F : constant GLenum := 16#2A24#;
GL_N3F_V3F : constant GLenum := 16#2A25#;
GL_C4F_N3F_V3F : constant GLenum := 16#2A26#;
GL_T2F_V3F : constant GLenum := 16#2A27#;
GL_T4F_V4F : constant GLenum := 16#2A28#;
GL_T2F_C4UB_V3F : constant GLenum := 16#2A29#;
GL_T2F_C3F_V3F : constant GLenum := 16#2A2A#;
GL_T2F_N3F_V3F : constant GLenum := 16#2A2B#;
GL_T2F_C4F_N3F_V3F : constant GLenum := 16#2A2C#;
GL_T4F_C4F_N3F_V4F : constant GLenum := 16#2A2D#;
GL_MATRIX_MODE : constant GLenum := 16#0BA0#;
GL_MODELVIEW : constant GLenum := 16#1700#;
GL_PROJECTION : constant GLenum := 16#1701#;
GL_TEXTURE : constant GLenum := 16#1702#;
GL_POINT_SMOOTH : constant GLenum := 16#0B10#;
GL_POINT_SIZE : constant GLenum := 16#0B11#;
GL_POINT_SIZE_GRANULARITY : constant GLenum := 16#0B13#;
GL_POINT_SIZE_RANGE : constant GLenum := 16#0B12#;
GL_LINE_SMOOTH : constant GLenum := 16#0B20#;
GL_LINE_STIPPLE : constant GLenum := 16#0B24#;
GL_LINE_STIPPLE_PATTERN : constant GLenum := 16#0B25#;
GL_LINE_STIPPLE_REPEAT : constant GLenum := 16#0B26#;
GL_LINE_WIDTH : constant GLenum := 16#0B21#;
GL_LINE_WIDTH_GRANULARITY : constant GLenum := 16#0B23#;
GL_LINE_WIDTH_RANGE : constant GLenum := 16#0B22#;
GL_POINT : constant GLenum := 16#1B00#;
GL_LINE : constant GLenum := 16#1B01#;
GL_FILL : constant GLenum := 16#1B02#;
GL_CW : constant GLenum := 16#0900#;
GL_CCW : constant GLenum := 16#0901#;
GL_FRONT : constant GLenum := 16#0404#;
GL_BACK : constant GLenum := 16#0405#;
GL_POLYGON_MODE : constant GLenum := 16#0B40#;
GL_POLYGON_SMOOTH : constant GLenum := 16#0B41#;
GL_POLYGON_STIPPLE : constant GLenum := 16#0B42#;
GL_EDGE_FLAG : constant GLenum := 16#0B43#;
GL_CULL_FACE : constant GLenum := 16#0B44#;
GL_CULL_FACE_MODE : constant GLenum := 16#0B45#;
GL_FRONT_FACE : constant GLenum := 16#0B46#;
GL_POLYGON_OFFSET_FACTOR : constant GLenum := 16#8038#;
GL_POLYGON_OFFSET_UNITS : constant GLenum := 16#2A00#;
GL_POLYGON_OFFSET_POINT : constant GLenum := 16#2A01#;
GL_POLYGON_OFFSET_LINE : constant GLenum := 16#2A02#;
GL_POLYGON_OFFSET_FILL : constant GLenum := 16#8037#;
GL_COMPILE : constant GLenum := 16#1300#;
GL_COMPILE_AND_EXECUTE : constant GLenum := 16#1301#;
GL_LIST_BASE : constant GLenum := 16#0B32#;
GL_LIST_INDEX : constant GLenum := 16#0B33#;
GL_LIST_MODE : constant GLenum := 16#0B30#;
GL_NEVER : constant GLenum := 16#0200#;
GL_LESS : constant GLenum := 16#0201#;
GL_EQUAL : constant GLenum := 16#0202#;
GL_LEQUAL : constant GLenum := 16#0203#;
GL_GREATER : constant GLenum := 16#0204#;
GL_NOTEQUAL : constant GLenum := 16#0205#;
GL_GEQUAL : constant GLenum := 16#0206#;
GL_ALWAYS : constant GLenum := 16#0207#;
GL_DEPTH_TEST : constant GLenum := 16#0B71#;
GL_DEPTH_BITS : constant GLenum := 16#0D56#;
GL_DEPTH_CLEAR_VALUE : constant GLenum := 16#0B73#;
GL_DEPTH_FUNC : constant GLenum := 16#0B74#;
GL_DEPTH_RANGE : constant GLenum := 16#0B70#;
GL_DEPTH_WRITEMASK : constant GLenum := 16#0B72#;
GL_DEPTH_COMPONENT : constant GLenum := 16#1902#;
GL_LIGHTING : constant GLenum := 16#0B50#;
GL_LIGHT0 : constant GLenum := 16#4000#;
GL_LIGHT1 : constant GLenum := 16#4001#;
GL_LIGHT2 : constant GLenum := 16#4002#;
GL_LIGHT3 : constant GLenum := 16#4003#;
GL_LIGHT4 : constant GLenum := 16#4004#;
GL_LIGHT5 : constant GLenum := 16#4005#;
GL_LIGHT6 : constant GLenum := 16#4006#;
GL_LIGHT7 : constant GLenum := 16#4007#;
GL_SPOT_EXPONENT : constant GLenum := 16#1205#;
GL_SPOT_CUTOFF : constant GLenum := 16#1206#;
GL_CONSTANT_ATTENUATION : constant GLenum := 16#1207#;
GL_LINEAR_ATTENUATION : constant GLenum := 16#1208#;
GL_QUADRATIC_ATTENUATION : constant GLenum := 16#1209#;
GL_AMBIENT : constant GLenum := 16#1200#;
GL_DIFFUSE : constant GLenum := 16#1201#;
GL_SPECULAR : constant GLenum := 16#1202#;
GL_SHININESS : constant GLenum := 16#1601#;
GL_EMISSION : constant GLenum := 16#1600#;
GL_POSITION : constant GLenum := 16#1203#;
GL_SPOT_DIRECTION : constant GLenum := 16#1204#;
GL_AMBIENT_AND_DIFFUSE : constant GLenum := 16#1602#;
GL_COLOR_INDEXES : constant GLenum := 16#1603#;
GL_LIGHT_MODEL_TWO_SIDE : constant GLenum := 16#0B52#;
GL_LIGHT_MODEL_LOCAL_VIEWER : constant GLenum := 16#0B51#;
GL_LIGHT_MODEL_AMBIENT : constant GLenum := 16#0B53#;
GL_FRONT_AND_BACK : constant GLenum := 16#0408#;
GL_SHADE_MODEL : constant GLenum := 16#0B54#;
GL_FLAT : constant GLenum := 16#1D00#;
GL_SMOOTH : constant GLenum := 16#1D01#;
GL_COLOR_MATERIAL : constant GLenum := 16#0B57#;
GL_COLOR_MATERIAL_FACE : constant GLenum := 16#0B55#;
GL_COLOR_MATERIAL_PARAMETER : constant GLenum := 16#0B56#;
GL_NORMALIZE : constant GLenum := 16#0BA1#;
GL_CLIP_PLANE0 : constant GLenum := 16#3000#;
GL_CLIP_PLANE1 : constant GLenum := 16#3001#;
GL_CLIP_PLANE2 : constant GLenum := 16#3002#;
GL_CLIP_PLANE3 : constant GLenum := 16#3003#;
GL_CLIP_PLANE4 : constant GLenum := 16#3004#;
GL_CLIP_PLANE5 : constant GLenum := 16#3005#;
GL_ACCUM_RED_BITS : constant GLenum := 16#0D58#;
GL_ACCUM_GREEN_BITS : constant GLenum := 16#0D59#;
GL_ACCUM_BLUE_BITS : constant GLenum := 16#0D5A#;
GL_ACCUM_ALPHA_BITS : constant GLenum := 16#0D5B#;
GL_ACCUM_CLEAR_VALUE : constant GLenum := 16#0B80#;
GL_ACCUM : constant GLenum := 16#0100#;
GL_ADD : constant GLenum := 16#0104#;
GL_LOAD : constant GLenum := 16#0101#;
GL_MULT : constant GLenum := 16#0103#;
GL_RETURN : constant GLenum := 16#0102#;
GL_ALPHA_TEST : constant GLenum := 16#0BC0#;
GL_ALPHA_TEST_REF : constant GLenum := 16#0BC2#;
GL_ALPHA_TEST_FUNC : constant GLenum := 16#0BC1#;
GL_BLEND : constant GLenum := 16#0BE2#;
GL_BLEND_SRC : constant GLenum := 16#0BE1#;
GL_BLEND_DST : constant GLenum := 16#0BE0#;
GL_ZERO : constant GLenum := 16#0#;
GL_ONE : constant GLenum := 16#1#;
GL_SRC_COLOR : constant GLenum := 16#0300#;
GL_ONE_MINUS_SRC_COLOR : constant GLenum := 16#0301#;
GL_SRC_ALPHA : constant GLenum := 16#0302#;
GL_ONE_MINUS_SRC_ALPHA : constant GLenum := 16#0303#;
GL_DST_ALPHA : constant GLenum := 16#0304#;
GL_ONE_MINUS_DST_ALPHA : constant GLenum := 16#0305#;
GL_DST_COLOR : constant GLenum := 16#0306#;
GL_ONE_MINUS_DST_COLOR : constant GLenum := 16#0307#;
GL_SRC_ALPHA_SATURATE : constant GLenum := 16#0308#;
GL_CONSTANT_COLOR : constant GLenum := 16#8001#;
GL_ONE_MINUS_CONSTANT_COLOR : constant GLenum := 16#8002#;
GL_CONSTANT_ALPHA : constant GLenum := 16#8003#;
GL_ONE_MINUS_CONSTANT_ALPHA : constant GLenum := 16#8004#;
GL_FEEDBACK : constant GLenum := 16#1C01#;
GL_RENDER : constant GLenum := 16#1C00#;
GL_SELECT : constant GLenum := 16#1C02#;
GL_2D : constant GLenum := 16#0600#;
GL_3D : constant GLenum := 16#0601#;
GL_3D_COLOR : constant GLenum := 16#0602#;
GL_3D_COLOR_TEXTURE : constant GLenum := 16#0603#;
GL_4D_COLOR_TEXTURE : constant GLenum := 16#0604#;
GL_POINT_TOKEN : constant GLenum := 16#0701#;
GL_LINE_TOKEN : constant GLenum := 16#0702#;
GL_LINE_RESET_TOKEN : constant GLenum := 16#0707#;
GL_POLYGON_TOKEN : constant GLenum := 16#0703#;
GL_BITMAP_TOKEN : constant GLenum := 16#0704#;
GL_DRAW_PIXEL_TOKEN : constant GLenum := 16#0705#;
GL_COPY_PIXEL_TOKEN : constant GLenum := 16#0706#;
GL_PASS_THROUGH_TOKEN : constant GLenum := 16#0700#;
GL_FEEDBACK_BUFFER_POINTER : constant GLenum := 16#0DF0#;
GL_FEEDBACK_BUFFER_SIZE : constant GLenum := 16#0DF1#;
GL_FEEDBACK_BUFFER_TYPE : constant GLenum := 16#0DF2#;
GL_SELECTION_BUFFER_POINTER : constant GLenum := 16#0DF3#;
GL_SELECTION_BUFFER_SIZE : constant GLenum := 16#0DF4#;
GL_FOG : constant GLenum := 16#0B60#;
GL_FOG_MODE : constant GLenum := 16#0B65#;
GL_FOG_DENSITY : constant GLenum := 16#0B62#;
GL_FOG_COLOR : constant GLenum := 16#0B66#;
GL_FOG_INDEX : constant GLenum := 16#0B61#;
GL_FOG_START : constant GLenum := 16#0B63#;
GL_FOG_END : constant GLenum := 16#0B64#;
GL_LINEAR : constant GLenum := 16#2601#;
GL_EXP : constant GLenum := 16#0800#;
GL_EXP2 : constant GLenum := 16#0801#;
GL_LOGIC_OP : constant GLenum := 16#0BF1#;
GL_INDEX_LOGIC_OP : constant GLenum := 16#0BF1#;
GL_COLOR_LOGIC_OP : constant GLenum := 16#0BF2#;
GL_LOGIC_OP_MODE : constant GLenum := 16#0BF0#;
GL_CLEAR : constant GLenum := 16#1500#;
GL_SET : constant GLenum := 16#150F#;
GL_COPY : constant GLenum := 16#1503#;
GL_COPY_INVERTED : constant GLenum := 16#150C#;
GL_NOOP : constant GLenum := 16#1505#;
GL_INVERT : constant GLenum := 16#150A#;
GL_AND : constant GLenum := 16#1501#;
GL_NAND : constant GLenum := 16#150E#;
GL_OR : constant GLenum := 16#1507#;
GL_NOR : constant GLenum := 16#1508#;
GL_XOR : constant GLenum := 16#1506#;
GL_EQUIV : constant GLenum := 16#1509#;
GL_AND_REVERSE : constant GLenum := 16#1502#;
GL_AND_INVERTED : constant GLenum := 16#1504#;
GL_OR_REVERSE : constant GLenum := 16#150B#;
GL_OR_INVERTED : constant GLenum := 16#150D#;
GL_STENCIL_TEST : constant GLenum := 16#0B90#;
GL_STENCIL_WRITEMASK : constant GLenum := 16#0B98#;
GL_STENCIL_BITS : constant GLenum := 16#0D57#;
GL_STENCIL_FUNC : constant GLenum := 16#0B92#;
GL_STENCIL_VALUE_MASK : constant GLenum := 16#0B93#;
GL_STENCIL_REF : constant GLenum := 16#0B97#;
GL_STENCIL_FAIL : constant GLenum := 16#0B94#;
GL_STENCIL_PASS_DEPTH_PASS : constant GLenum := 16#0B96#;
GL_STENCIL_PASS_DEPTH_FAIL : constant GLenum := 16#0B95#;
GL_STENCIL_CLEAR_VALUE : constant GLenum := 16#0B91#;
GL_STENCIL_INDEX : constant GLenum := 16#1901#;
GL_KEEP : constant GLenum := 16#1E00#;
GL_REPLACE : constant GLenum := 16#1E01#;
GL_INCR : constant GLenum := 16#1E02#;
GL_DECR : constant GLenum := 16#1E03#;
GL_NONE : constant GLenum := 16#0#;
GL_LEFT : constant GLenum := 16#0406#;
GL_RIGHT : constant GLenum := 16#0407#;
GL_FRONT_LEFT : constant GLenum := 16#0400#;
GL_FRONT_RIGHT : constant GLenum := 16#0401#;
GL_BACK_LEFT : constant GLenum := 16#0402#;
GL_BACK_RIGHT : constant GLenum := 16#0403#;
GL_AUX0 : constant GLenum := 16#0409#;
GL_AUX1 : constant GLenum := 16#040A#;
GL_AUX2 : constant GLenum := 16#040B#;
GL_AUX3 : constant GLenum := 16#040C#;
GL_COLOR_INDEX : constant GLenum := 16#1900#;
GL_RED : constant GLenum := 16#1903#;
GL_GREEN : constant GLenum := 16#1904#;
GL_BLUE : constant GLenum := 16#1905#;
GL_ALPHA : constant GLenum := 16#1906#;
GL_LUMINANCE : constant GLenum := 16#1909#;
GL_LUMINANCE_ALPHA : constant GLenum := 16#190A#;
GL_ALPHA_BITS : constant GLenum := 16#0D55#;
GL_RED_BITS : constant GLenum := 16#0D52#;
GL_GREEN_BITS : constant GLenum := 16#0D53#;
GL_BLUE_BITS : constant GLenum := 16#0D54#;
GL_INDEX_BITS : constant GLenum := 16#0D51#;
GL_SUBPIXEL_BITS : constant GLenum := 16#0D50#;
GL_AUX_BUFFERS : constant GLenum := 16#0C00#;
GL_READ_BUFFER : constant GLenum := 16#0C02#;
GL_DRAW_BUFFER : constant GLenum := 16#0C01#;
GL_DOUBLEBUFFER : constant GLenum := 16#0C32#;
GL_STEREO : constant GLenum := 16#0C33#;
GL_BITMAP : constant GLenum := 16#1A00#;
GL_COLOR : constant GLenum := 16#1800#;
GL_DEPTH : constant GLenum := 16#1801#;
GL_STENCIL : constant GLenum := 16#1802#;
GL_DITHER : constant GLenum := 16#0BD0#;
GL_RGB : constant GLenum := 16#1907#;
GL_RGBA : constant GLenum := 16#1908#;
GL_MAX_LIST_NESTING : constant GLenum := 16#0B31#;
GL_MAX_ATTRIB_STACK_DEPTH : constant GLenum := 16#0D35#;
GL_MAX_MODELVIEW_STACK_DEPTH : constant GLenum := 16#0D36#;
GL_MAX_NAME_STACK_DEPTH : constant GLenum := 16#0D37#;
GL_MAX_PROJECTION_STACK_DEPTH : constant GLenum := 16#0D38#;
GL_MAX_TEXTURE_STACK_DEPTH : constant GLenum := 16#0D39#;
GL_MAX_EVAL_ORDER : constant GLenum := 16#0D30#;
GL_MAX_LIGHTS : constant GLenum := 16#0D31#;
GL_MAX_CLIP_PLANES : constant GLenum := 16#0D32#;
GL_MAX_TEXTURE_SIZE : constant GLenum := 16#0D33#;
GL_MAX_PIXEL_MAP_TABLE : constant GLenum := 16#0D34#;
GL_MAX_VIEWPORT_DIMS : constant GLenum := 16#0D3A#;
GL_MAX_CLIENT_ATTRIB_STACK_DEPTH : constant GLenum := 16#0D3B#;
GL_ATTRIB_STACK_DEPTH : constant GLenum := 16#0BB0#;
GL_CLIENT_ATTRIB_STACK_DEPTH : constant GLenum := 16#0BB1#;
GL_COLOR_CLEAR_VALUE : constant GLenum := 16#0C22#;
GL_COLOR_WRITEMASK : constant GLenum := 16#0C23#;
GL_CURRENT_INDEX : constant GLenum := 16#0B01#;
GL_CURRENT_COLOR : constant GLenum := 16#0B00#;
GL_CURRENT_NORMAL : constant GLenum := 16#0B02#;
GL_CURRENT_RASTER_COLOR : constant GLenum := 16#0B04#;
GL_CURRENT_RASTER_DISTANCE : constant GLenum := 16#0B09#;
GL_CURRENT_RASTER_INDEX : constant GLenum := 16#0B05#;
GL_CURRENT_RASTER_POSITION : constant GLenum := 16#0B07#;
GL_CURRENT_RASTER_TEXTURE_COORDS : constant GLenum := 16#0B06#;
GL_CURRENT_RASTER_POSITION_VALID : constant GLenum := 16#0B08#;
GL_CURRENT_TEXTURE_COORDS : constant GLenum := 16#0B03#;
GL_INDEX_CLEAR_VALUE : constant GLenum := 16#0C20#;
GL_INDEX_MODE : constant GLenum := 16#0C30#;
GL_INDEX_WRITEMASK : constant GLenum := 16#0C21#;
GL_MODELVIEW_MATRIX : constant GLenum := 16#0BA6#;
GL_MODELVIEW_STACK_DEPTH : constant GLenum := 16#0BA3#;
GL_NAME_STACK_DEPTH : constant GLenum := 16#0D70#;
GL_PROJECTION_MATRIX : constant GLenum := 16#0BA7#;
GL_PROJECTION_STACK_DEPTH : constant GLenum := 16#0BA4#;
GL_RENDER_MODE : constant GLenum := 16#0C40#;
GL_RGBA_MODE : constant GLenum := 16#0C31#;
GL_TEXTURE_MATRIX : constant GLenum := 16#0BA8#;
GL_TEXTURE_STACK_DEPTH : constant GLenum := 16#0BA5#;
GL_VIEWPORT : constant GLenum := 16#0BA2#;
GL_AUTO_NORMAL : constant GLenum := 16#0D80#;
GL_MAP1_COLOR_4 : constant GLenum := 16#0D90#;
GL_MAP1_GRID_DOMAIN : constant GLenum := 16#0DD0#;
GL_MAP1_GRID_SEGMENTS : constant GLenum := 16#0DD1#;
GL_MAP1_INDEX : constant GLenum := 16#0D91#;
GL_MAP1_NORMAL : constant GLenum := 16#0D92#;
GL_MAP1_TEXTURE_COORD_1 : constant GLenum := 16#0D93#;
GL_MAP1_TEXTURE_COORD_2 : constant GLenum := 16#0D94#;
GL_MAP1_TEXTURE_COORD_3 : constant GLenum := 16#0D95#;
GL_MAP1_TEXTURE_COORD_4 : constant GLenum := 16#0D96#;
GL_MAP1_VERTEX_3 : constant GLenum := 16#0D97#;
GL_MAP1_VERTEX_4 : constant GLenum := 16#0D98#;
GL_MAP2_COLOR_4 : constant GLenum := 16#0DB0#;
GL_MAP2_GRID_DOMAIN : constant GLenum := 16#0DD2#;
GL_MAP2_GRID_SEGMENTS : constant GLenum := 16#0DD3#;
GL_MAP2_INDEX : constant GLenum := 16#0DB1#;
GL_MAP2_NORMAL : constant GLenum := 16#0DB2#;
GL_MAP2_TEXTURE_COORD_1 : constant GLenum := 16#0DB3#;
GL_MAP2_TEXTURE_COORD_2 : constant GLenum := 16#0DB4#;
GL_MAP2_TEXTURE_COORD_3 : constant GLenum := 16#0DB5#;
GL_MAP2_TEXTURE_COORD_4 : constant GLenum := 16#0DB6#;
GL_MAP2_VERTEX_3 : constant GLenum := 16#0DB7#;
GL_MAP2_VERTEX_4 : constant GLenum := 16#0DB8#;
GL_COEFF : constant GLenum := 16#0A00#;
GL_DOMAIN : constant GLenum := 16#0A02#;
GL_ORDER : constant GLenum := 16#0A01#;
GL_FOG_HINT : constant GLenum := 16#0C54#;
GL_LINE_SMOOTH_HINT : constant GLenum := 16#0C52#;
GL_PERSPECTIVE_CORRECTION_HINT : constant GLenum := 16#0C50#;
GL_POINT_SMOOTH_HINT : constant GLenum := 16#0C51#;
GL_POLYGON_SMOOTH_HINT : constant GLenum := 16#0C53#;
GL_DONT_CARE : constant GLenum := 16#1100#;
GL_FASTEST : constant GLenum := 16#1101#;
GL_NICEST : constant GLenum := 16#1102#;
GL_SCISSOR_TEST : constant GLenum := 16#0C11#;
GL_SCISSOR_BOX : constant GLenum := 16#0C10#;
GL_MAP_COLOR : constant GLenum := 16#0D10#;
GL_MAP_STENCIL : constant GLenum := 16#0D11#;
GL_INDEX_SHIFT : constant GLenum := 16#0D12#;
GL_INDEX_OFFSET : constant GLenum := 16#0D13#;
GL_RED_SCALE : constant GLenum := 16#0D14#;
GL_RED_BIAS : constant GLenum := 16#0D15#;
GL_GREEN_SCALE : constant GLenum := 16#0D18#;
GL_GREEN_BIAS : constant GLenum := 16#0D19#;
GL_BLUE_SCALE : constant GLenum := 16#0D1A#;
GL_BLUE_BIAS : constant GLenum := 16#0D1B#;
GL_ALPHA_SCALE : constant GLenum := 16#0D1C#;
GL_ALPHA_BIAS : constant GLenum := 16#0D1D#;
GL_DEPTH_SCALE : constant GLenum := 16#0D1E#;
GL_DEPTH_BIAS : constant GLenum := 16#0D1F#;
GL_PIXEL_MAP_S_TO_S_SIZE : constant GLenum := 16#0CB1#;
GL_PIXEL_MAP_I_TO_I_SIZE : constant GLenum := 16#0CB0#;
GL_PIXEL_MAP_I_TO_R_SIZE : constant GLenum := 16#0CB2#;
GL_PIXEL_MAP_I_TO_G_SIZE : constant GLenum := 16#0CB3#;
GL_PIXEL_MAP_I_TO_B_SIZE : constant GLenum := 16#0CB4#;
GL_PIXEL_MAP_I_TO_A_SIZE : constant GLenum := 16#0CB5#;
GL_PIXEL_MAP_R_TO_R_SIZE : constant GLenum := 16#0CB6#;
GL_PIXEL_MAP_G_TO_G_SIZE : constant GLenum := 16#0CB7#;
GL_PIXEL_MAP_B_TO_B_SIZE : constant GLenum := 16#0CB8#;
GL_PIXEL_MAP_A_TO_A_SIZE : constant GLenum := 16#0CB9#;
GL_PIXEL_MAP_S_TO_S : constant GLenum := 16#0C71#;
GL_PIXEL_MAP_I_TO_I : constant GLenum := 16#0C70#;
GL_PIXEL_MAP_I_TO_R : constant GLenum := 16#0C72#;
GL_PIXEL_MAP_I_TO_G : constant GLenum := 16#0C73#;
GL_PIXEL_MAP_I_TO_B : constant GLenum := 16#0C74#;
GL_PIXEL_MAP_I_TO_A : constant GLenum := 16#0C75#;
GL_PIXEL_MAP_R_TO_R : constant GLenum := 16#0C76#;
GL_PIXEL_MAP_G_TO_G : constant GLenum := 16#0C77#;
GL_PIXEL_MAP_B_TO_B : constant GLenum := 16#0C78#;
GL_PIXEL_MAP_A_TO_A : constant GLenum := 16#0C79#;
GL_PACK_ALIGNMENT : constant GLenum := 16#0D05#;
GL_PACK_LSB_FIRST : constant GLenum := 16#0D01#;
GL_PACK_ROW_LENGTH : constant GLenum := 16#0D02#;
GL_PACK_SKIP_PIXELS : constant GLenum := 16#0D04#;
GL_PACK_SKIP_ROWS : constant GLenum := 16#0D03#;
GL_PACK_SWAP_BYTES : constant GLenum := 16#0D00#;
GL_UNPACK_ALIGNMENT : constant GLenum := 16#0CF5#;
GL_UNPACK_LSB_FIRST : constant GLenum := 16#0CF1#;
GL_UNPACK_ROW_LENGTH : constant GLenum := 16#0CF2#;
GL_UNPACK_SKIP_PIXELS : constant GLenum := 16#0CF4#;
GL_UNPACK_SKIP_ROWS : constant GLenum := 16#0CF3#;
GL_UNPACK_SWAP_BYTES : constant GLenum := 16#0CF0#;
GL_ZOOM_X : constant GLenum := 16#0D16#;
GL_ZOOM_Y : constant GLenum := 16#0D17#;
GL_TEXTURE_ENV : constant GLenum := 16#2300#;
GL_TEXTURE_ENV_MODE : constant GLenum := 16#2200#;
GL_TEXTURE_1D : constant GLenum := 16#0DE0#;
GL_TEXTURE_2D : constant GLenum := 16#0DE1#;
GL_TEXTURE_WRAP_S : constant GLenum := 16#2802#;
GL_TEXTURE_WRAP_T : constant GLenum := 16#2803#;
GL_TEXTURE_MAG_FILTER : constant GLenum := 16#2800#;
GL_TEXTURE_MIN_FILTER : constant GLenum := 16#2801#;
GL_TEXTURE_ENV_COLOR : constant GLenum := 16#2201#;
GL_TEXTURE_GEN_S : constant GLenum := 16#0C60#;
GL_TEXTURE_GEN_T : constant GLenum := 16#0C61#;
GL_TEXTURE_GEN_MODE : constant GLenum := 16#2500#;
GL_TEXTURE_BORDER_COLOR : constant GLenum := 16#1004#;
GL_TEXTURE_WIDTH : constant GLenum := 16#1000#;
GL_TEXTURE_HEIGHT : constant GLenum := 16#1001#;
GL_TEXTURE_BORDER : constant GLenum := 16#1005#;
GL_TEXTURE_COMPONENTS : constant GLenum := 16#1003#;
GL_TEXTURE_RED_SIZE : constant GLenum := 16#805C#;
GL_TEXTURE_GREEN_SIZE : constant GLenum := 16#805D#;
GL_TEXTURE_BLUE_SIZE : constant GLenum := 16#805E#;
GL_TEXTURE_ALPHA_SIZE : constant GLenum := 16#805F#;
GL_TEXTURE_LUMINANCE_SIZE : constant GLenum := 16#8060#;
GL_TEXTURE_INTENSITY_SIZE : constant GLenum := 16#8061#;
GL_NEAREST_MIPMAP_NEAREST : constant GLenum := 16#2700#;
GL_NEAREST_MIPMAP_LINEAR : constant GLenum := 16#2702#;
GL_LINEAR_MIPMAP_NEAREST : constant GLenum := 16#2701#;
GL_LINEAR_MIPMAP_LINEAR : constant GLenum := 16#2703#;
GL_OBJECT_LINEAR : constant GLenum := 16#2401#;
GL_OBJECT_PLANE : constant GLenum := 16#2501#;
GL_EYE_LINEAR : constant GLenum := 16#2400#;
GL_EYE_PLANE : constant GLenum := 16#2502#;
GL_SPHERE_MAP : constant GLenum := 16#2402#;
GL_DECAL : constant GLenum := 16#2101#;
GL_MODULATE : constant GLenum := 16#2100#;
GL_NEAREST : constant GLenum := 16#2600#;
GL_REPEAT : constant GLenum := 16#2901#;
GL_CLAMP : constant GLenum := 16#2900#;
GL_S : constant GLenum := 16#2000#;
GL_T : constant GLenum := 16#2001#;
GL_R : constant GLenum := 16#2002#;
GL_Q : constant GLenum := 16#2003#;
GL_TEXTURE_GEN_R : constant GLenum := 16#0C62#;
GL_TEXTURE_GEN_Q : constant GLenum := 16#0C63#;
GL_VENDOR : constant GLenum := 16#1F00#;
GL_RENDERER : constant GLenum := 16#1F01#;
GL_VERSION : constant GLenum := 16#1F02#;
GL_EXTENSIONS : constant GLenum := 16#1F03#;
GL_NO_ERROR : constant GLenum := 16#0#;
GL_INVALID_VALUE : constant GLenum := 16#0501#;
GL_INVALID_ENUM : constant GLenum := 16#0500#;
GL_INVALID_OPERATION : constant GLenum := 16#0502#;
GL_STACK_OVERFLOW : constant GLenum := 16#0503#;
GL_STACK_UNDERFLOW : constant GLenum := 16#0504#;
GL_OUT_OF_MEMORY : constant GLenum := 16#0505#;
GL_CURRENT_BIT : constant GLenum := 16#00000001#;
GL_POINT_BIT : constant GLenum := 16#00000002#;
GL_LINE_BIT : constant GLenum := 16#00000004#;
GL_POLYGON_BIT : constant GLenum := 16#00000008#;
GL_POLYGON_STIPPLE_BIT : constant GLenum := 16#00000010#;
GL_PIXEL_MODE_BIT : constant GLenum := 16#00000020#;
GL_LIGHTING_BIT : constant GLenum := 16#00000040#;
GL_FOG_BIT : constant GLenum := 16#00000080#;
GL_DEPTH_BUFFER_BIT : constant GLenum := 16#00000100#;
GL_ACCUM_BUFFER_BIT : constant GLenum := 16#00000200#;
GL_STENCIL_BUFFER_BIT : constant GLenum := 16#00000400#;
GL_VIEWPORT_BIT : constant GLenum := 16#00000800#;
GL_TRANSFORM_BIT : constant GLenum := 16#00001000#;
GL_ENABLE_BIT : constant GLenum := 16#00002000#;
GL_COLOR_BUFFER_BIT : constant GLenum := 16#00004000#;
GL_HINT_BIT : constant GLenum := 16#00008000#;
GL_EVAL_BIT : constant GLenum := 16#00010000#;
GL_LIST_BIT : constant GLenum := 16#00020000#;
GL_TEXTURE_BIT : constant GLenum := 16#00040000#;
GL_SCISSOR_BIT : constant GLenum := 16#00080000#;
GL_ALL_ATTRIB_BITS : constant GLenum := 16#000FFFFF#;
GL_PROXY_TEXTURE_1D : constant GLenum := 16#8063#;
GL_PROXY_TEXTURE_2D : constant GLenum := 16#8064#;
GL_TEXTURE_PRIORITY : constant GLenum := 16#8066#;
GL_TEXTURE_RESIDENT : constant GLenum := 16#8067#;
GL_TEXTURE_BINDING_1D : constant GLenum := 16#8068#;
GL_TEXTURE_BINDING_2D : constant GLenum := 16#8069#;
GL_TEXTURE_INTERNAL_FORMAT : constant GLenum := 16#1003#;
GL_ALPHA4 : constant GLenum := 16#803B#;
GL_ALPHA8 : constant GLenum := 16#803C#;
GL_ALPHA12 : constant GLenum := 16#803D#;
GL_ALPHA16 : constant GLenum := 16#803E#;
GL_LUMINANCE4 : constant GLenum := 16#803F#;
GL_LUMINANCE8 : constant GLenum := 16#8040#;
GL_LUMINANCE12 : constant GLenum := 16#8041#;
GL_LUMINANCE16 : constant GLenum := 16#8042#;
GL_LUMINANCE4_ALPHA4 : constant GLenum := 16#8043#;
GL_LUMINANCE6_ALPHA2 : constant GLenum := 16#8044#;
GL_LUMINANCE8_ALPHA8 : constant GLenum := 16#8045#;
GL_LUMINANCE12_ALPHA4 : constant GLenum := 16#8046#;
GL_LUMINANCE12_ALPHA12 : constant GLenum := 16#8047#;
GL_LUMINANCE16_ALPHA16 : constant GLenum := 16#8048#;
GL_INTENSITY : constant GLenum := 16#8049#;
GL_INTENSITY4 : constant GLenum := 16#804A#;
GL_INTENSITY8 : constant GLenum := 16#804B#;
GL_INTENSITY12 : constant GLenum := 16#804C#;
GL_INTENSITY16 : constant GLenum := 16#804D#;
GL_R3_G3_B2 : constant GLenum := 16#2A10#;
GL_RGB4 : constant GLenum := 16#804F#;
GL_RGB5 : constant GLenum := 16#8050#;
GL_RGB8 : constant GLenum := 16#8051#;
GL_RGB10 : constant GLenum := 16#8052#;
GL_RGB12 : constant GLenum := 16#8053#;
GL_RGB16 : constant GLenum := 16#8054#;
GL_RGBA2 : constant GLenum := 16#8055#;
GL_RGBA4 : constant GLenum := 16#8056#;
GL_RGB5_A1 : constant GLenum := 16#8057#;
GL_RGBA8 : constant GLenum := 16#8058#;
GL_RGB10_A2 : constant GLenum := 16#8059#;
GL_RGBA12 : constant GLenum := 16#805A#;
GL_RGBA16 : constant GLenum := 16#805B#;
GL_CLIENT_PIXEL_STORE_BIT : constant GLenum := 16#00000001#;
GL_CLIENT_VERTEX_ARRAY_BIT : constant GLenum := 16#00000002#;
GL_ALL_CLIENT_ATTRIB_BITS : constant GLenum := 16#FFFFFFFF#;
GL_CLIENT_ALL_ATTRIB_BITS : constant GLenum := 16#FFFFFFFF#;
GL_RESCALE_NORMAL : constant GLenum := 16#803A#;
GL_CLAMP_TO_EDGE : constant GLenum := 16#812F#;
GL_MAX_ELEMENTS_VERTICES : constant GLenum := 16#80E8#;
GL_MAX_ELEMENTS_INDICES : constant GLenum := 16#80E9#;
GL_BGR : constant GLenum := 16#80E0#;
GL_BGRA : constant GLenum := 16#80E1#;
GL_UNSIGNED_BYTE_3_3_2 : constant GLenum := 16#8032#;
GL_UNSIGNED_BYTE_2_3_3_REV : constant GLenum := 16#8362#;
GL_UNSIGNED_SHORT_5_6_5 : constant GLenum := 16#8363#;
GL_UNSIGNED_SHORT_5_6_5_REV : constant GLenum := 16#8364#;
GL_UNSIGNED_SHORT_4_4_4_4 : constant GLenum := 16#8033#;
GL_UNSIGNED_SHORT_4_4_4_4_REV : constant GLenum := 16#8365#;
GL_UNSIGNED_SHORT_5_5_5_1 : constant GLenum := 16#8034#;
GL_UNSIGNED_SHORT_1_5_5_5_REV : constant GLenum := 16#8366#;
GL_UNSIGNED_INT_8_8_8_8 : constant GLenum := 16#8035#;
GL_UNSIGNED_INT_8_8_8_8_REV : constant GLenum := 16#8367#;
GL_UNSIGNED_INT_10_10_10_2 : constant GLenum := 16#8036#;
GL_UNSIGNED_INT_2_10_10_10_REV : constant GLenum := 16#8368#;
GL_LIGHT_MODEL_COLOR_CONTROL : constant GLenum := 16#81F8#;
GL_SINGLE_COLOR : constant GLenum := 16#81F9#;
GL_SEPARATE_SPECULAR_COLOR : constant GLenum := 16#81FA#;
GL_TEXTURE_MIN_LOD : constant GLenum := 16#813A#;
GL_TEXTURE_MAX_LOD : constant GLenum := 16#813B#;
GL_TEXTURE_BASE_LEVEL : constant GLenum := 16#813C#;
GL_TEXTURE_MAX_LEVEL : constant GLenum := 16#813D#;
GL_SMOOTH_POINT_SIZE_RANGE : constant GLenum := 16#0B12#;
GL_SMOOTH_POINT_SIZE_GRANULARITY : constant GLenum := 16#0B13#;
GL_SMOOTH_LINE_WIDTH_RANGE : constant GLenum := 16#0B22#;
GL_SMOOTH_LINE_WIDTH_GRANULARITY : constant GLenum := 16#0B23#;
GL_ALIASED_POINT_SIZE_RANGE : constant GLenum := 16#846D#;
GL_ALIASED_LINE_WIDTH_RANGE : constant GLenum := 16#846E#;
GL_PACK_SKIP_IMAGES : constant GLenum := 16#806B#;
GL_PACK_IMAGE_HEIGHT : constant GLenum := 16#806C#;
GL_UNPACK_SKIP_IMAGES : constant GLenum := 16#806D#;
GL_UNPACK_IMAGE_HEIGHT : constant GLenum := 16#806E#;
GL_TEXTURE_3D : constant GLenum := 16#806F#;
GL_PROXY_TEXTURE_3D : constant GLenum := 16#8070#;
GL_TEXTURE_DEPTH : constant GLenum := 16#8071#;
GL_TEXTURE_WRAP_R : constant GLenum := 16#8072#;
GL_MAX_3D_TEXTURE_SIZE : constant GLenum := 16#8073#;
GL_TEXTURE_BINDING_3D : constant GLenum := 16#806A#;
GL_COLOR_TABLE : constant GLenum := 16#80D0#;
GL_POST_CONVOLUTION_COLOR_TABLE : constant GLenum := 16#80D1#;
GL_POST_COLOR_MATRIX_COLOR_TABLE : constant GLenum := 16#80D2#;
GL_PROXY_COLOR_TABLE : constant GLenum := 16#80D3#;
GL_PROXY_POST_CONVOLUTION_COLOR_TABLE : constant GLenum := 16#80D4#;
GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE : constant GLenum := 16#80D5#;
GL_COLOR_TABLE_SCALE : constant GLenum := 16#80D6#;
GL_COLOR_TABLE_BIAS : constant GLenum := 16#80D7#;
GL_COLOR_TABLE_FORMAT : constant GLenum := 16#80D8#;
GL_COLOR_TABLE_WIDTH : constant GLenum := 16#80D9#;
GL_COLOR_TABLE_RED_SIZE : constant GLenum := 16#80DA#;
GL_COLOR_TABLE_GREEN_SIZE : constant GLenum := 16#80DB#;
GL_COLOR_TABLE_BLUE_SIZE : constant GLenum := 16#80DC#;
GL_COLOR_TABLE_ALPHA_SIZE : constant GLenum := 16#80DD#;
GL_COLOR_TABLE_LUMINANCE_SIZE : constant GLenum := 16#80DE#;
GL_COLOR_TABLE_INTENSITY_SIZE : constant GLenum := 16#80DF#;
GL_CONVOLUTION_1D : constant GLenum := 16#8010#;
GL_CONVOLUTION_2D : constant GLenum := 16#8011#;
GL_SEPARABLE_2D : constant GLenum := 16#8012#;
GL_CONVOLUTION_BORDER_MODE : constant GLenum := 16#8013#;
GL_CONVOLUTION_FILTER_SCALE : constant GLenum := 16#8014#;
GL_CONVOLUTION_FILTER_BIAS : constant GLenum := 16#8015#;
GL_REDUCE : constant GLenum := 16#8016#;
GL_CONVOLUTION_FORMAT : constant GLenum := 16#8017#;
GL_CONVOLUTION_WIDTH : constant GLenum := 16#8018#;
GL_CONVOLUTION_HEIGHT : constant GLenum := 16#8019#;
GL_MAX_CONVOLUTION_WIDTH : constant GLenum := 16#801A#;
GL_MAX_CONVOLUTION_HEIGHT : constant GLenum := 16#801B#;
GL_POST_CONVOLUTION_RED_SCALE : constant GLenum := 16#801C#;
GL_POST_CONVOLUTION_GREEN_SCALE : constant GLenum := 16#801D#;
GL_POST_CONVOLUTION_BLUE_SCALE : constant GLenum := 16#801E#;
GL_POST_CONVOLUTION_ALPHA_SCALE : constant GLenum := 16#801F#;
GL_POST_CONVOLUTION_RED_BIAS : constant GLenum := 16#8020#;
GL_POST_CONVOLUTION_GREEN_BIAS : constant GLenum := 16#8021#;
GL_POST_CONVOLUTION_BLUE_BIAS : constant GLenum := 16#8022#;
GL_POST_CONVOLUTION_ALPHA_BIAS : constant GLenum := 16#8023#;
GL_CONSTANT_BORDER : constant GLenum := 16#8151#;
GL_REPLICATE_BORDER : constant GLenum := 16#8153#;
GL_CONVOLUTION_BORDER_COLOR : constant GLenum := 16#8154#;
GL_COLOR_MATRIX : constant GLenum := 16#80B1#;
GL_COLOR_MATRIX_STACK_DEPTH : constant GLenum := 16#80B2#;
GL_MAX_COLOR_MATRIX_STACK_DEPTH : constant GLenum := 16#80B3#;
GL_POST_COLOR_MATRIX_RED_SCALE : constant GLenum := 16#80B4#;
GL_POST_COLOR_MATRIX_GREEN_SCALE : constant GLenum := 16#80B5#;
GL_POST_COLOR_MATRIX_BLUE_SCALE : constant GLenum := 16#80B6#;
GL_POST_COLOR_MATRIX_ALPHA_SCALE : constant GLenum := 16#80B7#;
GL_POST_COLOR_MATRIX_RED_BIAS : constant GLenum := 16#80B8#;
GL_POST_COLOR_MATRIX_GREEN_BIAS : constant GLenum := 16#80B9#;
GL_POST_COLOR_MATRIX_BLUE_BIAS : constant GLenum := 16#80BA#;
GL_POST_COLOR_MATRIX_ALPHA_BIAS : constant GLenum := 16#80BB#;
GL_HISTOGRAM : constant GLenum := 16#8024#;
GL_PROXY_HISTOGRAM : constant GLenum := 16#8025#;
GL_HISTOGRAM_WIDTH : constant GLenum := 16#8026#;
GL_HISTOGRAM_FORMAT : constant GLenum := 16#8027#;
GL_HISTOGRAM_RED_SIZE : constant GLenum := 16#8028#;
GL_HISTOGRAM_GREEN_SIZE : constant GLenum := 16#8029#;
GL_HISTOGRAM_BLUE_SIZE : constant GLenum := 16#802A#;
GL_HISTOGRAM_ALPHA_SIZE : constant GLenum := 16#802B#;
GL_HISTOGRAM_LUMINANCE_SIZE : constant GLenum := 16#802C#;
GL_HISTOGRAM_SINK : constant GLenum := 16#802D#;
GL_MINMAX : constant GLenum := 16#802E#;
GL_MINMAX_FORMAT : constant GLenum := 16#802F#;
GL_MINMAX_SINK : constant GLenum := 16#8030#;
GL_TABLE_TOO_LARGE : constant GLenum := 16#8031#;
GL_BLEND_EQUATION : constant GLenum := 16#8009#;
GL_MIN : constant GLenum := 16#8007#;
GL_MAX : constant GLenum := 16#8008#;
GL_FUNC_ADD : constant GLenum := 16#8006#;
GL_FUNC_SUBTRACT : constant GLenum := 16#800A#;
GL_FUNC_REVERSE_SUBTRACT : constant GLenum := 16#800B#;
GL_BLEND_COLOR : constant GLenum := 16#8005#;
GL_TEXTURE0 : constant GLenum := 16#84C0#;
GL_TEXTURE1 : constant GLenum := 16#84C1#;
GL_TEXTURE2 : constant GLenum := 16#84C2#;
GL_TEXTURE3 : constant GLenum := 16#84C3#;
GL_TEXTURE4 : constant GLenum := 16#84C4#;
GL_TEXTURE5 : constant GLenum := 16#84C5#;
GL_TEXTURE6 : constant GLenum := 16#84C6#;
GL_TEXTURE7 : constant GLenum := 16#84C7#;
GL_TEXTURE8 : constant GLenum := 16#84C8#;
GL_TEXTURE9 : constant GLenum := 16#84C9#;
GL_TEXTURE10 : constant GLenum := 16#84CA#;
GL_TEXTURE11 : constant GLenum := 16#84CB#;
GL_TEXTURE12 : constant GLenum := 16#84CC#;
GL_TEXTURE13 : constant GLenum := 16#84CD#;
GL_TEXTURE14 : constant GLenum := 16#84CE#;
GL_TEXTURE15 : constant GLenum := 16#84CF#;
GL_TEXTURE16 : constant GLenum := 16#84D0#;
GL_TEXTURE17 : constant GLenum := 16#84D1#;
GL_TEXTURE18 : constant GLenum := 16#84D2#;
GL_TEXTURE19 : constant GLenum := 16#84D3#;
GL_TEXTURE20 : constant GLenum := 16#84D4#;
GL_TEXTURE21 : constant GLenum := 16#84D5#;
GL_TEXTURE22 : constant GLenum := 16#84D6#;
GL_TEXTURE23 : constant GLenum := 16#84D7#;
GL_TEXTURE24 : constant GLenum := 16#84D8#;
GL_TEXTURE25 : constant GLenum := 16#84D9#;
GL_TEXTURE26 : constant GLenum := 16#84DA#;
GL_TEXTURE27 : constant GLenum := 16#84DB#;
GL_TEXTURE28 : constant GLenum := 16#84DC#;
GL_TEXTURE29 : constant GLenum := 16#84DD#;
GL_TEXTURE30 : constant GLenum := 16#84DE#;
GL_TEXTURE31 : constant GLenum := 16#84DF#;
GL_ACTIVE_TEXTURE : constant GLenum := 16#84E0#;
GL_CLIENT_ACTIVE_TEXTURE : constant GLenum := 16#84E1#;
GL_MAX_TEXTURE_UNITS : constant GLenum := 16#84E2#;
GL_NORMAL_MAP : constant GLenum := 16#8511#;
GL_REFLECTION_MAP : constant GLenum := 16#8512#;
GL_TEXTURE_CUBE_MAP : constant GLenum := 16#8513#;
GL_TEXTURE_BINDING_CUBE_MAP : constant GLenum := 16#8514#;
GL_TEXTURE_CUBE_MAP_POSITIVE_X : constant GLenum := 16#8515#;
GL_TEXTURE_CUBE_MAP_NEGATIVE_X : constant GLenum := 16#8516#;
GL_TEXTURE_CUBE_MAP_POSITIVE_Y : constant GLenum := 16#8517#;
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y : constant GLenum := 16#8518#;
GL_TEXTURE_CUBE_MAP_POSITIVE_Z : constant GLenum := 16#8519#;
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z : constant GLenum := 16#851A#;
GL_PROXY_TEXTURE_CUBE_MAP : constant GLenum := 16#851B#;
GL_MAX_CUBE_MAP_TEXTURE_SIZE : constant GLenum := 16#851C#;
GL_COMPRESSED_ALPHA : constant GLenum := 16#84E9#;
GL_COMPRESSED_LUMINANCE : constant GLenum := 16#84EA#;
GL_COMPRESSED_LUMINANCE_ALPHA : constant GLenum := 16#84EB#;
GL_COMPRESSED_INTENSITY : constant GLenum := 16#84EC#;
GL_COMPRESSED_RGB : constant GLenum := 16#84ED#;
GL_COMPRESSED_RGBA : constant GLenum := 16#84EE#;
GL_TEXTURE_COMPRESSION_HINT : constant GLenum := 16#84EF#;
GL_TEXTURE_COMPRESSED_IMAGE_SIZE : constant GLenum := 16#86A0#;
GL_TEXTURE_COMPRESSED : constant GLenum := 16#86A1#;
GL_NUM_COMPRESSED_TEXTURE_FORMATS : constant GLenum := 16#86A2#;
GL_COMPRESSED_TEXTURE_FORMATS : constant GLenum := 16#86A3#;
GL_MULTISAMPLE : constant GLenum := 16#809D#;
GL_SAMPLE_ALPHA_TO_COVERAGE : constant GLenum := 16#809E#;
GL_SAMPLE_ALPHA_TO_ONE : constant GLenum := 16#809F#;
GL_SAMPLE_COVERAGE : constant GLenum := 16#80A0#;
GL_SAMPLE_BUFFERS : constant GLenum := 16#80A8#;
GL_SAMPLES : constant GLenum := 16#80A9#;
GL_SAMPLE_COVERAGE_VALUE : constant GLenum := 16#80AA#;
GL_SAMPLE_COVERAGE_INVERT : constant GLenum := 16#80AB#;
GL_MULTISAMPLE_BIT : constant GLenum := 16#20000000#;
GL_TRANSPOSE_MODELVIEW_MATRIX : constant GLenum := 16#84E3#;
GL_TRANSPOSE_PROJECTION_MATRIX : constant GLenum := 16#84E4#;
GL_TRANSPOSE_TEXTURE_MATRIX : constant GLenum := 16#84E5#;
GL_TRANSPOSE_COLOR_MATRIX : constant GLenum := 16#84E6#;
GL_COMBINE : constant GLenum := 16#8570#;
GL_COMBINE_RGB : constant GLenum := 16#8571#;
GL_COMBINE_ALPHA : constant GLenum := 16#8572#;
GL_SOURCE0_RGB : constant GLenum := 16#8580#;
GL_SOURCE1_RGB : constant GLenum := 16#8581#;
GL_SOURCE2_RGB : constant GLenum := 16#8582#;
GL_SOURCE0_ALPHA : constant GLenum := 16#8588#;
GL_SOURCE1_ALPHA : constant GLenum := 16#8589#;
GL_SOURCE2_ALPHA : constant GLenum := 16#858A#;
GL_OPERAND0_RGB : constant GLenum := 16#8590#;
GL_OPERAND1_RGB : constant GLenum := 16#8591#;
GL_OPERAND2_RGB : constant GLenum := 16#8592#;
GL_OPERAND0_ALPHA : constant GLenum := 16#8598#;
GL_OPERAND1_ALPHA : constant GLenum := 16#8599#;
GL_OPERAND2_ALPHA : constant GLenum := 16#859A#;
GL_RGB_SCALE : constant GLenum := 16#8573#;
GL_ADD_SIGNED : constant GLenum := 16#8574#;
GL_INTERPOLATE : constant GLenum := 16#8575#;
GL_SUBTRACT : constant GLenum := 16#84E7#;
GL_CONSTANT : constant GLenum := 16#8576#;
GL_PRIMARY_COLOR : constant GLenum := 16#8577#;
GL_PREVIOUS : constant GLenum := 16#8578#;
GL_DOT3_RGB : constant GLenum := 16#86AE#;
GL_DOT3_RGBA : constant GLenum := 16#86AF#;
GL_CLAMP_TO_BORDER : constant GLenum := 16#812D#;
-- ////////////////////////////////////////////////////////////
-- // GL functions
-- ////////////////////////////////////////////////////////////
procedure glClearIndex (c : GLfloat);
procedure glClearColor
(red : GLclampf;
green : GLclampf;
blue : GLclampf;
alpha : GLclampf);
procedure glClear (mask : GLbitfield);
procedure glIndexMask (mask : GLuint);
procedure glColorMask
(red : GLboolean;
green : GLboolean;
blue : GLboolean;
alpha : GLboolean);
procedure glAlphaFunc (func : GLenum; ref : GLclampf);
procedure glBlendFunc (sfactor : GLenum; dfactor : GLenum);
procedure glLogicOp (opcode : GLenum);
procedure glCullFace (mode : GLenum);
procedure glFrontFace (mode : GLenum);
procedure glPointSize (size : GLfloat);
procedure glLineWidth (width : GLfloat);
procedure glLineStipple (factor : GLint; pattern : GLushort);
procedure glPolygonMode (face : GLenum; mode : GLenum);
procedure glPolygonOffset (factor : GLfloat; units : GLfloat);
procedure glPolygonStipple (mask : access GLubyte);
procedure glGetPolygonStipple (mask : access GLubyte);
procedure glEdgeFlag (flag : GLboolean);
procedure glEdgeFlagv (flag : access GLboolean);
procedure glScissor
(x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glClipPlane (plane : GLenum; equation : access GLdouble);
procedure glGetClipPlane (plane : GLenum; equation : access GLdouble);
procedure glDrawBuffer (mode : GLenum);
procedure glReadBuffer (mode : GLenum);
procedure glEnable (cap : GLenum);
procedure glDisable (cap : GLenum);
function glIsEnabled (cap : GLenum) return GLboolean;
procedure glEnableClientState (cap : GLenum);
procedure glDisableClientState (cap : GLenum);
procedure glGetBooleanv (pname : GLenum; params : access GLboolean);
procedure glGetDoublev (pname : GLenum; params : access GLdouble);
procedure glGetFloatv (pname : GLenum; params : access GLfloat);
procedure glGetIntegerv (pname : GLenum; params : access GLint);
procedure glPushAttrib (mask : GLbitfield);
procedure glPopAttrib;
procedure glPushClientAttrib (mask : GLbitfield);
procedure glPopClientAttrib;
function glRenderMode (mode : GLenum) return GLint;
function glGetError return GLenum;
function glGetString (name : GLenum) return GLubyte_Ptr;
procedure glFinish;
procedure glFlush;
procedure glHint (target : GLenum; mode : GLenum);
procedure glClearDepth (depth : GLclampd);
procedure glDepthFunc (func : GLenum);
procedure glDepthMask (flag : GLboolean);
procedure glDepthRange (near_val : GLclampd; far_val : GLclampd);
procedure glClearAccum
(red : GLfloat;
green : GLfloat;
blue : GLfloat;
alpha : GLfloat);
procedure glAccum (op : GLenum; value : GLfloat);
procedure glMatrixMode (mode : GLenum);
procedure glOrtho
(left : GLdouble;
right : GLdouble;
bottom : GLdouble;
top : GLdouble;
near_val : GLdouble;
far_val : GLdouble);
procedure glFrustum
(left : GLdouble;
right : GLdouble;
bottom : GLdouble;
top : GLdouble;
near_val : GLdouble;
far_val : GLdouble);
procedure glViewport
(x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glPushMatrix;
procedure glPopMatrix;
procedure glLoadIdentity;
procedure glLoadMatrixd (m : access GLdouble);
procedure glLoadMatrixf (m : access GLfloat);
procedure glMultMatrixd (m : access GLdouble);
procedure glMultMatrixf (m : access GLfloat);
procedure glRotated
(angle : GLdouble;
x : GLdouble;
y : GLdouble;
z : GLdouble);
procedure glRotatef
(angle : GLfloat;
x : GLfloat;
y : GLfloat;
z : GLfloat);
procedure glScaled (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glScalef (x : GLfloat; y : GLfloat; z : GLfloat);
procedure glTranslated (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glTranslatef (x : GLfloat; y : GLfloat; z : GLfloat);
function glIsList (list : GLuint) return GLboolean;
procedure glDeleteLists (list : GLuint; c_range : GLsizei);
function glGenLists (c_range : GLsizei) return GLuint;
procedure glNewList (list : GLuint; mode : GLenum);
procedure glEndList;
procedure glCallList (list : GLuint);
procedure glCallLists (n : GLsizei; c_type : GLenum; lists : GLvoid_Ptr);
procedure glListBase (base : GLuint);
procedure glBegin (mode : GLenum);
procedure glEnd;
procedure glVertex2d (x : GLdouble; y : GLdouble);
procedure glVertex2f (x : GLfloat; y : GLfloat);
procedure glVertex2i (x : GLint; y : GLint);
procedure glVertex2s (x : GLshort; y : GLshort);
procedure glVertex3d (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glVertex3f (x : GLfloat; y : GLfloat; z : GLfloat);
procedure glVertex3i (x : GLint; y : GLint; z : GLint);
procedure glVertex3s (x : GLshort; y : GLshort; z : GLshort);
procedure glVertex4d
(x : GLdouble;
y : GLdouble;
z : GLdouble;
w : GLdouble);
procedure glVertex4f
(x : GLfloat;
y : GLfloat;
z : GLfloat;
w : GLfloat);
procedure glVertex4i
(x : GLint;
y : GLint;
z : GLint;
w : GLint);
procedure glVertex4s
(x : GLshort;
y : GLshort;
z : GLshort;
w : GLshort);
procedure glVertex2dv (v : access GLdouble);
procedure glVertex2fv (v : access GLfloat);
procedure glVertex2iv (v : access GLint);
procedure glVertex2sv (v : access GLshort);
procedure glVertex3dv (v : access GLdouble);
procedure glVertex3fv (v : access GLfloat);
procedure glVertex3iv (v : access GLint);
procedure glVertex3sv (v : access GLshort);
procedure glVertex4dv (v : access GLdouble);
procedure glVertex4fv (v : access GLfloat);
procedure glVertex4iv (v : access GLint);
procedure glVertex4sv (v : access GLshort);
procedure glNormal3b (nx : GLbyte; ny : GLbyte; nz : GLbyte);
procedure glNormal3d (nx : GLdouble; ny : GLdouble; nz : GLdouble);
procedure glNormal3f (nx : GLfloat; ny : GLfloat; nz : GLfloat);
procedure glNormal3i (nx : GLint; ny : GLint; nz : GLint);
procedure glNormal3s (nx : GLshort; ny : GLshort; nz : GLshort);
procedure glNormal3bv (v : access GLbyte);
procedure glNormal3dv (v : access GLdouble);
procedure glNormal3fv (v : access GLfloat);
procedure glNormal3iv (v : access GLint);
procedure glNormal3sv (v : access GLshort);
procedure glIndexd (c : GLdouble);
procedure glIndexf (c : GLfloat);
procedure glIndexi (c : GLint);
procedure glIndexs (c : GLshort);
procedure glIndexub (c : GLubyte);
procedure glIndexdv (c : access GLdouble);
procedure glIndexfv (c : access GLfloat);
procedure glIndexiv (c : access GLint);
procedure glIndexsv (c : access GLshort);
procedure glIndexubv (c : access GLubyte);
procedure glColor3b (red : GLbyte; green : GLbyte; blue : GLbyte);
procedure glColor3d (red : GLdouble; green : GLdouble; blue : GLdouble);
procedure glColor3f (red : GLfloat; green : GLfloat; blue : GLfloat);
procedure glColor3i (red : GLint; green : GLint; blue : GLint);
procedure glColor3s (red : GLshort; green : GLshort; blue : GLshort);
procedure glColor3ub (red : GLubyte; green : GLubyte; blue : GLubyte);
procedure glColor3ui (red : GLuint; green : GLuint; blue : GLuint);
procedure glColor3us (red : GLushort; green : GLushort; blue : GLushort);
procedure glColor4b
(red : GLbyte;
green : GLbyte;
blue : GLbyte;
alpha : GLbyte);
procedure glColor4d
(red : GLdouble;
green : GLdouble;
blue : GLdouble;
alpha : GLdouble);
procedure glColor4f
(red : GLfloat;
green : GLfloat;
blue : GLfloat;
alpha : GLfloat);
procedure glColor4i
(red : GLint;
green : GLint;
blue : GLint;
alpha : GLint);
procedure glColor4s
(red : GLshort;
green : GLshort;
blue : GLshort;
alpha : GLshort);
procedure glColor4ub
(red : GLubyte;
green : GLubyte;
blue : GLubyte;
alpha : GLubyte);
procedure glColor4ui
(red : GLuint;
green : GLuint;
blue : GLuint;
alpha : GLuint);
procedure glColor4us
(red : GLushort;
green : GLushort;
blue : GLushort;
alpha : GLushort);
procedure glColor3bv (v : access GLbyte);
procedure glColor3dv (v : access GLdouble);
procedure glColor3fv (v : access GLfloat);
procedure glColor3iv (v : access GLint);
procedure glColor3sv (v : access GLshort);
procedure glColor3ubv (v : access GLubyte);
procedure glColor3uiv (v : access GLuint);
procedure glColor3usv (v : access GLushort);
procedure glColor4bv (v : access GLbyte);
procedure glColor4dv (v : access GLdouble);
procedure glColor4fv (v : access GLfloat);
procedure glColor4iv (v : access GLint);
procedure glColor4sv (v : access GLshort);
procedure glColor4ubv (v : access GLubyte);
procedure glColor4uiv (v : access GLuint);
procedure glColor4usv (v : access GLushort);
procedure glTexCoord1d (s : GLdouble);
procedure glTexCoord1f (s : GLfloat);
procedure glTexCoord1i (s : GLint);
procedure glTexCoord1s (s : GLshort);
procedure glTexCoord2d (s : GLdouble; t : GLdouble);
procedure glTexCoord2f (s : GLfloat; t : GLfloat);
procedure glTexCoord2i (s : GLint; t : GLint);
procedure glTexCoord2s (s : GLshort; t : GLshort);
procedure glTexCoord3d (s : GLdouble; t : GLdouble; r : GLdouble);
procedure glTexCoord3f (s : GLfloat; t : GLfloat; r : GLfloat);
procedure glTexCoord3i (s : GLint; t : GLint; r : GLint);
procedure glTexCoord3s (s : GLshort; t : GLshort; r : GLshort);
procedure glTexCoord4d
(s : GLdouble;
t : GLdouble;
r : GLdouble;
q : GLdouble);
procedure glTexCoord4f
(s : GLfloat;
t : GLfloat;
r : GLfloat;
q : GLfloat);
procedure glTexCoord4i
(s : GLint;
t : GLint;
r : GLint;
q : GLint);
procedure glTexCoord4s
(s : GLshort;
t : GLshort;
r : GLshort;
q : GLshort);
procedure glTexCoord1dv (v : access GLdouble);
procedure glTexCoord1fv (v : access GLfloat);
procedure glTexCoord1iv (v : access GLint);
procedure glTexCoord1sv (v : access GLshort);
procedure glTexCoord2dv (v : access GLdouble);
procedure glTexCoord2fv (v : access GLfloat);
procedure glTexCoord2iv (v : access GLint);
procedure glTexCoord2sv (v : access GLshort);
procedure glTexCoord3dv (v : access GLdouble);
procedure glTexCoord3fv (v : access GLfloat);
procedure glTexCoord3iv (v : access GLint);
procedure glTexCoord3sv (v : access GLshort);
procedure glTexCoord4dv (v : access GLdouble);
procedure glTexCoord4fv (v : access GLfloat);
procedure glTexCoord4iv (v : access GLint);
procedure glTexCoord4sv (v : access GLshort);
procedure glRasterPos2d (x : GLdouble; y : GLdouble);
procedure glRasterPos2f (x : GLfloat; y : GLfloat);
procedure glRasterPos2i (x : GLint; y : GLint);
procedure glRasterPos2s (x : GLshort; y : GLshort);
procedure glRasterPos3d (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glRasterPos3f (x : GLfloat; y : GLfloat; z : GLfloat);
procedure glRasterPos3i (x : GLint; y : GLint; z : GLint);
procedure glRasterPos3s (x : GLshort; y : GLshort; z : GLshort);
procedure glRasterPos4d
(x : GLdouble;
y : GLdouble;
z : GLdouble;
w : GLdouble);
procedure glRasterPos4f
(x : GLfloat;
y : GLfloat;
z : GLfloat;
w : GLfloat);
procedure glRasterPos4i
(x : GLint;
y : GLint;
z : GLint;
w : GLint);
procedure glRasterPos4s
(x : GLshort;
y : GLshort;
z : GLshort;
w : GLshort);
procedure glRasterPos2dv (v : access GLdouble);
procedure glRasterPos2fv (v : access GLfloat);
procedure glRasterPos2iv (v : access GLint);
procedure glRasterPos2sv (v : access GLshort);
procedure glRasterPos3dv (v : access GLdouble);
procedure glRasterPos3fv (v : access GLfloat);
procedure glRasterPos3iv (v : access GLint);
procedure glRasterPos3sv (v : access GLshort);
procedure glRasterPos4dv (v : access GLdouble);
procedure glRasterPos4fv (v : access GLfloat);
procedure glRasterPos4iv (v : access GLint);
procedure glRasterPos4sv (v : access GLshort);
procedure glRectd
(x1 : GLdouble;
y1 : GLdouble;
x2 : GLdouble;
y2 : GLdouble);
procedure glRectf
(x1 : GLfloat;
y1 : GLfloat;
x2 : GLfloat;
y2 : GLfloat);
procedure glRecti
(x1 : GLint;
y1 : GLint;
x2 : GLint;
y2 : GLint);
procedure glRects
(x1 : GLshort;
y1 : GLshort;
x2 : GLshort;
y2 : GLshort);
procedure glRectdv (v1 : access GLdouble; v2 : access GLdouble);
procedure glRectfv (v1 : access GLfloat; v2 : access GLfloat);
procedure glRectiv (v1 : access GLint; v2 : access GLint);
procedure glRectsv (v1 : access GLshort; v2 : access GLshort);
procedure glShadeModel (mode : GLenum);
procedure glLightf (light : GLenum; pname : GLenum; param : GLfloat);
procedure glLighti (light : GLenum; pname : GLenum; param : GLint);
procedure glLightfv (light : GLenum; pname : GLenum; params : access GLfloat);
procedure glLightiv (light : GLenum; pname : GLenum; params : access GLint);
procedure glGetLightfv (light : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetLightiv (light : GLenum; pname : GLenum; params : access GLint);
procedure glLightModelf (pname : GLenum; param : GLfloat);
procedure glLightModeli (pname : GLenum; param : GLint);
procedure glLightModelfv (pname : GLenum; params : access GLfloat);
procedure glLightModeliv (pname : GLenum; params : access GLint);
procedure glMaterialf (face : GLenum; pname : GLenum; param : GLfloat);
procedure glMateriali (face : GLenum; pname : GLenum; param : GLint);
procedure glMaterialfv (face : GLenum; pname : GLenum; params : access GLfloat);
procedure glMaterialiv (face : GLenum; pname : GLenum; params : access GLint);
procedure glGetMaterialfv (face : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetMaterialiv (face : GLenum; pname : GLenum; params : access GLint);
procedure glColorMaterial (face : GLenum; mode : GLenum);
procedure glPixelZoom (xfactor : GLfloat; yfactor : GLfloat);
procedure glPixelStoref (pname : GLenum; param : GLfloat);
procedure glPixelStorei (pname : GLenum; param : GLint);
procedure glPixelTransferf (pname : GLenum; param : GLfloat);
procedure glPixelTransferi (pname : GLenum; param : GLint);
procedure glPixelMapfv (map : GLenum; mapsize : GLint; values : access GLfloat);
procedure glPixelMapuiv (map : GLenum; mapsize : GLint; values : access GLuint);
procedure glPixelMapusv (map : GLenum; mapsize : GLint; values : access GLushort);
procedure glGetPixelMapfv (map : GLenum; values : access GLfloat);
procedure glGetPixelMapuiv (map : GLenum; values : access GLuint);
procedure glGetPixelMapusv (map : GLenum; values : access GLushort);
procedure glBitmap
(width : GLsizei;
height : GLsizei;
xorig : GLfloat;
yorig : GLfloat;
xmove : GLfloat;
ymove : GLfloat;
bitmap : access GLubyte);
procedure glReadPixels
(x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glDrawPixels
(width : GLsizei;
height : GLsizei;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glCopyPixels
(x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei;
c_type : GLenum);
procedure glStencilFunc (func : GLenum; ref : GLint; mask : GLuint);
procedure glStencilMask (mask : GLuint);
procedure glStencilOp (fail : GLenum; zfail : GLenum; zpass : GLenum);
procedure glClearStencil (s : GLint);
procedure glTexGend (coord : GLenum; pname : GLenum; param : GLdouble);
procedure glTexGenf (coord : GLenum; pname : GLenum; param : GLfloat);
procedure glTexGeni (coord : GLenum; pname : GLenum; param : GLint);
procedure glTexGendv (coord : GLenum; pname : GLenum; params : access GLdouble);
procedure glTexGenfv (coord : GLenum; pname : GLenum; params : access GLfloat);
procedure glTexGeniv (coord : GLenum; pname : GLenum; params : access GLint);
procedure glGetTexGendv (coord : GLenum; pname : GLenum; params : access GLdouble);
procedure glGetTexGenfv (coord : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetTexGeniv (coord : GLenum; pname : GLenum; params : access GLint);
procedure glTexEnvf (target : GLenum; pname : GLenum; param : GLfloat);
procedure glTexEnvi (target : GLenum; pname : GLenum; param : GLint);
procedure glTexEnvfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glTexEnviv (target : GLenum; pname : GLenum; params : access GLint);
procedure glGetTexEnvfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetTexEnviv (target : GLenum; pname : GLenum; params : access GLint);
procedure glTexParameterf (target : GLenum; pname : GLenum; param : GLfloat);
procedure glTexParameteri (target : GLenum; pname : GLenum; param : GLint);
procedure glTexParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glTexParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glGetTexParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetTexParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glGetTexLevelParameterfv
(target : GLenum;
level : GLint;
pname : GLenum;
params : access GLfloat);
procedure glGetTexLevelParameteriv
(target : GLenum;
level : GLint;
pname : GLenum;
params : access GLint);
procedure glTexImage1D
(target : GLenum;
level : GLint;
internalFormat : GLint;
width : GLsizei;
border : GLint;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glTexImage2D
(target : GLenum;
level : GLint;
internalFormat : GLint;
width : GLsizei;
height : GLsizei;
border : GLint;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glGetTexImage
(target : GLenum;
level : GLint;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glMap1d
(target : GLenum;
u1 : GLdouble;
u2 : GLdouble;
stride : GLint;
order : GLint;
points : access GLdouble);
procedure glMap1f
(target : GLenum;
u1 : GLfloat;
u2 : GLfloat;
stride : GLint;
order : GLint;
points : access GLfloat);
procedure glMap2d
(target : GLenum;
u1 : GLdouble;
u2 : GLdouble;
ustride : GLint;
uorder : GLint;
v1 : GLdouble;
v2 : GLdouble;
vstride : GLint;
vorder : GLint;
points : access GLdouble);
procedure glMap2f
(target : GLenum;
u1 : GLfloat;
u2 : GLfloat;
ustride : GLint;
uorder : GLint;
v1 : GLfloat;
v2 : GLfloat;
vstride : GLint;
vorder : GLint;
points : access GLfloat);
procedure glGetMapdv (target : GLenum; query : GLenum; v : access GLdouble);
procedure glGetMapfv (target : GLenum; query : GLenum; v : access GLfloat);
procedure glGetMapiv (target : GLenum; query : GLenum; v : access GLint);
procedure glEvalCoord1d (u : GLdouble);
procedure glEvalCoord1f (u : GLfloat);
procedure glEvalCoord1dv (u : access GLdouble);
procedure glEvalCoord1fv (u : access GLfloat);
procedure glEvalCoord2d (u : GLdouble; v : GLdouble);
procedure glEvalCoord2f (u : GLfloat; v : GLfloat);
procedure glEvalCoord2dv (u : access GLdouble);
procedure glEvalCoord2fv (u : access GLfloat);
procedure glMapGrid1d (un : GLint; u1 : GLdouble; u2 : GLdouble);
procedure glMapGrid1f (un : GLint; u1 : GLfloat; u2 : GLfloat);
procedure glMapGrid2d
(un : GLint;
u1 : GLdouble;
u2 : GLdouble;
vn : GLint;
v1 : GLdouble;
v2 : GLdouble);
procedure glMapGrid2f
(un : GLint;
u1 : GLfloat;
u2 : GLfloat;
vn : GLint;
v1 : GLfloat;
v2 : GLfloat);
procedure glEvalPoint1 (i : GLint);
procedure glEvalPoint2 (i : GLint; j : GLint);
procedure glEvalMesh1 (mode : GLenum; i1 : GLint; i2 : GLint);
procedure glEvalMesh2
(mode : GLenum;
i1 : GLint;
i2 : GLint;
j1 : GLint;
j2 : GLint);
procedure glFogf (pname : GLenum; param : GLfloat);
procedure glFogi (pname : GLenum; param : GLint);
procedure glFogfv (pname : GLenum; params : access GLfloat);
procedure glFogiv (pname : GLenum; params : access GLint);
procedure glFeedbackBuffer (size : GLsizei; c_type : GLenum; buffer : access GLfloat);
procedure glPassThrough (token : GLfloat);
procedure glSelectBuffer (size : GLsizei; buffer : access GLuint);
procedure glInitNames;
procedure glLoadName (name : GLuint);
procedure glPushName (name : GLuint);
procedure glPopName;
procedure glGenTextures (n : GLsizei; textures : access GLuint);
procedure glDeleteTextures (n : GLsizei; textures : access GLuint);
procedure glBindTexture (target : GLenum; texture : GLuint);
procedure glPrioritizeTextures (n : GLsizei; textures : access GLuint; priorities : access GLclampf);
function glAreTexturesResident
(n : GLsizei;
textures : access GLuint;
residences : access GLboolean)
return GLboolean;
function glIsTexture (texture : GLuint) return GLboolean;
procedure glTexSubImage1D
(target : GLenum;
level : GLint;
xoffset : GLint;
width : GLsizei;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glTexSubImage2D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
width : GLsizei;
height : GLsizei;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glCopyTexImage1D
(target : GLenum;
level : GLint;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei;
border : GLint);
procedure glCopyTexImage2D
(target : GLenum;
level : GLint;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei;
border : GLint);
procedure glCopyTexSubImage1D
(target : GLenum;
level : GLint;
xoffset : GLint;
x : GLint;
y : GLint;
width : GLsizei);
procedure glCopyTexSubImage2D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glVertexPointer
(size : GLint;
c_type : GLenum;
stride : GLsizei;
ptr : GLvoid_Ptr);
procedure glNormalPointer (c_type : GLenum; stride : GLsizei; ptr : GLvoid_Ptr);
procedure glColorPointer
(size : GLint;
c_type : GLenum;
stride : GLsizei;
ptr : GLvoid_Ptr);
procedure glIndexPointer (c_type : GLenum; stride : GLsizei; ptr : GLvoid_Ptr);
procedure glTexCoordPointer
(size : GLint;
c_type : GLenum;
stride : GLsizei;
ptr : GLvoid_Ptr);
procedure glEdgeFlagPointer (stride : GLsizei; ptr : GLvoid_Ptr);
procedure glGetPointerv (pname : GLenum; params : GLvoid_Ptr);
procedure glArrayElement (i : GLint);
procedure glDrawArrays (mode : GLenum; first : GLint; count : GLsizei);
procedure glDrawElements
(mode : GLenum;
count : GLsizei;
c_type : GLenum;
indices : GLvoid_Ptr);
procedure glInterleavedArrays (format : GLenum; stride : GLsizei; pointer : GLvoid_Ptr);
procedure glDrawRangeElements
(mode : GLenum;
start : GLuint;
c_end : GLuint;
count : GLsizei;
c_type : GLenum;
indices : GLvoid_Ptr);
procedure glTexImage3D
(target : GLenum;
level : GLint;
internalFormat : GLenum;
width : GLsizei;
height : GLsizei;
depth : GLsizei;
border : GLint;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glTexSubImage3D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
zoffset : GLint;
width : GLsizei;
height : GLsizei;
depth : GLsizei;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glCopyTexSubImage3D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
zoffset : GLint;
x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glColorTable
(target : GLenum;
internalformat : GLenum;
width : GLsizei;
format : GLenum;
c_type : GLenum;
table : GLvoid_Ptr);
procedure glColorSubTable
(target : GLenum;
start : GLsizei;
count : GLsizei;
format : GLenum;
c_type : GLenum;
data : GLvoid_Ptr);
procedure glColorTableParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glColorTableParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glCopyColorSubTable
(target : GLenum;
start : GLsizei;
x : GLint;
y : GLint;
width : GLsizei);
procedure glCopyColorTable
(target : GLenum;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei);
procedure glGetColorTable
(target : GLenum;
format : GLenum;
c_type : GLenum;
table : GLvoid_Ptr);
procedure glGetColorTableParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetColorTableParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glBlendEquation (mode : GLenum);
procedure glBlendColor
(red : GLclampf;
green : GLclampf;
blue : GLclampf;
alpha : GLclampf);
procedure glHistogram
(target : GLenum;
width : GLsizei;
internalformat : GLenum;
sink : GLboolean);
procedure glResetHistogram (target : GLenum);
procedure glGetHistogram
(target : GLenum;
reset : GLboolean;
format : GLenum;
c_type : GLenum;
values : GLvoid_Ptr);
procedure glGetHistogramParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetHistogramParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glMinmax (target : GLenum; internalformat : GLenum; sink : GLboolean);
procedure glResetMinmax (target : GLenum);
procedure glGetMinmax
(target : GLenum;
reset : GLboolean;
format : GLenum;
types : GLenum;
values : GLvoid_Ptr);
procedure glGetMinmaxParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetMinmaxParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glConvolutionFilter1D
(target : GLenum;
internalformat : GLenum;
width : GLsizei;
format : GLenum;
c_type : GLenum;
image : GLvoid_Ptr);
procedure glConvolutionFilter2D
(target : GLenum;
internalformat : GLenum;
width : GLsizei;
height : GLsizei;
format : GLenum;
c_type : GLenum;
image : GLvoid_Ptr);
procedure glConvolutionParameterf (target : GLenum; pname : GLenum; params : GLfloat);
procedure glConvolutionParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glConvolutionParameteri (target : GLenum; pname : GLenum; params : GLint);
procedure glConvolutionParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glCopyConvolutionFilter1D
(target : GLenum;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei);
procedure glCopyConvolutionFilter2D
(target : GLenum;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glGetConvolutionFilter
(target : GLenum;
format : GLenum;
c_type : GLenum;
image : GLvoid_Ptr);
procedure glGetConvolutionParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetConvolutionParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glSeparableFilter2D
(target : GLenum;
internalformat : GLenum;
width : GLsizei;
height : GLsizei;
format : GLenum;
c_type : GLenum;
row : GLvoid_Ptr;
column : GLvoid_Ptr);
procedure glGetSeparableFilter
(target : GLenum;
format : GLenum;
c_type : GLenum;
row : GLvoid_Ptr;
column : GLvoid_Ptr;
span : GLvoid_Ptr);
procedure glActiveTexture (texture : GLenum);
procedure glClientActiveTexture (texture : GLenum);
procedure glCompressedTexImage1D
(target : GLenum;
level : GLint;
internalformat : GLenum;
width : GLsizei;
border : GLint;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glCompressedTexImage2D
(target : GLenum;
level : GLint;
internalformat : GLenum;
width : GLsizei;
height : GLsizei;
border : GLint;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glCompressedTexImage3D
(target : GLenum;
level : GLint;
internalformat : GLenum;
width : GLsizei;
height : GLsizei;
depth : GLsizei;
border : GLint;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glCompressedTexSubImage1D
(target : GLenum;
level : GLint;
xoffset : GLint;
width : GLsizei;
format : GLenum;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glCompressedTexSubImage2D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
width : GLsizei;
height : GLsizei;
format : GLenum;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glCompressedTexSubImage3D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
zoffset : GLint;
width : GLsizei;
height : GLsizei;
depth : GLsizei;
format : GLenum;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glGetCompressedTexImage (target : GLenum; lod : GLint; img : GLvoid_Ptr);
procedure glMultiTexCoord1d (target : GLenum; s : GLdouble);
procedure glMultiTexCoord1dv (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord1f (target : GLenum; s : GLfloat);
procedure glMultiTexCoord1fv (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord1i (target : GLenum; s : GLint);
procedure glMultiTexCoord1iv (target : GLenum; v : access GLint);
procedure glMultiTexCoord1s (target : GLenum; s : GLshort);
procedure glMultiTexCoord1sv (target : GLenum; v : access GLshort);
procedure glMultiTexCoord2d (target : GLenum; s : GLdouble; t : GLdouble);
procedure glMultiTexCoord2dv (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord2f (target : GLenum; s : GLfloat; t : GLfloat);
procedure glMultiTexCoord2fv (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord2i (target : GLenum; s : GLint; t : GLint);
procedure glMultiTexCoord2iv (target : GLenum; v : access GLint);
procedure glMultiTexCoord2s (target : GLenum; s : GLshort; t : GLshort);
procedure glMultiTexCoord2sv (target : GLenum; v : access GLshort);
procedure glMultiTexCoord3d
(target : GLenum;
s : GLdouble;
t : GLdouble;
r : GLdouble);
procedure glMultiTexCoord3dv (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord3f
(target : GLenum;
s : GLfloat;
t : GLfloat;
r : GLfloat);
procedure glMultiTexCoord3fv (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord3i
(target : GLenum;
s : GLint;
t : GLint;
r : GLint);
procedure glMultiTexCoord3iv (target : GLenum; v : access GLint);
procedure glMultiTexCoord3s
(target : GLenum;
s : GLshort;
t : GLshort;
r : GLshort);
procedure glMultiTexCoord3sv (target : GLenum; v : access GLshort);
procedure glMultiTexCoord4d
(target : GLenum;
s : GLdouble;
t : GLdouble;
r : GLdouble;
q : GLdouble);
procedure glMultiTexCoord4dv (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord4f
(target : GLenum;
s : GLfloat;
t : GLfloat;
r : GLfloat;
q : GLfloat);
procedure glMultiTexCoord4fv (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord4i
(target : GLenum;
s : GLint;
t : GLint;
r : GLint;
q : GLint);
procedure glMultiTexCoord4iv (target : GLenum; v : access GLint);
procedure glMultiTexCoord4s
(target : GLenum;
s : GLshort;
t : GLshort;
r : GLshort;
q : GLshort);
procedure glMultiTexCoord4sv (target : GLenum; v : access GLshort);
procedure glLoadTransposeMatrixd (m : access GLdouble);
procedure glLoadTransposeMatrixf (m : access GLfloat);
procedure glMultTransposeMatrixd (m : access GLdouble);
procedure glMultTransposeMatrixf (m : access GLfloat);
procedure glSampleCoverage (value : GLclampf; invert : GLboolean);
procedure glSamplePass (pass : GLenum);
private
pragma Import (Stdcall, glClearIndex, "glClearIndex");
pragma Import (Stdcall, glClearColor, "glClearColor");
pragma Import (Stdcall, glClear, "glClear");
pragma Import (Stdcall, glIndexMask, "glIndexMask");
pragma Import (Stdcall, glColorMask, "glColorMask");
pragma Import (Stdcall, glAlphaFunc, "glAlphaFunc");
pragma Import (Stdcall, glBlendFunc, "glBlendFunc");
pragma Import (Stdcall, glLogicOp, "glLogicOp");
pragma Import (Stdcall, glCullFace, "glCullFace");
pragma Import (Stdcall, glFrontFace, "glFrontFace");
pragma Import (Stdcall, glPointSize, "glPointSize");
pragma Import (Stdcall, glLineWidth, "glLineWidth");
pragma Import (Stdcall, glLineStipple, "glLineStipple");
pragma Import (Stdcall, glPolygonMode, "glPolygonMode");
pragma Import (Stdcall, glPolygonOffset, "glPolygonOffset");
pragma Import (Stdcall, glPolygonStipple, "glPolygonStipple");
pragma Import (Stdcall, glGetPolygonStipple, "glGetPolygonStipple");
pragma Import (Stdcall, glEdgeFlag, "glEdgeFlag");
pragma Import (Stdcall, glEdgeFlagv, "glEdgeFlagv");
pragma Import (Stdcall, glScissor, "glScissor");
pragma Import (Stdcall, glClipPlane, "glClipPlane");
pragma Import (Stdcall, glGetClipPlane, "glGetClipPlane");
pragma Import (Stdcall, glDrawBuffer, "glDrawBuffer");
pragma Import (Stdcall, glReadBuffer, "glReadBuffer");
pragma Import (Stdcall, glEnable, "glEnable");
pragma Import (Stdcall, glDisable, "glDisable");
pragma Import (Stdcall, glIsEnabled, "glIsEnabled");
pragma Import (Stdcall, glEnableClientState, "glEnableClientState");
pragma Import (Stdcall, glDisableClientState, "glDisableClientState");
pragma Import (Stdcall, glGetBooleanv, "glGetBooleanv");
pragma Import (Stdcall, glGetDoublev, "glGetDoublev");
pragma Import (Stdcall, glGetFloatv, "glGetFloatv");
pragma Import (Stdcall, glGetIntegerv, "glGetIntegerv");
pragma Import (Stdcall, glPushAttrib, "glPushAttrib");
pragma Import (Stdcall, glPopAttrib, "glPopAttrib");
pragma Import (Stdcall, glPushClientAttrib, "glPushClientAttrib");
pragma Import (Stdcall, glPopClientAttrib, "glPopClientAttrib");
pragma Import (Stdcall, glRenderMode, "glRenderMode");
pragma Import (Stdcall, glGetError, "glGetError");
pragma Import (Stdcall, glGetString, "glGetString");
pragma Import (Stdcall, glFinish, "glFinish");
pragma Import (Stdcall, glFlush, "glFlush");
pragma Import (Stdcall, glHint, "glHint");
pragma Import (Stdcall, glClearDepth, "glClearDepth");
pragma Import (Stdcall, glDepthFunc, "glDepthFunc");
pragma Import (Stdcall, glDepthMask, "glDepthMask");
pragma Import (Stdcall, glDepthRange, "glDepthRange");
pragma Import (Stdcall, glClearAccum, "glClearAccum");
pragma Import (Stdcall, glAccum, "glAccum");
pragma Import (Stdcall, glMatrixMode, "glMatrixMode");
pragma Import (Stdcall, glOrtho, "glOrtho");
pragma Import (Stdcall, glFrustum, "glFrustum");
pragma Import (Stdcall, glViewport, "glViewport");
pragma Import (Stdcall, glPushMatrix, "glPushMatrix");
pragma Import (Stdcall, glPopMatrix, "glPopMatrix");
pragma Import (Stdcall, glLoadIdentity, "glLoadIdentity");
pragma Import (Stdcall, glLoadMatrixd, "glLoadMatrixd");
pragma Import (Stdcall, glLoadMatrixf, "glLoadMatrixf");
pragma Import (Stdcall, glMultMatrixd, "glMultMatrixd");
pragma Import (Stdcall, glMultMatrixf, "glMultMatrixf");
pragma Import (Stdcall, glRotated, "glRotated");
pragma Import (Stdcall, glRotatef, "glRotatef");
pragma Import (Stdcall, glScaled, "glScaled");
pragma Import (Stdcall, glScalef, "glScalef");
pragma Import (Stdcall, glTranslated, "glTranslated");
pragma Import (Stdcall, glTranslatef, "glTranslatef");
pragma Import (Stdcall, glIsList, "glIsList");
pragma Import (Stdcall, glDeleteLists, "glDeleteLists");
pragma Import (Stdcall, glGenLists, "glGenLists");
pragma Import (Stdcall, glNewList, "glNewList");
pragma Import (Stdcall, glEndList, "glEndList");
pragma Import (Stdcall, glCallList, "glCallList");
pragma Import (Stdcall, glCallLists, "glCallLists");
pragma Import (Stdcall, glListBase, "glListBase");
pragma Import (Stdcall, glBegin, "glBegin");
pragma Import (Stdcall, glEnd, "glEnd");
pragma Import (Stdcall, glVertex2d, "glVertex2d");
pragma Import (Stdcall, glVertex2f, "glVertex2f");
pragma Import (Stdcall, glVertex2i, "glVertex2i");
pragma Import (Stdcall, glVertex2s, "glVertex2s");
pragma Import (Stdcall, glVertex3d, "glVertex3d");
pragma Import (Stdcall, glVertex3f, "glVertex3f");
pragma Import (Stdcall, glVertex3i, "glVertex3i");
pragma Import (Stdcall, glVertex3s, "glVertex3s");
pragma Import (Stdcall, glVertex4d, "glVertex4d");
pragma Import (Stdcall, glVertex4f, "glVertex4f");
pragma Import (Stdcall, glVertex4i, "glVertex4i");
pragma Import (Stdcall, glVertex4s, "glVertex4s");
pragma Import (Stdcall, glVertex2dv, "glVertex2dv");
pragma Import (Stdcall, glVertex2fv, "glVertex2fv");
pragma Import (Stdcall, glVertex2iv, "glVertex2iv");
pragma Import (Stdcall, glVertex2sv, "glVertex2sv");
pragma Import (Stdcall, glVertex3dv, "glVertex3dv");
pragma Import (Stdcall, glVertex3fv, "glVertex3fv");
pragma Import (Stdcall, glVertex3iv, "glVertex3iv");
pragma Import (Stdcall, glVertex3sv, "glVertex3sv");
pragma Import (Stdcall, glVertex4dv, "glVertex4dv");
pragma Import (Stdcall, glVertex4fv, "glVertex4fv");
pragma Import (Stdcall, glVertex4iv, "glVertex4iv");
pragma Import (Stdcall, glVertex4sv, "glVertex4sv");
pragma Import (Stdcall, glNormal3b, "glNormal3b");
pragma Import (Stdcall, glNormal3d, "glNormal3d");
pragma Import (Stdcall, glNormal3f, "glNormal3f");
pragma Import (Stdcall, glNormal3i, "glNormal3i");
pragma Import (Stdcall, glNormal3s, "glNormal3s");
pragma Import (Stdcall, glNormal3bv, "glNormal3bv");
pragma Import (Stdcall, glNormal3dv, "glNormal3dv");
pragma Import (Stdcall, glNormal3fv, "glNormal3fv");
pragma Import (Stdcall, glNormal3iv, "glNormal3iv");
pragma Import (Stdcall, glNormal3sv, "glNormal3sv");
pragma Import (Stdcall, glIndexd, "glIndexd");
pragma Import (Stdcall, glIndexf, "glIndexf");
pragma Import (Stdcall, glIndexi, "glIndexi");
pragma Import (Stdcall, glIndexs, "glIndexs");
pragma Import (Stdcall, glIndexub, "glIndexub");
pragma Import (Stdcall, glIndexdv, "glIndexdv");
pragma Import (Stdcall, glIndexfv, "glIndexfv");
pragma Import (Stdcall, glIndexiv, "glIndexiv");
pragma Import (Stdcall, glIndexsv, "glIndexsv");
pragma Import (Stdcall, glIndexubv, "glIndexubv");
pragma Import (Stdcall, glColor3b, "glColor3b");
pragma Import (Stdcall, glColor3d, "glColor3d");
pragma Import (Stdcall, glColor3f, "glColor3f");
pragma Import (Stdcall, glColor3i, "glColor3i");
pragma Import (Stdcall, glColor3s, "glColor3s");
pragma Import (Stdcall, glColor3ub, "glColor3ub");
pragma Import (Stdcall, glColor3ui, "glColor3ui");
pragma Import (Stdcall, glColor3us, "glColor3us");
pragma Import (Stdcall, glColor4b, "glColor4b");
pragma Import (Stdcall, glColor4d, "glColor4d");
pragma Import (Stdcall, glColor4f, "glColor4f");
pragma Import (Stdcall, glColor4i, "glColor4i");
pragma Import (Stdcall, glColor4s, "glColor4s");
pragma Import (Stdcall, glColor4ub, "glColor4ub");
pragma Import (Stdcall, glColor4ui, "glColor4ui");
pragma Import (Stdcall, glColor4us, "glColor4us");
pragma Import (Stdcall, glColor3bv, "glColor3bv");
pragma Import (Stdcall, glColor3dv, "glColor3dv");
pragma Import (Stdcall, glColor3fv, "glColor3fv");
pragma Import (Stdcall, glColor3iv, "glColor3iv");
pragma Import (Stdcall, glColor3sv, "glColor3sv");
pragma Import (Stdcall, glColor3ubv, "glColor3ubv");
pragma Import (Stdcall, glColor3uiv, "glColor3uiv");
pragma Import (Stdcall, glColor3usv, "glColor3usv");
pragma Import (Stdcall, glColor4bv, "glColor4bv");
pragma Import (Stdcall, glColor4dv, "glColor4dv");
pragma Import (Stdcall, glColor4fv, "glColor4fv");
pragma Import (Stdcall, glColor4iv, "glColor4iv");
pragma Import (Stdcall, glColor4sv, "glColor4sv");
pragma Import (Stdcall, glColor4ubv, "glColor4ubv");
pragma Import (Stdcall, glColor4uiv, "glColor4uiv");
pragma Import (Stdcall, glColor4usv, "glColor4usv");
pragma Import (Stdcall, glTexCoord1d, "glTexCoord1d");
pragma Import (Stdcall, glTexCoord1f, "glTexCoord1f");
pragma Import (Stdcall, glTexCoord1i, "glTexCoord1i");
pragma Import (Stdcall, glTexCoord1s, "glTexCoord1s");
pragma Import (Stdcall, glTexCoord2d, "glTexCoord2d");
pragma Import (Stdcall, glTexCoord2f, "glTexCoord2f");
pragma Import (Stdcall, glTexCoord2i, "glTexCoord2i");
pragma Import (Stdcall, glTexCoord2s, "glTexCoord2s");
pragma Import (Stdcall, glTexCoord3d, "glTexCoord3d");
pragma Import (Stdcall, glTexCoord3f, "glTexCoord3f");
pragma Import (Stdcall, glTexCoord3i, "glTexCoord3i");
pragma Import (Stdcall, glTexCoord3s, "glTexCoord3s");
pragma Import (Stdcall, glTexCoord4d, "glTexCoord4d");
pragma Import (Stdcall, glTexCoord4f, "glTexCoord4f");
pragma Import (Stdcall, glTexCoord4i, "glTexCoord4i");
pragma Import (Stdcall, glTexCoord4s, "glTexCoord4s");
pragma Import (Stdcall, glTexCoord1dv, "glTexCoord1dv");
pragma Import (Stdcall, glTexCoord1fv, "glTexCoord1fv");
pragma Import (Stdcall, glTexCoord1iv, "glTexCoord1iv");
pragma Import (Stdcall, glTexCoord1sv, "glTexCoord1sv");
pragma Import (Stdcall, glTexCoord2dv, "glTexCoord2dv");
pragma Import (Stdcall, glTexCoord2fv, "glTexCoord2fv");
pragma Import (Stdcall, glTexCoord2iv, "glTexCoord2iv");
pragma Import (Stdcall, glTexCoord2sv, "glTexCoord2sv");
pragma Import (Stdcall, glTexCoord3dv, "glTexCoord3dv");
pragma Import (Stdcall, glTexCoord3fv, "glTexCoord3fv");
pragma Import (Stdcall, glTexCoord3iv, "glTexCoord3iv");
pragma Import (Stdcall, glTexCoord3sv, "glTexCoord3sv");
pragma Import (Stdcall, glTexCoord4dv, "glTexCoord4dv");
pragma Import (Stdcall, glTexCoord4fv, "glTexCoord4fv");
pragma Import (Stdcall, glTexCoord4iv, "glTexCoord4iv");
pragma Import (Stdcall, glTexCoord4sv, "glTexCoord4sv");
pragma Import (Stdcall, glRasterPos2d, "glRasterPos2d");
pragma Import (Stdcall, glRasterPos2f, "glRasterPos2f");
pragma Import (Stdcall, glRasterPos2i, "glRasterPos2i");
pragma Import (Stdcall, glRasterPos2s, "glRasterPos2s");
pragma Import (Stdcall, glRasterPos3d, "glRasterPos3d");
pragma Import (Stdcall, glRasterPos3f, "glRasterPos3f");
pragma Import (Stdcall, glRasterPos3i, "glRasterPos3i");
pragma Import (Stdcall, glRasterPos3s, "glRasterPos3s");
pragma Import (Stdcall, glRasterPos4d, "glRasterPos4d");
pragma Import (Stdcall, glRasterPos4f, "glRasterPos4f");
pragma Import (Stdcall, glRasterPos4i, "glRasterPos4i");
pragma Import (Stdcall, glRasterPos4s, "glRasterPos4s");
pragma Import (Stdcall, glRasterPos2dv, "glRasterPos2dv");
pragma Import (Stdcall, glRasterPos2fv, "glRasterPos2fv");
pragma Import (Stdcall, glRasterPos2iv, "glRasterPos2iv");
pragma Import (Stdcall, glRasterPos2sv, "glRasterPos2sv");
pragma Import (Stdcall, glRasterPos3dv, "glRasterPos3dv");
pragma Import (Stdcall, glRasterPos3fv, "glRasterPos3fv");
pragma Import (Stdcall, glRasterPos3iv, "glRasterPos3iv");
pragma Import (Stdcall, glRasterPos3sv, "glRasterPos3sv");
pragma Import (Stdcall, glRasterPos4dv, "glRasterPos4dv");
pragma Import (Stdcall, glRasterPos4fv, "glRasterPos4fv");
pragma Import (Stdcall, glRasterPos4iv, "glRasterPos4iv");
pragma Import (Stdcall, glRasterPos4sv, "glRasterPos4sv");
pragma Import (Stdcall, glRectd, "glRectd");
pragma Import (Stdcall, glRectf, "glRectf");
pragma Import (Stdcall, glRecti, "glRecti");
pragma Import (Stdcall, glRects, "glRects");
pragma Import (Stdcall, glRectdv, "glRectdv");
pragma Import (Stdcall, glRectfv, "glRectfv");
pragma Import (Stdcall, glRectiv, "glRectiv");
pragma Import (Stdcall, glRectsv, "glRectsv");
pragma Import (Stdcall, glShadeModel, "glShadeModel");
pragma Import (Stdcall, glLightf, "glLightf");
pragma Import (Stdcall, glLighti, "glLighti");
pragma Import (Stdcall, glLightfv, "glLightfv");
pragma Import (Stdcall, glLightiv, "glLightiv");
pragma Import (Stdcall, glGetLightfv, "glGetLightfv");
pragma Import (Stdcall, glGetLightiv, "glGetLightiv");
pragma Import (Stdcall, glLightModelf, "glLightModelf");
pragma Import (Stdcall, glLightModeli, "glLightModeli");
pragma Import (Stdcall, glLightModelfv, "glLightModelfv");
pragma Import (Stdcall, glLightModeliv, "glLightModeliv");
pragma Import (Stdcall, glMaterialf, "glMaterialf");
pragma Import (Stdcall, glMateriali, "glMateriali");
pragma Import (Stdcall, glMaterialfv, "glMaterialfv");
pragma Import (Stdcall, glMaterialiv, "glMaterialiv");
pragma Import (Stdcall, glGetMaterialfv, "glGetMaterialfv");
pragma Import (Stdcall, glGetMaterialiv, "glGetMaterialiv");
pragma Import (Stdcall, glColorMaterial, "glColorMaterial");
pragma Import (Stdcall, glPixelZoom, "glPixelZoom");
pragma Import (Stdcall, glPixelStoref, "glPixelStoref");
pragma Import (Stdcall, glPixelStorei, "glPixelStorei");
pragma Import (Stdcall, glPixelTransferf, "glPixelTransferf");
pragma Import (Stdcall, glPixelTransferi, "glPixelTransferi");
pragma Import (Stdcall, glPixelMapfv, "glPixelMapfv");
pragma Import (Stdcall, glPixelMapuiv, "glPixelMapuiv");
pragma Import (Stdcall, glPixelMapusv, "glPixelMapusv");
pragma Import (Stdcall, glGetPixelMapfv, "glGetPixelMapfv");
pragma Import (Stdcall, glGetPixelMapuiv, "glGetPixelMapuiv");
pragma Import (Stdcall, glGetPixelMapusv, "glGetPixelMapusv");
pragma Import (Stdcall, glBitmap, "glBitmap");
pragma Import (Stdcall, glReadPixels, "glReadPixels");
pragma Import (Stdcall, glDrawPixels, "glDrawPixels");
pragma Import (Stdcall, glCopyPixels, "glCopyPixels");
pragma Import (Stdcall, glStencilFunc, "glStencilFunc");
pragma Import (Stdcall, glStencilMask, "glStencilMask");
pragma Import (Stdcall, glStencilOp, "glStencilOp");
pragma Import (Stdcall, glClearStencil, "glClearStencil");
pragma Import (Stdcall, glTexGend, "glTexGend");
pragma Import (Stdcall, glTexGenf, "glTexGenf");
pragma Import (Stdcall, glTexGeni, "glTexGeni");
pragma Import (Stdcall, glTexGendv, "glTexGendv");
pragma Import (Stdcall, glTexGenfv, "glTexGenfv");
pragma Import (Stdcall, glTexGeniv, "glTexGeniv");
pragma Import (Stdcall, glGetTexGendv, "glGetTexGendv");
pragma Import (Stdcall, glGetTexGenfv, "glGetTexGenfv");
pragma Import (Stdcall, glGetTexGeniv, "glGetTexGeniv");
pragma Import (Stdcall, glTexEnvf, "glTexEnvf");
pragma Import (Stdcall, glTexEnvi, "glTexEnvi");
pragma Import (Stdcall, glTexEnvfv, "glTexEnvfv");
pragma Import (Stdcall, glTexEnviv, "glTexEnviv");
pragma Import (Stdcall, glGetTexEnvfv, "glGetTexEnvfv");
pragma Import (Stdcall, glGetTexEnviv, "glGetTexEnviv");
pragma Import (Stdcall, glTexParameterf, "glTexParameterf");
pragma Import (Stdcall, glTexParameteri, "glTexParameteri");
pragma Import (Stdcall, glTexParameterfv, "glTexParameterfv");
pragma Import (Stdcall, glTexParameteriv, "glTexParameteriv");
pragma Import (Stdcall, glGetTexParameterfv, "glGetTexParameterfv");
pragma Import (Stdcall, glGetTexParameteriv, "glGetTexParameteriv");
pragma Import (Stdcall, glGetTexLevelParameterfv, "glGetTexLevelParameterfv");
pragma Import (Stdcall, glGetTexLevelParameteriv, "glGetTexLevelParameteriv");
pragma Import (Stdcall, glTexImage1D, "glTexImage1D");
pragma Import (Stdcall, glTexImage2D, "glTexImage2D");
pragma Import (Stdcall, glGetTexImage, "glGetTexImage");
pragma Import (Stdcall, glMap1d, "glMap1d");
pragma Import (Stdcall, glMap1f, "glMap1f");
pragma Import (Stdcall, glMap2d, "glMap2d");
pragma Import (Stdcall, glMap2f, "glMap2f");
pragma Import (Stdcall, glGetMapdv, "glGetMapdv");
pragma Import (Stdcall, glGetMapfv, "glGetMapfv");
pragma Import (Stdcall, glGetMapiv, "glGetMapiv");
pragma Import (Stdcall, glEvalCoord1d, "glEvalCoord1d");
pragma Import (Stdcall, glEvalCoord1f, "glEvalCoord1f");
pragma Import (Stdcall, glEvalCoord1dv, "glEvalCoord1dv");
pragma Import (Stdcall, glEvalCoord1fv, "glEvalCoord1fv");
pragma Import (Stdcall, glEvalCoord2d, "glEvalCoord2d");
pragma Import (Stdcall, glEvalCoord2f, "glEvalCoord2f");
pragma Import (Stdcall, glEvalCoord2dv, "glEvalCoord2dv");
pragma Import (Stdcall, glEvalCoord2fv, "glEvalCoord2fv");
pragma Import (Stdcall, glMapGrid1d, "glMapGrid1d");
pragma Import (Stdcall, glMapGrid1f, "glMapGrid1f");
pragma Import (Stdcall, glMapGrid2d, "glMapGrid2d");
pragma Import (Stdcall, glMapGrid2f, "glMapGrid2f");
pragma Import (Stdcall, glEvalPoint1, "glEvalPoint1");
pragma Import (Stdcall, glEvalPoint2, "glEvalPoint2");
pragma Import (Stdcall, glEvalMesh1, "glEvalMesh1");
pragma Import (Stdcall, glEvalMesh2, "glEvalMesh2");
pragma Import (Stdcall, glFogf, "glFogf");
pragma Import (Stdcall, glFogi, "glFogi");
pragma Import (Stdcall, glFogfv, "glFogfv");
pragma Import (Stdcall, glFogiv, "glFogiv");
pragma Import (Stdcall, glFeedbackBuffer, "glFeedbackBuffer");
pragma Import (Stdcall, glPassThrough, "glPassThrough");
pragma Import (Stdcall, glSelectBuffer, "glSelectBuffer");
pragma Import (Stdcall, glInitNames, "glInitNames");
pragma Import (Stdcall, glLoadName, "glLoadName");
pragma Import (Stdcall, glPushName, "glPushName");
pragma Import (Stdcall, glPopName, "glPopName");
pragma Import (Stdcall, glGenTextures, "glGenTextures");
pragma Import (Stdcall, glDeleteTextures, "glDeleteTextures");
pragma Import (Stdcall, glBindTexture, "glBindTexture");
pragma Import (Stdcall, glPrioritizeTextures, "glPrioritizeTextures");
pragma Import (Stdcall, glAreTexturesResident, "glAreTexturesResident");
pragma Import (Stdcall, glIsTexture, "glIsTexture");
pragma Import (Stdcall, glTexSubImage1D, "glTexSubImage1D");
pragma Import (Stdcall, glTexSubImage2D, "glTexSubImage2D");
pragma Import (Stdcall, glCopyTexImage1D, "glCopyTexImage1D");
pragma Import (Stdcall, glCopyTexImage2D, "glCopyTexImage2D");
pragma Import (Stdcall, glCopyTexSubImage1D, "glCopyTexSubImage1D");
pragma Import (Stdcall, glCopyTexSubImage2D, "glCopyTexSubImage2D");
pragma Import (Stdcall, glVertexPointer, "glVertexPointer");
pragma Import (Stdcall, glNormalPointer, "glNormalPointer");
pragma Import (Stdcall, glColorPointer, "glColorPointer");
pragma Import (Stdcall, glIndexPointer, "glIndexPointer");
pragma Import (Stdcall, glTexCoordPointer, "glTexCoordPointer");
pragma Import (Stdcall, glEdgeFlagPointer, "glEdgeFlagPointer");
pragma Import (Stdcall, glGetPointerv, "glGetPointerv");
pragma Import (Stdcall, glArrayElement, "glArrayElement");
pragma Import (Stdcall, glDrawArrays, "glDrawArrays");
pragma Import (Stdcall, glDrawElements, "glDrawElements");
pragma Import (Stdcall, glInterleavedArrays, "glInterleavedArrays");
pragma Import (Stdcall, glDrawRangeElements, "glDrawRangeElements");
pragma Import (Stdcall, glTexImage3D, "glTexImage3D");
pragma Import (Stdcall, glTexSubImage3D, "glTexSubImage3D");
pragma Import (Stdcall, glCopyTexSubImage3D, "glCopyTexSubImage3D");
pragma Import (Stdcall, glColorTable, "glColorTable");
pragma Import (Stdcall, glColorSubTable, "glColorSubTable");
pragma Import (Stdcall, glColorTableParameteriv, "glColorTableParameteriv");
pragma Import (Stdcall, glColorTableParameterfv, "glColorTableParameterfv");
pragma Import (Stdcall, glCopyColorSubTable, "glCopyColorSubTable");
pragma Import (Stdcall, glCopyColorTable, "glCopyColorTable");
pragma Import (Stdcall, glGetColorTable, "glGetColorTable");
pragma Import (Stdcall, glGetColorTableParameterfv, "glGetColorTableParameterfv");
pragma Import (Stdcall, glGetColorTableParameteriv, "glGetColorTableParameteriv");
pragma Import (Stdcall, glBlendEquation, "glBlendEquation");
pragma Import (Stdcall, glBlendColor, "glBlendColor");
pragma Import (Stdcall, glHistogram, "glHistogram");
pragma Import (Stdcall, glResetHistogram, "glResetHistogram");
pragma Import (Stdcall, glGetHistogram, "glGetHistogram");
pragma Import (Stdcall, glGetHistogramParameterfv, "glGetHistogramParameterfv");
pragma Import (Stdcall, glGetHistogramParameteriv, "glGetHistogramParameteriv");
pragma Import (Stdcall, glMinmax, "glMinmax");
pragma Import (Stdcall, glResetMinmax, "glResetMinmax");
pragma Import (Stdcall, glGetMinmax, "glGetMinmax");
pragma Import (Stdcall, glGetMinmaxParameterfv, "glGetMinmaxParameterfv");
pragma Import (Stdcall, glGetMinmaxParameteriv, "glGetMinmaxParameteriv");
pragma Import (Stdcall, glConvolutionFilter1D, "glConvolutionFilter1D");
pragma Import (Stdcall, glConvolutionFilter2D, "glConvolutionFilter2D");
pragma Import (Stdcall, glConvolutionParameterf, "glConvolutionParameterf");
pragma Import (Stdcall, glConvolutionParameterfv, "glConvolutionParameterfv");
pragma Import (Stdcall, glConvolutionParameteri, "glConvolutionParameteri");
pragma Import (Stdcall, glConvolutionParameteriv, "glConvolutionParameteriv");
pragma Import (Stdcall, glCopyConvolutionFilter1D, "glCopyConvolutionFilter1D");
pragma Import (Stdcall, glCopyConvolutionFilter2D, "glCopyConvolutionFilter2D");
pragma Import (Stdcall, glGetConvolutionFilter, "glGetConvolutionFilter");
pragma Import (Stdcall, glGetConvolutionParameterfv, "glGetConvolutionParameterfv");
pragma Import (Stdcall, glGetConvolutionParameteriv, "glGetConvolutionParameteriv");
pragma Import (Stdcall, glSeparableFilter2D, "glSeparableFilter2D");
pragma Import (Stdcall, glGetSeparableFilter, "glGetSeparableFilter");
pragma Import (Stdcall, glActiveTexture, "glActiveTexture");
pragma Import (Stdcall, glClientActiveTexture, "glClientActiveTexture");
pragma Import (Stdcall, glCompressedTexImage1D, "glCompressedTexImage1D");
pragma Import (Stdcall, glCompressedTexImage2D, "glCompressedTexImage2D");
pragma Import (Stdcall, glCompressedTexImage3D, "glCompressedTexImage3D");
pragma Import (Stdcall, glCompressedTexSubImage1D, "glCompressedTexSubImage1D");
pragma Import (Stdcall, glCompressedTexSubImage2D, "glCompressedTexSubImage2D");
pragma Import (Stdcall, glCompressedTexSubImage3D, "glCompressedTexSubImage3D");
pragma Import (Stdcall, glGetCompressedTexImage, "glGetCompressedTexImage");
pragma Import (Stdcall, glMultiTexCoord1d, "glMultiTexCoord1d");
pragma Import (Stdcall, glMultiTexCoord1dv, "glMultiTexCoord1dv");
pragma Import (Stdcall, glMultiTexCoord1f, "glMultiTexCoord1f");
pragma Import (Stdcall, glMultiTexCoord1fv, "glMultiTexCoord1fv");
pragma Import (Stdcall, glMultiTexCoord1i, "glMultiTexCoord1i");
pragma Import (Stdcall, glMultiTexCoord1iv, "glMultiTexCoord1iv");
pragma Import (Stdcall, glMultiTexCoord1s, "glMultiTexCoord1s");
pragma Import (Stdcall, glMultiTexCoord1sv, "glMultiTexCoord1sv");
pragma Import (Stdcall, glMultiTexCoord2d, "glMultiTexCoord2d");
pragma Import (Stdcall, glMultiTexCoord2dv, "glMultiTexCoord2dv");
pragma Import (Stdcall, glMultiTexCoord2f, "glMultiTexCoord2f");
pragma Import (Stdcall, glMultiTexCoord2fv, "glMultiTexCoord2fv");
pragma Import (Stdcall, glMultiTexCoord2i, "glMultiTexCoord2i");
pragma Import (Stdcall, glMultiTexCoord2iv, "glMultiTexCoord2iv");
pragma Import (Stdcall, glMultiTexCoord2s, "glMultiTexCoord2s");
pragma Import (Stdcall, glMultiTexCoord2sv, "glMultiTexCoord2sv");
pragma Import (Stdcall, glMultiTexCoord3d, "glMultiTexCoord3d");
pragma Import (Stdcall, glMultiTexCoord3dv, "glMultiTexCoord3dv");
pragma Import (Stdcall, glMultiTexCoord3f, "glMultiTexCoord3f");
pragma Import (Stdcall, glMultiTexCoord3fv, "glMultiTexCoord3fv");
pragma Import (Stdcall, glMultiTexCoord3i, "glMultiTexCoord3i");
pragma Import (Stdcall, glMultiTexCoord3iv, "glMultiTexCoord3iv");
pragma Import (Stdcall, glMultiTexCoord3s, "glMultiTexCoord3s");
pragma Import (Stdcall, glMultiTexCoord3sv, "glMultiTexCoord3sv");
pragma Import (Stdcall, glMultiTexCoord4d, "glMultiTexCoord4d");
pragma Import (Stdcall, glMultiTexCoord4dv, "glMultiTexCoord4dv");
pragma Import (Stdcall, glMultiTexCoord4f, "glMultiTexCoord4f");
pragma Import (Stdcall, glMultiTexCoord4fv, "glMultiTexCoord4fv");
pragma Import (Stdcall, glMultiTexCoord4i, "glMultiTexCoord4i");
pragma Import (Stdcall, glMultiTexCoord4iv, "glMultiTexCoord4iv");
pragma Import (Stdcall, glMultiTexCoord4s, "glMultiTexCoord4s");
pragma Import (Stdcall, glMultiTexCoord4sv, "glMultiTexCoord4sv");
pragma Import (Stdcall, glLoadTransposeMatrixd, "glLoadTransposeMatrixd");
pragma Import (Stdcall, glLoadTransposeMatrixf, "glLoadTransposeMatrixf");
pragma Import (Stdcall, glMultTransposeMatrixd, "glMultTransposeMatrixd");
pragma Import (Stdcall, glMultTransposeMatrixf, "glMultTransposeMatrixf");
pragma Import (Stdcall, glSampleCoverage, "glSampleCoverage");
pragma Import (Stdcall, glSamplePass, "glSamplePass");
end Sf.Window.GL;
| 14328 | -- ////////////////////////////////////////////////////////////
-- //
-- // SFML - Simple and Fast Multimedia Library
-- // Copyright (C) 2007-2009 <NAME> (<EMAIL>)
-- //
-- // This software is provided 'as-is', without any express or implied warranty.
-- // In no event will the authors be held liable for any damages arising from the use of this software.
-- //
-- // Permission is granted to anyone to use this software for any purpose,
-- // including commercial applications, and to alter it and redistribute it freely,
-- // subject to the following restrictions:
-- //
-- // 1. The origin of this software must not be misrepresented;
-- // you must not claim that you wrote the original software.
-- // If you use this software in a product, an acknowledgment
-- // in the product documentation would be appreciated but is not required.
-- //
-- // 2. Altered source versions must be plainly marked as such,
-- // and must not be misrepresented as being the original software.
-- //
-- // 3. This notice may not be removed or altered from any source distribution.
-- //
-- ////////////////////////////////////////////////////////////
package Sf.Window.GL is
-- ////////////////////////////////////////////////////////////
-- // Define portable types
-- ////////////////////////////////////////////////////////////
type GLuint is mod 2 ** Integer'SIZE;
type GLuint_Ptr is access all GLuint;
type GLenum is mod 2 ** Integer'SIZE;
type GLbitfield is mod 2 ** Integer'SIZE;
type GLboolean is mod 256;
for GLboolean'SIZE use 8;
type GLvoid is null record;
type GLvoid_Ptr is access all GLvoid;
type GLbyte is range -128 .. 127;
for GLbyte'SIZE use 8;
type GLshort is new Short_Integer;
type GLint is new Integer;
type GLubyte is mod 256;
for GLubyte'SIZE use 8;
type GLubyte_Ptr is access all GLubyte;
type GLushort is mod 2 ** Short_Integer'SIZE;
type GLsizei is new Integer;
type GLfloat is new Float;
type GLclampf is new Float;
type GLdouble is new Long_Float;
type GLclampd is new Long_Float;
pragma Convention (C, GLuint);
pragma Convention (C, GLuint_Ptr);
pragma Convention (C, GLenum);
pragma Convention (C, GLbitfield);
pragma Convention (C, GLboolean);
pragma Convention (C, GLvoid);
pragma Convention (C, GLvoid_Ptr);
pragma Convention (C, GLbyte);
pragma Convention (C, GLshort);
pragma Convention (C, GLint);
pragma Convention (C, GLubyte);
pragma Convention (C, GLubyte_Ptr);
pragma Convention (C, GLushort);
pragma Convention (C, GLsizei);
pragma Convention (C, GLfloat);
pragma Convention (C, GLclampf);
pragma Convention (C, GLdouble);
pragma Convention (C, GLclampd);
-- ////////////////////////////////////////////////////////////
-- // Define constants
-- ////////////////////////////////////////////////////////////
GL_VERSION_1_1 : constant GLenum := 1;
GL_VERSION_1_2 : constant GLenum := 1;
GL_VERSION_1_3 : constant GLenum := 1;
GL_ARB_imaging : constant GLenum := 1;
GL_FALSE : constant GLboolean := 16#0#;
GL_TRUE : constant GLboolean := 16#1#;
GL_BYTE : constant GLenum := 16#1400#;
GL_UNSIGNED_BYTE : constant GLenum := 16#1401#;
GL_SHORT : constant GLenum := 16#1402#;
GL_UNSIGNED_SHORT : constant GLenum := 16#1403#;
GL_INT : constant GLenum := 16#1404#;
GL_UNSIGNED_INT : constant GLenum := 16#1405#;
GL_FLOAT : constant GLenum := 16#1406#;
GL_DOUBLE : constant GLenum := 16#140A#;
GL_2_BYTES : constant GLenum := 16#1407#;
GL_3_BYTES : constant GLenum := 16#1408#;
GL_4_BYTES : constant GLenum := 16#1409#;
GL_POINTS : constant GLenum := 16#0000#;
GL_LINES : constant GLenum := 16#0001#;
GL_LINE_LOOP : constant GLenum := 16#0002#;
GL_LINE_STRIP : constant GLenum := 16#0003#;
GL_TRIANGLES : constant GLenum := 16#0004#;
GL_TRIANGLE_STRIP : constant GLenum := 16#0005#;
GL_TRIANGLE_FAN : constant GLenum := 16#0006#;
GL_QUADS : constant GLenum := 16#0007#;
GL_QUAD_STRIP : constant GLenum := 16#0008#;
GL_POLYGON : constant GLenum := 16#0009#;
GL_VERTEX_ARRAY : constant GLenum := 16#8074#;
GL_NORMAL_ARRAY : constant GLenum := 16#8075#;
GL_COLOR_ARRAY : constant GLenum := 16#8076#;
GL_INDEX_ARRAY : constant GLenum := 16#8077#;
GL_TEXTURE_COORD_ARRAY : constant GLenum := 16#8078#;
GL_EDGE_FLAG_ARRAY : constant GLenum := 16#8079#;
GL_VERTEX_ARRAY_SIZE : constant GLenum := 16#807A#;
GL_VERTEX_ARRAY_TYPE : constant GLenum := 16#807B#;
GL_VERTEX_ARRAY_STRIDE : constant GLenum := 16#807C#;
GL_NORMAL_ARRAY_TYPE : constant GLenum := 16#807E#;
GL_NORMAL_ARRAY_STRIDE : constant GLenum := 16#807F#;
GL_COLOR_ARRAY_SIZE : constant GLenum := 16#8081#;
GL_COLOR_ARRAY_TYPE : constant GLenum := 16#8082#;
GL_COLOR_ARRAY_STRIDE : constant GLenum := 16#8083#;
GL_INDEX_ARRAY_TYPE : constant GLenum := 16#8085#;
GL_INDEX_ARRAY_STRIDE : constant GLenum := 16#8086#;
GL_TEXTURE_COORD_ARRAY_SIZE : constant GLenum := 16#8088#;
GL_TEXTURE_COORD_ARRAY_TYPE : constant GLenum := 16#8089#;
GL_TEXTURE_COORD_ARRAY_STRIDE : constant GLenum := 16#808A#;
GL_EDGE_FLAG_ARRAY_STRIDE : constant GLenum := 16#808C#;
GL_VERTEX_ARRAY_POINTER : constant GLenum := 16#808E#;
GL_NORMAL_ARRAY_POINTER : constant GLenum := 16#808F#;
GL_COLOR_ARRAY_POINTER : constant GLenum := 16#8090#;
GL_INDEX_ARRAY_POINTER : constant GLenum := 16#8091#;
GL_TEXTURE_COORD_ARRAY_POINTER : constant GLenum := 16#8092#;
GL_EDGE_FLAG_ARRAY_POINTER : constant GLenum := 16#8093#;
GL_V2F : constant GLenum := 16#2A20#;
GL_V3F : constant GLenum := 16#2A21#;
GL_C4UB_V2F : constant GLenum := 16#2A22#;
GL_C4UB_V3F : constant GLenum := 16#2A23#;
GL_C3F_V3F : constant GLenum := 16#2A24#;
GL_N3F_V3F : constant GLenum := 16#2A25#;
GL_C4F_N3F_V3F : constant GLenum := 16#2A26#;
GL_T2F_V3F : constant GLenum := 16#2A27#;
GL_T4F_V4F : constant GLenum := 16#2A28#;
GL_T2F_C4UB_V3F : constant GLenum := 16#2A29#;
GL_T2F_C3F_V3F : constant GLenum := 16#2A2A#;
GL_T2F_N3F_V3F : constant GLenum := 16#2A2B#;
GL_T2F_C4F_N3F_V3F : constant GLenum := 16#2A2C#;
GL_T4F_C4F_N3F_V4F : constant GLenum := 16#2A2D#;
GL_MATRIX_MODE : constant GLenum := 16#0BA0#;
GL_MODELVIEW : constant GLenum := 16#1700#;
GL_PROJECTION : constant GLenum := 16#1701#;
GL_TEXTURE : constant GLenum := 16#1702#;
GL_POINT_SMOOTH : constant GLenum := 16#0B10#;
GL_POINT_SIZE : constant GLenum := 16#0B11#;
GL_POINT_SIZE_GRANULARITY : constant GLenum := 16#0B13#;
GL_POINT_SIZE_RANGE : constant GLenum := 16#0B12#;
GL_LINE_SMOOTH : constant GLenum := 16#0B20#;
GL_LINE_STIPPLE : constant GLenum := 16#0B24#;
GL_LINE_STIPPLE_PATTERN : constant GLenum := 16#0B25#;
GL_LINE_STIPPLE_REPEAT : constant GLenum := 16#0B26#;
GL_LINE_WIDTH : constant GLenum := 16#0B21#;
GL_LINE_WIDTH_GRANULARITY : constant GLenum := 16#0B23#;
GL_LINE_WIDTH_RANGE : constant GLenum := 16#0B22#;
GL_POINT : constant GLenum := 16#1B00#;
GL_LINE : constant GLenum := 16#1B01#;
GL_FILL : constant GLenum := 16#1B02#;
GL_CW : constant GLenum := 16#0900#;
GL_CCW : constant GLenum := 16#0901#;
GL_FRONT : constant GLenum := 16#0404#;
GL_BACK : constant GLenum := 16#0405#;
GL_POLYGON_MODE : constant GLenum := 16#0B40#;
GL_POLYGON_SMOOTH : constant GLenum := 16#0B41#;
GL_POLYGON_STIPPLE : constant GLenum := 16#0B42#;
GL_EDGE_FLAG : constant GLenum := 16#0B43#;
GL_CULL_FACE : constant GLenum := 16#0B44#;
GL_CULL_FACE_MODE : constant GLenum := 16#0B45#;
GL_FRONT_FACE : constant GLenum := 16#0B46#;
GL_POLYGON_OFFSET_FACTOR : constant GLenum := 16#8038#;
GL_POLYGON_OFFSET_UNITS : constant GLenum := 16#2A00#;
GL_POLYGON_OFFSET_POINT : constant GLenum := 16#2A01#;
GL_POLYGON_OFFSET_LINE : constant GLenum := 16#2A02#;
GL_POLYGON_OFFSET_FILL : constant GLenum := 16#8037#;
GL_COMPILE : constant GLenum := 16#1300#;
GL_COMPILE_AND_EXECUTE : constant GLenum := 16#1301#;
GL_LIST_BASE : constant GLenum := 16#0B32#;
GL_LIST_INDEX : constant GLenum := 16#0B33#;
GL_LIST_MODE : constant GLenum := 16#0B30#;
GL_NEVER : constant GLenum := 16#0200#;
GL_LESS : constant GLenum := 16#0201#;
GL_EQUAL : constant GLenum := 16#0202#;
GL_LEQUAL : constant GLenum := 16#0203#;
GL_GREATER : constant GLenum := 16#0204#;
GL_NOTEQUAL : constant GLenum := 16#0205#;
GL_GEQUAL : constant GLenum := 16#0206#;
GL_ALWAYS : constant GLenum := 16#0207#;
GL_DEPTH_TEST : constant GLenum := 16#0B71#;
GL_DEPTH_BITS : constant GLenum := 16#0D56#;
GL_DEPTH_CLEAR_VALUE : constant GLenum := 16#0B73#;
GL_DEPTH_FUNC : constant GLenum := 16#0B74#;
GL_DEPTH_RANGE : constant GLenum := 16#0B70#;
GL_DEPTH_WRITEMASK : constant GLenum := 16#0B72#;
GL_DEPTH_COMPONENT : constant GLenum := 16#1902#;
GL_LIGHTING : constant GLenum := 16#0B50#;
GL_LIGHT0 : constant GLenum := 16#4000#;
GL_LIGHT1 : constant GLenum := 16#4001#;
GL_LIGHT2 : constant GLenum := 16#4002#;
GL_LIGHT3 : constant GLenum := 16#4003#;
GL_LIGHT4 : constant GLenum := 16#4004#;
GL_LIGHT5 : constant GLenum := 16#4005#;
GL_LIGHT6 : constant GLenum := 16#4006#;
GL_LIGHT7 : constant GLenum := 16#4007#;
GL_SPOT_EXPONENT : constant GLenum := 16#1205#;
GL_SPOT_CUTOFF : constant GLenum := 16#1206#;
GL_CONSTANT_ATTENUATION : constant GLenum := 16#1207#;
GL_LINEAR_ATTENUATION : constant GLenum := 16#1208#;
GL_QUADRATIC_ATTENUATION : constant GLenum := 16#1209#;
GL_AMBIENT : constant GLenum := 16#1200#;
GL_DIFFUSE : constant GLenum := 16#1201#;
GL_SPECULAR : constant GLenum := 16#1202#;
GL_SHININESS : constant GLenum := 16#1601#;
GL_EMISSION : constant GLenum := 16#1600#;
GL_POSITION : constant GLenum := 16#1203#;
GL_SPOT_DIRECTION : constant GLenum := 16#1204#;
GL_AMBIENT_AND_DIFFUSE : constant GLenum := 16#1602#;
GL_COLOR_INDEXES : constant GLenum := 16#1603#;
GL_LIGHT_MODEL_TWO_SIDE : constant GLenum := 16#0B52#;
GL_LIGHT_MODEL_LOCAL_VIEWER : constant GLenum := 16#0B51#;
GL_LIGHT_MODEL_AMBIENT : constant GLenum := 16#0B53#;
GL_FRONT_AND_BACK : constant GLenum := 16#0408#;
GL_SHADE_MODEL : constant GLenum := 16#0B54#;
GL_FLAT : constant GLenum := 16#1D00#;
GL_SMOOTH : constant GLenum := 16#1D01#;
GL_COLOR_MATERIAL : constant GLenum := 16#0B57#;
GL_COLOR_MATERIAL_FACE : constant GLenum := 16#0B55#;
GL_COLOR_MATERIAL_PARAMETER : constant GLenum := 16#0B56#;
GL_NORMALIZE : constant GLenum := 16#0BA1#;
GL_CLIP_PLANE0 : constant GLenum := 16#3000#;
GL_CLIP_PLANE1 : constant GLenum := 16#3001#;
GL_CLIP_PLANE2 : constant GLenum := 16#3002#;
GL_CLIP_PLANE3 : constant GLenum := 16#3003#;
GL_CLIP_PLANE4 : constant GLenum := 16#3004#;
GL_CLIP_PLANE5 : constant GLenum := 16#3005#;
GL_ACCUM_RED_BITS : constant GLenum := 16#0D58#;
GL_ACCUM_GREEN_BITS : constant GLenum := 16#0D59#;
GL_ACCUM_BLUE_BITS : constant GLenum := 16#0D5A#;
GL_ACCUM_ALPHA_BITS : constant GLenum := 16#0D5B#;
GL_ACCUM_CLEAR_VALUE : constant GLenum := 16#0B80#;
GL_ACCUM : constant GLenum := 16#0100#;
GL_ADD : constant GLenum := 16#0104#;
GL_LOAD : constant GLenum := 16#0101#;
GL_MULT : constant GLenum := 16#0103#;
GL_RETURN : constant GLenum := 16#0102#;
GL_ALPHA_TEST : constant GLenum := 16#0BC0#;
GL_ALPHA_TEST_REF : constant GLenum := 16#0BC2#;
GL_ALPHA_TEST_FUNC : constant GLenum := 16#0BC1#;
GL_BLEND : constant GLenum := 16#0BE2#;
GL_BLEND_SRC : constant GLenum := 16#0BE1#;
GL_BLEND_DST : constant GLenum := 16#0BE0#;
GL_ZERO : constant GLenum := 16#0#;
GL_ONE : constant GLenum := 16#1#;
GL_SRC_COLOR : constant GLenum := 16#0300#;
GL_ONE_MINUS_SRC_COLOR : constant GLenum := 16#0301#;
GL_SRC_ALPHA : constant GLenum := 16#0302#;
GL_ONE_MINUS_SRC_ALPHA : constant GLenum := 16#0303#;
GL_DST_ALPHA : constant GLenum := 16#0304#;
GL_ONE_MINUS_DST_ALPHA : constant GLenum := 16#0305#;
GL_DST_COLOR : constant GLenum := 16#0306#;
GL_ONE_MINUS_DST_COLOR : constant GLenum := 16#0307#;
GL_SRC_ALPHA_SATURATE : constant GLenum := 16#0308#;
GL_CONSTANT_COLOR : constant GLenum := 16#8001#;
GL_ONE_MINUS_CONSTANT_COLOR : constant GLenum := 16#8002#;
GL_CONSTANT_ALPHA : constant GLenum := 16#8003#;
GL_ONE_MINUS_CONSTANT_ALPHA : constant GLenum := 16#8004#;
GL_FEEDBACK : constant GLenum := 16#1C01#;
GL_RENDER : constant GLenum := 16#1C00#;
GL_SELECT : constant GLenum := 16#1C02#;
GL_2D : constant GLenum := 16#0600#;
GL_3D : constant GLenum := 16#0601#;
GL_3D_COLOR : constant GLenum := 16#0602#;
GL_3D_COLOR_TEXTURE : constant GLenum := 16#0603#;
GL_4D_COLOR_TEXTURE : constant GLenum := 16#0604#;
GL_POINT_TOKEN : constant GLenum := 16#0701#;
GL_LINE_TOKEN : constant GLenum := 16#0<PASSWORD>2#;
GL_LINE_RESET_TOKEN : constant GLenum := 16#0707#;
GL_POLYGON_TOKEN : constant GLenum := 16#0703#;
GL_BITMAP_TOKEN : constant GLenum := 16#0704#;
GL_DRAW_PIXEL_TOKEN : constant GLenum := 16#0705#;
GL_COPY_PIXEL_TOKEN : constant GLenum := 16#0706#;
GL_PASS_THROUGH_TOKEN : constant GLenum := 16#0700#;
GL_FEEDBACK_BUFFER_POINTER : constant GLenum := 16#0DF0#;
GL_FEEDBACK_BUFFER_SIZE : constant GLenum := 16#0DF1#;
GL_FEEDBACK_BUFFER_TYPE : constant GLenum := 16#0DF2#;
GL_SELECTION_BUFFER_POINTER : constant GLenum := 16#0DF3#;
GL_SELECTION_BUFFER_SIZE : constant GLenum := 16#0DF4#;
GL_FOG : constant GLenum := 16#0B60#;
GL_FOG_MODE : constant GLenum := 16#0B65#;
GL_FOG_DENSITY : constant GLenum := 16#0B62#;
GL_FOG_COLOR : constant GLenum := 16#0B66#;
GL_FOG_INDEX : constant GLenum := 16#0B61#;
GL_FOG_START : constant GLenum := 16#0B63#;
GL_FOG_END : constant GLenum := 16#0B64#;
GL_LINEAR : constant GLenum := 16#2601#;
GL_EXP : constant GLenum := 16#0800#;
GL_EXP2 : constant GLenum := 16#0801#;
GL_LOGIC_OP : constant GLenum := 16#0BF1#;
GL_INDEX_LOGIC_OP : constant GLenum := 16#0BF1#;
GL_COLOR_LOGIC_OP : constant GLenum := 16#0BF2#;
GL_LOGIC_OP_MODE : constant GLenum := 16#0BF0#;
GL_CLEAR : constant GLenum := 16#1500#;
GL_SET : constant GLenum := 16#150F#;
GL_COPY : constant GLenum := 16#1503#;
GL_COPY_INVERTED : constant GLenum := 16#150C#;
GL_NOOP : constant GLenum := 16#1505#;
GL_INVERT : constant GLenum := 16#150A#;
GL_AND : constant GLenum := 16#1501#;
GL_NAND : constant GLenum := 16#150E#;
GL_OR : constant GLenum := 16#1507#;
GL_NOR : constant GLenum := 16#1508#;
GL_XOR : constant GLenum := 16#1506#;
GL_EQUIV : constant GLenum := 16#1509#;
GL_AND_REVERSE : constant GLenum := 16#1502#;
GL_AND_INVERTED : constant GLenum := 16#1504#;
GL_OR_REVERSE : constant GLenum := 16#150B#;
GL_OR_INVERTED : constant GLenum := 16#150D#;
GL_STENCIL_TEST : constant GLenum := 16#0B90#;
GL_STENCIL_WRITEMASK : constant GLenum := 16#0B98#;
GL_STENCIL_BITS : constant GLenum := 16#0D57#;
GL_STENCIL_FUNC : constant GLenum := 16#0B92#;
GL_STENCIL_VALUE_MASK : constant GLenum := 16#0B93#;
GL_STENCIL_REF : constant GLenum := 16#0B97#;
GL_STENCIL_FAIL : constant GLenum := 16#0B94#;
GL_STENCIL_PASS_DEPTH_PASS : constant GLenum := 16#0B96#;
GL_STENCIL_PASS_DEPTH_FAIL : constant GLenum := 16#0B95#;
GL_STENCIL_CLEAR_VALUE : constant GLenum := 16#0B91#;
GL_STENCIL_INDEX : constant GLenum := 16#1901#;
GL_KEEP : constant GLenum := 16#1E00#;
GL_REPLACE : constant GLenum := 16#1E01#;
GL_INCR : constant GLenum := 16#1E02#;
GL_DECR : constant GLenum := 16#1E03#;
GL_NONE : constant GLenum := 16#0#;
GL_LEFT : constant GLenum := 16#0406#;
GL_RIGHT : constant GLenum := 16#0407#;
GL_FRONT_LEFT : constant GLenum := 16#0400#;
GL_FRONT_RIGHT : constant GLenum := 16#0401#;
GL_BACK_LEFT : constant GLenum := 16#0402#;
GL_BACK_RIGHT : constant GLenum := 16#0403#;
GL_AUX0 : constant GLenum := 16#0409#;
GL_AUX1 : constant GLenum := 16#040A#;
GL_AUX2 : constant GLenum := 16#040B#;
GL_AUX3 : constant GLenum := 16#040C#;
GL_COLOR_INDEX : constant GLenum := 16#1900#;
GL_RED : constant GLenum := 16#1903#;
GL_GREEN : constant GLenum := 16#1904#;
GL_BLUE : constant GLenum := 16#1905#;
GL_ALPHA : constant GLenum := 16#1906#;
GL_LUMINANCE : constant GLenum := 16#1909#;
GL_LUMINANCE_ALPHA : constant GLenum := 16#190A#;
GL_ALPHA_BITS : constant GLenum := 16#0D55#;
GL_RED_BITS : constant GLenum := 16#0D52#;
GL_GREEN_BITS : constant GLenum := 16#0D53#;
GL_BLUE_BITS : constant GLenum := 16#0D54#;
GL_INDEX_BITS : constant GLenum := 16#0D51#;
GL_SUBPIXEL_BITS : constant GLenum := 16#0D50#;
GL_AUX_BUFFERS : constant GLenum := 16#0C00#;
GL_READ_BUFFER : constant GLenum := 16#0C02#;
GL_DRAW_BUFFER : constant GLenum := 16#0C01#;
GL_DOUBLEBUFFER : constant GLenum := 16#0C32#;
GL_STEREO : constant GLenum := 16#0C33#;
GL_BITMAP : constant GLenum := 16#1A00#;
GL_COLOR : constant GLenum := 16#1800#;
GL_DEPTH : constant GLenum := 16#1801#;
GL_STENCIL : constant GLenum := 16#1802#;
GL_DITHER : constant GLenum := 16#0BD0#;
GL_RGB : constant GLenum := 16#1907#;
GL_RGBA : constant GLenum := 16#1908#;
GL_MAX_LIST_NESTING : constant GLenum := 16#0B31#;
GL_MAX_ATTRIB_STACK_DEPTH : constant GLenum := 16#0D35#;
GL_MAX_MODELVIEW_STACK_DEPTH : constant GLenum := 16#0D36#;
GL_MAX_NAME_STACK_DEPTH : constant GLenum := 16#0D37#;
GL_MAX_PROJECTION_STACK_DEPTH : constant GLenum := 16#0D38#;
GL_MAX_TEXTURE_STACK_DEPTH : constant GLenum := 16#0D39#;
GL_MAX_EVAL_ORDER : constant GLenum := 16#0D30#;
GL_MAX_LIGHTS : constant GLenum := 16#0D31#;
GL_MAX_CLIP_PLANES : constant GLenum := 16#0D32#;
GL_MAX_TEXTURE_SIZE : constant GLenum := 16#0D33#;
GL_MAX_PIXEL_MAP_TABLE : constant GLenum := 16#0D34#;
GL_MAX_VIEWPORT_DIMS : constant GLenum := 16#0D3A#;
GL_MAX_CLIENT_ATTRIB_STACK_DEPTH : constant GLenum := 16#0D3B#;
GL_ATTRIB_STACK_DEPTH : constant GLenum := 16#0BB0#;
GL_CLIENT_ATTRIB_STACK_DEPTH : constant GLenum := 16#0BB1#;
GL_COLOR_CLEAR_VALUE : constant GLenum := 16#0C22#;
GL_COLOR_WRITEMASK : constant GLenum := 16#0C23#;
GL_CURRENT_INDEX : constant GLenum := 16#0B01#;
GL_CURRENT_COLOR : constant GLenum := 16#0B00#;
GL_CURRENT_NORMAL : constant GLenum := 16#0B02#;
GL_CURRENT_RASTER_COLOR : constant GLenum := 16#0B04#;
GL_CURRENT_RASTER_DISTANCE : constant GLenum := 16#0B09#;
GL_CURRENT_RASTER_INDEX : constant GLenum := 16#0B05#;
GL_CURRENT_RASTER_POSITION : constant GLenum := 16#0B07#;
GL_CURRENT_RASTER_TEXTURE_COORDS : constant GLenum := 16#0B06#;
GL_CURRENT_RASTER_POSITION_VALID : constant GLenum := 16#0B08#;
GL_CURRENT_TEXTURE_COORDS : constant GLenum := 16#0B03#;
GL_INDEX_CLEAR_VALUE : constant GLenum := 16#0C20#;
GL_INDEX_MODE : constant GLenum := 16#0C30#;
GL_INDEX_WRITEMASK : constant GLenum := 16#0C21#;
GL_MODELVIEW_MATRIX : constant GLenum := 16#0BA6#;
GL_MODELVIEW_STACK_DEPTH : constant GLenum := 16#0BA3#;
GL_NAME_STACK_DEPTH : constant GLenum := 16#0D70#;
GL_PROJECTION_MATRIX : constant GLenum := 16#0BA7#;
GL_PROJECTION_STACK_DEPTH : constant GLenum := 16#0BA4#;
GL_RENDER_MODE : constant GLenum := 16#0C40#;
GL_RGBA_MODE : constant GLenum := 16#0C31#;
GL_TEXTURE_MATRIX : constant GLenum := 16#0BA8#;
GL_TEXTURE_STACK_DEPTH : constant GLenum := 16#0BA5#;
GL_VIEWPORT : constant GLenum := 16#0BA2#;
GL_AUTO_NORMAL : constant GLenum := 16#0D80#;
GL_MAP1_COLOR_4 : constant GLenum := 16#0D90#;
GL_MAP1_GRID_DOMAIN : constant GLenum := 16#0DD0#;
GL_MAP1_GRID_SEGMENTS : constant GLenum := 16#0DD1#;
GL_MAP1_INDEX : constant GLenum := 16#0D91#;
GL_MAP1_NORMAL : constant GLenum := 16#0D92#;
GL_MAP1_TEXTURE_COORD_1 : constant GLenum := 16#0D93#;
GL_MAP1_TEXTURE_COORD_2 : constant GLenum := 16#0D94#;
GL_MAP1_TEXTURE_COORD_3 : constant GLenum := 16#0D95#;
GL_MAP1_TEXTURE_COORD_4 : constant GLenum := 16#0D96#;
GL_MAP1_VERTEX_3 : constant GLenum := 16#0D97#;
GL_MAP1_VERTEX_4 : constant GLenum := 16#0D98#;
GL_MAP2_COLOR_4 : constant GLenum := 16#0DB0#;
GL_MAP2_GRID_DOMAIN : constant GLenum := 16#0DD2#;
GL_MAP2_GRID_SEGMENTS : constant GLenum := 16#0DD3#;
GL_MAP2_INDEX : constant GLenum := 16#0DB1#;
GL_MAP2_NORMAL : constant GLenum := 16#0DB2#;
GL_MAP2_TEXTURE_COORD_1 : constant GLenum := 16#0DB3#;
GL_MAP2_TEXTURE_COORD_2 : constant GLenum := 16#0DB4#;
GL_MAP2_TEXTURE_COORD_3 : constant GLenum := 16#0DB5#;
GL_MAP2_TEXTURE_COORD_4 : constant GLenum := 16#0DB6#;
GL_MAP2_VERTEX_3 : constant GLenum := 16#0DB7#;
GL_MAP2_VERTEX_4 : constant GLenum := 16#0DB8#;
GL_COEFF : constant GLenum := 16#0A00#;
GL_DOMAIN : constant GLenum := 16#0A02#;
GL_ORDER : constant GLenum := 16#0A01#;
GL_FOG_HINT : constant GLenum := 16#0C54#;
GL_LINE_SMOOTH_HINT : constant GLenum := 16#0C52#;
GL_PERSPECTIVE_CORRECTION_HINT : constant GLenum := 16#0C50#;
GL_POINT_SMOOTH_HINT : constant GLenum := 16#0C51#;
GL_POLYGON_SMOOTH_HINT : constant GLenum := 16#0C53#;
GL_DONT_CARE : constant GLenum := 16#1100#;
GL_FASTEST : constant GLenum := 16#1101#;
GL_NICEST : constant GLenum := 16#1102#;
GL_SCISSOR_TEST : constant GLenum := 16#0C11#;
GL_SCISSOR_BOX : constant GLenum := 16#0C10#;
GL_MAP_COLOR : constant GLenum := 16#0D10#;
GL_MAP_STENCIL : constant GLenum := 16#0D11#;
GL_INDEX_SHIFT : constant GLenum := 16#0D12#;
GL_INDEX_OFFSET : constant GLenum := 16#0D13#;
GL_RED_SCALE : constant GLenum := 16#0D14#;
GL_RED_BIAS : constant GLenum := 16#0D15#;
GL_GREEN_SCALE : constant GLenum := 16#0D18#;
GL_GREEN_BIAS : constant GLenum := 16#0D19#;
GL_BLUE_SCALE : constant GLenum := 16#0D1A#;
GL_BLUE_BIAS : constant GLenum := 16#0D1B#;
GL_ALPHA_SCALE : constant GLenum := 16#0D1C#;
GL_ALPHA_BIAS : constant GLenum := 16#0D1D#;
GL_DEPTH_SCALE : constant GLenum := 16#0D1E#;
GL_DEPTH_BIAS : constant GLenum := 16#0D1F#;
GL_PIXEL_MAP_S_TO_S_SIZE : constant GLenum := 16#0CB1#;
GL_PIXEL_MAP_I_TO_I_SIZE : constant GLenum := 16#0CB0#;
GL_PIXEL_MAP_I_TO_R_SIZE : constant GLenum := 16#0CB2#;
GL_PIXEL_MAP_I_TO_G_SIZE : constant GLenum := 16#0CB3#;
GL_PIXEL_MAP_I_TO_B_SIZE : constant GLenum := 16#0CB4#;
GL_PIXEL_MAP_I_TO_A_SIZE : constant GLenum := 16#0CB5#;
GL_PIXEL_MAP_R_TO_R_SIZE : constant GLenum := 16#0CB6#;
GL_PIXEL_MAP_G_TO_G_SIZE : constant GLenum := 16#0CB7#;
GL_PIXEL_MAP_B_TO_B_SIZE : constant GLenum := 16#0CB8#;
GL_PIXEL_MAP_A_TO_A_SIZE : constant GLenum := 16#0CB9#;
GL_PIXEL_MAP_S_TO_S : constant GLenum := 16#0C71#;
GL_PIXEL_MAP_I_TO_I : constant GLenum := 16#0C70#;
GL_PIXEL_MAP_I_TO_R : constant GLenum := 16#0C72#;
GL_PIXEL_MAP_I_TO_G : constant GLenum := 16#0C73#;
GL_PIXEL_MAP_I_TO_B : constant GLenum := 16#0C74#;
GL_PIXEL_MAP_I_TO_A : constant GLenum := 16#0C75#;
GL_PIXEL_MAP_R_TO_R : constant GLenum := 16#0C76#;
GL_PIXEL_MAP_G_TO_G : constant GLenum := 16#0C77#;
GL_PIXEL_MAP_B_TO_B : constant GLenum := 16#0C78#;
GL_PIXEL_MAP_A_TO_A : constant GLenum := 16#0C79#;
GL_PACK_ALIGNMENT : constant GLenum := 16#0D05#;
GL_PACK_LSB_FIRST : constant GLenum := 16#0D01#;
GL_PACK_ROW_LENGTH : constant GLenum := 16#0D02#;
GL_PACK_SKIP_PIXELS : constant GLenum := 16#0D04#;
GL_PACK_SKIP_ROWS : constant GLenum := 16#0D03#;
GL_PACK_SWAP_BYTES : constant GLenum := 16#0D00#;
GL_UNPACK_ALIGNMENT : constant GLenum := 16#0CF5#;
GL_UNPACK_LSB_FIRST : constant GLenum := 16#0CF1#;
GL_UNPACK_ROW_LENGTH : constant GLenum := 16#0CF2#;
GL_UNPACK_SKIP_PIXELS : constant GLenum := 16#0CF4#;
GL_UNPACK_SKIP_ROWS : constant GLenum := 16#0CF3#;
GL_UNPACK_SWAP_BYTES : constant GLenum := 16#0CF0#;
GL_ZOOM_X : constant GLenum := 16#0D16#;
GL_ZOOM_Y : constant GLenum := 16#0D17#;
GL_TEXTURE_ENV : constant GLenum := 16#2300#;
GL_TEXTURE_ENV_MODE : constant GLenum := 16#2200#;
GL_TEXTURE_1D : constant GLenum := 16#0DE0#;
GL_TEXTURE_2D : constant GLenum := 16#0DE1#;
GL_TEXTURE_WRAP_S : constant GLenum := 16#2802#;
GL_TEXTURE_WRAP_T : constant GLenum := 16#2803#;
GL_TEXTURE_MAG_FILTER : constant GLenum := 16#2800#;
GL_TEXTURE_MIN_FILTER : constant GLenum := 16#2801#;
GL_TEXTURE_ENV_COLOR : constant GLenum := 16#2201#;
GL_TEXTURE_GEN_S : constant GLenum := 16#0C60#;
GL_TEXTURE_GEN_T : constant GLenum := 16#0C61#;
GL_TEXTURE_GEN_MODE : constant GLenum := 16#2500#;
GL_TEXTURE_BORDER_COLOR : constant GLenum := 16#1004#;
GL_TEXTURE_WIDTH : constant GLenum := 16#1000#;
GL_TEXTURE_HEIGHT : constant GLenum := 16#1001#;
GL_TEXTURE_BORDER : constant GLenum := 16#1005#;
GL_TEXTURE_COMPONENTS : constant GLenum := 16#1003#;
GL_TEXTURE_RED_SIZE : constant GLenum := 16#805C#;
GL_TEXTURE_GREEN_SIZE : constant GLenum := 16#805D#;
GL_TEXTURE_BLUE_SIZE : constant GLenum := 16#805E#;
GL_TEXTURE_ALPHA_SIZE : constant GLenum := 16#805F#;
GL_TEXTURE_LUMINANCE_SIZE : constant GLenum := 16#8060#;
GL_TEXTURE_INTENSITY_SIZE : constant GLenum := 16#8061#;
GL_NEAREST_MIPMAP_NEAREST : constant GLenum := 16#2700#;
GL_NEAREST_MIPMAP_LINEAR : constant GLenum := 16#2702#;
GL_LINEAR_MIPMAP_NEAREST : constant GLenum := 16#2701#;
GL_LINEAR_MIPMAP_LINEAR : constant GLenum := 16#2703#;
GL_OBJECT_LINEAR : constant GLenum := 16#2401#;
GL_OBJECT_PLANE : constant GLenum := 16#2501#;
GL_EYE_LINEAR : constant GLenum := 16#2400#;
GL_EYE_PLANE : constant GLenum := 16#2502#;
GL_SPHERE_MAP : constant GLenum := 16#2402#;
GL_DECAL : constant GLenum := 16#2101#;
GL_MODULATE : constant GLenum := 16#2100#;
GL_NEAREST : constant GLenum := 16#2600#;
GL_REPEAT : constant GLenum := 16#2901#;
GL_CLAMP : constant GLenum := 16#2900#;
GL_S : constant GLenum := 16#2000#;
GL_T : constant GLenum := 16#2001#;
GL_R : constant GLenum := 16#2002#;
GL_Q : constant GLenum := 16#2003#;
GL_TEXTURE_GEN_R : constant GLenum := 16#0C62#;
GL_TEXTURE_GEN_Q : constant GLenum := 16#0C63#;
GL_VENDOR : constant GLenum := 16#1F00#;
GL_RENDERER : constant GLenum := 16#1F01#;
GL_VERSION : constant GLenum := 16#1F02#;
GL_EXTENSIONS : constant GLenum := 16#1F03#;
GL_NO_ERROR : constant GLenum := 16#0#;
GL_INVALID_VALUE : constant GLenum := 16#0501#;
GL_INVALID_ENUM : constant GLenum := 16#0500#;
GL_INVALID_OPERATION : constant GLenum := 16#0502#;
GL_STACK_OVERFLOW : constant GLenum := 16#0503#;
GL_STACK_UNDERFLOW : constant GLenum := 16#0504#;
GL_OUT_OF_MEMORY : constant GLenum := 16#0505#;
GL_CURRENT_BIT : constant GLenum := 16#00000001#;
GL_POINT_BIT : constant GLenum := 16#00000002#;
GL_LINE_BIT : constant GLenum := 16#00000004#;
GL_POLYGON_BIT : constant GLenum := 16#00000008#;
GL_POLYGON_STIPPLE_BIT : constant GLenum := 16#00000010#;
GL_PIXEL_MODE_BIT : constant GLenum := 16#00000020#;
GL_LIGHTING_BIT : constant GLenum := 16#00000040#;
GL_FOG_BIT : constant GLenum := 16#00000080#;
GL_DEPTH_BUFFER_BIT : constant GLenum := 16#00000100#;
GL_ACCUM_BUFFER_BIT : constant GLenum := 16#00000200#;
GL_STENCIL_BUFFER_BIT : constant GLenum := 16#00000400#;
GL_VIEWPORT_BIT : constant GLenum := 16#00000800#;
GL_TRANSFORM_BIT : constant GLenum := 16#00001000#;
GL_ENABLE_BIT : constant GLenum := 16#00002000#;
GL_COLOR_BUFFER_BIT : constant GLenum := 16#00004000#;
GL_HINT_BIT : constant GLenum := 16#00008000#;
GL_EVAL_BIT : constant GLenum := 16#00010000#;
GL_LIST_BIT : constant GLenum := 16#00020000#;
GL_TEXTURE_BIT : constant GLenum := 16#00040000#;
GL_SCISSOR_BIT : constant GLenum := 16#00080000#;
GL_ALL_ATTRIB_BITS : constant GLenum := 16#000FFFFF#;
GL_PROXY_TEXTURE_1D : constant GLenum := 16#8063#;
GL_PROXY_TEXTURE_2D : constant GLenum := 16#8064#;
GL_TEXTURE_PRIORITY : constant GLenum := 16#8066#;
GL_TEXTURE_RESIDENT : constant GLenum := 16#8067#;
GL_TEXTURE_BINDING_1D : constant GLenum := 16#8068#;
GL_TEXTURE_BINDING_2D : constant GLenum := 16#8069#;
GL_TEXTURE_INTERNAL_FORMAT : constant GLenum := 16#1003#;
GL_ALPHA4 : constant GLenum := 16#803B#;
GL_ALPHA8 : constant GLenum := 16#803C#;
GL_ALPHA12 : constant GLenum := 16#803D#;
GL_ALPHA16 : constant GLenum := 16#803E#;
GL_LUMINANCE4 : constant GLenum := 16#803F#;
GL_LUMINANCE8 : constant GLenum := 16#8040#;
GL_LUMINANCE12 : constant GLenum := 16#8041#;
GL_LUMINANCE16 : constant GLenum := 16#8042#;
GL_LUMINANCE4_ALPHA4 : constant GLenum := 16#8043#;
GL_LUMINANCE6_ALPHA2 : constant GLenum := 16#8044#;
GL_LUMINANCE8_ALPHA8 : constant GLenum := 16#8045#;
GL_LUMINANCE12_ALPHA4 : constant GLenum := 16#8046#;
GL_LUMINANCE12_ALPHA12 : constant GLenum := 16#8047#;
GL_LUMINANCE16_ALPHA16 : constant GLenum := 16#8048#;
GL_INTENSITY : constant GLenum := 16#8049#;
GL_INTENSITY4 : constant GLenum := 16#804A#;
GL_INTENSITY8 : constant GLenum := 16#804B#;
GL_INTENSITY12 : constant GLenum := 16#804C#;
GL_INTENSITY16 : constant GLenum := 16#804D#;
GL_R3_G3_B2 : constant GLenum := 16#2A10#;
GL_RGB4 : constant GLenum := 16#804F#;
GL_RGB5 : constant GLenum := 16#8050#;
GL_RGB8 : constant GLenum := 16#8051#;
GL_RGB10 : constant GLenum := 16#8052#;
GL_RGB12 : constant GLenum := 16#8053#;
GL_RGB16 : constant GLenum := 16#8054#;
GL_RGBA2 : constant GLenum := 16#8055#;
GL_RGBA4 : constant GLenum := 16#8056#;
GL_RGB5_A1 : constant GLenum := 16#8057#;
GL_RGBA8 : constant GLenum := 16#8058#;
GL_RGB10_A2 : constant GLenum := 16#8059#;
GL_RGBA12 : constant GLenum := 16#805A#;
GL_RGBA16 : constant GLenum := 16#805B#;
GL_CLIENT_PIXEL_STORE_BIT : constant GLenum := 16#00000001#;
GL_CLIENT_VERTEX_ARRAY_BIT : constant GLenum := 16#00000002#;
GL_ALL_CLIENT_ATTRIB_BITS : constant GLenum := 16#FFFFFFFF#;
GL_CLIENT_ALL_ATTRIB_BITS : constant GLenum := 16#FFFFFFFF#;
GL_RESCALE_NORMAL : constant GLenum := 16#803A#;
GL_CLAMP_TO_EDGE : constant GLenum := 16#812F#;
GL_MAX_ELEMENTS_VERTICES : constant GLenum := 16#80E8#;
GL_MAX_ELEMENTS_INDICES : constant GLenum := 16#80E9#;
GL_BGR : constant GLenum := 16#80E0#;
GL_BGRA : constant GLenum := 16#80E1#;
GL_UNSIGNED_BYTE_3_3_2 : constant GLenum := 16#8032#;
GL_UNSIGNED_BYTE_2_3_3_REV : constant GLenum := 16#8362#;
GL_UNSIGNED_SHORT_5_6_5 : constant GLenum := 16#8363#;
GL_UNSIGNED_SHORT_5_6_5_REV : constant GLenum := 16#8364#;
GL_UNSIGNED_SHORT_4_4_4_4 : constant GLenum := 16#8033#;
GL_UNSIGNED_SHORT_4_4_4_4_REV : constant GLenum := 16#8365#;
GL_UNSIGNED_SHORT_5_5_5_1 : constant GLenum := 16#8034#;
GL_UNSIGNED_SHORT_1_5_5_5_REV : constant GLenum := 16#8366#;
GL_UNSIGNED_INT_8_8_8_8 : constant GLenum := 16#8035#;
GL_UNSIGNED_INT_8_8_8_8_REV : constant GLenum := 16#8367#;
GL_UNSIGNED_INT_10_10_10_2 : constant GLenum := 16#8036#;
GL_UNSIGNED_INT_2_10_10_10_REV : constant GLenum := 16#8368#;
GL_LIGHT_MODEL_COLOR_CONTROL : constant GLenum := 16#81F8#;
GL_SINGLE_COLOR : constant GLenum := 16#81F9#;
GL_SEPARATE_SPECULAR_COLOR : constant GLenum := 16#81FA#;
GL_TEXTURE_MIN_LOD : constant GLenum := 16#813A#;
GL_TEXTURE_MAX_LOD : constant GLenum := 16#813B#;
GL_TEXTURE_BASE_LEVEL : constant GLenum := 16#813C#;
GL_TEXTURE_MAX_LEVEL : constant GLenum := 16#813D#;
GL_SMOOTH_POINT_SIZE_RANGE : constant GLenum := 16#0B12#;
GL_SMOOTH_POINT_SIZE_GRANULARITY : constant GLenum := 16#0B13#;
GL_SMOOTH_LINE_WIDTH_RANGE : constant GLenum := 16#0B22#;
GL_SMOOTH_LINE_WIDTH_GRANULARITY : constant GLenum := 16#0B23#;
GL_ALIASED_POINT_SIZE_RANGE : constant GLenum := 16#846D#;
GL_ALIASED_LINE_WIDTH_RANGE : constant GLenum := 16#846E#;
GL_PACK_SKIP_IMAGES : constant GLenum := 16#806B#;
GL_PACK_IMAGE_HEIGHT : constant GLenum := 16#806C#;
GL_UNPACK_SKIP_IMAGES : constant GLenum := 16#806D#;
GL_UNPACK_IMAGE_HEIGHT : constant GLenum := 16#806E#;
GL_TEXTURE_3D : constant GLenum := 16#806F#;
GL_PROXY_TEXTURE_3D : constant GLenum := 16#8070#;
GL_TEXTURE_DEPTH : constant GLenum := 16#8071#;
GL_TEXTURE_WRAP_R : constant GLenum := 16#8072#;
GL_MAX_3D_TEXTURE_SIZE : constant GLenum := 16#8073#;
GL_TEXTURE_BINDING_3D : constant GLenum := 16#806A#;
GL_COLOR_TABLE : constant GLenum := 16#80D0#;
GL_POST_CONVOLUTION_COLOR_TABLE : constant GLenum := 16#80D1#;
GL_POST_COLOR_MATRIX_COLOR_TABLE : constant GLenum := 16#80D2#;
GL_PROXY_COLOR_TABLE : constant GLenum := 16#80D3#;
GL_PROXY_POST_CONVOLUTION_COLOR_TABLE : constant GLenum := 16#80D4#;
GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE : constant GLenum := 16#80D5#;
GL_COLOR_TABLE_SCALE : constant GLenum := 16#80D6#;
GL_COLOR_TABLE_BIAS : constant GLenum := 16#80D7#;
GL_COLOR_TABLE_FORMAT : constant GLenum := 16#80D8#;
GL_COLOR_TABLE_WIDTH : constant GLenum := 16#80D9#;
GL_COLOR_TABLE_RED_SIZE : constant GLenum := 16#80DA#;
GL_COLOR_TABLE_GREEN_SIZE : constant GLenum := 16#80DB#;
GL_COLOR_TABLE_BLUE_SIZE : constant GLenum := 16#80DC#;
GL_COLOR_TABLE_ALPHA_SIZE : constant GLenum := 16#80DD#;
GL_COLOR_TABLE_LUMINANCE_SIZE : constant GLenum := 16#80DE#;
GL_COLOR_TABLE_INTENSITY_SIZE : constant GLenum := 16#80DF#;
GL_CONVOLUTION_1D : constant GLenum := 16#8010#;
GL_CONVOLUTION_2D : constant GLenum := 16#8011#;
GL_SEPARABLE_2D : constant GLenum := 16#8012#;
GL_CONVOLUTION_BORDER_MODE : constant GLenum := 16#8013#;
GL_CONVOLUTION_FILTER_SCALE : constant GLenum := 16#8014#;
GL_CONVOLUTION_FILTER_BIAS : constant GLenum := 16#8015#;
GL_REDUCE : constant GLenum := 16#8016#;
GL_CONVOLUTION_FORMAT : constant GLenum := 16#8017#;
GL_CONVOLUTION_WIDTH : constant GLenum := 16#8018#;
GL_CONVOLUTION_HEIGHT : constant GLenum := 16#8019#;
GL_MAX_CONVOLUTION_WIDTH : constant GLenum := 16#801A#;
GL_MAX_CONVOLUTION_HEIGHT : constant GLenum := 16#801B#;
GL_POST_CONVOLUTION_RED_SCALE : constant GLenum := 16#801C#;
GL_POST_CONVOLUTION_GREEN_SCALE : constant GLenum := 16#801D#;
GL_POST_CONVOLUTION_BLUE_SCALE : constant GLenum := 16#801E#;
GL_POST_CONVOLUTION_ALPHA_SCALE : constant GLenum := 16#801F#;
GL_POST_CONVOLUTION_RED_BIAS : constant GLenum := 16#8020#;
GL_POST_CONVOLUTION_GREEN_BIAS : constant GLenum := 16#8021#;
GL_POST_CONVOLUTION_BLUE_BIAS : constant GLenum := 16#8022#;
GL_POST_CONVOLUTION_ALPHA_BIAS : constant GLenum := 16#8023#;
GL_CONSTANT_BORDER : constant GLenum := 16#8151#;
GL_REPLICATE_BORDER : constant GLenum := 16#8153#;
GL_CONVOLUTION_BORDER_COLOR : constant GLenum := 16#8154#;
GL_COLOR_MATRIX : constant GLenum := 16#80B1#;
GL_COLOR_MATRIX_STACK_DEPTH : constant GLenum := 16#80B2#;
GL_MAX_COLOR_MATRIX_STACK_DEPTH : constant GLenum := 16#80B3#;
GL_POST_COLOR_MATRIX_RED_SCALE : constant GLenum := 16#80B4#;
GL_POST_COLOR_MATRIX_GREEN_SCALE : constant GLenum := 16#80B5#;
GL_POST_COLOR_MATRIX_BLUE_SCALE : constant GLenum := 16#80B6#;
GL_POST_COLOR_MATRIX_ALPHA_SCALE : constant GLenum := 16#80B7#;
GL_POST_COLOR_MATRIX_RED_BIAS : constant GLenum := 16#80B8#;
GL_POST_COLOR_MATRIX_GREEN_BIAS : constant GLenum := 16#80B9#;
GL_POST_COLOR_MATRIX_BLUE_BIAS : constant GLenum := 16#80BA#;
GL_POST_COLOR_MATRIX_ALPHA_BIAS : constant GLenum := 16#80BB#;
GL_HISTOGRAM : constant GLenum := 16#8024#;
GL_PROXY_HISTOGRAM : constant GLenum := 16#8025#;
GL_HISTOGRAM_WIDTH : constant GLenum := 16#8026#;
GL_HISTOGRAM_FORMAT : constant GLenum := 16#8027#;
GL_HISTOGRAM_RED_SIZE : constant GLenum := 16#8028#;
GL_HISTOGRAM_GREEN_SIZE : constant GLenum := 16#8029#;
GL_HISTOGRAM_BLUE_SIZE : constant GLenum := 16#802A#;
GL_HISTOGRAM_ALPHA_SIZE : constant GLenum := 16#802B#;
GL_HISTOGRAM_LUMINANCE_SIZE : constant GLenum := 16#802C#;
GL_HISTOGRAM_SINK : constant GLenum := 16#802D#;
GL_MINMAX : constant GLenum := 16#802E#;
GL_MINMAX_FORMAT : constant GLenum := 16#802F#;
GL_MINMAX_SINK : constant GLenum := 16#8030#;
GL_TABLE_TOO_LARGE : constant GLenum := 16#8031#;
GL_BLEND_EQUATION : constant GLenum := 16#8009#;
GL_MIN : constant GLenum := 16#8007#;
GL_MAX : constant GLenum := 16#8008#;
GL_FUNC_ADD : constant GLenum := 16#8006#;
GL_FUNC_SUBTRACT : constant GLenum := 16#800A#;
GL_FUNC_REVERSE_SUBTRACT : constant GLenum := 16#800B#;
GL_BLEND_COLOR : constant GLenum := 16#8005#;
GL_TEXTURE0 : constant GLenum := 16#84C0#;
GL_TEXTURE1 : constant GLenum := 16#84C1#;
GL_TEXTURE2 : constant GLenum := 16#84C2#;
GL_TEXTURE3 : constant GLenum := 16#84C3#;
GL_TEXTURE4 : constant GLenum := 16#84C4#;
GL_TEXTURE5 : constant GLenum := 16#84C5#;
GL_TEXTURE6 : constant GLenum := 16#84C6#;
GL_TEXTURE7 : constant GLenum := 16#84C7#;
GL_TEXTURE8 : constant GLenum := 16#84C8#;
GL_TEXTURE9 : constant GLenum := 16#84C9#;
GL_TEXTURE10 : constant GLenum := 16#84CA#;
GL_TEXTURE11 : constant GLenum := 16#84CB#;
GL_TEXTURE12 : constant GLenum := 16#84CC#;
GL_TEXTURE13 : constant GLenum := 16#84CD#;
GL_TEXTURE14 : constant GLenum := 16#84CE#;
GL_TEXTURE15 : constant GLenum := 16#84CF#;
GL_TEXTURE16 : constant GLenum := 16#84D0#;
GL_TEXTURE17 : constant GLenum := 16#84D1#;
GL_TEXTURE18 : constant GLenum := 16#84D2#;
GL_TEXTURE19 : constant GLenum := 16#84D3#;
GL_TEXTURE20 : constant GLenum := 16#84D4#;
GL_TEXTURE21 : constant GLenum := 16#84D5#;
GL_TEXTURE22 : constant GLenum := 16#84D6#;
GL_TEXTURE23 : constant GLenum := 16#84D7#;
GL_TEXTURE24 : constant GLenum := 16#84D8#;
GL_TEXTURE25 : constant GLenum := 16#84D9#;
GL_TEXTURE26 : constant GLenum := 16#84DA#;
GL_TEXTURE27 : constant GLenum := 16#84DB#;
GL_TEXTURE28 : constant GLenum := 16#84DC#;
GL_TEXTURE29 : constant GLenum := 16#84DD#;
GL_TEXTURE30 : constant GLenum := 16#84DE#;
GL_TEXTURE31 : constant GLenum := 16#84DF#;
GL_ACTIVE_TEXTURE : constant GLenum := 16#84E0#;
GL_CLIENT_ACTIVE_TEXTURE : constant GLenum := 16#84E1#;
GL_MAX_TEXTURE_UNITS : constant GLenum := 16#84E2#;
GL_NORMAL_MAP : constant GLenum := 16#8511#;
GL_REFLECTION_MAP : constant GLenum := 16#8512#;
GL_TEXTURE_CUBE_MAP : constant GLenum := 16#8513#;
GL_TEXTURE_BINDING_CUBE_MAP : constant GLenum := 16#8514#;
GL_TEXTURE_CUBE_MAP_POSITIVE_X : constant GLenum := 16#8515#;
GL_TEXTURE_CUBE_MAP_NEGATIVE_X : constant GLenum := 16#8516#;
GL_TEXTURE_CUBE_MAP_POSITIVE_Y : constant GLenum := 16#8517#;
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y : constant GLenum := 16#8518#;
GL_TEXTURE_CUBE_MAP_POSITIVE_Z : constant GLenum := 16#8519#;
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z : constant GLenum := 16#851A#;
GL_PROXY_TEXTURE_CUBE_MAP : constant GLenum := 16#851B#;
GL_MAX_CUBE_MAP_TEXTURE_SIZE : constant GLenum := 16#851C#;
GL_COMPRESSED_ALPHA : constant GLenum := 16#84E9#;
GL_COMPRESSED_LUMINANCE : constant GLenum := 16#84EA#;
GL_COMPRESSED_LUMINANCE_ALPHA : constant GLenum := 16#84EB#;
GL_COMPRESSED_INTENSITY : constant GLenum := 16#84EC#;
GL_COMPRESSED_RGB : constant GLenum := 16#84ED#;
GL_COMPRESSED_RGBA : constant GLenum := 16#84EE#;
GL_TEXTURE_COMPRESSION_HINT : constant GLenum := 16#84EF#;
GL_TEXTURE_COMPRESSED_IMAGE_SIZE : constant GLenum := 16#86A0#;
GL_TEXTURE_COMPRESSED : constant GLenum := 16#86A1#;
GL_NUM_COMPRESSED_TEXTURE_FORMATS : constant GLenum := 16#86A2#;
GL_COMPRESSED_TEXTURE_FORMATS : constant GLenum := 16#86A3#;
GL_MULTISAMPLE : constant GLenum := 16#809D#;
GL_SAMPLE_ALPHA_TO_COVERAGE : constant GLenum := 16#809E#;
GL_SAMPLE_ALPHA_TO_ONE : constant GLenum := 16#809F#;
GL_SAMPLE_COVERAGE : constant GLenum := 16#80A0#;
GL_SAMPLE_BUFFERS : constant GLenum := 16#80A8#;
GL_SAMPLES : constant GLenum := 16#80A9#;
GL_SAMPLE_COVERAGE_VALUE : constant GLenum := 16#80AA#;
GL_SAMPLE_COVERAGE_INVERT : constant GLenum := 16#80AB#;
GL_MULTISAMPLE_BIT : constant GLenum := 16#20000000#;
GL_TRANSPOSE_MODELVIEW_MATRIX : constant GLenum := 16#84E3#;
GL_TRANSPOSE_PROJECTION_MATRIX : constant GLenum := 16#84E4#;
GL_TRANSPOSE_TEXTURE_MATRIX : constant GLenum := 16#84E5#;
GL_TRANSPOSE_COLOR_MATRIX : constant GLenum := 16#84E6#;
GL_COMBINE : constant GLenum := 16#8570#;
GL_COMBINE_RGB : constant GLenum := 16#8571#;
GL_COMBINE_ALPHA : constant GLenum := 16#8572#;
GL_SOURCE0_RGB : constant GLenum := 16#8580#;
GL_SOURCE1_RGB : constant GLenum := 16#8581#;
GL_SOURCE2_RGB : constant GLenum := 16#8582#;
GL_SOURCE0_ALPHA : constant GLenum := 16#8588#;
GL_SOURCE1_ALPHA : constant GLenum := 16#8589#;
GL_SOURCE2_ALPHA : constant GLenum := 16#858A#;
GL_OPERAND0_RGB : constant GLenum := 16#8590#;
GL_OPERAND1_RGB : constant GLenum := 16#8591#;
GL_OPERAND2_RGB : constant GLenum := 16#8592#;
GL_OPERAND0_ALPHA : constant GLenum := 16#8598#;
GL_OPERAND1_ALPHA : constant GLenum := 16#8599#;
GL_OPERAND2_ALPHA : constant GLenum := 16#859A#;
GL_RGB_SCALE : constant GLenum := 16#8573#;
GL_ADD_SIGNED : constant GLenum := 16#8574#;
GL_INTERPOLATE : constant GLenum := 16#8575#;
GL_SUBTRACT : constant GLenum := 16#84E7#;
GL_CONSTANT : constant GLenum := 16#8576#;
GL_PRIMARY_COLOR : constant GLenum := 16#8577#;
GL_PREVIOUS : constant GLenum := 16#8578#;
GL_DOT3_RGB : constant GLenum := 16#86AE#;
GL_DOT3_RGBA : constant GLenum := 16#86AF#;
GL_CLAMP_TO_BORDER : constant GLenum := 16#812D#;
-- ////////////////////////////////////////////////////////////
-- // GL functions
-- ////////////////////////////////////////////////////////////
procedure glClearIndex (c : GLfloat);
procedure glClearColor
(red : GLclampf;
green : GLclampf;
blue : GLclampf;
alpha : GLclampf);
procedure glClear (mask : GLbitfield);
procedure glIndexMask (mask : GLuint);
procedure glColorMask
(red : GLboolean;
green : GLboolean;
blue : GLboolean;
alpha : GLboolean);
procedure glAlphaFunc (func : GLenum; ref : GLclampf);
procedure glBlendFunc (sfactor : GLenum; dfactor : GLenum);
procedure glLogicOp (opcode : GLenum);
procedure glCullFace (mode : GLenum);
procedure glFrontFace (mode : GLenum);
procedure glPointSize (size : GLfloat);
procedure glLineWidth (width : GLfloat);
procedure glLineStipple (factor : GLint; pattern : GLushort);
procedure glPolygonMode (face : GLenum; mode : GLenum);
procedure glPolygonOffset (factor : GLfloat; units : GLfloat);
procedure glPolygonStipple (mask : access GLubyte);
procedure glGetPolygonStipple (mask : access GLubyte);
procedure glEdgeFlag (flag : GLboolean);
procedure glEdgeFlagv (flag : access GLboolean);
procedure glScissor
(x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glClipPlane (plane : GLenum; equation : access GLdouble);
procedure glGetClipPlane (plane : GLenum; equation : access GLdouble);
procedure glDrawBuffer (mode : GLenum);
procedure glReadBuffer (mode : GLenum);
procedure glEnable (cap : GLenum);
procedure glDisable (cap : GLenum);
function glIsEnabled (cap : GLenum) return GLboolean;
procedure glEnableClientState (cap : GLenum);
procedure glDisableClientState (cap : GLenum);
procedure glGetBooleanv (pname : GLenum; params : access GLboolean);
procedure glGetDoublev (pname : GLenum; params : access GLdouble);
procedure glGetFloatv (pname : GLenum; params : access GLfloat);
procedure glGetIntegerv (pname : GLenum; params : access GLint);
procedure glPushAttrib (mask : GLbitfield);
procedure glPopAttrib;
procedure glPushClientAttrib (mask : GLbitfield);
procedure glPopClientAttrib;
function glRenderMode (mode : GLenum) return GLint;
function glGetError return GLenum;
function glGetString (name : GLenum) return GLubyte_Ptr;
procedure glFinish;
procedure glFlush;
procedure glHint (target : GLenum; mode : GLenum);
procedure glClearDepth (depth : GLclampd);
procedure glDepthFunc (func : GLenum);
procedure glDepthMask (flag : GLboolean);
procedure glDepthRange (near_val : GLclampd; far_val : GLclampd);
procedure glClearAccum
(red : GLfloat;
green : GLfloat;
blue : GLfloat;
alpha : GLfloat);
procedure glAccum (op : GLenum; value : GLfloat);
procedure glMatrixMode (mode : GLenum);
procedure glOrtho
(left : GLdouble;
right : GLdouble;
bottom : GLdouble;
top : GLdouble;
near_val : GLdouble;
far_val : GLdouble);
procedure glFrustum
(left : GLdouble;
right : GLdouble;
bottom : GLdouble;
top : GLdouble;
near_val : GLdouble;
far_val : GLdouble);
procedure glViewport
(x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glPushMatrix;
procedure glPopMatrix;
procedure glLoadIdentity;
procedure glLoadMatrixd (m : access GLdouble);
procedure glLoadMatrixf (m : access GLfloat);
procedure glMultMatrixd (m : access GLdouble);
procedure glMultMatrixf (m : access GLfloat);
procedure glRotated
(angle : GLdouble;
x : GLdouble;
y : GLdouble;
z : GLdouble);
procedure glRotatef
(angle : GLfloat;
x : GLfloat;
y : GLfloat;
z : GLfloat);
procedure glScaled (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glScalef (x : GLfloat; y : GLfloat; z : GLfloat);
procedure glTranslated (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glTranslatef (x : GLfloat; y : GLfloat; z : GLfloat);
function glIsList (list : GLuint) return GLboolean;
procedure glDeleteLists (list : GLuint; c_range : GLsizei);
function glGenLists (c_range : GLsizei) return GLuint;
procedure glNewList (list : GLuint; mode : GLenum);
procedure glEndList;
procedure glCallList (list : GLuint);
procedure glCallLists (n : GLsizei; c_type : GLenum; lists : GLvoid_Ptr);
procedure glListBase (base : GLuint);
procedure glBegin (mode : GLenum);
procedure glEnd;
procedure glVertex2d (x : GLdouble; y : GLdouble);
procedure glVertex2f (x : GLfloat; y : GLfloat);
procedure glVertex2i (x : GLint; y : GLint);
procedure glVertex2s (x : GLshort; y : GLshort);
procedure glVertex3d (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glVertex3f (x : GLfloat; y : GLfloat; z : GLfloat);
procedure glVertex3i (x : GLint; y : GLint; z : GLint);
procedure glVertex3s (x : GLshort; y : GLshort; z : GLshort);
procedure glVertex4d
(x : GLdouble;
y : GLdouble;
z : GLdouble;
w : GLdouble);
procedure glVertex4f
(x : GLfloat;
y : GLfloat;
z : GLfloat;
w : GLfloat);
procedure glVertex4i
(x : GLint;
y : GLint;
z : GLint;
w : GLint);
procedure glVertex4s
(x : GLshort;
y : GLshort;
z : GLshort;
w : GLshort);
procedure glVertex2dv (v : access GLdouble);
procedure glVertex2fv (v : access GLfloat);
procedure glVertex2iv (v : access GLint);
procedure glVertex2sv (v : access GLshort);
procedure glVertex3dv (v : access GLdouble);
procedure glVertex3fv (v : access GLfloat);
procedure glVertex3iv (v : access GLint);
procedure glVertex3sv (v : access GLshort);
procedure glVertex4dv (v : access GLdouble);
procedure glVertex4fv (v : access GLfloat);
procedure glVertex4iv (v : access GLint);
procedure glVertex4sv (v : access GLshort);
procedure glNormal3b (nx : GLbyte; ny : GLbyte; nz : GLbyte);
procedure glNormal3d (nx : GLdouble; ny : GLdouble; nz : GLdouble);
procedure glNormal3f (nx : GLfloat; ny : GLfloat; nz : GLfloat);
procedure glNormal3i (nx : GLint; ny : GLint; nz : GLint);
procedure glNormal3s (nx : GLshort; ny : GLshort; nz : GLshort);
procedure glNormal3bv (v : access GLbyte);
procedure glNormal3dv (v : access GLdouble);
procedure glNormal3fv (v : access GLfloat);
procedure glNormal3iv (v : access GLint);
procedure glNormal3sv (v : access GLshort);
procedure glIndexd (c : GLdouble);
procedure glIndexf (c : GLfloat);
procedure glIndexi (c : GLint);
procedure glIndexs (c : GLshort);
procedure glIndexub (c : GLubyte);
procedure glIndexdv (c : access GLdouble);
procedure glIndexfv (c : access GLfloat);
procedure glIndexiv (c : access GLint);
procedure glIndexsv (c : access GLshort);
procedure glIndexubv (c : access GLubyte);
procedure glColor3b (red : GLbyte; green : GLbyte; blue : GLbyte);
procedure glColor3d (red : GLdouble; green : GLdouble; blue : GLdouble);
procedure glColor3f (red : GLfloat; green : GLfloat; blue : GLfloat);
procedure glColor3i (red : GLint; green : GLint; blue : GLint);
procedure glColor3s (red : GLshort; green : GLshort; blue : GLshort);
procedure glColor3ub (red : GLubyte; green : GLubyte; blue : GLubyte);
procedure glColor3ui (red : GLuint; green : GLuint; blue : GLuint);
procedure glColor3us (red : GLushort; green : GLushort; blue : GLushort);
procedure glColor4b
(red : GLbyte;
green : GLbyte;
blue : GLbyte;
alpha : GLbyte);
procedure glColor4d
(red : GLdouble;
green : GLdouble;
blue : GLdouble;
alpha : GLdouble);
procedure glColor4f
(red : GLfloat;
green : GLfloat;
blue : GLfloat;
alpha : GLfloat);
procedure glColor4i
(red : GLint;
green : GLint;
blue : GLint;
alpha : GLint);
procedure glColor4s
(red : GLshort;
green : GLshort;
blue : GLshort;
alpha : GLshort);
procedure glColor4ub
(red : GLubyte;
green : GLubyte;
blue : GLubyte;
alpha : GLubyte);
procedure glColor4ui
(red : GLuint;
green : GLuint;
blue : GLuint;
alpha : GLuint);
procedure glColor4us
(red : GLushort;
green : GLushort;
blue : GLushort;
alpha : GLushort);
procedure glColor3bv (v : access GLbyte);
procedure glColor3dv (v : access GLdouble);
procedure glColor3fv (v : access GLfloat);
procedure glColor3iv (v : access GLint);
procedure glColor3sv (v : access GLshort);
procedure glColor3ubv (v : access GLubyte);
procedure glColor3uiv (v : access GLuint);
procedure glColor3usv (v : access GLushort);
procedure glColor4bv (v : access GLbyte);
procedure glColor4dv (v : access GLdouble);
procedure glColor4fv (v : access GLfloat);
procedure glColor4iv (v : access GLint);
procedure glColor4sv (v : access GLshort);
procedure glColor4ubv (v : access GLubyte);
procedure glColor4uiv (v : access GLuint);
procedure glColor4usv (v : access GLushort);
procedure glTexCoord1d (s : GLdouble);
procedure glTexCoord1f (s : GLfloat);
procedure glTexCoord1i (s : GLint);
procedure glTexCoord1s (s : GLshort);
procedure glTexCoord2d (s : GLdouble; t : GLdouble);
procedure glTexCoord2f (s : GLfloat; t : GLfloat);
procedure glTexCoord2i (s : GLint; t : GLint);
procedure glTexCoord2s (s : GLshort; t : GLshort);
procedure glTexCoord3d (s : GLdouble; t : GLdouble; r : GLdouble);
procedure glTexCoord3f (s : GLfloat; t : GLfloat; r : GLfloat);
procedure glTexCoord3i (s : GLint; t : GLint; r : GLint);
procedure glTexCoord3s (s : GLshort; t : GLshort; r : GLshort);
procedure glTexCoord4d
(s : GLdouble;
t : GLdouble;
r : GLdouble;
q : GLdouble);
procedure glTexCoord4f
(s : GLfloat;
t : GLfloat;
r : GLfloat;
q : GLfloat);
procedure glTexCoord4i
(s : GLint;
t : GLint;
r : GLint;
q : GLint);
procedure glTexCoord4s
(s : GLshort;
t : GLshort;
r : GLshort;
q : GLshort);
procedure glTexCoord1dv (v : access GLdouble);
procedure glTexCoord1fv (v : access GLfloat);
procedure glTexCoord1iv (v : access GLint);
procedure glTexCoord1sv (v : access GLshort);
procedure glTexCoord2dv (v : access GLdouble);
procedure glTexCoord2fv (v : access GLfloat);
procedure glTexCoord2iv (v : access GLint);
procedure glTexCoord2sv (v : access GLshort);
procedure glTexCoord3dv (v : access GLdouble);
procedure glTexCoord3fv (v : access GLfloat);
procedure glTexCoord3iv (v : access GLint);
procedure glTexCoord3sv (v : access GLshort);
procedure glTexCoord4dv (v : access GLdouble);
procedure glTexCoord4fv (v : access GLfloat);
procedure glTexCoord4iv (v : access GLint);
procedure glTexCoord4sv (v : access GLshort);
procedure glRasterPos2d (x : GLdouble; y : GLdouble);
procedure glRasterPos2f (x : GLfloat; y : GLfloat);
procedure glRasterPos2i (x : GLint; y : GLint);
procedure glRasterPos2s (x : GLshort; y : GLshort);
procedure glRasterPos3d (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glRasterPos3f (x : GLfloat; y : GLfloat; z : GLfloat);
procedure glRasterPos3i (x : GLint; y : GLint; z : GLint);
procedure glRasterPos3s (x : GLshort; y : GLshort; z : GLshort);
procedure glRasterPos4d
(x : GLdouble;
y : GLdouble;
z : GLdouble;
w : GLdouble);
procedure glRasterPos4f
(x : GLfloat;
y : GLfloat;
z : GLfloat;
w : GLfloat);
procedure glRasterPos4i
(x : GLint;
y : GLint;
z : GLint;
w : GLint);
procedure glRasterPos4s
(x : GLshort;
y : GLshort;
z : GLshort;
w : GLshort);
procedure glRasterPos2dv (v : access GLdouble);
procedure glRasterPos2fv (v : access GLfloat);
procedure glRasterPos2iv (v : access GLint);
procedure glRasterPos2sv (v : access GLshort);
procedure glRasterPos3dv (v : access GLdouble);
procedure glRasterPos3fv (v : access GLfloat);
procedure glRasterPos3iv (v : access GLint);
procedure glRasterPos3sv (v : access GLshort);
procedure glRasterPos4dv (v : access GLdouble);
procedure glRasterPos4fv (v : access GLfloat);
procedure glRasterPos4iv (v : access GLint);
procedure glRasterPos4sv (v : access GLshort);
procedure glRectd
(x1 : GLdouble;
y1 : GLdouble;
x2 : GLdouble;
y2 : GLdouble);
procedure glRectf
(x1 : GLfloat;
y1 : GLfloat;
x2 : GLfloat;
y2 : GLfloat);
procedure glRecti
(x1 : GLint;
y1 : GLint;
x2 : GLint;
y2 : GLint);
procedure glRects
(x1 : GLshort;
y1 : GLshort;
x2 : GLshort;
y2 : GLshort);
procedure glRectdv (v1 : access GLdouble; v2 : access GLdouble);
procedure glRectfv (v1 : access GLfloat; v2 : access GLfloat);
procedure glRectiv (v1 : access GLint; v2 : access GLint);
procedure glRectsv (v1 : access GLshort; v2 : access GLshort);
procedure glShadeModel (mode : GLenum);
procedure glLightf (light : GLenum; pname : GLenum; param : GLfloat);
procedure glLighti (light : GLenum; pname : GLenum; param : GLint);
procedure glLightfv (light : GLenum; pname : GLenum; params : access GLfloat);
procedure glLightiv (light : GLenum; pname : GLenum; params : access GLint);
procedure glGetLightfv (light : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetLightiv (light : GLenum; pname : GLenum; params : access GLint);
procedure glLightModelf (pname : GLenum; param : GLfloat);
procedure glLightModeli (pname : GLenum; param : GLint);
procedure glLightModelfv (pname : GLenum; params : access GLfloat);
procedure glLightModeliv (pname : GLenum; params : access GLint);
procedure glMaterialf (face : GLenum; pname : GLenum; param : GLfloat);
procedure glMateriali (face : GLenum; pname : GLenum; param : GLint);
procedure glMaterialfv (face : GLenum; pname : GLenum; params : access GLfloat);
procedure glMaterialiv (face : GLenum; pname : GLenum; params : access GLint);
procedure glGetMaterialfv (face : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetMaterialiv (face : GLenum; pname : GLenum; params : access GLint);
procedure glColorMaterial (face : GLenum; mode : GLenum);
procedure glPixelZoom (xfactor : GLfloat; yfactor : GLfloat);
procedure glPixelStoref (pname : GLenum; param : GLfloat);
procedure glPixelStorei (pname : GLenum; param : GLint);
procedure glPixelTransferf (pname : GLenum; param : GLfloat);
procedure glPixelTransferi (pname : GLenum; param : GLint);
procedure glPixelMapfv (map : GLenum; mapsize : GLint; values : access GLfloat);
procedure glPixelMapuiv (map : GLenum; mapsize : GLint; values : access GLuint);
procedure glPixelMapusv (map : GLenum; mapsize : GLint; values : access GLushort);
procedure glGetPixelMapfv (map : GLenum; values : access GLfloat);
procedure glGetPixelMapuiv (map : GLenum; values : access GLuint);
procedure glGetPixelMapusv (map : GLenum; values : access GLushort);
procedure glBitmap
(width : GLsizei;
height : GLsizei;
xorig : GLfloat;
yorig : GLfloat;
xmove : GLfloat;
ymove : GLfloat;
bitmap : access GLubyte);
procedure glReadPixels
(x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glDrawPixels
(width : GLsizei;
height : GLsizei;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glCopyPixels
(x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei;
c_type : GLenum);
procedure glStencilFunc (func : GLenum; ref : GLint; mask : GLuint);
procedure glStencilMask (mask : GLuint);
procedure glStencilOp (fail : GLenum; zfail : GLenum; zpass : GLenum);
procedure glClearStencil (s : GLint);
procedure glTexGend (coord : GLenum; pname : GLenum; param : GLdouble);
procedure glTexGenf (coord : GLenum; pname : GLenum; param : GLfloat);
procedure glTexGeni (coord : GLenum; pname : GLenum; param : GLint);
procedure glTexGendv (coord : GLenum; pname : GLenum; params : access GLdouble);
procedure glTexGenfv (coord : GLenum; pname : GLenum; params : access GLfloat);
procedure glTexGeniv (coord : GLenum; pname : GLenum; params : access GLint);
procedure glGetTexGendv (coord : GLenum; pname : GLenum; params : access GLdouble);
procedure glGetTexGenfv (coord : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetTexGeniv (coord : GLenum; pname : GLenum; params : access GLint);
procedure glTexEnvf (target : GLenum; pname : GLenum; param : GLfloat);
procedure glTexEnvi (target : GLenum; pname : GLenum; param : GLint);
procedure glTexEnvfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glTexEnviv (target : GLenum; pname : GLenum; params : access GLint);
procedure glGetTexEnvfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetTexEnviv (target : GLenum; pname : GLenum; params : access GLint);
procedure glTexParameterf (target : GLenum; pname : GLenum; param : GLfloat);
procedure glTexParameteri (target : GLenum; pname : GLenum; param : GLint);
procedure glTexParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glTexParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glGetTexParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetTexParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glGetTexLevelParameterfv
(target : GLenum;
level : GLint;
pname : GLenum;
params : access GLfloat);
procedure glGetTexLevelParameteriv
(target : GLenum;
level : GLint;
pname : GLenum;
params : access GLint);
procedure glTexImage1D
(target : GLenum;
level : GLint;
internalFormat : GLint;
width : GLsizei;
border : GLint;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glTexImage2D
(target : GLenum;
level : GLint;
internalFormat : GLint;
width : GLsizei;
height : GLsizei;
border : GLint;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glGetTexImage
(target : GLenum;
level : GLint;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glMap1d
(target : GLenum;
u1 : GLdouble;
u2 : GLdouble;
stride : GLint;
order : GLint;
points : access GLdouble);
procedure glMap1f
(target : GLenum;
u1 : GLfloat;
u2 : GLfloat;
stride : GLint;
order : GLint;
points : access GLfloat);
procedure glMap2d
(target : GLenum;
u1 : GLdouble;
u2 : GLdouble;
ustride : GLint;
uorder : GLint;
v1 : GLdouble;
v2 : GLdouble;
vstride : GLint;
vorder : GLint;
points : access GLdouble);
procedure glMap2f
(target : GLenum;
u1 : GLfloat;
u2 : GLfloat;
ustride : GLint;
uorder : GLint;
v1 : GLfloat;
v2 : GLfloat;
vstride : GLint;
vorder : GLint;
points : access GLfloat);
procedure glGetMapdv (target : GLenum; query : GLenum; v : access GLdouble);
procedure glGetMapfv (target : GLenum; query : GLenum; v : access GLfloat);
procedure glGetMapiv (target : GLenum; query : GLenum; v : access GLint);
procedure glEvalCoord1d (u : GLdouble);
procedure glEvalCoord1f (u : GLfloat);
procedure glEvalCoord1dv (u : access GLdouble);
procedure glEvalCoord1fv (u : access GLfloat);
procedure glEvalCoord2d (u : GLdouble; v : GLdouble);
procedure glEvalCoord2f (u : GLfloat; v : GLfloat);
procedure glEvalCoord2dv (u : access GLdouble);
procedure glEvalCoord2fv (u : access GLfloat);
procedure glMapGrid1d (un : GLint; u1 : GLdouble; u2 : GLdouble);
procedure glMapGrid1f (un : GLint; u1 : GLfloat; u2 : GLfloat);
procedure glMapGrid2d
(un : GLint;
u1 : GLdouble;
u2 : GLdouble;
vn : GLint;
v1 : GLdouble;
v2 : GLdouble);
procedure glMapGrid2f
(un : GLint;
u1 : GLfloat;
u2 : GLfloat;
vn : GLint;
v1 : GLfloat;
v2 : GLfloat);
procedure glEvalPoint1 (i : GLint);
procedure glEvalPoint2 (i : GLint; j : GLint);
procedure glEvalMesh1 (mode : GLenum; i1 : GLint; i2 : GLint);
procedure glEvalMesh2
(mode : GLenum;
i1 : GLint;
i2 : GLint;
j1 : GLint;
j2 : GLint);
procedure glFogf (pname : GLenum; param : GLfloat);
procedure glFogi (pname : GLenum; param : GLint);
procedure glFogfv (pname : GLenum; params : access GLfloat);
procedure glFogiv (pname : GLenum; params : access GLint);
procedure glFeedbackBuffer (size : GLsizei; c_type : GLenum; buffer : access GLfloat);
procedure glPassThrough (token : GLfloat);
procedure glSelectBuffer (size : GLsizei; buffer : access GLuint);
procedure glInitNames;
procedure glLoadName (name : GLuint);
procedure glPushName (name : GLuint);
procedure glPopName;
procedure glGenTextures (n : GLsizei; textures : access GLuint);
procedure glDeleteTextures (n : GLsizei; textures : access GLuint);
procedure glBindTexture (target : GLenum; texture : GLuint);
procedure glPrioritizeTextures (n : GLsizei; textures : access GLuint; priorities : access GLclampf);
function glAreTexturesResident
(n : GLsizei;
textures : access GLuint;
residences : access GLboolean)
return GLboolean;
function glIsTexture (texture : GLuint) return GLboolean;
procedure glTexSubImage1D
(target : GLenum;
level : GLint;
xoffset : GLint;
width : GLsizei;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glTexSubImage2D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
width : GLsizei;
height : GLsizei;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glCopyTexImage1D
(target : GLenum;
level : GLint;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei;
border : GLint);
procedure glCopyTexImage2D
(target : GLenum;
level : GLint;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei;
border : GLint);
procedure glCopyTexSubImage1D
(target : GLenum;
level : GLint;
xoffset : GLint;
x : GLint;
y : GLint;
width : GLsizei);
procedure glCopyTexSubImage2D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glVertexPointer
(size : GLint;
c_type : GLenum;
stride : GLsizei;
ptr : GLvoid_Ptr);
procedure glNormalPointer (c_type : GLenum; stride : GLsizei; ptr : GLvoid_Ptr);
procedure glColorPointer
(size : GLint;
c_type : GLenum;
stride : GLsizei;
ptr : GLvoid_Ptr);
procedure glIndexPointer (c_type : GLenum; stride : GLsizei; ptr : GLvoid_Ptr);
procedure glTexCoordPointer
(size : GLint;
c_type : GLenum;
stride : GLsizei;
ptr : GLvoid_Ptr);
procedure glEdgeFlagPointer (stride : GLsizei; ptr : GLvoid_Ptr);
procedure glGetPointerv (pname : GLenum; params : GLvoid_Ptr);
procedure glArrayElement (i : GLint);
procedure glDrawArrays (mode : GLenum; first : GLint; count : GLsizei);
procedure glDrawElements
(mode : GLenum;
count : GLsizei;
c_type : GLenum;
indices : GLvoid_Ptr);
procedure glInterleavedArrays (format : GLenum; stride : GLsizei; pointer : GLvoid_Ptr);
procedure glDrawRangeElements
(mode : GLenum;
start : GLuint;
c_end : GLuint;
count : GLsizei;
c_type : GLenum;
indices : GLvoid_Ptr);
procedure glTexImage3D
(target : GLenum;
level : GLint;
internalFormat : GLenum;
width : GLsizei;
height : GLsizei;
depth : GLsizei;
border : GLint;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glTexSubImage3D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
zoffset : GLint;
width : GLsizei;
height : GLsizei;
depth : GLsizei;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glCopyTexSubImage3D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
zoffset : GLint;
x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glColorTable
(target : GLenum;
internalformat : GLenum;
width : GLsizei;
format : GLenum;
c_type : GLenum;
table : GLvoid_Ptr);
procedure glColorSubTable
(target : GLenum;
start : GLsizei;
count : GLsizei;
format : GLenum;
c_type : GLenum;
data : GLvoid_Ptr);
procedure glColorTableParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glColorTableParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glCopyColorSubTable
(target : GLenum;
start : GLsizei;
x : GLint;
y : GLint;
width : GLsizei);
procedure glCopyColorTable
(target : GLenum;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei);
procedure glGetColorTable
(target : GLenum;
format : GLenum;
c_type : GLenum;
table : GLvoid_Ptr);
procedure glGetColorTableParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetColorTableParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glBlendEquation (mode : GLenum);
procedure glBlendColor
(red : GLclampf;
green : GLclampf;
blue : GLclampf;
alpha : GLclampf);
procedure glHistogram
(target : GLenum;
width : GLsizei;
internalformat : GLenum;
sink : GLboolean);
procedure glResetHistogram (target : GLenum);
procedure glGetHistogram
(target : GLenum;
reset : GLboolean;
format : GLenum;
c_type : GLenum;
values : GLvoid_Ptr);
procedure glGetHistogramParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetHistogramParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glMinmax (target : GLenum; internalformat : GLenum; sink : GLboolean);
procedure glResetMinmax (target : GLenum);
procedure glGetMinmax
(target : GLenum;
reset : GLboolean;
format : GLenum;
types : GLenum;
values : GLvoid_Ptr);
procedure glGetMinmaxParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetMinmaxParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glConvolutionFilter1D
(target : GLenum;
internalformat : GLenum;
width : GLsizei;
format : GLenum;
c_type : GLenum;
image : GLvoid_Ptr);
procedure glConvolutionFilter2D
(target : GLenum;
internalformat : GLenum;
width : GLsizei;
height : GLsizei;
format : GLenum;
c_type : GLenum;
image : GLvoid_Ptr);
procedure glConvolutionParameterf (target : GLenum; pname : GLenum; params : GLfloat);
procedure glConvolutionParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glConvolutionParameteri (target : GLenum; pname : GLenum; params : GLint);
procedure glConvolutionParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glCopyConvolutionFilter1D
(target : GLenum;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei);
procedure glCopyConvolutionFilter2D
(target : GLenum;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glGetConvolutionFilter
(target : GLenum;
format : GLenum;
c_type : GLenum;
image : GLvoid_Ptr);
procedure glGetConvolutionParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetConvolutionParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glSeparableFilter2D
(target : GLenum;
internalformat : GLenum;
width : GLsizei;
height : GLsizei;
format : GLenum;
c_type : GLenum;
row : GLvoid_Ptr;
column : GLvoid_Ptr);
procedure glGetSeparableFilter
(target : GLenum;
format : GLenum;
c_type : GLenum;
row : GLvoid_Ptr;
column : GLvoid_Ptr;
span : GLvoid_Ptr);
procedure glActiveTexture (texture : GLenum);
procedure glClientActiveTexture (texture : GLenum);
procedure glCompressedTexImage1D
(target : GLenum;
level : GLint;
internalformat : GLenum;
width : GLsizei;
border : GLint;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glCompressedTexImage2D
(target : GLenum;
level : GLint;
internalformat : GLenum;
width : GLsizei;
height : GLsizei;
border : GLint;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glCompressedTexImage3D
(target : GLenum;
level : GLint;
internalformat : GLenum;
width : GLsizei;
height : GLsizei;
depth : GLsizei;
border : GLint;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glCompressedTexSubImage1D
(target : GLenum;
level : GLint;
xoffset : GLint;
width : GLsizei;
format : GLenum;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glCompressedTexSubImage2D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
width : GLsizei;
height : GLsizei;
format : GLenum;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glCompressedTexSubImage3D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
zoffset : GLint;
width : GLsizei;
height : GLsizei;
depth : GLsizei;
format : GLenum;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glGetCompressedTexImage (target : GLenum; lod : GLint; img : GLvoid_Ptr);
procedure glMultiTexCoord1d (target : GLenum; s : GLdouble);
procedure glMultiTexCoord1dv (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord1f (target : GLenum; s : GLfloat);
procedure glMultiTexCoord1fv (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord1i (target : GLenum; s : GLint);
procedure glMultiTexCoord1iv (target : GLenum; v : access GLint);
procedure glMultiTexCoord1s (target : GLenum; s : GLshort);
procedure glMultiTexCoord1sv (target : GLenum; v : access GLshort);
procedure glMultiTexCoord2d (target : GLenum; s : GLdouble; t : GLdouble);
procedure glMultiTexCoord2dv (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord2f (target : GLenum; s : GLfloat; t : GLfloat);
procedure glMultiTexCoord2fv (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord2i (target : GLenum; s : GLint; t : GLint);
procedure glMultiTexCoord2iv (target : GLenum; v : access GLint);
procedure glMultiTexCoord2s (target : GLenum; s : GLshort; t : GLshort);
procedure glMultiTexCoord2sv (target : GLenum; v : access GLshort);
procedure glMultiTexCoord3d
(target : GLenum;
s : GLdouble;
t : GLdouble;
r : GLdouble);
procedure glMultiTexCoord3dv (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord3f
(target : GLenum;
s : GLfloat;
t : GLfloat;
r : GLfloat);
procedure glMultiTexCoord3fv (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord3i
(target : GLenum;
s : GLint;
t : GLint;
r : GLint);
procedure glMultiTexCoord3iv (target : GLenum; v : access GLint);
procedure glMultiTexCoord3s
(target : GLenum;
s : GLshort;
t : GLshort;
r : GLshort);
procedure glMultiTexCoord3sv (target : GLenum; v : access GLshort);
procedure glMultiTexCoord4d
(target : GLenum;
s : GLdouble;
t : GLdouble;
r : GLdouble;
q : GLdouble);
procedure glMultiTexCoord4dv (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord4f
(target : GLenum;
s : GLfloat;
t : GLfloat;
r : GLfloat;
q : GLfloat);
procedure glMultiTexCoord4fv (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord4i
(target : GLenum;
s : GLint;
t : GLint;
r : GLint;
q : GLint);
procedure glMultiTexCoord4iv (target : GLenum; v : access GLint);
procedure glMultiTexCoord4s
(target : GLenum;
s : GLshort;
t : GLshort;
r : GLshort;
q : GLshort);
procedure glMultiTexCoord4sv (target : GLenum; v : access GLshort);
procedure glLoadTransposeMatrixd (m : access GLdouble);
procedure glLoadTransposeMatrixf (m : access GLfloat);
procedure glMultTransposeMatrixd (m : access GLdouble);
procedure glMultTransposeMatrixf (m : access GLfloat);
procedure glSampleCoverage (value : GLclampf; invert : GLboolean);
procedure glSamplePass (pass : GLenum);
private
pragma Import (Stdcall, glClearIndex, "glClearIndex");
pragma Import (Stdcall, glClearColor, "glClearColor");
pragma Import (Stdcall, glClear, "glClear");
pragma Import (Stdcall, glIndexMask, "glIndexMask");
pragma Import (Stdcall, glColorMask, "glColorMask");
pragma Import (Stdcall, glAlphaFunc, "glAlphaFunc");
pragma Import (Stdcall, glBlendFunc, "glBlendFunc");
pragma Import (Stdcall, glLogicOp, "glLogicOp");
pragma Import (Stdcall, glCullFace, "glCullFace");
pragma Import (Stdcall, glFrontFace, "glFrontFace");
pragma Import (Stdcall, glPointSize, "glPointSize");
pragma Import (Stdcall, glLineWidth, "glLineWidth");
pragma Import (Stdcall, glLineStipple, "glLineStipple");
pragma Import (Stdcall, glPolygonMode, "glPolygonMode");
pragma Import (Stdcall, glPolygonOffset, "glPolygonOffset");
pragma Import (Stdcall, glPolygonStipple, "glPolygonStipple");
pragma Import (Stdcall, glGetPolygonStipple, "glGetPolygonStipple");
pragma Import (Stdcall, glEdgeFlag, "glEdgeFlag");
pragma Import (Stdcall, glEdgeFlagv, "glEdgeFlagv");
pragma Import (Stdcall, glScissor, "glScissor");
pragma Import (Stdcall, glClipPlane, "glClipPlane");
pragma Import (Stdcall, glGetClipPlane, "glGetClipPlane");
pragma Import (Stdcall, glDrawBuffer, "glDrawBuffer");
pragma Import (Stdcall, glReadBuffer, "glReadBuffer");
pragma Import (Stdcall, glEnable, "glEnable");
pragma Import (Stdcall, glDisable, "glDisable");
pragma Import (Stdcall, glIsEnabled, "glIsEnabled");
pragma Import (Stdcall, glEnableClientState, "glEnableClientState");
pragma Import (Stdcall, glDisableClientState, "glDisableClientState");
pragma Import (Stdcall, glGetBooleanv, "glGetBooleanv");
pragma Import (Stdcall, glGetDoublev, "glGetDoublev");
pragma Import (Stdcall, glGetFloatv, "glGetFloatv");
pragma Import (Stdcall, glGetIntegerv, "glGetIntegerv");
pragma Import (Stdcall, glPushAttrib, "glPushAttrib");
pragma Import (Stdcall, glPopAttrib, "glPopAttrib");
pragma Import (Stdcall, glPushClientAttrib, "glPushClientAttrib");
pragma Import (Stdcall, glPopClientAttrib, "glPopClientAttrib");
pragma Import (Stdcall, glRenderMode, "glRenderMode");
pragma Import (Stdcall, glGetError, "glGetError");
pragma Import (Stdcall, glGetString, "glGetString");
pragma Import (Stdcall, glFinish, "glFinish");
pragma Import (Stdcall, glFlush, "glFlush");
pragma Import (Stdcall, glHint, "glHint");
pragma Import (Stdcall, glClearDepth, "glClearDepth");
pragma Import (Stdcall, glDepthFunc, "glDepthFunc");
pragma Import (Stdcall, glDepthMask, "glDepthMask");
pragma Import (Stdcall, glDepthRange, "glDepthRange");
pragma Import (Stdcall, glClearAccum, "glClearAccum");
pragma Import (Stdcall, glAccum, "glAccum");
pragma Import (Stdcall, glMatrixMode, "glMatrixMode");
pragma Import (Stdcall, glOrtho, "glOrtho");
pragma Import (Stdcall, glFrustum, "glFrustum");
pragma Import (Stdcall, glViewport, "glViewport");
pragma Import (Stdcall, glPushMatrix, "glPushMatrix");
pragma Import (Stdcall, glPopMatrix, "glPopMatrix");
pragma Import (Stdcall, glLoadIdentity, "glLoadIdentity");
pragma Import (Stdcall, glLoadMatrixd, "glLoadMatrixd");
pragma Import (Stdcall, glLoadMatrixf, "glLoadMatrixf");
pragma Import (Stdcall, glMultMatrixd, "glMultMatrixd");
pragma Import (Stdcall, glMultMatrixf, "glMultMatrixf");
pragma Import (Stdcall, glRotated, "glRotated");
pragma Import (Stdcall, glRotatef, "glRotatef");
pragma Import (Stdcall, glScaled, "glScaled");
pragma Import (Stdcall, glScalef, "glScalef");
pragma Import (Stdcall, glTranslated, "glTranslated");
pragma Import (Stdcall, glTranslatef, "glTranslatef");
pragma Import (Stdcall, glIsList, "glIsList");
pragma Import (Stdcall, glDeleteLists, "glDeleteLists");
pragma Import (Stdcall, glGenLists, "glGenLists");
pragma Import (Stdcall, glNewList, "glNewList");
pragma Import (Stdcall, glEndList, "glEndList");
pragma Import (Stdcall, glCallList, "glCallList");
pragma Import (Stdcall, glCallLists, "glCallLists");
pragma Import (Stdcall, glListBase, "glListBase");
pragma Import (Stdcall, glBegin, "glBegin");
pragma Import (Stdcall, glEnd, "glEnd");
pragma Import (Stdcall, glVertex2d, "glVertex2d");
pragma Import (Stdcall, glVertex2f, "glVertex2f");
pragma Import (Stdcall, glVertex2i, "glVertex2i");
pragma Import (Stdcall, glVertex2s, "glVertex2s");
pragma Import (Stdcall, glVertex3d, "glVertex3d");
pragma Import (Stdcall, glVertex3f, "glVertex3f");
pragma Import (Stdcall, glVertex3i, "glVertex3i");
pragma Import (Stdcall, glVertex3s, "glVertex3s");
pragma Import (Stdcall, glVertex4d, "glVertex4d");
pragma Import (Stdcall, glVertex4f, "glVertex4f");
pragma Import (Stdcall, glVertex4i, "glVertex4i");
pragma Import (Stdcall, glVertex4s, "glVertex4s");
pragma Import (Stdcall, glVertex2dv, "glVertex2dv");
pragma Import (Stdcall, glVertex2fv, "glVertex2fv");
pragma Import (Stdcall, glVertex2iv, "glVertex2iv");
pragma Import (Stdcall, glVertex2sv, "glVertex2sv");
pragma Import (Stdcall, glVertex3dv, "glVertex3dv");
pragma Import (Stdcall, glVertex3fv, "glVertex3fv");
pragma Import (Stdcall, glVertex3iv, "glVertex3iv");
pragma Import (Stdcall, glVertex3sv, "glVertex3sv");
pragma Import (Stdcall, glVertex4dv, "glVertex4dv");
pragma Import (Stdcall, glVertex4fv, "glVertex4fv");
pragma Import (Stdcall, glVertex4iv, "glVertex4iv");
pragma Import (Stdcall, glVertex4sv, "glVertex4sv");
pragma Import (Stdcall, glNormal3b, "glNormal3b");
pragma Import (Stdcall, glNormal3d, "glNormal3d");
pragma Import (Stdcall, glNormal3f, "glNormal3f");
pragma Import (Stdcall, glNormal3i, "glNormal3i");
pragma Import (Stdcall, glNormal3s, "glNormal3s");
pragma Import (Stdcall, glNormal3bv, "glNormal3bv");
pragma Import (Stdcall, glNormal3dv, "glNormal3dv");
pragma Import (Stdcall, glNormal3fv, "glNormal3fv");
pragma Import (Stdcall, glNormal3iv, "glNormal3iv");
pragma Import (Stdcall, glNormal3sv, "glNormal3sv");
pragma Import (Stdcall, glIndexd, "glIndexd");
pragma Import (Stdcall, glIndexf, "glIndexf");
pragma Import (Stdcall, glIndexi, "glIndexi");
pragma Import (Stdcall, glIndexs, "glIndexs");
pragma Import (Stdcall, glIndexub, "glIndexub");
pragma Import (Stdcall, glIndexdv, "glIndexdv");
pragma Import (Stdcall, glIndexfv, "glIndexfv");
pragma Import (Stdcall, glIndexiv, "glIndexiv");
pragma Import (Stdcall, glIndexsv, "glIndexsv");
pragma Import (Stdcall, glIndexubv, "glIndexubv");
pragma Import (Stdcall, glColor3b, "glColor3b");
pragma Import (Stdcall, glColor3d, "glColor3d");
pragma Import (Stdcall, glColor3f, "glColor3f");
pragma Import (Stdcall, glColor3i, "glColor3i");
pragma Import (Stdcall, glColor3s, "glColor3s");
pragma Import (Stdcall, glColor3ub, "glColor3ub");
pragma Import (Stdcall, glColor3ui, "glColor3ui");
pragma Import (Stdcall, glColor3us, "glColor3us");
pragma Import (Stdcall, glColor4b, "glColor4b");
pragma Import (Stdcall, glColor4d, "glColor4d");
pragma Import (Stdcall, glColor4f, "glColor4f");
pragma Import (Stdcall, glColor4i, "glColor4i");
pragma Import (Stdcall, glColor4s, "glColor4s");
pragma Import (Stdcall, glColor4ub, "glColor4ub");
pragma Import (Stdcall, glColor4ui, "glColor4ui");
pragma Import (Stdcall, glColor4us, "glColor4us");
pragma Import (Stdcall, glColor3bv, "glColor3bv");
pragma Import (Stdcall, glColor3dv, "glColor3dv");
pragma Import (Stdcall, glColor3fv, "glColor3fv");
pragma Import (Stdcall, glColor3iv, "glColor3iv");
pragma Import (Stdcall, glColor3sv, "glColor3sv");
pragma Import (Stdcall, glColor3ubv, "glColor3ubv");
pragma Import (Stdcall, glColor3uiv, "glColor3uiv");
pragma Import (Stdcall, glColor3usv, "glColor3usv");
pragma Import (Stdcall, glColor4bv, "glColor4bv");
pragma Import (Stdcall, glColor4dv, "glColor4dv");
pragma Import (Stdcall, glColor4fv, "glColor4fv");
pragma Import (Stdcall, glColor4iv, "glColor4iv");
pragma Import (Stdcall, glColor4sv, "glColor4sv");
pragma Import (Stdcall, glColor4ubv, "glColor4ubv");
pragma Import (Stdcall, glColor4uiv, "glColor4uiv");
pragma Import (Stdcall, glColor4usv, "glColor4usv");
pragma Import (Stdcall, glTexCoord1d, "glTexCoord1d");
pragma Import (Stdcall, glTexCoord1f, "glTexCoord1f");
pragma Import (Stdcall, glTexCoord1i, "glTexCoord1i");
pragma Import (Stdcall, glTexCoord1s, "glTexCoord1s");
pragma Import (Stdcall, glTexCoord2d, "glTexCoord2d");
pragma Import (Stdcall, glTexCoord2f, "glTexCoord2f");
pragma Import (Stdcall, glTexCoord2i, "glTexCoord2i");
pragma Import (Stdcall, glTexCoord2s, "glTexCoord2s");
pragma Import (Stdcall, glTexCoord3d, "glTexCoord3d");
pragma Import (Stdcall, glTexCoord3f, "glTexCoord3f");
pragma Import (Stdcall, glTexCoord3i, "glTexCoord3i");
pragma Import (Stdcall, glTexCoord3s, "glTexCoord3s");
pragma Import (Stdcall, glTexCoord4d, "glTexCoord4d");
pragma Import (Stdcall, glTexCoord4f, "glTexCoord4f");
pragma Import (Stdcall, glTexCoord4i, "glTexCoord4i");
pragma Import (Stdcall, glTexCoord4s, "glTexCoord4s");
pragma Import (Stdcall, glTexCoord1dv, "glTexCoord1dv");
pragma Import (Stdcall, glTexCoord1fv, "glTexCoord1fv");
pragma Import (Stdcall, glTexCoord1iv, "glTexCoord1iv");
pragma Import (Stdcall, glTexCoord1sv, "glTexCoord1sv");
pragma Import (Stdcall, glTexCoord2dv, "glTexCoord2dv");
pragma Import (Stdcall, glTexCoord2fv, "glTexCoord2fv");
pragma Import (Stdcall, glTexCoord2iv, "glTexCoord2iv");
pragma Import (Stdcall, glTexCoord2sv, "glTexCoord2sv");
pragma Import (Stdcall, glTexCoord3dv, "glTexCoord3dv");
pragma Import (Stdcall, glTexCoord3fv, "glTexCoord3fv");
pragma Import (Stdcall, glTexCoord3iv, "glTexCoord3iv");
pragma Import (Stdcall, glTexCoord3sv, "glTexCoord3sv");
pragma Import (Stdcall, glTexCoord4dv, "glTexCoord4dv");
pragma Import (Stdcall, glTexCoord4fv, "glTexCoord4fv");
pragma Import (Stdcall, glTexCoord4iv, "glTexCoord4iv");
pragma Import (Stdcall, glTexCoord4sv, "glTexCoord4sv");
pragma Import (Stdcall, glRasterPos2d, "glRasterPos2d");
pragma Import (Stdcall, glRasterPos2f, "glRasterPos2f");
pragma Import (Stdcall, glRasterPos2i, "glRasterPos2i");
pragma Import (Stdcall, glRasterPos2s, "glRasterPos2s");
pragma Import (Stdcall, glRasterPos3d, "glRasterPos3d");
pragma Import (Stdcall, glRasterPos3f, "glRasterPos3f");
pragma Import (Stdcall, glRasterPos3i, "glRasterPos3i");
pragma Import (Stdcall, glRasterPos3s, "glRasterPos3s");
pragma Import (Stdcall, glRasterPos4d, "glRasterPos4d");
pragma Import (Stdcall, glRasterPos4f, "glRasterPos4f");
pragma Import (Stdcall, glRasterPos4i, "glRasterPos4i");
pragma Import (Stdcall, glRasterPos4s, "glRasterPos4s");
pragma Import (Stdcall, glRasterPos2dv, "glRasterPos2dv");
pragma Import (Stdcall, glRasterPos2fv, "glRasterPos2fv");
pragma Import (Stdcall, glRasterPos2iv, "glRasterPos2iv");
pragma Import (Stdcall, glRasterPos2sv, "glRasterPos2sv");
pragma Import (Stdcall, glRasterPos3dv, "glRasterPos3dv");
pragma Import (Stdcall, glRasterPos3fv, "glRasterPos3fv");
pragma Import (Stdcall, glRasterPos3iv, "glRasterPos3iv");
pragma Import (Stdcall, glRasterPos3sv, "glRasterPos3sv");
pragma Import (Stdcall, glRasterPos4dv, "glRasterPos4dv");
pragma Import (Stdcall, glRasterPos4fv, "glRasterPos4fv");
pragma Import (Stdcall, glRasterPos4iv, "glRasterPos4iv");
pragma Import (Stdcall, glRasterPos4sv, "glRasterPos4sv");
pragma Import (Stdcall, glRectd, "glRectd");
pragma Import (Stdcall, glRectf, "glRectf");
pragma Import (Stdcall, glRecti, "glRecti");
pragma Import (Stdcall, glRects, "glRects");
pragma Import (Stdcall, glRectdv, "glRectdv");
pragma Import (Stdcall, glRectfv, "glRectfv");
pragma Import (Stdcall, glRectiv, "glRectiv");
pragma Import (Stdcall, glRectsv, "glRectsv");
pragma Import (Stdcall, glShadeModel, "glShadeModel");
pragma Import (Stdcall, glLightf, "glLightf");
pragma Import (Stdcall, glLighti, "glLighti");
pragma Import (Stdcall, glLightfv, "glLightfv");
pragma Import (Stdcall, glLightiv, "glLightiv");
pragma Import (Stdcall, glGetLightfv, "glGetLightfv");
pragma Import (Stdcall, glGetLightiv, "glGetLightiv");
pragma Import (Stdcall, glLightModelf, "glLightModelf");
pragma Import (Stdcall, glLightModeli, "glLightModeli");
pragma Import (Stdcall, glLightModelfv, "glLightModelfv");
pragma Import (Stdcall, glLightModeliv, "glLightModeliv");
pragma Import (Stdcall, glMaterialf, "glMaterialf");
pragma Import (Stdcall, glMateriali, "glMateriali");
pragma Import (Stdcall, glMaterialfv, "glMaterialfv");
pragma Import (Stdcall, glMaterialiv, "glMaterialiv");
pragma Import (Stdcall, glGetMaterialfv, "glGetMaterialfv");
pragma Import (Stdcall, glGetMaterialiv, "glGetMaterialiv");
pragma Import (Stdcall, glColorMaterial, "glColorMaterial");
pragma Import (Stdcall, glPixelZoom, "glPixelZoom");
pragma Import (Stdcall, glPixelStoref, "glPixelStoref");
pragma Import (Stdcall, glPixelStorei, "glPixelStorei");
pragma Import (Stdcall, glPixelTransferf, "glPixelTransferf");
pragma Import (Stdcall, glPixelTransferi, "glPixelTransferi");
pragma Import (Stdcall, glPixelMapfv, "glPixelMapfv");
pragma Import (Stdcall, glPixelMapuiv, "glPixelMapuiv");
pragma Import (Stdcall, glPixelMapusv, "glPixelMapusv");
pragma Import (Stdcall, glGetPixelMapfv, "glGetPixelMapfv");
pragma Import (Stdcall, glGetPixelMapuiv, "glGetPixelMapuiv");
pragma Import (Stdcall, glGetPixelMapusv, "glGetPixelMapusv");
pragma Import (Stdcall, glBitmap, "glBitmap");
pragma Import (Stdcall, glReadPixels, "glReadPixels");
pragma Import (Stdcall, glDrawPixels, "glDrawPixels");
pragma Import (Stdcall, glCopyPixels, "glCopyPixels");
pragma Import (Stdcall, glStencilFunc, "glStencilFunc");
pragma Import (Stdcall, glStencilMask, "glStencilMask");
pragma Import (Stdcall, glStencilOp, "glStencilOp");
pragma Import (Stdcall, glClearStencil, "glClearStencil");
pragma Import (Stdcall, glTexGend, "glTexGend");
pragma Import (Stdcall, glTexGenf, "glTexGenf");
pragma Import (Stdcall, glTexGeni, "glTexGeni");
pragma Import (Stdcall, glTexGendv, "glTexGendv");
pragma Import (Stdcall, glTexGenfv, "glTexGenfv");
pragma Import (Stdcall, glTexGeniv, "glTexGeniv");
pragma Import (Stdcall, glGetTexGendv, "glGetTexGendv");
pragma Import (Stdcall, glGetTexGenfv, "glGetTexGenfv");
pragma Import (Stdcall, glGetTexGeniv, "glGetTexGeniv");
pragma Import (Stdcall, glTexEnvf, "glTexEnvf");
pragma Import (Stdcall, glTexEnvi, "glTexEnvi");
pragma Import (Stdcall, glTexEnvfv, "glTexEnvfv");
pragma Import (Stdcall, glTexEnviv, "glTexEnviv");
pragma Import (Stdcall, glGetTexEnvfv, "glGetTexEnvfv");
pragma Import (Stdcall, glGetTexEnviv, "glGetTexEnviv");
pragma Import (Stdcall, glTexParameterf, "glTexParameterf");
pragma Import (Stdcall, glTexParameteri, "glTexParameteri");
pragma Import (Stdcall, glTexParameterfv, "glTexParameterfv");
pragma Import (Stdcall, glTexParameteriv, "glTexParameteriv");
pragma Import (Stdcall, glGetTexParameterfv, "glGetTexParameterfv");
pragma Import (Stdcall, glGetTexParameteriv, "glGetTexParameteriv");
pragma Import (Stdcall, glGetTexLevelParameterfv, "glGetTexLevelParameterfv");
pragma Import (Stdcall, glGetTexLevelParameteriv, "glGetTexLevelParameteriv");
pragma Import (Stdcall, glTexImage1D, "glTexImage1D");
pragma Import (Stdcall, glTexImage2D, "glTexImage2D");
pragma Import (Stdcall, glGetTexImage, "glGetTexImage");
pragma Import (Stdcall, glMap1d, "glMap1d");
pragma Import (Stdcall, glMap1f, "glMap1f");
pragma Import (Stdcall, glMap2d, "glMap2d");
pragma Import (Stdcall, glMap2f, "glMap2f");
pragma Import (Stdcall, glGetMapdv, "glGetMapdv");
pragma Import (Stdcall, glGetMapfv, "glGetMapfv");
pragma Import (Stdcall, glGetMapiv, "glGetMapiv");
pragma Import (Stdcall, glEvalCoord1d, "glEvalCoord1d");
pragma Import (Stdcall, glEvalCoord1f, "glEvalCoord1f");
pragma Import (Stdcall, glEvalCoord1dv, "glEvalCoord1dv");
pragma Import (Stdcall, glEvalCoord1fv, "glEvalCoord1fv");
pragma Import (Stdcall, glEvalCoord2d, "glEvalCoord2d");
pragma Import (Stdcall, glEvalCoord2f, "glEvalCoord2f");
pragma Import (Stdcall, glEvalCoord2dv, "glEvalCoord2dv");
pragma Import (Stdcall, glEvalCoord2fv, "glEvalCoord2fv");
pragma Import (Stdcall, glMapGrid1d, "glMapGrid1d");
pragma Import (Stdcall, glMapGrid1f, "glMapGrid1f");
pragma Import (Stdcall, glMapGrid2d, "glMapGrid2d");
pragma Import (Stdcall, glMapGrid2f, "glMapGrid2f");
pragma Import (Stdcall, glEvalPoint1, "glEvalPoint1");
pragma Import (Stdcall, glEvalPoint2, "glEvalPoint2");
pragma Import (Stdcall, glEvalMesh1, "glEvalMesh1");
pragma Import (Stdcall, glEvalMesh2, "glEvalMesh2");
pragma Import (Stdcall, glFogf, "glFogf");
pragma Import (Stdcall, glFogi, "glFogi");
pragma Import (Stdcall, glFogfv, "glFogfv");
pragma Import (Stdcall, glFogiv, "glFogiv");
pragma Import (Stdcall, glFeedbackBuffer, "glFeedbackBuffer");
pragma Import (Stdcall, glPassThrough, "glPassThrough");
pragma Import (Stdcall, glSelectBuffer, "glSelectBuffer");
pragma Import (Stdcall, glInitNames, "glInitNames");
pragma Import (Stdcall, glLoadName, "glLoadName");
pragma Import (Stdcall, glPushName, "glPushName");
pragma Import (Stdcall, glPopName, "glPopName");
pragma Import (Stdcall, glGenTextures, "glGenTextures");
pragma Import (Stdcall, glDeleteTextures, "glDeleteTextures");
pragma Import (Stdcall, glBindTexture, "glBindTexture");
pragma Import (Stdcall, glPrioritizeTextures, "glPrioritizeTextures");
pragma Import (Stdcall, glAreTexturesResident, "glAreTexturesResident");
pragma Import (Stdcall, glIsTexture, "glIsTexture");
pragma Import (Stdcall, glTexSubImage1D, "glTexSubImage1D");
pragma Import (Stdcall, glTexSubImage2D, "glTexSubImage2D");
pragma Import (Stdcall, glCopyTexImage1D, "glCopyTexImage1D");
pragma Import (Stdcall, glCopyTexImage2D, "glCopyTexImage2D");
pragma Import (Stdcall, glCopyTexSubImage1D, "glCopyTexSubImage1D");
pragma Import (Stdcall, glCopyTexSubImage2D, "glCopyTexSubImage2D");
pragma Import (Stdcall, glVertexPointer, "glVertexPointer");
pragma Import (Stdcall, glNormalPointer, "glNormalPointer");
pragma Import (Stdcall, glColorPointer, "glColorPointer");
pragma Import (Stdcall, glIndexPointer, "glIndexPointer");
pragma Import (Stdcall, glTexCoordPointer, "glTexCoordPointer");
pragma Import (Stdcall, glEdgeFlagPointer, "glEdgeFlagPointer");
pragma Import (Stdcall, glGetPointerv, "glGetPointerv");
pragma Import (Stdcall, glArrayElement, "glArrayElement");
pragma Import (Stdcall, glDrawArrays, "glDrawArrays");
pragma Import (Stdcall, glDrawElements, "glDrawElements");
pragma Import (Stdcall, glInterleavedArrays, "glInterleavedArrays");
pragma Import (Stdcall, glDrawRangeElements, "glDrawRangeElements");
pragma Import (Stdcall, glTexImage3D, "glTexImage3D");
pragma Import (Stdcall, glTexSubImage3D, "glTexSubImage3D");
pragma Import (Stdcall, glCopyTexSubImage3D, "glCopyTexSubImage3D");
pragma Import (Stdcall, glColorTable, "glColorTable");
pragma Import (Stdcall, glColorSubTable, "glColorSubTable");
pragma Import (Stdcall, glColorTableParameteriv, "glColorTableParameteriv");
pragma Import (Stdcall, glColorTableParameterfv, "glColorTableParameterfv");
pragma Import (Stdcall, glCopyColorSubTable, "glCopyColorSubTable");
pragma Import (Stdcall, glCopyColorTable, "glCopyColorTable");
pragma Import (Stdcall, glGetColorTable, "glGetColorTable");
pragma Import (Stdcall, glGetColorTableParameterfv, "glGetColorTableParameterfv");
pragma Import (Stdcall, glGetColorTableParameteriv, "glGetColorTableParameteriv");
pragma Import (Stdcall, glBlendEquation, "glBlendEquation");
pragma Import (Stdcall, glBlendColor, "glBlendColor");
pragma Import (Stdcall, glHistogram, "glHistogram");
pragma Import (Stdcall, glResetHistogram, "glResetHistogram");
pragma Import (Stdcall, glGetHistogram, "glGetHistogram");
pragma Import (Stdcall, glGetHistogramParameterfv, "glGetHistogramParameterfv");
pragma Import (Stdcall, glGetHistogramParameteriv, "glGetHistogramParameteriv");
pragma Import (Stdcall, glMinmax, "glMinmax");
pragma Import (Stdcall, glResetMinmax, "glResetMinmax");
pragma Import (Stdcall, glGetMinmax, "glGetMinmax");
pragma Import (Stdcall, glGetMinmaxParameterfv, "glGetMinmaxParameterfv");
pragma Import (Stdcall, glGetMinmaxParameteriv, "glGetMinmaxParameteriv");
pragma Import (Stdcall, glConvolutionFilter1D, "glConvolutionFilter1D");
pragma Import (Stdcall, glConvolutionFilter2D, "glConvolutionFilter2D");
pragma Import (Stdcall, glConvolutionParameterf, "glConvolutionParameterf");
pragma Import (Stdcall, glConvolutionParameterfv, "glConvolutionParameterfv");
pragma Import (Stdcall, glConvolutionParameteri, "glConvolutionParameteri");
pragma Import (Stdcall, glConvolutionParameteriv, "glConvolutionParameteriv");
pragma Import (Stdcall, glCopyConvolutionFilter1D, "glCopyConvolutionFilter1D");
pragma Import (Stdcall, glCopyConvolutionFilter2D, "glCopyConvolutionFilter2D");
pragma Import (Stdcall, glGetConvolutionFilter, "glGetConvolutionFilter");
pragma Import (Stdcall, glGetConvolutionParameterfv, "glGetConvolutionParameterfv");
pragma Import (Stdcall, glGetConvolutionParameteriv, "glGetConvolutionParameteriv");
pragma Import (Stdcall, glSeparableFilter2D, "glSeparableFilter2D");
pragma Import (Stdcall, glGetSeparableFilter, "glGetSeparableFilter");
pragma Import (Stdcall, glActiveTexture, "glActiveTexture");
pragma Import (Stdcall, glClientActiveTexture, "glClientActiveTexture");
pragma Import (Stdcall, glCompressedTexImage1D, "glCompressedTexImage1D");
pragma Import (Stdcall, glCompressedTexImage2D, "glCompressedTexImage2D");
pragma Import (Stdcall, glCompressedTexImage3D, "glCompressedTexImage3D");
pragma Import (Stdcall, glCompressedTexSubImage1D, "glCompressedTexSubImage1D");
pragma Import (Stdcall, glCompressedTexSubImage2D, "glCompressedTexSubImage2D");
pragma Import (Stdcall, glCompressedTexSubImage3D, "glCompressedTexSubImage3D");
pragma Import (Stdcall, glGetCompressedTexImage, "glGetCompressedTexImage");
pragma Import (Stdcall, glMultiTexCoord1d, "glMultiTexCoord1d");
pragma Import (Stdcall, glMultiTexCoord1dv, "glMultiTexCoord1dv");
pragma Import (Stdcall, glMultiTexCoord1f, "glMultiTexCoord1f");
pragma Import (Stdcall, glMultiTexCoord1fv, "glMultiTexCoord1fv");
pragma Import (Stdcall, glMultiTexCoord1i, "glMultiTexCoord1i");
pragma Import (Stdcall, glMultiTexCoord1iv, "glMultiTexCoord1iv");
pragma Import (Stdcall, glMultiTexCoord1s, "glMultiTexCoord1s");
pragma Import (Stdcall, glMultiTexCoord1sv, "glMultiTexCoord1sv");
pragma Import (Stdcall, glMultiTexCoord2d, "glMultiTexCoord2d");
pragma Import (Stdcall, glMultiTexCoord2dv, "glMultiTexCoord2dv");
pragma Import (Stdcall, glMultiTexCoord2f, "glMultiTexCoord2f");
pragma Import (Stdcall, glMultiTexCoord2fv, "glMultiTexCoord2fv");
pragma Import (Stdcall, glMultiTexCoord2i, "glMultiTexCoord2i");
pragma Import (Stdcall, glMultiTexCoord2iv, "glMultiTexCoord2iv");
pragma Import (Stdcall, glMultiTexCoord2s, "glMultiTexCoord2s");
pragma Import (Stdcall, glMultiTexCoord2sv, "glMultiTexCoord2sv");
pragma Import (Stdcall, glMultiTexCoord3d, "glMultiTexCoord3d");
pragma Import (Stdcall, glMultiTexCoord3dv, "glMultiTexCoord3dv");
pragma Import (Stdcall, glMultiTexCoord3f, "glMultiTexCoord3f");
pragma Import (Stdcall, glMultiTexCoord3fv, "glMultiTexCoord3fv");
pragma Import (Stdcall, glMultiTexCoord3i, "glMultiTexCoord3i");
pragma Import (Stdcall, glMultiTexCoord3iv, "glMultiTexCoord3iv");
pragma Import (Stdcall, glMultiTexCoord3s, "glMultiTexCoord3s");
pragma Import (Stdcall, glMultiTexCoord3sv, "glMultiTexCoord3sv");
pragma Import (Stdcall, glMultiTexCoord4d, "glMultiTexCoord4d");
pragma Import (Stdcall, glMultiTexCoord4dv, "glMultiTexCoord4dv");
pragma Import (Stdcall, glMultiTexCoord4f, "glMultiTexCoord4f");
pragma Import (Stdcall, glMultiTexCoord4fv, "glMultiTexCoord4fv");
pragma Import (Stdcall, glMultiTexCoord4i, "glMultiTexCoord4i");
pragma Import (Stdcall, glMultiTexCoord4iv, "glMultiTexCoord4iv");
pragma Import (Stdcall, glMultiTexCoord4s, "glMultiTexCoord4s");
pragma Import (Stdcall, glMultiTexCoord4sv, "glMultiTexCoord4sv");
pragma Import (Stdcall, glLoadTransposeMatrixd, "glLoadTransposeMatrixd");
pragma Import (Stdcall, glLoadTransposeMatrixf, "glLoadTransposeMatrixf");
pragma Import (Stdcall, glMultTransposeMatrixd, "glMultTransposeMatrixd");
pragma Import (Stdcall, glMultTransposeMatrixf, "glMultTransposeMatrixf");
pragma Import (Stdcall, glSampleCoverage, "glSampleCoverage");
pragma Import (Stdcall, glSamplePass, "glSamplePass");
end Sf.Window.GL;
| true | -- ////////////////////////////////////////////////////////////
-- //
-- // SFML - Simple and Fast Multimedia Library
-- // Copyright (C) 2007-2009 PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
-- //
-- // This software is provided 'as-is', without any express or implied warranty.
-- // In no event will the authors be held liable for any damages arising from the use of this software.
-- //
-- // Permission is granted to anyone to use this software for any purpose,
-- // including commercial applications, and to alter it and redistribute it freely,
-- // subject to the following restrictions:
-- //
-- // 1. The origin of this software must not be misrepresented;
-- // you must not claim that you wrote the original software.
-- // If you use this software in a product, an acknowledgment
-- // in the product documentation would be appreciated but is not required.
-- //
-- // 2. Altered source versions must be plainly marked as such,
-- // and must not be misrepresented as being the original software.
-- //
-- // 3. This notice may not be removed or altered from any source distribution.
-- //
-- ////////////////////////////////////////////////////////////
package Sf.Window.GL is
-- ////////////////////////////////////////////////////////////
-- // Define portable types
-- ////////////////////////////////////////////////////////////
type GLuint is mod 2 ** Integer'SIZE;
type GLuint_Ptr is access all GLuint;
type GLenum is mod 2 ** Integer'SIZE;
type GLbitfield is mod 2 ** Integer'SIZE;
type GLboolean is mod 256;
for GLboolean'SIZE use 8;
type GLvoid is null record;
type GLvoid_Ptr is access all GLvoid;
type GLbyte is range -128 .. 127;
for GLbyte'SIZE use 8;
type GLshort is new Short_Integer;
type GLint is new Integer;
type GLubyte is mod 256;
for GLubyte'SIZE use 8;
type GLubyte_Ptr is access all GLubyte;
type GLushort is mod 2 ** Short_Integer'SIZE;
type GLsizei is new Integer;
type GLfloat is new Float;
type GLclampf is new Float;
type GLdouble is new Long_Float;
type GLclampd is new Long_Float;
pragma Convention (C, GLuint);
pragma Convention (C, GLuint_Ptr);
pragma Convention (C, GLenum);
pragma Convention (C, GLbitfield);
pragma Convention (C, GLboolean);
pragma Convention (C, GLvoid);
pragma Convention (C, GLvoid_Ptr);
pragma Convention (C, GLbyte);
pragma Convention (C, GLshort);
pragma Convention (C, GLint);
pragma Convention (C, GLubyte);
pragma Convention (C, GLubyte_Ptr);
pragma Convention (C, GLushort);
pragma Convention (C, GLsizei);
pragma Convention (C, GLfloat);
pragma Convention (C, GLclampf);
pragma Convention (C, GLdouble);
pragma Convention (C, GLclampd);
-- ////////////////////////////////////////////////////////////
-- // Define constants
-- ////////////////////////////////////////////////////////////
GL_VERSION_1_1 : constant GLenum := 1;
GL_VERSION_1_2 : constant GLenum := 1;
GL_VERSION_1_3 : constant GLenum := 1;
GL_ARB_imaging : constant GLenum := 1;
GL_FALSE : constant GLboolean := 16#0#;
GL_TRUE : constant GLboolean := 16#1#;
GL_BYTE : constant GLenum := 16#1400#;
GL_UNSIGNED_BYTE : constant GLenum := 16#1401#;
GL_SHORT : constant GLenum := 16#1402#;
GL_UNSIGNED_SHORT : constant GLenum := 16#1403#;
GL_INT : constant GLenum := 16#1404#;
GL_UNSIGNED_INT : constant GLenum := 16#1405#;
GL_FLOAT : constant GLenum := 16#1406#;
GL_DOUBLE : constant GLenum := 16#140A#;
GL_2_BYTES : constant GLenum := 16#1407#;
GL_3_BYTES : constant GLenum := 16#1408#;
GL_4_BYTES : constant GLenum := 16#1409#;
GL_POINTS : constant GLenum := 16#0000#;
GL_LINES : constant GLenum := 16#0001#;
GL_LINE_LOOP : constant GLenum := 16#0002#;
GL_LINE_STRIP : constant GLenum := 16#0003#;
GL_TRIANGLES : constant GLenum := 16#0004#;
GL_TRIANGLE_STRIP : constant GLenum := 16#0005#;
GL_TRIANGLE_FAN : constant GLenum := 16#0006#;
GL_QUADS : constant GLenum := 16#0007#;
GL_QUAD_STRIP : constant GLenum := 16#0008#;
GL_POLYGON : constant GLenum := 16#0009#;
GL_VERTEX_ARRAY : constant GLenum := 16#8074#;
GL_NORMAL_ARRAY : constant GLenum := 16#8075#;
GL_COLOR_ARRAY : constant GLenum := 16#8076#;
GL_INDEX_ARRAY : constant GLenum := 16#8077#;
GL_TEXTURE_COORD_ARRAY : constant GLenum := 16#8078#;
GL_EDGE_FLAG_ARRAY : constant GLenum := 16#8079#;
GL_VERTEX_ARRAY_SIZE : constant GLenum := 16#807A#;
GL_VERTEX_ARRAY_TYPE : constant GLenum := 16#807B#;
GL_VERTEX_ARRAY_STRIDE : constant GLenum := 16#807C#;
GL_NORMAL_ARRAY_TYPE : constant GLenum := 16#807E#;
GL_NORMAL_ARRAY_STRIDE : constant GLenum := 16#807F#;
GL_COLOR_ARRAY_SIZE : constant GLenum := 16#8081#;
GL_COLOR_ARRAY_TYPE : constant GLenum := 16#8082#;
GL_COLOR_ARRAY_STRIDE : constant GLenum := 16#8083#;
GL_INDEX_ARRAY_TYPE : constant GLenum := 16#8085#;
GL_INDEX_ARRAY_STRIDE : constant GLenum := 16#8086#;
GL_TEXTURE_COORD_ARRAY_SIZE : constant GLenum := 16#8088#;
GL_TEXTURE_COORD_ARRAY_TYPE : constant GLenum := 16#8089#;
GL_TEXTURE_COORD_ARRAY_STRIDE : constant GLenum := 16#808A#;
GL_EDGE_FLAG_ARRAY_STRIDE : constant GLenum := 16#808C#;
GL_VERTEX_ARRAY_POINTER : constant GLenum := 16#808E#;
GL_NORMAL_ARRAY_POINTER : constant GLenum := 16#808F#;
GL_COLOR_ARRAY_POINTER : constant GLenum := 16#8090#;
GL_INDEX_ARRAY_POINTER : constant GLenum := 16#8091#;
GL_TEXTURE_COORD_ARRAY_POINTER : constant GLenum := 16#8092#;
GL_EDGE_FLAG_ARRAY_POINTER : constant GLenum := 16#8093#;
GL_V2F : constant GLenum := 16#2A20#;
GL_V3F : constant GLenum := 16#2A21#;
GL_C4UB_V2F : constant GLenum := 16#2A22#;
GL_C4UB_V3F : constant GLenum := 16#2A23#;
GL_C3F_V3F : constant GLenum := 16#2A24#;
GL_N3F_V3F : constant GLenum := 16#2A25#;
GL_C4F_N3F_V3F : constant GLenum := 16#2A26#;
GL_T2F_V3F : constant GLenum := 16#2A27#;
GL_T4F_V4F : constant GLenum := 16#2A28#;
GL_T2F_C4UB_V3F : constant GLenum := 16#2A29#;
GL_T2F_C3F_V3F : constant GLenum := 16#2A2A#;
GL_T2F_N3F_V3F : constant GLenum := 16#2A2B#;
GL_T2F_C4F_N3F_V3F : constant GLenum := 16#2A2C#;
GL_T4F_C4F_N3F_V4F : constant GLenum := 16#2A2D#;
GL_MATRIX_MODE : constant GLenum := 16#0BA0#;
GL_MODELVIEW : constant GLenum := 16#1700#;
GL_PROJECTION : constant GLenum := 16#1701#;
GL_TEXTURE : constant GLenum := 16#1702#;
GL_POINT_SMOOTH : constant GLenum := 16#0B10#;
GL_POINT_SIZE : constant GLenum := 16#0B11#;
GL_POINT_SIZE_GRANULARITY : constant GLenum := 16#0B13#;
GL_POINT_SIZE_RANGE : constant GLenum := 16#0B12#;
GL_LINE_SMOOTH : constant GLenum := 16#0B20#;
GL_LINE_STIPPLE : constant GLenum := 16#0B24#;
GL_LINE_STIPPLE_PATTERN : constant GLenum := 16#0B25#;
GL_LINE_STIPPLE_REPEAT : constant GLenum := 16#0B26#;
GL_LINE_WIDTH : constant GLenum := 16#0B21#;
GL_LINE_WIDTH_GRANULARITY : constant GLenum := 16#0B23#;
GL_LINE_WIDTH_RANGE : constant GLenum := 16#0B22#;
GL_POINT : constant GLenum := 16#1B00#;
GL_LINE : constant GLenum := 16#1B01#;
GL_FILL : constant GLenum := 16#1B02#;
GL_CW : constant GLenum := 16#0900#;
GL_CCW : constant GLenum := 16#0901#;
GL_FRONT : constant GLenum := 16#0404#;
GL_BACK : constant GLenum := 16#0405#;
GL_POLYGON_MODE : constant GLenum := 16#0B40#;
GL_POLYGON_SMOOTH : constant GLenum := 16#0B41#;
GL_POLYGON_STIPPLE : constant GLenum := 16#0B42#;
GL_EDGE_FLAG : constant GLenum := 16#0B43#;
GL_CULL_FACE : constant GLenum := 16#0B44#;
GL_CULL_FACE_MODE : constant GLenum := 16#0B45#;
GL_FRONT_FACE : constant GLenum := 16#0B46#;
GL_POLYGON_OFFSET_FACTOR : constant GLenum := 16#8038#;
GL_POLYGON_OFFSET_UNITS : constant GLenum := 16#2A00#;
GL_POLYGON_OFFSET_POINT : constant GLenum := 16#2A01#;
GL_POLYGON_OFFSET_LINE : constant GLenum := 16#2A02#;
GL_POLYGON_OFFSET_FILL : constant GLenum := 16#8037#;
GL_COMPILE : constant GLenum := 16#1300#;
GL_COMPILE_AND_EXECUTE : constant GLenum := 16#1301#;
GL_LIST_BASE : constant GLenum := 16#0B32#;
GL_LIST_INDEX : constant GLenum := 16#0B33#;
GL_LIST_MODE : constant GLenum := 16#0B30#;
GL_NEVER : constant GLenum := 16#0200#;
GL_LESS : constant GLenum := 16#0201#;
GL_EQUAL : constant GLenum := 16#0202#;
GL_LEQUAL : constant GLenum := 16#0203#;
GL_GREATER : constant GLenum := 16#0204#;
GL_NOTEQUAL : constant GLenum := 16#0205#;
GL_GEQUAL : constant GLenum := 16#0206#;
GL_ALWAYS : constant GLenum := 16#0207#;
GL_DEPTH_TEST : constant GLenum := 16#0B71#;
GL_DEPTH_BITS : constant GLenum := 16#0D56#;
GL_DEPTH_CLEAR_VALUE : constant GLenum := 16#0B73#;
GL_DEPTH_FUNC : constant GLenum := 16#0B74#;
GL_DEPTH_RANGE : constant GLenum := 16#0B70#;
GL_DEPTH_WRITEMASK : constant GLenum := 16#0B72#;
GL_DEPTH_COMPONENT : constant GLenum := 16#1902#;
GL_LIGHTING : constant GLenum := 16#0B50#;
GL_LIGHT0 : constant GLenum := 16#4000#;
GL_LIGHT1 : constant GLenum := 16#4001#;
GL_LIGHT2 : constant GLenum := 16#4002#;
GL_LIGHT3 : constant GLenum := 16#4003#;
GL_LIGHT4 : constant GLenum := 16#4004#;
GL_LIGHT5 : constant GLenum := 16#4005#;
GL_LIGHT6 : constant GLenum := 16#4006#;
GL_LIGHT7 : constant GLenum := 16#4007#;
GL_SPOT_EXPONENT : constant GLenum := 16#1205#;
GL_SPOT_CUTOFF : constant GLenum := 16#1206#;
GL_CONSTANT_ATTENUATION : constant GLenum := 16#1207#;
GL_LINEAR_ATTENUATION : constant GLenum := 16#1208#;
GL_QUADRATIC_ATTENUATION : constant GLenum := 16#1209#;
GL_AMBIENT : constant GLenum := 16#1200#;
GL_DIFFUSE : constant GLenum := 16#1201#;
GL_SPECULAR : constant GLenum := 16#1202#;
GL_SHININESS : constant GLenum := 16#1601#;
GL_EMISSION : constant GLenum := 16#1600#;
GL_POSITION : constant GLenum := 16#1203#;
GL_SPOT_DIRECTION : constant GLenum := 16#1204#;
GL_AMBIENT_AND_DIFFUSE : constant GLenum := 16#1602#;
GL_COLOR_INDEXES : constant GLenum := 16#1603#;
GL_LIGHT_MODEL_TWO_SIDE : constant GLenum := 16#0B52#;
GL_LIGHT_MODEL_LOCAL_VIEWER : constant GLenum := 16#0B51#;
GL_LIGHT_MODEL_AMBIENT : constant GLenum := 16#0B53#;
GL_FRONT_AND_BACK : constant GLenum := 16#0408#;
GL_SHADE_MODEL : constant GLenum := 16#0B54#;
GL_FLAT : constant GLenum := 16#1D00#;
GL_SMOOTH : constant GLenum := 16#1D01#;
GL_COLOR_MATERIAL : constant GLenum := 16#0B57#;
GL_COLOR_MATERIAL_FACE : constant GLenum := 16#0B55#;
GL_COLOR_MATERIAL_PARAMETER : constant GLenum := 16#0B56#;
GL_NORMALIZE : constant GLenum := 16#0BA1#;
GL_CLIP_PLANE0 : constant GLenum := 16#3000#;
GL_CLIP_PLANE1 : constant GLenum := 16#3001#;
GL_CLIP_PLANE2 : constant GLenum := 16#3002#;
GL_CLIP_PLANE3 : constant GLenum := 16#3003#;
GL_CLIP_PLANE4 : constant GLenum := 16#3004#;
GL_CLIP_PLANE5 : constant GLenum := 16#3005#;
GL_ACCUM_RED_BITS : constant GLenum := 16#0D58#;
GL_ACCUM_GREEN_BITS : constant GLenum := 16#0D59#;
GL_ACCUM_BLUE_BITS : constant GLenum := 16#0D5A#;
GL_ACCUM_ALPHA_BITS : constant GLenum := 16#0D5B#;
GL_ACCUM_CLEAR_VALUE : constant GLenum := 16#0B80#;
GL_ACCUM : constant GLenum := 16#0100#;
GL_ADD : constant GLenum := 16#0104#;
GL_LOAD : constant GLenum := 16#0101#;
GL_MULT : constant GLenum := 16#0103#;
GL_RETURN : constant GLenum := 16#0102#;
GL_ALPHA_TEST : constant GLenum := 16#0BC0#;
GL_ALPHA_TEST_REF : constant GLenum := 16#0BC2#;
GL_ALPHA_TEST_FUNC : constant GLenum := 16#0BC1#;
GL_BLEND : constant GLenum := 16#0BE2#;
GL_BLEND_SRC : constant GLenum := 16#0BE1#;
GL_BLEND_DST : constant GLenum := 16#0BE0#;
GL_ZERO : constant GLenum := 16#0#;
GL_ONE : constant GLenum := 16#1#;
GL_SRC_COLOR : constant GLenum := 16#0300#;
GL_ONE_MINUS_SRC_COLOR : constant GLenum := 16#0301#;
GL_SRC_ALPHA : constant GLenum := 16#0302#;
GL_ONE_MINUS_SRC_ALPHA : constant GLenum := 16#0303#;
GL_DST_ALPHA : constant GLenum := 16#0304#;
GL_ONE_MINUS_DST_ALPHA : constant GLenum := 16#0305#;
GL_DST_COLOR : constant GLenum := 16#0306#;
GL_ONE_MINUS_DST_COLOR : constant GLenum := 16#0307#;
GL_SRC_ALPHA_SATURATE : constant GLenum := 16#0308#;
GL_CONSTANT_COLOR : constant GLenum := 16#8001#;
GL_ONE_MINUS_CONSTANT_COLOR : constant GLenum := 16#8002#;
GL_CONSTANT_ALPHA : constant GLenum := 16#8003#;
GL_ONE_MINUS_CONSTANT_ALPHA : constant GLenum := 16#8004#;
GL_FEEDBACK : constant GLenum := 16#1C01#;
GL_RENDER : constant GLenum := 16#1C00#;
GL_SELECT : constant GLenum := 16#1C02#;
GL_2D : constant GLenum := 16#0600#;
GL_3D : constant GLenum := 16#0601#;
GL_3D_COLOR : constant GLenum := 16#0602#;
GL_3D_COLOR_TEXTURE : constant GLenum := 16#0603#;
GL_4D_COLOR_TEXTURE : constant GLenum := 16#0604#;
GL_POINT_TOKEN : constant GLenum := 16#0701#;
GL_LINE_TOKEN : constant GLenum := 16#0PI:PASSWORD:<PASSWORD>END_PI2#;
GL_LINE_RESET_TOKEN : constant GLenum := 16#0707#;
GL_POLYGON_TOKEN : constant GLenum := 16#0703#;
GL_BITMAP_TOKEN : constant GLenum := 16#0704#;
GL_DRAW_PIXEL_TOKEN : constant GLenum := 16#0705#;
GL_COPY_PIXEL_TOKEN : constant GLenum := 16#0706#;
GL_PASS_THROUGH_TOKEN : constant GLenum := 16#0700#;
GL_FEEDBACK_BUFFER_POINTER : constant GLenum := 16#0DF0#;
GL_FEEDBACK_BUFFER_SIZE : constant GLenum := 16#0DF1#;
GL_FEEDBACK_BUFFER_TYPE : constant GLenum := 16#0DF2#;
GL_SELECTION_BUFFER_POINTER : constant GLenum := 16#0DF3#;
GL_SELECTION_BUFFER_SIZE : constant GLenum := 16#0DF4#;
GL_FOG : constant GLenum := 16#0B60#;
GL_FOG_MODE : constant GLenum := 16#0B65#;
GL_FOG_DENSITY : constant GLenum := 16#0B62#;
GL_FOG_COLOR : constant GLenum := 16#0B66#;
GL_FOG_INDEX : constant GLenum := 16#0B61#;
GL_FOG_START : constant GLenum := 16#0B63#;
GL_FOG_END : constant GLenum := 16#0B64#;
GL_LINEAR : constant GLenum := 16#2601#;
GL_EXP : constant GLenum := 16#0800#;
GL_EXP2 : constant GLenum := 16#0801#;
GL_LOGIC_OP : constant GLenum := 16#0BF1#;
GL_INDEX_LOGIC_OP : constant GLenum := 16#0BF1#;
GL_COLOR_LOGIC_OP : constant GLenum := 16#0BF2#;
GL_LOGIC_OP_MODE : constant GLenum := 16#0BF0#;
GL_CLEAR : constant GLenum := 16#1500#;
GL_SET : constant GLenum := 16#150F#;
GL_COPY : constant GLenum := 16#1503#;
GL_COPY_INVERTED : constant GLenum := 16#150C#;
GL_NOOP : constant GLenum := 16#1505#;
GL_INVERT : constant GLenum := 16#150A#;
GL_AND : constant GLenum := 16#1501#;
GL_NAND : constant GLenum := 16#150E#;
GL_OR : constant GLenum := 16#1507#;
GL_NOR : constant GLenum := 16#1508#;
GL_XOR : constant GLenum := 16#1506#;
GL_EQUIV : constant GLenum := 16#1509#;
GL_AND_REVERSE : constant GLenum := 16#1502#;
GL_AND_INVERTED : constant GLenum := 16#1504#;
GL_OR_REVERSE : constant GLenum := 16#150B#;
GL_OR_INVERTED : constant GLenum := 16#150D#;
GL_STENCIL_TEST : constant GLenum := 16#0B90#;
GL_STENCIL_WRITEMASK : constant GLenum := 16#0B98#;
GL_STENCIL_BITS : constant GLenum := 16#0D57#;
GL_STENCIL_FUNC : constant GLenum := 16#0B92#;
GL_STENCIL_VALUE_MASK : constant GLenum := 16#0B93#;
GL_STENCIL_REF : constant GLenum := 16#0B97#;
GL_STENCIL_FAIL : constant GLenum := 16#0B94#;
GL_STENCIL_PASS_DEPTH_PASS : constant GLenum := 16#0B96#;
GL_STENCIL_PASS_DEPTH_FAIL : constant GLenum := 16#0B95#;
GL_STENCIL_CLEAR_VALUE : constant GLenum := 16#0B91#;
GL_STENCIL_INDEX : constant GLenum := 16#1901#;
GL_KEEP : constant GLenum := 16#1E00#;
GL_REPLACE : constant GLenum := 16#1E01#;
GL_INCR : constant GLenum := 16#1E02#;
GL_DECR : constant GLenum := 16#1E03#;
GL_NONE : constant GLenum := 16#0#;
GL_LEFT : constant GLenum := 16#0406#;
GL_RIGHT : constant GLenum := 16#0407#;
GL_FRONT_LEFT : constant GLenum := 16#0400#;
GL_FRONT_RIGHT : constant GLenum := 16#0401#;
GL_BACK_LEFT : constant GLenum := 16#0402#;
GL_BACK_RIGHT : constant GLenum := 16#0403#;
GL_AUX0 : constant GLenum := 16#0409#;
GL_AUX1 : constant GLenum := 16#040A#;
GL_AUX2 : constant GLenum := 16#040B#;
GL_AUX3 : constant GLenum := 16#040C#;
GL_COLOR_INDEX : constant GLenum := 16#1900#;
GL_RED : constant GLenum := 16#1903#;
GL_GREEN : constant GLenum := 16#1904#;
GL_BLUE : constant GLenum := 16#1905#;
GL_ALPHA : constant GLenum := 16#1906#;
GL_LUMINANCE : constant GLenum := 16#1909#;
GL_LUMINANCE_ALPHA : constant GLenum := 16#190A#;
GL_ALPHA_BITS : constant GLenum := 16#0D55#;
GL_RED_BITS : constant GLenum := 16#0D52#;
GL_GREEN_BITS : constant GLenum := 16#0D53#;
GL_BLUE_BITS : constant GLenum := 16#0D54#;
GL_INDEX_BITS : constant GLenum := 16#0D51#;
GL_SUBPIXEL_BITS : constant GLenum := 16#0D50#;
GL_AUX_BUFFERS : constant GLenum := 16#0C00#;
GL_READ_BUFFER : constant GLenum := 16#0C02#;
GL_DRAW_BUFFER : constant GLenum := 16#0C01#;
GL_DOUBLEBUFFER : constant GLenum := 16#0C32#;
GL_STEREO : constant GLenum := 16#0C33#;
GL_BITMAP : constant GLenum := 16#1A00#;
GL_COLOR : constant GLenum := 16#1800#;
GL_DEPTH : constant GLenum := 16#1801#;
GL_STENCIL : constant GLenum := 16#1802#;
GL_DITHER : constant GLenum := 16#0BD0#;
GL_RGB : constant GLenum := 16#1907#;
GL_RGBA : constant GLenum := 16#1908#;
GL_MAX_LIST_NESTING : constant GLenum := 16#0B31#;
GL_MAX_ATTRIB_STACK_DEPTH : constant GLenum := 16#0D35#;
GL_MAX_MODELVIEW_STACK_DEPTH : constant GLenum := 16#0D36#;
GL_MAX_NAME_STACK_DEPTH : constant GLenum := 16#0D37#;
GL_MAX_PROJECTION_STACK_DEPTH : constant GLenum := 16#0D38#;
GL_MAX_TEXTURE_STACK_DEPTH : constant GLenum := 16#0D39#;
GL_MAX_EVAL_ORDER : constant GLenum := 16#0D30#;
GL_MAX_LIGHTS : constant GLenum := 16#0D31#;
GL_MAX_CLIP_PLANES : constant GLenum := 16#0D32#;
GL_MAX_TEXTURE_SIZE : constant GLenum := 16#0D33#;
GL_MAX_PIXEL_MAP_TABLE : constant GLenum := 16#0D34#;
GL_MAX_VIEWPORT_DIMS : constant GLenum := 16#0D3A#;
GL_MAX_CLIENT_ATTRIB_STACK_DEPTH : constant GLenum := 16#0D3B#;
GL_ATTRIB_STACK_DEPTH : constant GLenum := 16#0BB0#;
GL_CLIENT_ATTRIB_STACK_DEPTH : constant GLenum := 16#0BB1#;
GL_COLOR_CLEAR_VALUE : constant GLenum := 16#0C22#;
GL_COLOR_WRITEMASK : constant GLenum := 16#0C23#;
GL_CURRENT_INDEX : constant GLenum := 16#0B01#;
GL_CURRENT_COLOR : constant GLenum := 16#0B00#;
GL_CURRENT_NORMAL : constant GLenum := 16#0B02#;
GL_CURRENT_RASTER_COLOR : constant GLenum := 16#0B04#;
GL_CURRENT_RASTER_DISTANCE : constant GLenum := 16#0B09#;
GL_CURRENT_RASTER_INDEX : constant GLenum := 16#0B05#;
GL_CURRENT_RASTER_POSITION : constant GLenum := 16#0B07#;
GL_CURRENT_RASTER_TEXTURE_COORDS : constant GLenum := 16#0B06#;
GL_CURRENT_RASTER_POSITION_VALID : constant GLenum := 16#0B08#;
GL_CURRENT_TEXTURE_COORDS : constant GLenum := 16#0B03#;
GL_INDEX_CLEAR_VALUE : constant GLenum := 16#0C20#;
GL_INDEX_MODE : constant GLenum := 16#0C30#;
GL_INDEX_WRITEMASK : constant GLenum := 16#0C21#;
GL_MODELVIEW_MATRIX : constant GLenum := 16#0BA6#;
GL_MODELVIEW_STACK_DEPTH : constant GLenum := 16#0BA3#;
GL_NAME_STACK_DEPTH : constant GLenum := 16#0D70#;
GL_PROJECTION_MATRIX : constant GLenum := 16#0BA7#;
GL_PROJECTION_STACK_DEPTH : constant GLenum := 16#0BA4#;
GL_RENDER_MODE : constant GLenum := 16#0C40#;
GL_RGBA_MODE : constant GLenum := 16#0C31#;
GL_TEXTURE_MATRIX : constant GLenum := 16#0BA8#;
GL_TEXTURE_STACK_DEPTH : constant GLenum := 16#0BA5#;
GL_VIEWPORT : constant GLenum := 16#0BA2#;
GL_AUTO_NORMAL : constant GLenum := 16#0D80#;
GL_MAP1_COLOR_4 : constant GLenum := 16#0D90#;
GL_MAP1_GRID_DOMAIN : constant GLenum := 16#0DD0#;
GL_MAP1_GRID_SEGMENTS : constant GLenum := 16#0DD1#;
GL_MAP1_INDEX : constant GLenum := 16#0D91#;
GL_MAP1_NORMAL : constant GLenum := 16#0D92#;
GL_MAP1_TEXTURE_COORD_1 : constant GLenum := 16#0D93#;
GL_MAP1_TEXTURE_COORD_2 : constant GLenum := 16#0D94#;
GL_MAP1_TEXTURE_COORD_3 : constant GLenum := 16#0D95#;
GL_MAP1_TEXTURE_COORD_4 : constant GLenum := 16#0D96#;
GL_MAP1_VERTEX_3 : constant GLenum := 16#0D97#;
GL_MAP1_VERTEX_4 : constant GLenum := 16#0D98#;
GL_MAP2_COLOR_4 : constant GLenum := 16#0DB0#;
GL_MAP2_GRID_DOMAIN : constant GLenum := 16#0DD2#;
GL_MAP2_GRID_SEGMENTS : constant GLenum := 16#0DD3#;
GL_MAP2_INDEX : constant GLenum := 16#0DB1#;
GL_MAP2_NORMAL : constant GLenum := 16#0DB2#;
GL_MAP2_TEXTURE_COORD_1 : constant GLenum := 16#0DB3#;
GL_MAP2_TEXTURE_COORD_2 : constant GLenum := 16#0DB4#;
GL_MAP2_TEXTURE_COORD_3 : constant GLenum := 16#0DB5#;
GL_MAP2_TEXTURE_COORD_4 : constant GLenum := 16#0DB6#;
GL_MAP2_VERTEX_3 : constant GLenum := 16#0DB7#;
GL_MAP2_VERTEX_4 : constant GLenum := 16#0DB8#;
GL_COEFF : constant GLenum := 16#0A00#;
GL_DOMAIN : constant GLenum := 16#0A02#;
GL_ORDER : constant GLenum := 16#0A01#;
GL_FOG_HINT : constant GLenum := 16#0C54#;
GL_LINE_SMOOTH_HINT : constant GLenum := 16#0C52#;
GL_PERSPECTIVE_CORRECTION_HINT : constant GLenum := 16#0C50#;
GL_POINT_SMOOTH_HINT : constant GLenum := 16#0C51#;
GL_POLYGON_SMOOTH_HINT : constant GLenum := 16#0C53#;
GL_DONT_CARE : constant GLenum := 16#1100#;
GL_FASTEST : constant GLenum := 16#1101#;
GL_NICEST : constant GLenum := 16#1102#;
GL_SCISSOR_TEST : constant GLenum := 16#0C11#;
GL_SCISSOR_BOX : constant GLenum := 16#0C10#;
GL_MAP_COLOR : constant GLenum := 16#0D10#;
GL_MAP_STENCIL : constant GLenum := 16#0D11#;
GL_INDEX_SHIFT : constant GLenum := 16#0D12#;
GL_INDEX_OFFSET : constant GLenum := 16#0D13#;
GL_RED_SCALE : constant GLenum := 16#0D14#;
GL_RED_BIAS : constant GLenum := 16#0D15#;
GL_GREEN_SCALE : constant GLenum := 16#0D18#;
GL_GREEN_BIAS : constant GLenum := 16#0D19#;
GL_BLUE_SCALE : constant GLenum := 16#0D1A#;
GL_BLUE_BIAS : constant GLenum := 16#0D1B#;
GL_ALPHA_SCALE : constant GLenum := 16#0D1C#;
GL_ALPHA_BIAS : constant GLenum := 16#0D1D#;
GL_DEPTH_SCALE : constant GLenum := 16#0D1E#;
GL_DEPTH_BIAS : constant GLenum := 16#0D1F#;
GL_PIXEL_MAP_S_TO_S_SIZE : constant GLenum := 16#0CB1#;
GL_PIXEL_MAP_I_TO_I_SIZE : constant GLenum := 16#0CB0#;
GL_PIXEL_MAP_I_TO_R_SIZE : constant GLenum := 16#0CB2#;
GL_PIXEL_MAP_I_TO_G_SIZE : constant GLenum := 16#0CB3#;
GL_PIXEL_MAP_I_TO_B_SIZE : constant GLenum := 16#0CB4#;
GL_PIXEL_MAP_I_TO_A_SIZE : constant GLenum := 16#0CB5#;
GL_PIXEL_MAP_R_TO_R_SIZE : constant GLenum := 16#0CB6#;
GL_PIXEL_MAP_G_TO_G_SIZE : constant GLenum := 16#0CB7#;
GL_PIXEL_MAP_B_TO_B_SIZE : constant GLenum := 16#0CB8#;
GL_PIXEL_MAP_A_TO_A_SIZE : constant GLenum := 16#0CB9#;
GL_PIXEL_MAP_S_TO_S : constant GLenum := 16#0C71#;
GL_PIXEL_MAP_I_TO_I : constant GLenum := 16#0C70#;
GL_PIXEL_MAP_I_TO_R : constant GLenum := 16#0C72#;
GL_PIXEL_MAP_I_TO_G : constant GLenum := 16#0C73#;
GL_PIXEL_MAP_I_TO_B : constant GLenum := 16#0C74#;
GL_PIXEL_MAP_I_TO_A : constant GLenum := 16#0C75#;
GL_PIXEL_MAP_R_TO_R : constant GLenum := 16#0C76#;
GL_PIXEL_MAP_G_TO_G : constant GLenum := 16#0C77#;
GL_PIXEL_MAP_B_TO_B : constant GLenum := 16#0C78#;
GL_PIXEL_MAP_A_TO_A : constant GLenum := 16#0C79#;
GL_PACK_ALIGNMENT : constant GLenum := 16#0D05#;
GL_PACK_LSB_FIRST : constant GLenum := 16#0D01#;
GL_PACK_ROW_LENGTH : constant GLenum := 16#0D02#;
GL_PACK_SKIP_PIXELS : constant GLenum := 16#0D04#;
GL_PACK_SKIP_ROWS : constant GLenum := 16#0D03#;
GL_PACK_SWAP_BYTES : constant GLenum := 16#0D00#;
GL_UNPACK_ALIGNMENT : constant GLenum := 16#0CF5#;
GL_UNPACK_LSB_FIRST : constant GLenum := 16#0CF1#;
GL_UNPACK_ROW_LENGTH : constant GLenum := 16#0CF2#;
GL_UNPACK_SKIP_PIXELS : constant GLenum := 16#0CF4#;
GL_UNPACK_SKIP_ROWS : constant GLenum := 16#0CF3#;
GL_UNPACK_SWAP_BYTES : constant GLenum := 16#0CF0#;
GL_ZOOM_X : constant GLenum := 16#0D16#;
GL_ZOOM_Y : constant GLenum := 16#0D17#;
GL_TEXTURE_ENV : constant GLenum := 16#2300#;
GL_TEXTURE_ENV_MODE : constant GLenum := 16#2200#;
GL_TEXTURE_1D : constant GLenum := 16#0DE0#;
GL_TEXTURE_2D : constant GLenum := 16#0DE1#;
GL_TEXTURE_WRAP_S : constant GLenum := 16#2802#;
GL_TEXTURE_WRAP_T : constant GLenum := 16#2803#;
GL_TEXTURE_MAG_FILTER : constant GLenum := 16#2800#;
GL_TEXTURE_MIN_FILTER : constant GLenum := 16#2801#;
GL_TEXTURE_ENV_COLOR : constant GLenum := 16#2201#;
GL_TEXTURE_GEN_S : constant GLenum := 16#0C60#;
GL_TEXTURE_GEN_T : constant GLenum := 16#0C61#;
GL_TEXTURE_GEN_MODE : constant GLenum := 16#2500#;
GL_TEXTURE_BORDER_COLOR : constant GLenum := 16#1004#;
GL_TEXTURE_WIDTH : constant GLenum := 16#1000#;
GL_TEXTURE_HEIGHT : constant GLenum := 16#1001#;
GL_TEXTURE_BORDER : constant GLenum := 16#1005#;
GL_TEXTURE_COMPONENTS : constant GLenum := 16#1003#;
GL_TEXTURE_RED_SIZE : constant GLenum := 16#805C#;
GL_TEXTURE_GREEN_SIZE : constant GLenum := 16#805D#;
GL_TEXTURE_BLUE_SIZE : constant GLenum := 16#805E#;
GL_TEXTURE_ALPHA_SIZE : constant GLenum := 16#805F#;
GL_TEXTURE_LUMINANCE_SIZE : constant GLenum := 16#8060#;
GL_TEXTURE_INTENSITY_SIZE : constant GLenum := 16#8061#;
GL_NEAREST_MIPMAP_NEAREST : constant GLenum := 16#2700#;
GL_NEAREST_MIPMAP_LINEAR : constant GLenum := 16#2702#;
GL_LINEAR_MIPMAP_NEAREST : constant GLenum := 16#2701#;
GL_LINEAR_MIPMAP_LINEAR : constant GLenum := 16#2703#;
GL_OBJECT_LINEAR : constant GLenum := 16#2401#;
GL_OBJECT_PLANE : constant GLenum := 16#2501#;
GL_EYE_LINEAR : constant GLenum := 16#2400#;
GL_EYE_PLANE : constant GLenum := 16#2502#;
GL_SPHERE_MAP : constant GLenum := 16#2402#;
GL_DECAL : constant GLenum := 16#2101#;
GL_MODULATE : constant GLenum := 16#2100#;
GL_NEAREST : constant GLenum := 16#2600#;
GL_REPEAT : constant GLenum := 16#2901#;
GL_CLAMP : constant GLenum := 16#2900#;
GL_S : constant GLenum := 16#2000#;
GL_T : constant GLenum := 16#2001#;
GL_R : constant GLenum := 16#2002#;
GL_Q : constant GLenum := 16#2003#;
GL_TEXTURE_GEN_R : constant GLenum := 16#0C62#;
GL_TEXTURE_GEN_Q : constant GLenum := 16#0C63#;
GL_VENDOR : constant GLenum := 16#1F00#;
GL_RENDERER : constant GLenum := 16#1F01#;
GL_VERSION : constant GLenum := 16#1F02#;
GL_EXTENSIONS : constant GLenum := 16#1F03#;
GL_NO_ERROR : constant GLenum := 16#0#;
GL_INVALID_VALUE : constant GLenum := 16#0501#;
GL_INVALID_ENUM : constant GLenum := 16#0500#;
GL_INVALID_OPERATION : constant GLenum := 16#0502#;
GL_STACK_OVERFLOW : constant GLenum := 16#0503#;
GL_STACK_UNDERFLOW : constant GLenum := 16#0504#;
GL_OUT_OF_MEMORY : constant GLenum := 16#0505#;
GL_CURRENT_BIT : constant GLenum := 16#00000001#;
GL_POINT_BIT : constant GLenum := 16#00000002#;
GL_LINE_BIT : constant GLenum := 16#00000004#;
GL_POLYGON_BIT : constant GLenum := 16#00000008#;
GL_POLYGON_STIPPLE_BIT : constant GLenum := 16#00000010#;
GL_PIXEL_MODE_BIT : constant GLenum := 16#00000020#;
GL_LIGHTING_BIT : constant GLenum := 16#00000040#;
GL_FOG_BIT : constant GLenum := 16#00000080#;
GL_DEPTH_BUFFER_BIT : constant GLenum := 16#00000100#;
GL_ACCUM_BUFFER_BIT : constant GLenum := 16#00000200#;
GL_STENCIL_BUFFER_BIT : constant GLenum := 16#00000400#;
GL_VIEWPORT_BIT : constant GLenum := 16#00000800#;
GL_TRANSFORM_BIT : constant GLenum := 16#00001000#;
GL_ENABLE_BIT : constant GLenum := 16#00002000#;
GL_COLOR_BUFFER_BIT : constant GLenum := 16#00004000#;
GL_HINT_BIT : constant GLenum := 16#00008000#;
GL_EVAL_BIT : constant GLenum := 16#00010000#;
GL_LIST_BIT : constant GLenum := 16#00020000#;
GL_TEXTURE_BIT : constant GLenum := 16#00040000#;
GL_SCISSOR_BIT : constant GLenum := 16#00080000#;
GL_ALL_ATTRIB_BITS : constant GLenum := 16#000FFFFF#;
GL_PROXY_TEXTURE_1D : constant GLenum := 16#8063#;
GL_PROXY_TEXTURE_2D : constant GLenum := 16#8064#;
GL_TEXTURE_PRIORITY : constant GLenum := 16#8066#;
GL_TEXTURE_RESIDENT : constant GLenum := 16#8067#;
GL_TEXTURE_BINDING_1D : constant GLenum := 16#8068#;
GL_TEXTURE_BINDING_2D : constant GLenum := 16#8069#;
GL_TEXTURE_INTERNAL_FORMAT : constant GLenum := 16#1003#;
GL_ALPHA4 : constant GLenum := 16#803B#;
GL_ALPHA8 : constant GLenum := 16#803C#;
GL_ALPHA12 : constant GLenum := 16#803D#;
GL_ALPHA16 : constant GLenum := 16#803E#;
GL_LUMINANCE4 : constant GLenum := 16#803F#;
GL_LUMINANCE8 : constant GLenum := 16#8040#;
GL_LUMINANCE12 : constant GLenum := 16#8041#;
GL_LUMINANCE16 : constant GLenum := 16#8042#;
GL_LUMINANCE4_ALPHA4 : constant GLenum := 16#8043#;
GL_LUMINANCE6_ALPHA2 : constant GLenum := 16#8044#;
GL_LUMINANCE8_ALPHA8 : constant GLenum := 16#8045#;
GL_LUMINANCE12_ALPHA4 : constant GLenum := 16#8046#;
GL_LUMINANCE12_ALPHA12 : constant GLenum := 16#8047#;
GL_LUMINANCE16_ALPHA16 : constant GLenum := 16#8048#;
GL_INTENSITY : constant GLenum := 16#8049#;
GL_INTENSITY4 : constant GLenum := 16#804A#;
GL_INTENSITY8 : constant GLenum := 16#804B#;
GL_INTENSITY12 : constant GLenum := 16#804C#;
GL_INTENSITY16 : constant GLenum := 16#804D#;
GL_R3_G3_B2 : constant GLenum := 16#2A10#;
GL_RGB4 : constant GLenum := 16#804F#;
GL_RGB5 : constant GLenum := 16#8050#;
GL_RGB8 : constant GLenum := 16#8051#;
GL_RGB10 : constant GLenum := 16#8052#;
GL_RGB12 : constant GLenum := 16#8053#;
GL_RGB16 : constant GLenum := 16#8054#;
GL_RGBA2 : constant GLenum := 16#8055#;
GL_RGBA4 : constant GLenum := 16#8056#;
GL_RGB5_A1 : constant GLenum := 16#8057#;
GL_RGBA8 : constant GLenum := 16#8058#;
GL_RGB10_A2 : constant GLenum := 16#8059#;
GL_RGBA12 : constant GLenum := 16#805A#;
GL_RGBA16 : constant GLenum := 16#805B#;
GL_CLIENT_PIXEL_STORE_BIT : constant GLenum := 16#00000001#;
GL_CLIENT_VERTEX_ARRAY_BIT : constant GLenum := 16#00000002#;
GL_ALL_CLIENT_ATTRIB_BITS : constant GLenum := 16#FFFFFFFF#;
GL_CLIENT_ALL_ATTRIB_BITS : constant GLenum := 16#FFFFFFFF#;
GL_RESCALE_NORMAL : constant GLenum := 16#803A#;
GL_CLAMP_TO_EDGE : constant GLenum := 16#812F#;
GL_MAX_ELEMENTS_VERTICES : constant GLenum := 16#80E8#;
GL_MAX_ELEMENTS_INDICES : constant GLenum := 16#80E9#;
GL_BGR : constant GLenum := 16#80E0#;
GL_BGRA : constant GLenum := 16#80E1#;
GL_UNSIGNED_BYTE_3_3_2 : constant GLenum := 16#8032#;
GL_UNSIGNED_BYTE_2_3_3_REV : constant GLenum := 16#8362#;
GL_UNSIGNED_SHORT_5_6_5 : constant GLenum := 16#8363#;
GL_UNSIGNED_SHORT_5_6_5_REV : constant GLenum := 16#8364#;
GL_UNSIGNED_SHORT_4_4_4_4 : constant GLenum := 16#8033#;
GL_UNSIGNED_SHORT_4_4_4_4_REV : constant GLenum := 16#8365#;
GL_UNSIGNED_SHORT_5_5_5_1 : constant GLenum := 16#8034#;
GL_UNSIGNED_SHORT_1_5_5_5_REV : constant GLenum := 16#8366#;
GL_UNSIGNED_INT_8_8_8_8 : constant GLenum := 16#8035#;
GL_UNSIGNED_INT_8_8_8_8_REV : constant GLenum := 16#8367#;
GL_UNSIGNED_INT_10_10_10_2 : constant GLenum := 16#8036#;
GL_UNSIGNED_INT_2_10_10_10_REV : constant GLenum := 16#8368#;
GL_LIGHT_MODEL_COLOR_CONTROL : constant GLenum := 16#81F8#;
GL_SINGLE_COLOR : constant GLenum := 16#81F9#;
GL_SEPARATE_SPECULAR_COLOR : constant GLenum := 16#81FA#;
GL_TEXTURE_MIN_LOD : constant GLenum := 16#813A#;
GL_TEXTURE_MAX_LOD : constant GLenum := 16#813B#;
GL_TEXTURE_BASE_LEVEL : constant GLenum := 16#813C#;
GL_TEXTURE_MAX_LEVEL : constant GLenum := 16#813D#;
GL_SMOOTH_POINT_SIZE_RANGE : constant GLenum := 16#0B12#;
GL_SMOOTH_POINT_SIZE_GRANULARITY : constant GLenum := 16#0B13#;
GL_SMOOTH_LINE_WIDTH_RANGE : constant GLenum := 16#0B22#;
GL_SMOOTH_LINE_WIDTH_GRANULARITY : constant GLenum := 16#0B23#;
GL_ALIASED_POINT_SIZE_RANGE : constant GLenum := 16#846D#;
GL_ALIASED_LINE_WIDTH_RANGE : constant GLenum := 16#846E#;
GL_PACK_SKIP_IMAGES : constant GLenum := 16#806B#;
GL_PACK_IMAGE_HEIGHT : constant GLenum := 16#806C#;
GL_UNPACK_SKIP_IMAGES : constant GLenum := 16#806D#;
GL_UNPACK_IMAGE_HEIGHT : constant GLenum := 16#806E#;
GL_TEXTURE_3D : constant GLenum := 16#806F#;
GL_PROXY_TEXTURE_3D : constant GLenum := 16#8070#;
GL_TEXTURE_DEPTH : constant GLenum := 16#8071#;
GL_TEXTURE_WRAP_R : constant GLenum := 16#8072#;
GL_MAX_3D_TEXTURE_SIZE : constant GLenum := 16#8073#;
GL_TEXTURE_BINDING_3D : constant GLenum := 16#806A#;
GL_COLOR_TABLE : constant GLenum := 16#80D0#;
GL_POST_CONVOLUTION_COLOR_TABLE : constant GLenum := 16#80D1#;
GL_POST_COLOR_MATRIX_COLOR_TABLE : constant GLenum := 16#80D2#;
GL_PROXY_COLOR_TABLE : constant GLenum := 16#80D3#;
GL_PROXY_POST_CONVOLUTION_COLOR_TABLE : constant GLenum := 16#80D4#;
GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE : constant GLenum := 16#80D5#;
GL_COLOR_TABLE_SCALE : constant GLenum := 16#80D6#;
GL_COLOR_TABLE_BIAS : constant GLenum := 16#80D7#;
GL_COLOR_TABLE_FORMAT : constant GLenum := 16#80D8#;
GL_COLOR_TABLE_WIDTH : constant GLenum := 16#80D9#;
GL_COLOR_TABLE_RED_SIZE : constant GLenum := 16#80DA#;
GL_COLOR_TABLE_GREEN_SIZE : constant GLenum := 16#80DB#;
GL_COLOR_TABLE_BLUE_SIZE : constant GLenum := 16#80DC#;
GL_COLOR_TABLE_ALPHA_SIZE : constant GLenum := 16#80DD#;
GL_COLOR_TABLE_LUMINANCE_SIZE : constant GLenum := 16#80DE#;
GL_COLOR_TABLE_INTENSITY_SIZE : constant GLenum := 16#80DF#;
GL_CONVOLUTION_1D : constant GLenum := 16#8010#;
GL_CONVOLUTION_2D : constant GLenum := 16#8011#;
GL_SEPARABLE_2D : constant GLenum := 16#8012#;
GL_CONVOLUTION_BORDER_MODE : constant GLenum := 16#8013#;
GL_CONVOLUTION_FILTER_SCALE : constant GLenum := 16#8014#;
GL_CONVOLUTION_FILTER_BIAS : constant GLenum := 16#8015#;
GL_REDUCE : constant GLenum := 16#8016#;
GL_CONVOLUTION_FORMAT : constant GLenum := 16#8017#;
GL_CONVOLUTION_WIDTH : constant GLenum := 16#8018#;
GL_CONVOLUTION_HEIGHT : constant GLenum := 16#8019#;
GL_MAX_CONVOLUTION_WIDTH : constant GLenum := 16#801A#;
GL_MAX_CONVOLUTION_HEIGHT : constant GLenum := 16#801B#;
GL_POST_CONVOLUTION_RED_SCALE : constant GLenum := 16#801C#;
GL_POST_CONVOLUTION_GREEN_SCALE : constant GLenum := 16#801D#;
GL_POST_CONVOLUTION_BLUE_SCALE : constant GLenum := 16#801E#;
GL_POST_CONVOLUTION_ALPHA_SCALE : constant GLenum := 16#801F#;
GL_POST_CONVOLUTION_RED_BIAS : constant GLenum := 16#8020#;
GL_POST_CONVOLUTION_GREEN_BIAS : constant GLenum := 16#8021#;
GL_POST_CONVOLUTION_BLUE_BIAS : constant GLenum := 16#8022#;
GL_POST_CONVOLUTION_ALPHA_BIAS : constant GLenum := 16#8023#;
GL_CONSTANT_BORDER : constant GLenum := 16#8151#;
GL_REPLICATE_BORDER : constant GLenum := 16#8153#;
GL_CONVOLUTION_BORDER_COLOR : constant GLenum := 16#8154#;
GL_COLOR_MATRIX : constant GLenum := 16#80B1#;
GL_COLOR_MATRIX_STACK_DEPTH : constant GLenum := 16#80B2#;
GL_MAX_COLOR_MATRIX_STACK_DEPTH : constant GLenum := 16#80B3#;
GL_POST_COLOR_MATRIX_RED_SCALE : constant GLenum := 16#80B4#;
GL_POST_COLOR_MATRIX_GREEN_SCALE : constant GLenum := 16#80B5#;
GL_POST_COLOR_MATRIX_BLUE_SCALE : constant GLenum := 16#80B6#;
GL_POST_COLOR_MATRIX_ALPHA_SCALE : constant GLenum := 16#80B7#;
GL_POST_COLOR_MATRIX_RED_BIAS : constant GLenum := 16#80B8#;
GL_POST_COLOR_MATRIX_GREEN_BIAS : constant GLenum := 16#80B9#;
GL_POST_COLOR_MATRIX_BLUE_BIAS : constant GLenum := 16#80BA#;
GL_POST_COLOR_MATRIX_ALPHA_BIAS : constant GLenum := 16#80BB#;
GL_HISTOGRAM : constant GLenum := 16#8024#;
GL_PROXY_HISTOGRAM : constant GLenum := 16#8025#;
GL_HISTOGRAM_WIDTH : constant GLenum := 16#8026#;
GL_HISTOGRAM_FORMAT : constant GLenum := 16#8027#;
GL_HISTOGRAM_RED_SIZE : constant GLenum := 16#8028#;
GL_HISTOGRAM_GREEN_SIZE : constant GLenum := 16#8029#;
GL_HISTOGRAM_BLUE_SIZE : constant GLenum := 16#802A#;
GL_HISTOGRAM_ALPHA_SIZE : constant GLenum := 16#802B#;
GL_HISTOGRAM_LUMINANCE_SIZE : constant GLenum := 16#802C#;
GL_HISTOGRAM_SINK : constant GLenum := 16#802D#;
GL_MINMAX : constant GLenum := 16#802E#;
GL_MINMAX_FORMAT : constant GLenum := 16#802F#;
GL_MINMAX_SINK : constant GLenum := 16#8030#;
GL_TABLE_TOO_LARGE : constant GLenum := 16#8031#;
GL_BLEND_EQUATION : constant GLenum := 16#8009#;
GL_MIN : constant GLenum := 16#8007#;
GL_MAX : constant GLenum := 16#8008#;
GL_FUNC_ADD : constant GLenum := 16#8006#;
GL_FUNC_SUBTRACT : constant GLenum := 16#800A#;
GL_FUNC_REVERSE_SUBTRACT : constant GLenum := 16#800B#;
GL_BLEND_COLOR : constant GLenum := 16#8005#;
GL_TEXTURE0 : constant GLenum := 16#84C0#;
GL_TEXTURE1 : constant GLenum := 16#84C1#;
GL_TEXTURE2 : constant GLenum := 16#84C2#;
GL_TEXTURE3 : constant GLenum := 16#84C3#;
GL_TEXTURE4 : constant GLenum := 16#84C4#;
GL_TEXTURE5 : constant GLenum := 16#84C5#;
GL_TEXTURE6 : constant GLenum := 16#84C6#;
GL_TEXTURE7 : constant GLenum := 16#84C7#;
GL_TEXTURE8 : constant GLenum := 16#84C8#;
GL_TEXTURE9 : constant GLenum := 16#84C9#;
GL_TEXTURE10 : constant GLenum := 16#84CA#;
GL_TEXTURE11 : constant GLenum := 16#84CB#;
GL_TEXTURE12 : constant GLenum := 16#84CC#;
GL_TEXTURE13 : constant GLenum := 16#84CD#;
GL_TEXTURE14 : constant GLenum := 16#84CE#;
GL_TEXTURE15 : constant GLenum := 16#84CF#;
GL_TEXTURE16 : constant GLenum := 16#84D0#;
GL_TEXTURE17 : constant GLenum := 16#84D1#;
GL_TEXTURE18 : constant GLenum := 16#84D2#;
GL_TEXTURE19 : constant GLenum := 16#84D3#;
GL_TEXTURE20 : constant GLenum := 16#84D4#;
GL_TEXTURE21 : constant GLenum := 16#84D5#;
GL_TEXTURE22 : constant GLenum := 16#84D6#;
GL_TEXTURE23 : constant GLenum := 16#84D7#;
GL_TEXTURE24 : constant GLenum := 16#84D8#;
GL_TEXTURE25 : constant GLenum := 16#84D9#;
GL_TEXTURE26 : constant GLenum := 16#84DA#;
GL_TEXTURE27 : constant GLenum := 16#84DB#;
GL_TEXTURE28 : constant GLenum := 16#84DC#;
GL_TEXTURE29 : constant GLenum := 16#84DD#;
GL_TEXTURE30 : constant GLenum := 16#84DE#;
GL_TEXTURE31 : constant GLenum := 16#84DF#;
GL_ACTIVE_TEXTURE : constant GLenum := 16#84E0#;
GL_CLIENT_ACTIVE_TEXTURE : constant GLenum := 16#84E1#;
GL_MAX_TEXTURE_UNITS : constant GLenum := 16#84E2#;
GL_NORMAL_MAP : constant GLenum := 16#8511#;
GL_REFLECTION_MAP : constant GLenum := 16#8512#;
GL_TEXTURE_CUBE_MAP : constant GLenum := 16#8513#;
GL_TEXTURE_BINDING_CUBE_MAP : constant GLenum := 16#8514#;
GL_TEXTURE_CUBE_MAP_POSITIVE_X : constant GLenum := 16#8515#;
GL_TEXTURE_CUBE_MAP_NEGATIVE_X : constant GLenum := 16#8516#;
GL_TEXTURE_CUBE_MAP_POSITIVE_Y : constant GLenum := 16#8517#;
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y : constant GLenum := 16#8518#;
GL_TEXTURE_CUBE_MAP_POSITIVE_Z : constant GLenum := 16#8519#;
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z : constant GLenum := 16#851A#;
GL_PROXY_TEXTURE_CUBE_MAP : constant GLenum := 16#851B#;
GL_MAX_CUBE_MAP_TEXTURE_SIZE : constant GLenum := 16#851C#;
GL_COMPRESSED_ALPHA : constant GLenum := 16#84E9#;
GL_COMPRESSED_LUMINANCE : constant GLenum := 16#84EA#;
GL_COMPRESSED_LUMINANCE_ALPHA : constant GLenum := 16#84EB#;
GL_COMPRESSED_INTENSITY : constant GLenum := 16#84EC#;
GL_COMPRESSED_RGB : constant GLenum := 16#84ED#;
GL_COMPRESSED_RGBA : constant GLenum := 16#84EE#;
GL_TEXTURE_COMPRESSION_HINT : constant GLenum := 16#84EF#;
GL_TEXTURE_COMPRESSED_IMAGE_SIZE : constant GLenum := 16#86A0#;
GL_TEXTURE_COMPRESSED : constant GLenum := 16#86A1#;
GL_NUM_COMPRESSED_TEXTURE_FORMATS : constant GLenum := 16#86A2#;
GL_COMPRESSED_TEXTURE_FORMATS : constant GLenum := 16#86A3#;
GL_MULTISAMPLE : constant GLenum := 16#809D#;
GL_SAMPLE_ALPHA_TO_COVERAGE : constant GLenum := 16#809E#;
GL_SAMPLE_ALPHA_TO_ONE : constant GLenum := 16#809F#;
GL_SAMPLE_COVERAGE : constant GLenum := 16#80A0#;
GL_SAMPLE_BUFFERS : constant GLenum := 16#80A8#;
GL_SAMPLES : constant GLenum := 16#80A9#;
GL_SAMPLE_COVERAGE_VALUE : constant GLenum := 16#80AA#;
GL_SAMPLE_COVERAGE_INVERT : constant GLenum := 16#80AB#;
GL_MULTISAMPLE_BIT : constant GLenum := 16#20000000#;
GL_TRANSPOSE_MODELVIEW_MATRIX : constant GLenum := 16#84E3#;
GL_TRANSPOSE_PROJECTION_MATRIX : constant GLenum := 16#84E4#;
GL_TRANSPOSE_TEXTURE_MATRIX : constant GLenum := 16#84E5#;
GL_TRANSPOSE_COLOR_MATRIX : constant GLenum := 16#84E6#;
GL_COMBINE : constant GLenum := 16#8570#;
GL_COMBINE_RGB : constant GLenum := 16#8571#;
GL_COMBINE_ALPHA : constant GLenum := 16#8572#;
GL_SOURCE0_RGB : constant GLenum := 16#8580#;
GL_SOURCE1_RGB : constant GLenum := 16#8581#;
GL_SOURCE2_RGB : constant GLenum := 16#8582#;
GL_SOURCE0_ALPHA : constant GLenum := 16#8588#;
GL_SOURCE1_ALPHA : constant GLenum := 16#8589#;
GL_SOURCE2_ALPHA : constant GLenum := 16#858A#;
GL_OPERAND0_RGB : constant GLenum := 16#8590#;
GL_OPERAND1_RGB : constant GLenum := 16#8591#;
GL_OPERAND2_RGB : constant GLenum := 16#8592#;
GL_OPERAND0_ALPHA : constant GLenum := 16#8598#;
GL_OPERAND1_ALPHA : constant GLenum := 16#8599#;
GL_OPERAND2_ALPHA : constant GLenum := 16#859A#;
GL_RGB_SCALE : constant GLenum := 16#8573#;
GL_ADD_SIGNED : constant GLenum := 16#8574#;
GL_INTERPOLATE : constant GLenum := 16#8575#;
GL_SUBTRACT : constant GLenum := 16#84E7#;
GL_CONSTANT : constant GLenum := 16#8576#;
GL_PRIMARY_COLOR : constant GLenum := 16#8577#;
GL_PREVIOUS : constant GLenum := 16#8578#;
GL_DOT3_RGB : constant GLenum := 16#86AE#;
GL_DOT3_RGBA : constant GLenum := 16#86AF#;
GL_CLAMP_TO_BORDER : constant GLenum := 16#812D#;
-- ////////////////////////////////////////////////////////////
-- // GL functions
-- ////////////////////////////////////////////////////////////
procedure glClearIndex (c : GLfloat);
procedure glClearColor
(red : GLclampf;
green : GLclampf;
blue : GLclampf;
alpha : GLclampf);
procedure glClear (mask : GLbitfield);
procedure glIndexMask (mask : GLuint);
procedure glColorMask
(red : GLboolean;
green : GLboolean;
blue : GLboolean;
alpha : GLboolean);
procedure glAlphaFunc (func : GLenum; ref : GLclampf);
procedure glBlendFunc (sfactor : GLenum; dfactor : GLenum);
procedure glLogicOp (opcode : GLenum);
procedure glCullFace (mode : GLenum);
procedure glFrontFace (mode : GLenum);
procedure glPointSize (size : GLfloat);
procedure glLineWidth (width : GLfloat);
procedure glLineStipple (factor : GLint; pattern : GLushort);
procedure glPolygonMode (face : GLenum; mode : GLenum);
procedure glPolygonOffset (factor : GLfloat; units : GLfloat);
procedure glPolygonStipple (mask : access GLubyte);
procedure glGetPolygonStipple (mask : access GLubyte);
procedure glEdgeFlag (flag : GLboolean);
procedure glEdgeFlagv (flag : access GLboolean);
procedure glScissor
(x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glClipPlane (plane : GLenum; equation : access GLdouble);
procedure glGetClipPlane (plane : GLenum; equation : access GLdouble);
procedure glDrawBuffer (mode : GLenum);
procedure glReadBuffer (mode : GLenum);
procedure glEnable (cap : GLenum);
procedure glDisable (cap : GLenum);
function glIsEnabled (cap : GLenum) return GLboolean;
procedure glEnableClientState (cap : GLenum);
procedure glDisableClientState (cap : GLenum);
procedure glGetBooleanv (pname : GLenum; params : access GLboolean);
procedure glGetDoublev (pname : GLenum; params : access GLdouble);
procedure glGetFloatv (pname : GLenum; params : access GLfloat);
procedure glGetIntegerv (pname : GLenum; params : access GLint);
procedure glPushAttrib (mask : GLbitfield);
procedure glPopAttrib;
procedure glPushClientAttrib (mask : GLbitfield);
procedure glPopClientAttrib;
function glRenderMode (mode : GLenum) return GLint;
function glGetError return GLenum;
function glGetString (name : GLenum) return GLubyte_Ptr;
procedure glFinish;
procedure glFlush;
procedure glHint (target : GLenum; mode : GLenum);
procedure glClearDepth (depth : GLclampd);
procedure glDepthFunc (func : GLenum);
procedure glDepthMask (flag : GLboolean);
procedure glDepthRange (near_val : GLclampd; far_val : GLclampd);
procedure glClearAccum
(red : GLfloat;
green : GLfloat;
blue : GLfloat;
alpha : GLfloat);
procedure glAccum (op : GLenum; value : GLfloat);
procedure glMatrixMode (mode : GLenum);
procedure glOrtho
(left : GLdouble;
right : GLdouble;
bottom : GLdouble;
top : GLdouble;
near_val : GLdouble;
far_val : GLdouble);
procedure glFrustum
(left : GLdouble;
right : GLdouble;
bottom : GLdouble;
top : GLdouble;
near_val : GLdouble;
far_val : GLdouble);
procedure glViewport
(x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glPushMatrix;
procedure glPopMatrix;
procedure glLoadIdentity;
procedure glLoadMatrixd (m : access GLdouble);
procedure glLoadMatrixf (m : access GLfloat);
procedure glMultMatrixd (m : access GLdouble);
procedure glMultMatrixf (m : access GLfloat);
procedure glRotated
(angle : GLdouble;
x : GLdouble;
y : GLdouble;
z : GLdouble);
procedure glRotatef
(angle : GLfloat;
x : GLfloat;
y : GLfloat;
z : GLfloat);
procedure glScaled (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glScalef (x : GLfloat; y : GLfloat; z : GLfloat);
procedure glTranslated (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glTranslatef (x : GLfloat; y : GLfloat; z : GLfloat);
function glIsList (list : GLuint) return GLboolean;
procedure glDeleteLists (list : GLuint; c_range : GLsizei);
function glGenLists (c_range : GLsizei) return GLuint;
procedure glNewList (list : GLuint; mode : GLenum);
procedure glEndList;
procedure glCallList (list : GLuint);
procedure glCallLists (n : GLsizei; c_type : GLenum; lists : GLvoid_Ptr);
procedure glListBase (base : GLuint);
procedure glBegin (mode : GLenum);
procedure glEnd;
procedure glVertex2d (x : GLdouble; y : GLdouble);
procedure glVertex2f (x : GLfloat; y : GLfloat);
procedure glVertex2i (x : GLint; y : GLint);
procedure glVertex2s (x : GLshort; y : GLshort);
procedure glVertex3d (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glVertex3f (x : GLfloat; y : GLfloat; z : GLfloat);
procedure glVertex3i (x : GLint; y : GLint; z : GLint);
procedure glVertex3s (x : GLshort; y : GLshort; z : GLshort);
procedure glVertex4d
(x : GLdouble;
y : GLdouble;
z : GLdouble;
w : GLdouble);
procedure glVertex4f
(x : GLfloat;
y : GLfloat;
z : GLfloat;
w : GLfloat);
procedure glVertex4i
(x : GLint;
y : GLint;
z : GLint;
w : GLint);
procedure glVertex4s
(x : GLshort;
y : GLshort;
z : GLshort;
w : GLshort);
procedure glVertex2dv (v : access GLdouble);
procedure glVertex2fv (v : access GLfloat);
procedure glVertex2iv (v : access GLint);
procedure glVertex2sv (v : access GLshort);
procedure glVertex3dv (v : access GLdouble);
procedure glVertex3fv (v : access GLfloat);
procedure glVertex3iv (v : access GLint);
procedure glVertex3sv (v : access GLshort);
procedure glVertex4dv (v : access GLdouble);
procedure glVertex4fv (v : access GLfloat);
procedure glVertex4iv (v : access GLint);
procedure glVertex4sv (v : access GLshort);
procedure glNormal3b (nx : GLbyte; ny : GLbyte; nz : GLbyte);
procedure glNormal3d (nx : GLdouble; ny : GLdouble; nz : GLdouble);
procedure glNormal3f (nx : GLfloat; ny : GLfloat; nz : GLfloat);
procedure glNormal3i (nx : GLint; ny : GLint; nz : GLint);
procedure glNormal3s (nx : GLshort; ny : GLshort; nz : GLshort);
procedure glNormal3bv (v : access GLbyte);
procedure glNormal3dv (v : access GLdouble);
procedure glNormal3fv (v : access GLfloat);
procedure glNormal3iv (v : access GLint);
procedure glNormal3sv (v : access GLshort);
procedure glIndexd (c : GLdouble);
procedure glIndexf (c : GLfloat);
procedure glIndexi (c : GLint);
procedure glIndexs (c : GLshort);
procedure glIndexub (c : GLubyte);
procedure glIndexdv (c : access GLdouble);
procedure glIndexfv (c : access GLfloat);
procedure glIndexiv (c : access GLint);
procedure glIndexsv (c : access GLshort);
procedure glIndexubv (c : access GLubyte);
procedure glColor3b (red : GLbyte; green : GLbyte; blue : GLbyte);
procedure glColor3d (red : GLdouble; green : GLdouble; blue : GLdouble);
procedure glColor3f (red : GLfloat; green : GLfloat; blue : GLfloat);
procedure glColor3i (red : GLint; green : GLint; blue : GLint);
procedure glColor3s (red : GLshort; green : GLshort; blue : GLshort);
procedure glColor3ub (red : GLubyte; green : GLubyte; blue : GLubyte);
procedure glColor3ui (red : GLuint; green : GLuint; blue : GLuint);
procedure glColor3us (red : GLushort; green : GLushort; blue : GLushort);
procedure glColor4b
(red : GLbyte;
green : GLbyte;
blue : GLbyte;
alpha : GLbyte);
procedure glColor4d
(red : GLdouble;
green : GLdouble;
blue : GLdouble;
alpha : GLdouble);
procedure glColor4f
(red : GLfloat;
green : GLfloat;
blue : GLfloat;
alpha : GLfloat);
procedure glColor4i
(red : GLint;
green : GLint;
blue : GLint;
alpha : GLint);
procedure glColor4s
(red : GLshort;
green : GLshort;
blue : GLshort;
alpha : GLshort);
procedure glColor4ub
(red : GLubyte;
green : GLubyte;
blue : GLubyte;
alpha : GLubyte);
procedure glColor4ui
(red : GLuint;
green : GLuint;
blue : GLuint;
alpha : GLuint);
procedure glColor4us
(red : GLushort;
green : GLushort;
blue : GLushort;
alpha : GLushort);
procedure glColor3bv (v : access GLbyte);
procedure glColor3dv (v : access GLdouble);
procedure glColor3fv (v : access GLfloat);
procedure glColor3iv (v : access GLint);
procedure glColor3sv (v : access GLshort);
procedure glColor3ubv (v : access GLubyte);
procedure glColor3uiv (v : access GLuint);
procedure glColor3usv (v : access GLushort);
procedure glColor4bv (v : access GLbyte);
procedure glColor4dv (v : access GLdouble);
procedure glColor4fv (v : access GLfloat);
procedure glColor4iv (v : access GLint);
procedure glColor4sv (v : access GLshort);
procedure glColor4ubv (v : access GLubyte);
procedure glColor4uiv (v : access GLuint);
procedure glColor4usv (v : access GLushort);
procedure glTexCoord1d (s : GLdouble);
procedure glTexCoord1f (s : GLfloat);
procedure glTexCoord1i (s : GLint);
procedure glTexCoord1s (s : GLshort);
procedure glTexCoord2d (s : GLdouble; t : GLdouble);
procedure glTexCoord2f (s : GLfloat; t : GLfloat);
procedure glTexCoord2i (s : GLint; t : GLint);
procedure glTexCoord2s (s : GLshort; t : GLshort);
procedure glTexCoord3d (s : GLdouble; t : GLdouble; r : GLdouble);
procedure glTexCoord3f (s : GLfloat; t : GLfloat; r : GLfloat);
procedure glTexCoord3i (s : GLint; t : GLint; r : GLint);
procedure glTexCoord3s (s : GLshort; t : GLshort; r : GLshort);
procedure glTexCoord4d
(s : GLdouble;
t : GLdouble;
r : GLdouble;
q : GLdouble);
procedure glTexCoord4f
(s : GLfloat;
t : GLfloat;
r : GLfloat;
q : GLfloat);
procedure glTexCoord4i
(s : GLint;
t : GLint;
r : GLint;
q : GLint);
procedure glTexCoord4s
(s : GLshort;
t : GLshort;
r : GLshort;
q : GLshort);
procedure glTexCoord1dv (v : access GLdouble);
procedure glTexCoord1fv (v : access GLfloat);
procedure glTexCoord1iv (v : access GLint);
procedure glTexCoord1sv (v : access GLshort);
procedure glTexCoord2dv (v : access GLdouble);
procedure glTexCoord2fv (v : access GLfloat);
procedure glTexCoord2iv (v : access GLint);
procedure glTexCoord2sv (v : access GLshort);
procedure glTexCoord3dv (v : access GLdouble);
procedure glTexCoord3fv (v : access GLfloat);
procedure glTexCoord3iv (v : access GLint);
procedure glTexCoord3sv (v : access GLshort);
procedure glTexCoord4dv (v : access GLdouble);
procedure glTexCoord4fv (v : access GLfloat);
procedure glTexCoord4iv (v : access GLint);
procedure glTexCoord4sv (v : access GLshort);
procedure glRasterPos2d (x : GLdouble; y : GLdouble);
procedure glRasterPos2f (x : GLfloat; y : GLfloat);
procedure glRasterPos2i (x : GLint; y : GLint);
procedure glRasterPos2s (x : GLshort; y : GLshort);
procedure glRasterPos3d (x : GLdouble; y : GLdouble; z : GLdouble);
procedure glRasterPos3f (x : GLfloat; y : GLfloat; z : GLfloat);
procedure glRasterPos3i (x : GLint; y : GLint; z : GLint);
procedure glRasterPos3s (x : GLshort; y : GLshort; z : GLshort);
procedure glRasterPos4d
(x : GLdouble;
y : GLdouble;
z : GLdouble;
w : GLdouble);
procedure glRasterPos4f
(x : GLfloat;
y : GLfloat;
z : GLfloat;
w : GLfloat);
procedure glRasterPos4i
(x : GLint;
y : GLint;
z : GLint;
w : GLint);
procedure glRasterPos4s
(x : GLshort;
y : GLshort;
z : GLshort;
w : GLshort);
procedure glRasterPos2dv (v : access GLdouble);
procedure glRasterPos2fv (v : access GLfloat);
procedure glRasterPos2iv (v : access GLint);
procedure glRasterPos2sv (v : access GLshort);
procedure glRasterPos3dv (v : access GLdouble);
procedure glRasterPos3fv (v : access GLfloat);
procedure glRasterPos3iv (v : access GLint);
procedure glRasterPos3sv (v : access GLshort);
procedure glRasterPos4dv (v : access GLdouble);
procedure glRasterPos4fv (v : access GLfloat);
procedure glRasterPos4iv (v : access GLint);
procedure glRasterPos4sv (v : access GLshort);
procedure glRectd
(x1 : GLdouble;
y1 : GLdouble;
x2 : GLdouble;
y2 : GLdouble);
procedure glRectf
(x1 : GLfloat;
y1 : GLfloat;
x2 : GLfloat;
y2 : GLfloat);
procedure glRecti
(x1 : GLint;
y1 : GLint;
x2 : GLint;
y2 : GLint);
procedure glRects
(x1 : GLshort;
y1 : GLshort;
x2 : GLshort;
y2 : GLshort);
procedure glRectdv (v1 : access GLdouble; v2 : access GLdouble);
procedure glRectfv (v1 : access GLfloat; v2 : access GLfloat);
procedure glRectiv (v1 : access GLint; v2 : access GLint);
procedure glRectsv (v1 : access GLshort; v2 : access GLshort);
procedure glShadeModel (mode : GLenum);
procedure glLightf (light : GLenum; pname : GLenum; param : GLfloat);
procedure glLighti (light : GLenum; pname : GLenum; param : GLint);
procedure glLightfv (light : GLenum; pname : GLenum; params : access GLfloat);
procedure glLightiv (light : GLenum; pname : GLenum; params : access GLint);
procedure glGetLightfv (light : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetLightiv (light : GLenum; pname : GLenum; params : access GLint);
procedure glLightModelf (pname : GLenum; param : GLfloat);
procedure glLightModeli (pname : GLenum; param : GLint);
procedure glLightModelfv (pname : GLenum; params : access GLfloat);
procedure glLightModeliv (pname : GLenum; params : access GLint);
procedure glMaterialf (face : GLenum; pname : GLenum; param : GLfloat);
procedure glMateriali (face : GLenum; pname : GLenum; param : GLint);
procedure glMaterialfv (face : GLenum; pname : GLenum; params : access GLfloat);
procedure glMaterialiv (face : GLenum; pname : GLenum; params : access GLint);
procedure glGetMaterialfv (face : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetMaterialiv (face : GLenum; pname : GLenum; params : access GLint);
procedure glColorMaterial (face : GLenum; mode : GLenum);
procedure glPixelZoom (xfactor : GLfloat; yfactor : GLfloat);
procedure glPixelStoref (pname : GLenum; param : GLfloat);
procedure glPixelStorei (pname : GLenum; param : GLint);
procedure glPixelTransferf (pname : GLenum; param : GLfloat);
procedure glPixelTransferi (pname : GLenum; param : GLint);
procedure glPixelMapfv (map : GLenum; mapsize : GLint; values : access GLfloat);
procedure glPixelMapuiv (map : GLenum; mapsize : GLint; values : access GLuint);
procedure glPixelMapusv (map : GLenum; mapsize : GLint; values : access GLushort);
procedure glGetPixelMapfv (map : GLenum; values : access GLfloat);
procedure glGetPixelMapuiv (map : GLenum; values : access GLuint);
procedure glGetPixelMapusv (map : GLenum; values : access GLushort);
procedure glBitmap
(width : GLsizei;
height : GLsizei;
xorig : GLfloat;
yorig : GLfloat;
xmove : GLfloat;
ymove : GLfloat;
bitmap : access GLubyte);
procedure glReadPixels
(x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glDrawPixels
(width : GLsizei;
height : GLsizei;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glCopyPixels
(x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei;
c_type : GLenum);
procedure glStencilFunc (func : GLenum; ref : GLint; mask : GLuint);
procedure glStencilMask (mask : GLuint);
procedure glStencilOp (fail : GLenum; zfail : GLenum; zpass : GLenum);
procedure glClearStencil (s : GLint);
procedure glTexGend (coord : GLenum; pname : GLenum; param : GLdouble);
procedure glTexGenf (coord : GLenum; pname : GLenum; param : GLfloat);
procedure glTexGeni (coord : GLenum; pname : GLenum; param : GLint);
procedure glTexGendv (coord : GLenum; pname : GLenum; params : access GLdouble);
procedure glTexGenfv (coord : GLenum; pname : GLenum; params : access GLfloat);
procedure glTexGeniv (coord : GLenum; pname : GLenum; params : access GLint);
procedure glGetTexGendv (coord : GLenum; pname : GLenum; params : access GLdouble);
procedure glGetTexGenfv (coord : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetTexGeniv (coord : GLenum; pname : GLenum; params : access GLint);
procedure glTexEnvf (target : GLenum; pname : GLenum; param : GLfloat);
procedure glTexEnvi (target : GLenum; pname : GLenum; param : GLint);
procedure glTexEnvfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glTexEnviv (target : GLenum; pname : GLenum; params : access GLint);
procedure glGetTexEnvfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetTexEnviv (target : GLenum; pname : GLenum; params : access GLint);
procedure glTexParameterf (target : GLenum; pname : GLenum; param : GLfloat);
procedure glTexParameteri (target : GLenum; pname : GLenum; param : GLint);
procedure glTexParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glTexParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glGetTexParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetTexParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glGetTexLevelParameterfv
(target : GLenum;
level : GLint;
pname : GLenum;
params : access GLfloat);
procedure glGetTexLevelParameteriv
(target : GLenum;
level : GLint;
pname : GLenum;
params : access GLint);
procedure glTexImage1D
(target : GLenum;
level : GLint;
internalFormat : GLint;
width : GLsizei;
border : GLint;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glTexImage2D
(target : GLenum;
level : GLint;
internalFormat : GLint;
width : GLsizei;
height : GLsizei;
border : GLint;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glGetTexImage
(target : GLenum;
level : GLint;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glMap1d
(target : GLenum;
u1 : GLdouble;
u2 : GLdouble;
stride : GLint;
order : GLint;
points : access GLdouble);
procedure glMap1f
(target : GLenum;
u1 : GLfloat;
u2 : GLfloat;
stride : GLint;
order : GLint;
points : access GLfloat);
procedure glMap2d
(target : GLenum;
u1 : GLdouble;
u2 : GLdouble;
ustride : GLint;
uorder : GLint;
v1 : GLdouble;
v2 : GLdouble;
vstride : GLint;
vorder : GLint;
points : access GLdouble);
procedure glMap2f
(target : GLenum;
u1 : GLfloat;
u2 : GLfloat;
ustride : GLint;
uorder : GLint;
v1 : GLfloat;
v2 : GLfloat;
vstride : GLint;
vorder : GLint;
points : access GLfloat);
procedure glGetMapdv (target : GLenum; query : GLenum; v : access GLdouble);
procedure glGetMapfv (target : GLenum; query : GLenum; v : access GLfloat);
procedure glGetMapiv (target : GLenum; query : GLenum; v : access GLint);
procedure glEvalCoord1d (u : GLdouble);
procedure glEvalCoord1f (u : GLfloat);
procedure glEvalCoord1dv (u : access GLdouble);
procedure glEvalCoord1fv (u : access GLfloat);
procedure glEvalCoord2d (u : GLdouble; v : GLdouble);
procedure glEvalCoord2f (u : GLfloat; v : GLfloat);
procedure glEvalCoord2dv (u : access GLdouble);
procedure glEvalCoord2fv (u : access GLfloat);
procedure glMapGrid1d (un : GLint; u1 : GLdouble; u2 : GLdouble);
procedure glMapGrid1f (un : GLint; u1 : GLfloat; u2 : GLfloat);
procedure glMapGrid2d
(un : GLint;
u1 : GLdouble;
u2 : GLdouble;
vn : GLint;
v1 : GLdouble;
v2 : GLdouble);
procedure glMapGrid2f
(un : GLint;
u1 : GLfloat;
u2 : GLfloat;
vn : GLint;
v1 : GLfloat;
v2 : GLfloat);
procedure glEvalPoint1 (i : GLint);
procedure glEvalPoint2 (i : GLint; j : GLint);
procedure glEvalMesh1 (mode : GLenum; i1 : GLint; i2 : GLint);
procedure glEvalMesh2
(mode : GLenum;
i1 : GLint;
i2 : GLint;
j1 : GLint;
j2 : GLint);
procedure glFogf (pname : GLenum; param : GLfloat);
procedure glFogi (pname : GLenum; param : GLint);
procedure glFogfv (pname : GLenum; params : access GLfloat);
procedure glFogiv (pname : GLenum; params : access GLint);
procedure glFeedbackBuffer (size : GLsizei; c_type : GLenum; buffer : access GLfloat);
procedure glPassThrough (token : GLfloat);
procedure glSelectBuffer (size : GLsizei; buffer : access GLuint);
procedure glInitNames;
procedure glLoadName (name : GLuint);
procedure glPushName (name : GLuint);
procedure glPopName;
procedure glGenTextures (n : GLsizei; textures : access GLuint);
procedure glDeleteTextures (n : GLsizei; textures : access GLuint);
procedure glBindTexture (target : GLenum; texture : GLuint);
procedure glPrioritizeTextures (n : GLsizei; textures : access GLuint; priorities : access GLclampf);
function glAreTexturesResident
(n : GLsizei;
textures : access GLuint;
residences : access GLboolean)
return GLboolean;
function glIsTexture (texture : GLuint) return GLboolean;
procedure glTexSubImage1D
(target : GLenum;
level : GLint;
xoffset : GLint;
width : GLsizei;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glTexSubImage2D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
width : GLsizei;
height : GLsizei;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glCopyTexImage1D
(target : GLenum;
level : GLint;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei;
border : GLint);
procedure glCopyTexImage2D
(target : GLenum;
level : GLint;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei;
border : GLint);
procedure glCopyTexSubImage1D
(target : GLenum;
level : GLint;
xoffset : GLint;
x : GLint;
y : GLint;
width : GLsizei);
procedure glCopyTexSubImage2D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glVertexPointer
(size : GLint;
c_type : GLenum;
stride : GLsizei;
ptr : GLvoid_Ptr);
procedure glNormalPointer (c_type : GLenum; stride : GLsizei; ptr : GLvoid_Ptr);
procedure glColorPointer
(size : GLint;
c_type : GLenum;
stride : GLsizei;
ptr : GLvoid_Ptr);
procedure glIndexPointer (c_type : GLenum; stride : GLsizei; ptr : GLvoid_Ptr);
procedure glTexCoordPointer
(size : GLint;
c_type : GLenum;
stride : GLsizei;
ptr : GLvoid_Ptr);
procedure glEdgeFlagPointer (stride : GLsizei; ptr : GLvoid_Ptr);
procedure glGetPointerv (pname : GLenum; params : GLvoid_Ptr);
procedure glArrayElement (i : GLint);
procedure glDrawArrays (mode : GLenum; first : GLint; count : GLsizei);
procedure glDrawElements
(mode : GLenum;
count : GLsizei;
c_type : GLenum;
indices : GLvoid_Ptr);
procedure glInterleavedArrays (format : GLenum; stride : GLsizei; pointer : GLvoid_Ptr);
procedure glDrawRangeElements
(mode : GLenum;
start : GLuint;
c_end : GLuint;
count : GLsizei;
c_type : GLenum;
indices : GLvoid_Ptr);
procedure glTexImage3D
(target : GLenum;
level : GLint;
internalFormat : GLenum;
width : GLsizei;
height : GLsizei;
depth : GLsizei;
border : GLint;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glTexSubImage3D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
zoffset : GLint;
width : GLsizei;
height : GLsizei;
depth : GLsizei;
format : GLenum;
c_type : GLenum;
pixels : GLvoid_Ptr);
procedure glCopyTexSubImage3D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
zoffset : GLint;
x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glColorTable
(target : GLenum;
internalformat : GLenum;
width : GLsizei;
format : GLenum;
c_type : GLenum;
table : GLvoid_Ptr);
procedure glColorSubTable
(target : GLenum;
start : GLsizei;
count : GLsizei;
format : GLenum;
c_type : GLenum;
data : GLvoid_Ptr);
procedure glColorTableParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glColorTableParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glCopyColorSubTable
(target : GLenum;
start : GLsizei;
x : GLint;
y : GLint;
width : GLsizei);
procedure glCopyColorTable
(target : GLenum;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei);
procedure glGetColorTable
(target : GLenum;
format : GLenum;
c_type : GLenum;
table : GLvoid_Ptr);
procedure glGetColorTableParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetColorTableParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glBlendEquation (mode : GLenum);
procedure glBlendColor
(red : GLclampf;
green : GLclampf;
blue : GLclampf;
alpha : GLclampf);
procedure glHistogram
(target : GLenum;
width : GLsizei;
internalformat : GLenum;
sink : GLboolean);
procedure glResetHistogram (target : GLenum);
procedure glGetHistogram
(target : GLenum;
reset : GLboolean;
format : GLenum;
c_type : GLenum;
values : GLvoid_Ptr);
procedure glGetHistogramParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetHistogramParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glMinmax (target : GLenum; internalformat : GLenum; sink : GLboolean);
procedure glResetMinmax (target : GLenum);
procedure glGetMinmax
(target : GLenum;
reset : GLboolean;
format : GLenum;
types : GLenum;
values : GLvoid_Ptr);
procedure glGetMinmaxParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetMinmaxParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glConvolutionFilter1D
(target : GLenum;
internalformat : GLenum;
width : GLsizei;
format : GLenum;
c_type : GLenum;
image : GLvoid_Ptr);
procedure glConvolutionFilter2D
(target : GLenum;
internalformat : GLenum;
width : GLsizei;
height : GLsizei;
format : GLenum;
c_type : GLenum;
image : GLvoid_Ptr);
procedure glConvolutionParameterf (target : GLenum; pname : GLenum; params : GLfloat);
procedure glConvolutionParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glConvolutionParameteri (target : GLenum; pname : GLenum; params : GLint);
procedure glConvolutionParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glCopyConvolutionFilter1D
(target : GLenum;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei);
procedure glCopyConvolutionFilter2D
(target : GLenum;
internalformat : GLenum;
x : GLint;
y : GLint;
width : GLsizei;
height : GLsizei);
procedure glGetConvolutionFilter
(target : GLenum;
format : GLenum;
c_type : GLenum;
image : GLvoid_Ptr);
procedure glGetConvolutionParameterfv (target : GLenum; pname : GLenum; params : access GLfloat);
procedure glGetConvolutionParameteriv (target : GLenum; pname : GLenum; params : access GLint);
procedure glSeparableFilter2D
(target : GLenum;
internalformat : GLenum;
width : GLsizei;
height : GLsizei;
format : GLenum;
c_type : GLenum;
row : GLvoid_Ptr;
column : GLvoid_Ptr);
procedure glGetSeparableFilter
(target : GLenum;
format : GLenum;
c_type : GLenum;
row : GLvoid_Ptr;
column : GLvoid_Ptr;
span : GLvoid_Ptr);
procedure glActiveTexture (texture : GLenum);
procedure glClientActiveTexture (texture : GLenum);
procedure glCompressedTexImage1D
(target : GLenum;
level : GLint;
internalformat : GLenum;
width : GLsizei;
border : GLint;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glCompressedTexImage2D
(target : GLenum;
level : GLint;
internalformat : GLenum;
width : GLsizei;
height : GLsizei;
border : GLint;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glCompressedTexImage3D
(target : GLenum;
level : GLint;
internalformat : GLenum;
width : GLsizei;
height : GLsizei;
depth : GLsizei;
border : GLint;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glCompressedTexSubImage1D
(target : GLenum;
level : GLint;
xoffset : GLint;
width : GLsizei;
format : GLenum;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glCompressedTexSubImage2D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
width : GLsizei;
height : GLsizei;
format : GLenum;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glCompressedTexSubImage3D
(target : GLenum;
level : GLint;
xoffset : GLint;
yoffset : GLint;
zoffset : GLint;
width : GLsizei;
height : GLsizei;
depth : GLsizei;
format : GLenum;
imageSize : GLsizei;
data : GLvoid_Ptr);
procedure glGetCompressedTexImage (target : GLenum; lod : GLint; img : GLvoid_Ptr);
procedure glMultiTexCoord1d (target : GLenum; s : GLdouble);
procedure glMultiTexCoord1dv (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord1f (target : GLenum; s : GLfloat);
procedure glMultiTexCoord1fv (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord1i (target : GLenum; s : GLint);
procedure glMultiTexCoord1iv (target : GLenum; v : access GLint);
procedure glMultiTexCoord1s (target : GLenum; s : GLshort);
procedure glMultiTexCoord1sv (target : GLenum; v : access GLshort);
procedure glMultiTexCoord2d (target : GLenum; s : GLdouble; t : GLdouble);
procedure glMultiTexCoord2dv (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord2f (target : GLenum; s : GLfloat; t : GLfloat);
procedure glMultiTexCoord2fv (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord2i (target : GLenum; s : GLint; t : GLint);
procedure glMultiTexCoord2iv (target : GLenum; v : access GLint);
procedure glMultiTexCoord2s (target : GLenum; s : GLshort; t : GLshort);
procedure glMultiTexCoord2sv (target : GLenum; v : access GLshort);
procedure glMultiTexCoord3d
(target : GLenum;
s : GLdouble;
t : GLdouble;
r : GLdouble);
procedure glMultiTexCoord3dv (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord3f
(target : GLenum;
s : GLfloat;
t : GLfloat;
r : GLfloat);
procedure glMultiTexCoord3fv (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord3i
(target : GLenum;
s : GLint;
t : GLint;
r : GLint);
procedure glMultiTexCoord3iv (target : GLenum; v : access GLint);
procedure glMultiTexCoord3s
(target : GLenum;
s : GLshort;
t : GLshort;
r : GLshort);
procedure glMultiTexCoord3sv (target : GLenum; v : access GLshort);
procedure glMultiTexCoord4d
(target : GLenum;
s : GLdouble;
t : GLdouble;
r : GLdouble;
q : GLdouble);
procedure glMultiTexCoord4dv (target : GLenum; v : access GLdouble);
procedure glMultiTexCoord4f
(target : GLenum;
s : GLfloat;
t : GLfloat;
r : GLfloat;
q : GLfloat);
procedure glMultiTexCoord4fv (target : GLenum; v : access GLfloat);
procedure glMultiTexCoord4i
(target : GLenum;
s : GLint;
t : GLint;
r : GLint;
q : GLint);
procedure glMultiTexCoord4iv (target : GLenum; v : access GLint);
procedure glMultiTexCoord4s
(target : GLenum;
s : GLshort;
t : GLshort;
r : GLshort;
q : GLshort);
procedure glMultiTexCoord4sv (target : GLenum; v : access GLshort);
procedure glLoadTransposeMatrixd (m : access GLdouble);
procedure glLoadTransposeMatrixf (m : access GLfloat);
procedure glMultTransposeMatrixd (m : access GLdouble);
procedure glMultTransposeMatrixf (m : access GLfloat);
procedure glSampleCoverage (value : GLclampf; invert : GLboolean);
procedure glSamplePass (pass : GLenum);
private
pragma Import (Stdcall, glClearIndex, "glClearIndex");
pragma Import (Stdcall, glClearColor, "glClearColor");
pragma Import (Stdcall, glClear, "glClear");
pragma Import (Stdcall, glIndexMask, "glIndexMask");
pragma Import (Stdcall, glColorMask, "glColorMask");
pragma Import (Stdcall, glAlphaFunc, "glAlphaFunc");
pragma Import (Stdcall, glBlendFunc, "glBlendFunc");
pragma Import (Stdcall, glLogicOp, "glLogicOp");
pragma Import (Stdcall, glCullFace, "glCullFace");
pragma Import (Stdcall, glFrontFace, "glFrontFace");
pragma Import (Stdcall, glPointSize, "glPointSize");
pragma Import (Stdcall, glLineWidth, "glLineWidth");
pragma Import (Stdcall, glLineStipple, "glLineStipple");
pragma Import (Stdcall, glPolygonMode, "glPolygonMode");
pragma Import (Stdcall, glPolygonOffset, "glPolygonOffset");
pragma Import (Stdcall, glPolygonStipple, "glPolygonStipple");
pragma Import (Stdcall, glGetPolygonStipple, "glGetPolygonStipple");
pragma Import (Stdcall, glEdgeFlag, "glEdgeFlag");
pragma Import (Stdcall, glEdgeFlagv, "glEdgeFlagv");
pragma Import (Stdcall, glScissor, "glScissor");
pragma Import (Stdcall, glClipPlane, "glClipPlane");
pragma Import (Stdcall, glGetClipPlane, "glGetClipPlane");
pragma Import (Stdcall, glDrawBuffer, "glDrawBuffer");
pragma Import (Stdcall, glReadBuffer, "glReadBuffer");
pragma Import (Stdcall, glEnable, "glEnable");
pragma Import (Stdcall, glDisable, "glDisable");
pragma Import (Stdcall, glIsEnabled, "glIsEnabled");
pragma Import (Stdcall, glEnableClientState, "glEnableClientState");
pragma Import (Stdcall, glDisableClientState, "glDisableClientState");
pragma Import (Stdcall, glGetBooleanv, "glGetBooleanv");
pragma Import (Stdcall, glGetDoublev, "glGetDoublev");
pragma Import (Stdcall, glGetFloatv, "glGetFloatv");
pragma Import (Stdcall, glGetIntegerv, "glGetIntegerv");
pragma Import (Stdcall, glPushAttrib, "glPushAttrib");
pragma Import (Stdcall, glPopAttrib, "glPopAttrib");
pragma Import (Stdcall, glPushClientAttrib, "glPushClientAttrib");
pragma Import (Stdcall, glPopClientAttrib, "glPopClientAttrib");
pragma Import (Stdcall, glRenderMode, "glRenderMode");
pragma Import (Stdcall, glGetError, "glGetError");
pragma Import (Stdcall, glGetString, "glGetString");
pragma Import (Stdcall, glFinish, "glFinish");
pragma Import (Stdcall, glFlush, "glFlush");
pragma Import (Stdcall, glHint, "glHint");
pragma Import (Stdcall, glClearDepth, "glClearDepth");
pragma Import (Stdcall, glDepthFunc, "glDepthFunc");
pragma Import (Stdcall, glDepthMask, "glDepthMask");
pragma Import (Stdcall, glDepthRange, "glDepthRange");
pragma Import (Stdcall, glClearAccum, "glClearAccum");
pragma Import (Stdcall, glAccum, "glAccum");
pragma Import (Stdcall, glMatrixMode, "glMatrixMode");
pragma Import (Stdcall, glOrtho, "glOrtho");
pragma Import (Stdcall, glFrustum, "glFrustum");
pragma Import (Stdcall, glViewport, "glViewport");
pragma Import (Stdcall, glPushMatrix, "glPushMatrix");
pragma Import (Stdcall, glPopMatrix, "glPopMatrix");
pragma Import (Stdcall, glLoadIdentity, "glLoadIdentity");
pragma Import (Stdcall, glLoadMatrixd, "glLoadMatrixd");
pragma Import (Stdcall, glLoadMatrixf, "glLoadMatrixf");
pragma Import (Stdcall, glMultMatrixd, "glMultMatrixd");
pragma Import (Stdcall, glMultMatrixf, "glMultMatrixf");
pragma Import (Stdcall, glRotated, "glRotated");
pragma Import (Stdcall, glRotatef, "glRotatef");
pragma Import (Stdcall, glScaled, "glScaled");
pragma Import (Stdcall, glScalef, "glScalef");
pragma Import (Stdcall, glTranslated, "glTranslated");
pragma Import (Stdcall, glTranslatef, "glTranslatef");
pragma Import (Stdcall, glIsList, "glIsList");
pragma Import (Stdcall, glDeleteLists, "glDeleteLists");
pragma Import (Stdcall, glGenLists, "glGenLists");
pragma Import (Stdcall, glNewList, "glNewList");
pragma Import (Stdcall, glEndList, "glEndList");
pragma Import (Stdcall, glCallList, "glCallList");
pragma Import (Stdcall, glCallLists, "glCallLists");
pragma Import (Stdcall, glListBase, "glListBase");
pragma Import (Stdcall, glBegin, "glBegin");
pragma Import (Stdcall, glEnd, "glEnd");
pragma Import (Stdcall, glVertex2d, "glVertex2d");
pragma Import (Stdcall, glVertex2f, "glVertex2f");
pragma Import (Stdcall, glVertex2i, "glVertex2i");
pragma Import (Stdcall, glVertex2s, "glVertex2s");
pragma Import (Stdcall, glVertex3d, "glVertex3d");
pragma Import (Stdcall, glVertex3f, "glVertex3f");
pragma Import (Stdcall, glVertex3i, "glVertex3i");
pragma Import (Stdcall, glVertex3s, "glVertex3s");
pragma Import (Stdcall, glVertex4d, "glVertex4d");
pragma Import (Stdcall, glVertex4f, "glVertex4f");
pragma Import (Stdcall, glVertex4i, "glVertex4i");
pragma Import (Stdcall, glVertex4s, "glVertex4s");
pragma Import (Stdcall, glVertex2dv, "glVertex2dv");
pragma Import (Stdcall, glVertex2fv, "glVertex2fv");
pragma Import (Stdcall, glVertex2iv, "glVertex2iv");
pragma Import (Stdcall, glVertex2sv, "glVertex2sv");
pragma Import (Stdcall, glVertex3dv, "glVertex3dv");
pragma Import (Stdcall, glVertex3fv, "glVertex3fv");
pragma Import (Stdcall, glVertex3iv, "glVertex3iv");
pragma Import (Stdcall, glVertex3sv, "glVertex3sv");
pragma Import (Stdcall, glVertex4dv, "glVertex4dv");
pragma Import (Stdcall, glVertex4fv, "glVertex4fv");
pragma Import (Stdcall, glVertex4iv, "glVertex4iv");
pragma Import (Stdcall, glVertex4sv, "glVertex4sv");
pragma Import (Stdcall, glNormal3b, "glNormal3b");
pragma Import (Stdcall, glNormal3d, "glNormal3d");
pragma Import (Stdcall, glNormal3f, "glNormal3f");
pragma Import (Stdcall, glNormal3i, "glNormal3i");
pragma Import (Stdcall, glNormal3s, "glNormal3s");
pragma Import (Stdcall, glNormal3bv, "glNormal3bv");
pragma Import (Stdcall, glNormal3dv, "glNormal3dv");
pragma Import (Stdcall, glNormal3fv, "glNormal3fv");
pragma Import (Stdcall, glNormal3iv, "glNormal3iv");
pragma Import (Stdcall, glNormal3sv, "glNormal3sv");
pragma Import (Stdcall, glIndexd, "glIndexd");
pragma Import (Stdcall, glIndexf, "glIndexf");
pragma Import (Stdcall, glIndexi, "glIndexi");
pragma Import (Stdcall, glIndexs, "glIndexs");
pragma Import (Stdcall, glIndexub, "glIndexub");
pragma Import (Stdcall, glIndexdv, "glIndexdv");
pragma Import (Stdcall, glIndexfv, "glIndexfv");
pragma Import (Stdcall, glIndexiv, "glIndexiv");
pragma Import (Stdcall, glIndexsv, "glIndexsv");
pragma Import (Stdcall, glIndexubv, "glIndexubv");
pragma Import (Stdcall, glColor3b, "glColor3b");
pragma Import (Stdcall, glColor3d, "glColor3d");
pragma Import (Stdcall, glColor3f, "glColor3f");
pragma Import (Stdcall, glColor3i, "glColor3i");
pragma Import (Stdcall, glColor3s, "glColor3s");
pragma Import (Stdcall, glColor3ub, "glColor3ub");
pragma Import (Stdcall, glColor3ui, "glColor3ui");
pragma Import (Stdcall, glColor3us, "glColor3us");
pragma Import (Stdcall, glColor4b, "glColor4b");
pragma Import (Stdcall, glColor4d, "glColor4d");
pragma Import (Stdcall, glColor4f, "glColor4f");
pragma Import (Stdcall, glColor4i, "glColor4i");
pragma Import (Stdcall, glColor4s, "glColor4s");
pragma Import (Stdcall, glColor4ub, "glColor4ub");
pragma Import (Stdcall, glColor4ui, "glColor4ui");
pragma Import (Stdcall, glColor4us, "glColor4us");
pragma Import (Stdcall, glColor3bv, "glColor3bv");
pragma Import (Stdcall, glColor3dv, "glColor3dv");
pragma Import (Stdcall, glColor3fv, "glColor3fv");
pragma Import (Stdcall, glColor3iv, "glColor3iv");
pragma Import (Stdcall, glColor3sv, "glColor3sv");
pragma Import (Stdcall, glColor3ubv, "glColor3ubv");
pragma Import (Stdcall, glColor3uiv, "glColor3uiv");
pragma Import (Stdcall, glColor3usv, "glColor3usv");
pragma Import (Stdcall, glColor4bv, "glColor4bv");
pragma Import (Stdcall, glColor4dv, "glColor4dv");
pragma Import (Stdcall, glColor4fv, "glColor4fv");
pragma Import (Stdcall, glColor4iv, "glColor4iv");
pragma Import (Stdcall, glColor4sv, "glColor4sv");
pragma Import (Stdcall, glColor4ubv, "glColor4ubv");
pragma Import (Stdcall, glColor4uiv, "glColor4uiv");
pragma Import (Stdcall, glColor4usv, "glColor4usv");
pragma Import (Stdcall, glTexCoord1d, "glTexCoord1d");
pragma Import (Stdcall, glTexCoord1f, "glTexCoord1f");
pragma Import (Stdcall, glTexCoord1i, "glTexCoord1i");
pragma Import (Stdcall, glTexCoord1s, "glTexCoord1s");
pragma Import (Stdcall, glTexCoord2d, "glTexCoord2d");
pragma Import (Stdcall, glTexCoord2f, "glTexCoord2f");
pragma Import (Stdcall, glTexCoord2i, "glTexCoord2i");
pragma Import (Stdcall, glTexCoord2s, "glTexCoord2s");
pragma Import (Stdcall, glTexCoord3d, "glTexCoord3d");
pragma Import (Stdcall, glTexCoord3f, "glTexCoord3f");
pragma Import (Stdcall, glTexCoord3i, "glTexCoord3i");
pragma Import (Stdcall, glTexCoord3s, "glTexCoord3s");
pragma Import (Stdcall, glTexCoord4d, "glTexCoord4d");
pragma Import (Stdcall, glTexCoord4f, "glTexCoord4f");
pragma Import (Stdcall, glTexCoord4i, "glTexCoord4i");
pragma Import (Stdcall, glTexCoord4s, "glTexCoord4s");
pragma Import (Stdcall, glTexCoord1dv, "glTexCoord1dv");
pragma Import (Stdcall, glTexCoord1fv, "glTexCoord1fv");
pragma Import (Stdcall, glTexCoord1iv, "glTexCoord1iv");
pragma Import (Stdcall, glTexCoord1sv, "glTexCoord1sv");
pragma Import (Stdcall, glTexCoord2dv, "glTexCoord2dv");
pragma Import (Stdcall, glTexCoord2fv, "glTexCoord2fv");
pragma Import (Stdcall, glTexCoord2iv, "glTexCoord2iv");
pragma Import (Stdcall, glTexCoord2sv, "glTexCoord2sv");
pragma Import (Stdcall, glTexCoord3dv, "glTexCoord3dv");
pragma Import (Stdcall, glTexCoord3fv, "glTexCoord3fv");
pragma Import (Stdcall, glTexCoord3iv, "glTexCoord3iv");
pragma Import (Stdcall, glTexCoord3sv, "glTexCoord3sv");
pragma Import (Stdcall, glTexCoord4dv, "glTexCoord4dv");
pragma Import (Stdcall, glTexCoord4fv, "glTexCoord4fv");
pragma Import (Stdcall, glTexCoord4iv, "glTexCoord4iv");
pragma Import (Stdcall, glTexCoord4sv, "glTexCoord4sv");
pragma Import (Stdcall, glRasterPos2d, "glRasterPos2d");
pragma Import (Stdcall, glRasterPos2f, "glRasterPos2f");
pragma Import (Stdcall, glRasterPos2i, "glRasterPos2i");
pragma Import (Stdcall, glRasterPos2s, "glRasterPos2s");
pragma Import (Stdcall, glRasterPos3d, "glRasterPos3d");
pragma Import (Stdcall, glRasterPos3f, "glRasterPos3f");
pragma Import (Stdcall, glRasterPos3i, "glRasterPos3i");
pragma Import (Stdcall, glRasterPos3s, "glRasterPos3s");
pragma Import (Stdcall, glRasterPos4d, "glRasterPos4d");
pragma Import (Stdcall, glRasterPos4f, "glRasterPos4f");
pragma Import (Stdcall, glRasterPos4i, "glRasterPos4i");
pragma Import (Stdcall, glRasterPos4s, "glRasterPos4s");
pragma Import (Stdcall, glRasterPos2dv, "glRasterPos2dv");
pragma Import (Stdcall, glRasterPos2fv, "glRasterPos2fv");
pragma Import (Stdcall, glRasterPos2iv, "glRasterPos2iv");
pragma Import (Stdcall, glRasterPos2sv, "glRasterPos2sv");
pragma Import (Stdcall, glRasterPos3dv, "glRasterPos3dv");
pragma Import (Stdcall, glRasterPos3fv, "glRasterPos3fv");
pragma Import (Stdcall, glRasterPos3iv, "glRasterPos3iv");
pragma Import (Stdcall, glRasterPos3sv, "glRasterPos3sv");
pragma Import (Stdcall, glRasterPos4dv, "glRasterPos4dv");
pragma Import (Stdcall, glRasterPos4fv, "glRasterPos4fv");
pragma Import (Stdcall, glRasterPos4iv, "glRasterPos4iv");
pragma Import (Stdcall, glRasterPos4sv, "glRasterPos4sv");
pragma Import (Stdcall, glRectd, "glRectd");
pragma Import (Stdcall, glRectf, "glRectf");
pragma Import (Stdcall, glRecti, "glRecti");
pragma Import (Stdcall, glRects, "glRects");
pragma Import (Stdcall, glRectdv, "glRectdv");
pragma Import (Stdcall, glRectfv, "glRectfv");
pragma Import (Stdcall, glRectiv, "glRectiv");
pragma Import (Stdcall, glRectsv, "glRectsv");
pragma Import (Stdcall, glShadeModel, "glShadeModel");
pragma Import (Stdcall, glLightf, "glLightf");
pragma Import (Stdcall, glLighti, "glLighti");
pragma Import (Stdcall, glLightfv, "glLightfv");
pragma Import (Stdcall, glLightiv, "glLightiv");
pragma Import (Stdcall, glGetLightfv, "glGetLightfv");
pragma Import (Stdcall, glGetLightiv, "glGetLightiv");
pragma Import (Stdcall, glLightModelf, "glLightModelf");
pragma Import (Stdcall, glLightModeli, "glLightModeli");
pragma Import (Stdcall, glLightModelfv, "glLightModelfv");
pragma Import (Stdcall, glLightModeliv, "glLightModeliv");
pragma Import (Stdcall, glMaterialf, "glMaterialf");
pragma Import (Stdcall, glMateriali, "glMateriali");
pragma Import (Stdcall, glMaterialfv, "glMaterialfv");
pragma Import (Stdcall, glMaterialiv, "glMaterialiv");
pragma Import (Stdcall, glGetMaterialfv, "glGetMaterialfv");
pragma Import (Stdcall, glGetMaterialiv, "glGetMaterialiv");
pragma Import (Stdcall, glColorMaterial, "glColorMaterial");
pragma Import (Stdcall, glPixelZoom, "glPixelZoom");
pragma Import (Stdcall, glPixelStoref, "glPixelStoref");
pragma Import (Stdcall, glPixelStorei, "glPixelStorei");
pragma Import (Stdcall, glPixelTransferf, "glPixelTransferf");
pragma Import (Stdcall, glPixelTransferi, "glPixelTransferi");
pragma Import (Stdcall, glPixelMapfv, "glPixelMapfv");
pragma Import (Stdcall, glPixelMapuiv, "glPixelMapuiv");
pragma Import (Stdcall, glPixelMapusv, "glPixelMapusv");
pragma Import (Stdcall, glGetPixelMapfv, "glGetPixelMapfv");
pragma Import (Stdcall, glGetPixelMapuiv, "glGetPixelMapuiv");
pragma Import (Stdcall, glGetPixelMapusv, "glGetPixelMapusv");
pragma Import (Stdcall, glBitmap, "glBitmap");
pragma Import (Stdcall, glReadPixels, "glReadPixels");
pragma Import (Stdcall, glDrawPixels, "glDrawPixels");
pragma Import (Stdcall, glCopyPixels, "glCopyPixels");
pragma Import (Stdcall, glStencilFunc, "glStencilFunc");
pragma Import (Stdcall, glStencilMask, "glStencilMask");
pragma Import (Stdcall, glStencilOp, "glStencilOp");
pragma Import (Stdcall, glClearStencil, "glClearStencil");
pragma Import (Stdcall, glTexGend, "glTexGend");
pragma Import (Stdcall, glTexGenf, "glTexGenf");
pragma Import (Stdcall, glTexGeni, "glTexGeni");
pragma Import (Stdcall, glTexGendv, "glTexGendv");
pragma Import (Stdcall, glTexGenfv, "glTexGenfv");
pragma Import (Stdcall, glTexGeniv, "glTexGeniv");
pragma Import (Stdcall, glGetTexGendv, "glGetTexGendv");
pragma Import (Stdcall, glGetTexGenfv, "glGetTexGenfv");
pragma Import (Stdcall, glGetTexGeniv, "glGetTexGeniv");
pragma Import (Stdcall, glTexEnvf, "glTexEnvf");
pragma Import (Stdcall, glTexEnvi, "glTexEnvi");
pragma Import (Stdcall, glTexEnvfv, "glTexEnvfv");
pragma Import (Stdcall, glTexEnviv, "glTexEnviv");
pragma Import (Stdcall, glGetTexEnvfv, "glGetTexEnvfv");
pragma Import (Stdcall, glGetTexEnviv, "glGetTexEnviv");
pragma Import (Stdcall, glTexParameterf, "glTexParameterf");
pragma Import (Stdcall, glTexParameteri, "glTexParameteri");
pragma Import (Stdcall, glTexParameterfv, "glTexParameterfv");
pragma Import (Stdcall, glTexParameteriv, "glTexParameteriv");
pragma Import (Stdcall, glGetTexParameterfv, "glGetTexParameterfv");
pragma Import (Stdcall, glGetTexParameteriv, "glGetTexParameteriv");
pragma Import (Stdcall, glGetTexLevelParameterfv, "glGetTexLevelParameterfv");
pragma Import (Stdcall, glGetTexLevelParameteriv, "glGetTexLevelParameteriv");
pragma Import (Stdcall, glTexImage1D, "glTexImage1D");
pragma Import (Stdcall, glTexImage2D, "glTexImage2D");
pragma Import (Stdcall, glGetTexImage, "glGetTexImage");
pragma Import (Stdcall, glMap1d, "glMap1d");
pragma Import (Stdcall, glMap1f, "glMap1f");
pragma Import (Stdcall, glMap2d, "glMap2d");
pragma Import (Stdcall, glMap2f, "glMap2f");
pragma Import (Stdcall, glGetMapdv, "glGetMapdv");
pragma Import (Stdcall, glGetMapfv, "glGetMapfv");
pragma Import (Stdcall, glGetMapiv, "glGetMapiv");
pragma Import (Stdcall, glEvalCoord1d, "glEvalCoord1d");
pragma Import (Stdcall, glEvalCoord1f, "glEvalCoord1f");
pragma Import (Stdcall, glEvalCoord1dv, "glEvalCoord1dv");
pragma Import (Stdcall, glEvalCoord1fv, "glEvalCoord1fv");
pragma Import (Stdcall, glEvalCoord2d, "glEvalCoord2d");
pragma Import (Stdcall, glEvalCoord2f, "glEvalCoord2f");
pragma Import (Stdcall, glEvalCoord2dv, "glEvalCoord2dv");
pragma Import (Stdcall, glEvalCoord2fv, "glEvalCoord2fv");
pragma Import (Stdcall, glMapGrid1d, "glMapGrid1d");
pragma Import (Stdcall, glMapGrid1f, "glMapGrid1f");
pragma Import (Stdcall, glMapGrid2d, "glMapGrid2d");
pragma Import (Stdcall, glMapGrid2f, "glMapGrid2f");
pragma Import (Stdcall, glEvalPoint1, "glEvalPoint1");
pragma Import (Stdcall, glEvalPoint2, "glEvalPoint2");
pragma Import (Stdcall, glEvalMesh1, "glEvalMesh1");
pragma Import (Stdcall, glEvalMesh2, "glEvalMesh2");
pragma Import (Stdcall, glFogf, "glFogf");
pragma Import (Stdcall, glFogi, "glFogi");
pragma Import (Stdcall, glFogfv, "glFogfv");
pragma Import (Stdcall, glFogiv, "glFogiv");
pragma Import (Stdcall, glFeedbackBuffer, "glFeedbackBuffer");
pragma Import (Stdcall, glPassThrough, "glPassThrough");
pragma Import (Stdcall, glSelectBuffer, "glSelectBuffer");
pragma Import (Stdcall, glInitNames, "glInitNames");
pragma Import (Stdcall, glLoadName, "glLoadName");
pragma Import (Stdcall, glPushName, "glPushName");
pragma Import (Stdcall, glPopName, "glPopName");
pragma Import (Stdcall, glGenTextures, "glGenTextures");
pragma Import (Stdcall, glDeleteTextures, "glDeleteTextures");
pragma Import (Stdcall, glBindTexture, "glBindTexture");
pragma Import (Stdcall, glPrioritizeTextures, "glPrioritizeTextures");
pragma Import (Stdcall, glAreTexturesResident, "glAreTexturesResident");
pragma Import (Stdcall, glIsTexture, "glIsTexture");
pragma Import (Stdcall, glTexSubImage1D, "glTexSubImage1D");
pragma Import (Stdcall, glTexSubImage2D, "glTexSubImage2D");
pragma Import (Stdcall, glCopyTexImage1D, "glCopyTexImage1D");
pragma Import (Stdcall, glCopyTexImage2D, "glCopyTexImage2D");
pragma Import (Stdcall, glCopyTexSubImage1D, "glCopyTexSubImage1D");
pragma Import (Stdcall, glCopyTexSubImage2D, "glCopyTexSubImage2D");
pragma Import (Stdcall, glVertexPointer, "glVertexPointer");
pragma Import (Stdcall, glNormalPointer, "glNormalPointer");
pragma Import (Stdcall, glColorPointer, "glColorPointer");
pragma Import (Stdcall, glIndexPointer, "glIndexPointer");
pragma Import (Stdcall, glTexCoordPointer, "glTexCoordPointer");
pragma Import (Stdcall, glEdgeFlagPointer, "glEdgeFlagPointer");
pragma Import (Stdcall, glGetPointerv, "glGetPointerv");
pragma Import (Stdcall, glArrayElement, "glArrayElement");
pragma Import (Stdcall, glDrawArrays, "glDrawArrays");
pragma Import (Stdcall, glDrawElements, "glDrawElements");
pragma Import (Stdcall, glInterleavedArrays, "glInterleavedArrays");
pragma Import (Stdcall, glDrawRangeElements, "glDrawRangeElements");
pragma Import (Stdcall, glTexImage3D, "glTexImage3D");
pragma Import (Stdcall, glTexSubImage3D, "glTexSubImage3D");
pragma Import (Stdcall, glCopyTexSubImage3D, "glCopyTexSubImage3D");
pragma Import (Stdcall, glColorTable, "glColorTable");
pragma Import (Stdcall, glColorSubTable, "glColorSubTable");
pragma Import (Stdcall, glColorTableParameteriv, "glColorTableParameteriv");
pragma Import (Stdcall, glColorTableParameterfv, "glColorTableParameterfv");
pragma Import (Stdcall, glCopyColorSubTable, "glCopyColorSubTable");
pragma Import (Stdcall, glCopyColorTable, "glCopyColorTable");
pragma Import (Stdcall, glGetColorTable, "glGetColorTable");
pragma Import (Stdcall, glGetColorTableParameterfv, "glGetColorTableParameterfv");
pragma Import (Stdcall, glGetColorTableParameteriv, "glGetColorTableParameteriv");
pragma Import (Stdcall, glBlendEquation, "glBlendEquation");
pragma Import (Stdcall, glBlendColor, "glBlendColor");
pragma Import (Stdcall, glHistogram, "glHistogram");
pragma Import (Stdcall, glResetHistogram, "glResetHistogram");
pragma Import (Stdcall, glGetHistogram, "glGetHistogram");
pragma Import (Stdcall, glGetHistogramParameterfv, "glGetHistogramParameterfv");
pragma Import (Stdcall, glGetHistogramParameteriv, "glGetHistogramParameteriv");
pragma Import (Stdcall, glMinmax, "glMinmax");
pragma Import (Stdcall, glResetMinmax, "glResetMinmax");
pragma Import (Stdcall, glGetMinmax, "glGetMinmax");
pragma Import (Stdcall, glGetMinmaxParameterfv, "glGetMinmaxParameterfv");
pragma Import (Stdcall, glGetMinmaxParameteriv, "glGetMinmaxParameteriv");
pragma Import (Stdcall, glConvolutionFilter1D, "glConvolutionFilter1D");
pragma Import (Stdcall, glConvolutionFilter2D, "glConvolutionFilter2D");
pragma Import (Stdcall, glConvolutionParameterf, "glConvolutionParameterf");
pragma Import (Stdcall, glConvolutionParameterfv, "glConvolutionParameterfv");
pragma Import (Stdcall, glConvolutionParameteri, "glConvolutionParameteri");
pragma Import (Stdcall, glConvolutionParameteriv, "glConvolutionParameteriv");
pragma Import (Stdcall, glCopyConvolutionFilter1D, "glCopyConvolutionFilter1D");
pragma Import (Stdcall, glCopyConvolutionFilter2D, "glCopyConvolutionFilter2D");
pragma Import (Stdcall, glGetConvolutionFilter, "glGetConvolutionFilter");
pragma Import (Stdcall, glGetConvolutionParameterfv, "glGetConvolutionParameterfv");
pragma Import (Stdcall, glGetConvolutionParameteriv, "glGetConvolutionParameteriv");
pragma Import (Stdcall, glSeparableFilter2D, "glSeparableFilter2D");
pragma Import (Stdcall, glGetSeparableFilter, "glGetSeparableFilter");
pragma Import (Stdcall, glActiveTexture, "glActiveTexture");
pragma Import (Stdcall, glClientActiveTexture, "glClientActiveTexture");
pragma Import (Stdcall, glCompressedTexImage1D, "glCompressedTexImage1D");
pragma Import (Stdcall, glCompressedTexImage2D, "glCompressedTexImage2D");
pragma Import (Stdcall, glCompressedTexImage3D, "glCompressedTexImage3D");
pragma Import (Stdcall, glCompressedTexSubImage1D, "glCompressedTexSubImage1D");
pragma Import (Stdcall, glCompressedTexSubImage2D, "glCompressedTexSubImage2D");
pragma Import (Stdcall, glCompressedTexSubImage3D, "glCompressedTexSubImage3D");
pragma Import (Stdcall, glGetCompressedTexImage, "glGetCompressedTexImage");
pragma Import (Stdcall, glMultiTexCoord1d, "glMultiTexCoord1d");
pragma Import (Stdcall, glMultiTexCoord1dv, "glMultiTexCoord1dv");
pragma Import (Stdcall, glMultiTexCoord1f, "glMultiTexCoord1f");
pragma Import (Stdcall, glMultiTexCoord1fv, "glMultiTexCoord1fv");
pragma Import (Stdcall, glMultiTexCoord1i, "glMultiTexCoord1i");
pragma Import (Stdcall, glMultiTexCoord1iv, "glMultiTexCoord1iv");
pragma Import (Stdcall, glMultiTexCoord1s, "glMultiTexCoord1s");
pragma Import (Stdcall, glMultiTexCoord1sv, "glMultiTexCoord1sv");
pragma Import (Stdcall, glMultiTexCoord2d, "glMultiTexCoord2d");
pragma Import (Stdcall, glMultiTexCoord2dv, "glMultiTexCoord2dv");
pragma Import (Stdcall, glMultiTexCoord2f, "glMultiTexCoord2f");
pragma Import (Stdcall, glMultiTexCoord2fv, "glMultiTexCoord2fv");
pragma Import (Stdcall, glMultiTexCoord2i, "glMultiTexCoord2i");
pragma Import (Stdcall, glMultiTexCoord2iv, "glMultiTexCoord2iv");
pragma Import (Stdcall, glMultiTexCoord2s, "glMultiTexCoord2s");
pragma Import (Stdcall, glMultiTexCoord2sv, "glMultiTexCoord2sv");
pragma Import (Stdcall, glMultiTexCoord3d, "glMultiTexCoord3d");
pragma Import (Stdcall, glMultiTexCoord3dv, "glMultiTexCoord3dv");
pragma Import (Stdcall, glMultiTexCoord3f, "glMultiTexCoord3f");
pragma Import (Stdcall, glMultiTexCoord3fv, "glMultiTexCoord3fv");
pragma Import (Stdcall, glMultiTexCoord3i, "glMultiTexCoord3i");
pragma Import (Stdcall, glMultiTexCoord3iv, "glMultiTexCoord3iv");
pragma Import (Stdcall, glMultiTexCoord3s, "glMultiTexCoord3s");
pragma Import (Stdcall, glMultiTexCoord3sv, "glMultiTexCoord3sv");
pragma Import (Stdcall, glMultiTexCoord4d, "glMultiTexCoord4d");
pragma Import (Stdcall, glMultiTexCoord4dv, "glMultiTexCoord4dv");
pragma Import (Stdcall, glMultiTexCoord4f, "glMultiTexCoord4f");
pragma Import (Stdcall, glMultiTexCoord4fv, "glMultiTexCoord4fv");
pragma Import (Stdcall, glMultiTexCoord4i, "glMultiTexCoord4i");
pragma Import (Stdcall, glMultiTexCoord4iv, "glMultiTexCoord4iv");
pragma Import (Stdcall, glMultiTexCoord4s, "glMultiTexCoord4s");
pragma Import (Stdcall, glMultiTexCoord4sv, "glMultiTexCoord4sv");
pragma Import (Stdcall, glLoadTransposeMatrixd, "glLoadTransposeMatrixd");
pragma Import (Stdcall, glLoadTransposeMatrixf, "glLoadTransposeMatrixf");
pragma Import (Stdcall, glMultTransposeMatrixd, "glMultTransposeMatrixd");
pragma Import (Stdcall, glMultTransposeMatrixf, "glMultTransposeMatrixf");
pragma Import (Stdcall, glSampleCoverage, "glSampleCoverage");
pragma Import (Stdcall, glSamplePass, "glSamplePass");
end Sf.Window.GL;
|
[
{
"context": "Resource Embedder Generator\n-- Copyright (C) 2021 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@g",
"end": 168,
"score": 0.9998763203620911,
"start": 153,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": " Copyright (C) 2021 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under",
"end": 199,
"score": 0.9998817443847656,
"start": 184,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "1 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under the Apache License, Versio",
"end": 226,
"score": 0.9999259114265442,
"start": 201,
"tag": "EMAIL",
"value": "Stephane.Carrez@gmail.com"
}
] | src/are-generator.adb | stcarrez/resource-embedder | 7 | -----------------------------------------------------------------------
-- are-generator -- Advanced Resource Embedder Generator
-- Copyright (C) 2021 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.Directories;
with Ada.Command_Line;
with Ada.Text_IO;
with Are.Generator.Ada2012;
with Are.Generator.C;
with Are.Generator.Go;
with Are.Installer;
package body Are.Generator is
use type GNAT.Strings.String_Access;
use type Ada.Command_Line.Exit_Status;
Ada_Generator : Are.Generator.Ada2012.Generator_Type;
C_Generator : Are.Generator.C.Generator_Type;
Go_Generator : Are.Generator.Go.Generator_Type;
Installer : Are.Installer.Installer_Type;
Config : GC.Command_Line_Configuration;
Context : Are.Context_Type;
Cur_Resource : Are.Resource_Access;
procedure Add_Option (Switch, Value : in String) is
begin
if Switch = "--resource" then
Are.Create_Resource (List => Context.Resources,
Name => Value,
Resource => Cur_Resource);
else
Installer.Add_Rule (Resource => Cur_Resource,
Pattern => Value);
end if;
end Add_Option;
procedure Specific_Options (Config : in out GC.Command_Line_Configuration;
Context : in out Are.Context_Type'Class) is separate;
-- ------------------------------
-- Return a string that identifies the program.
-- ------------------------------
function Get_Title return String is
begin
return "Advanced Resource Embedder 1.2.0";
end Get_Title;
-- ------------------------------
-- Print the command usage.
-- ------------------------------
procedure Usage is
begin
GC.Display_Help (Config);
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end Usage;
procedure Main is
Has_Files : Boolean := False;
begin
GC.Set_Usage (Config => Config,
Usage => "[switchs] {file|directory}",
Help => -("are - resource embedder to include files "
& "in your Ada,C/C++,Go binaries"));
GC.Define_Switch (Config => Config,
Output => Context.Verbose'Access,
Switch => "-v",
Long_Switch => "--verbose",
Help => -("Verbose execution mode"));
GC.Define_Switch (Config => Config,
Output => Context.Debug'Access,
Switch => "-vv",
Long_Switch => "--debug",
Help => -("Enable debug execution"));
GC.Define_Switch (Config => Config,
Output => Context.Version'Access,
Switch => "-V",
Long_Switch => "--version",
Help => -("Print the program version"));
GC.Define_Switch (Config => Config,
Output => Context.Tmp_Dir'Access,
Long_Switch => "--tmp=",
Argument => "DIRECTORY",
Help => -("Use the directory to build the resource files"));
GC.Define_Switch (Config => Config,
Output => Context.Keep_Temporary'Access,
Switch => "-k",
Long_Switch => "--keep",
Help => -("Keep the directory used to prepare the resource files"));
GC.Define_Switch (Config => Config,
Output => Context.Output'Access,
Switch => "-o:",
Long_Switch => "--output=",
Argument => "DIRECTORY",
Help => -("Set the output directory path where generators "
& "write the code"));
GC.Define_Switch (Config => Config,
Output => Context.Language'Access,
Switch => "-l:",
Long_Switch => "--lang=",
Argument => "NAME",
Help => -("Select the target generator language"));
GC.Define_Switch (Config => Config,
Output => Context.Rule_File'Access,
Switch => "-r:",
Long_Switch => "--rule=",
Argument => "PATH",
Help => -("Read the XML file that describe the resources to generate"));
-- Hack to cope with different implementations of GNAT.Command_Line package.
Specific_Options (Config, Context);
GC.Define_Switch (Config => Config,
Output => Context.Ignore_Case'Access,
Long_Switch => "--ignore-case",
Help => -("Ignore the case when comparing names"));
GC.Define_Switch (Config => Config,
Output => Context.Name_Index'Access,
Long_Switch => "--name-access",
Help => -("Generate support to query content with a name"));
GC.Define_Switch (Config => Config,
Output => Context.List_Content'Access,
Long_Switch => "--list-access",
Help => -("Generate support to list the content names"));
GC.Define_Switch (Config => Config,
Output => Context.Declare_Var'Access,
Long_Switch => "--var-access",
Help => -("Declare a variable to give access to each content"));
GC.Define_Switch (Config => Config,
Output => Context.Var_Prefix'Access,
Long_Switch => "--var-prefix=",
Argument => "PREFIX",
Help => -("Defines the prefix to be used for variable names"));
GC.Define_Switch (Config => Config,
Output => Context.No_Type_Declaration'Access,
Long_Switch => "--no-type-declaration",
Help => -("Do not declare any type in the package "
& "specification (assume they are inherited)"));
GC.Define_Switch (Config => Config,
Output => Context.Type_Name'Access,
Long_Switch => "--type-name=",
Argument => "NAME",
Help => -("Define the name of the type used to hold the information"));
GC.Define_Switch (Config => Config,
Output => Context.Function_Name'Access,
Long_Switch => "--function-name=",
Argument => "NAME",
Help => -("Define the name of the function to get the "
& "information from a name"));
GC.Define_Switch (Config => Config,
Output => Context.Member_Content_Name'Access,
Long_Switch => "--member-content=",
Argument => "NAME",
Help => -("Define the name data structure member holding "
& "the content"));
GC.Define_Switch (Config => Config,
Output => Context.Member_Length_Name'Access,
Long_Switch => "--member-length=",
Argument => "NAME",
Help => -("Define the name data structure member holding "
& "the length"));
GC.Define_Switch (Config => Config,
Output => Context.Member_Modtime_Name'Access,
Long_Switch => "--member-modtime=",
Argument => "NAME",
Help => -("Define the name data structure member holding "
& "the modification time"));
GC.Define_Switch (Config => Config,
Output => Context.Member_Format_Name'Access,
Long_Switch => "--member-format=",
Argument => "NAME",
Help => -("Define the name data structure member holding "
& "the content format"));
Ada_Generator.Setup (Config);
GC.Getopt (Config => Config);
if Context.Version then
Ada.Text_IO.Put_Line (Get_Title);
return;
end if;
if Context.Verbose or Context.Debug then
Are.Configure_Logs (Verbose => Context.Verbose,
Debug => Context.Debug);
end if;
-- Emulate the Define_Switch with the Callback support
if Context.Resource_Name /= null and then Context.Resource_Name'Length > 0 then
Add_Option ("--resource", Context.Resource_Name.all);
end if;
if Context.Fileset_Pattern /= null and then Context.Fileset_Pattern'Length > 0 then
Add_Option ("--fileset", Context.Fileset_Pattern.all);
end if;
if Context.Var_Prefix'Length > 0 then
Context.Declare_Var := True;
end if;
-- Read the rule definitions.
if Context.Rule_File'Length > 0 then
Installer.Read_Package (Context.Rule_File.all, Context);
if Context.Status /= 0 then
Ada.Command_Line.Set_Exit_Status (Context.Status);
return;
end if;
end if;
-- Step #1: collect the files by scanning the directories and files passed as argument.
loop
declare
use Ada.Directories;
S : constant String := GC.Get_Argument;
begin
exit when S'Length = 0;
Has_Files := True;
if not Ada.Directories.Exists (S) then
Context.Error ("path {0} does not exist", S);
elsif Ada.Directories.Kind (S) = Ada.Directories.Directory then
Installer.Scan_Directory (S, Context);
else
Context.Error ("path {0} is not a directory", S);
end if;
end;
end loop;
if not Has_Files then
Usage;
return;
end if;
-- Step #2: apply the package rules to load the files and optionally apply some
-- specific transformations on them (such as running a Javascript minifier).
Installer.Execute (Context);
if Context.Status = 0 then
-- Step #3: run the code generator.
if Context.Language.all = "c" then
C_Generator.Generate (Context.Resources, Context);
elsif Context.Language.all = "go" then
Go_Generator.Generate (Context.Resources, Context);
elsif Context.Language.all = "Ada" or Context.Language'Length = 0 then
Ada_Generator.Generate (Context.Resources, Context);
else
Context.Error ("language {0} not recognized", Context.Language.all);
end if;
end if;
if not Context.Keep_Temporary then
declare
Path : constant String := Context.Get_Generation_Path ("");
begin
if Ada.Directories.Exists (Path) then
Ada.Directories.Delete_Tree (Path);
end if;
end;
end if;
Ada.Command_Line.Set_Exit_Status (Context.Status);
end Main;
end Are.Generator;
| 17982 | -----------------------------------------------------------------------
-- are-generator -- Advanced Resource Embedder Generator
-- Copyright (C) 2021 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Directories;
with Ada.Command_Line;
with Ada.Text_IO;
with Are.Generator.Ada2012;
with Are.Generator.C;
with Are.Generator.Go;
with Are.Installer;
package body Are.Generator is
use type GNAT.Strings.String_Access;
use type Ada.Command_Line.Exit_Status;
Ada_Generator : Are.Generator.Ada2012.Generator_Type;
C_Generator : Are.Generator.C.Generator_Type;
Go_Generator : Are.Generator.Go.Generator_Type;
Installer : Are.Installer.Installer_Type;
Config : GC.Command_Line_Configuration;
Context : Are.Context_Type;
Cur_Resource : Are.Resource_Access;
procedure Add_Option (Switch, Value : in String) is
begin
if Switch = "--resource" then
Are.Create_Resource (List => Context.Resources,
Name => Value,
Resource => Cur_Resource);
else
Installer.Add_Rule (Resource => Cur_Resource,
Pattern => Value);
end if;
end Add_Option;
procedure Specific_Options (Config : in out GC.Command_Line_Configuration;
Context : in out Are.Context_Type'Class) is separate;
-- ------------------------------
-- Return a string that identifies the program.
-- ------------------------------
function Get_Title return String is
begin
return "Advanced Resource Embedder 1.2.0";
end Get_Title;
-- ------------------------------
-- Print the command usage.
-- ------------------------------
procedure Usage is
begin
GC.Display_Help (Config);
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end Usage;
procedure Main is
Has_Files : Boolean := False;
begin
GC.Set_Usage (Config => Config,
Usage => "[switchs] {file|directory}",
Help => -("are - resource embedder to include files "
& "in your Ada,C/C++,Go binaries"));
GC.Define_Switch (Config => Config,
Output => Context.Verbose'Access,
Switch => "-v",
Long_Switch => "--verbose",
Help => -("Verbose execution mode"));
GC.Define_Switch (Config => Config,
Output => Context.Debug'Access,
Switch => "-vv",
Long_Switch => "--debug",
Help => -("Enable debug execution"));
GC.Define_Switch (Config => Config,
Output => Context.Version'Access,
Switch => "-V",
Long_Switch => "--version",
Help => -("Print the program version"));
GC.Define_Switch (Config => Config,
Output => Context.Tmp_Dir'Access,
Long_Switch => "--tmp=",
Argument => "DIRECTORY",
Help => -("Use the directory to build the resource files"));
GC.Define_Switch (Config => Config,
Output => Context.Keep_Temporary'Access,
Switch => "-k",
Long_Switch => "--keep",
Help => -("Keep the directory used to prepare the resource files"));
GC.Define_Switch (Config => Config,
Output => Context.Output'Access,
Switch => "-o:",
Long_Switch => "--output=",
Argument => "DIRECTORY",
Help => -("Set the output directory path where generators "
& "write the code"));
GC.Define_Switch (Config => Config,
Output => Context.Language'Access,
Switch => "-l:",
Long_Switch => "--lang=",
Argument => "NAME",
Help => -("Select the target generator language"));
GC.Define_Switch (Config => Config,
Output => Context.Rule_File'Access,
Switch => "-r:",
Long_Switch => "--rule=",
Argument => "PATH",
Help => -("Read the XML file that describe the resources to generate"));
-- Hack to cope with different implementations of GNAT.Command_Line package.
Specific_Options (Config, Context);
GC.Define_Switch (Config => Config,
Output => Context.Ignore_Case'Access,
Long_Switch => "--ignore-case",
Help => -("Ignore the case when comparing names"));
GC.Define_Switch (Config => Config,
Output => Context.Name_Index'Access,
Long_Switch => "--name-access",
Help => -("Generate support to query content with a name"));
GC.Define_Switch (Config => Config,
Output => Context.List_Content'Access,
Long_Switch => "--list-access",
Help => -("Generate support to list the content names"));
GC.Define_Switch (Config => Config,
Output => Context.Declare_Var'Access,
Long_Switch => "--var-access",
Help => -("Declare a variable to give access to each content"));
GC.Define_Switch (Config => Config,
Output => Context.Var_Prefix'Access,
Long_Switch => "--var-prefix=",
Argument => "PREFIX",
Help => -("Defines the prefix to be used for variable names"));
GC.Define_Switch (Config => Config,
Output => Context.No_Type_Declaration'Access,
Long_Switch => "--no-type-declaration",
Help => -("Do not declare any type in the package "
& "specification (assume they are inherited)"));
GC.Define_Switch (Config => Config,
Output => Context.Type_Name'Access,
Long_Switch => "--type-name=",
Argument => "NAME",
Help => -("Define the name of the type used to hold the information"));
GC.Define_Switch (Config => Config,
Output => Context.Function_Name'Access,
Long_Switch => "--function-name=",
Argument => "NAME",
Help => -("Define the name of the function to get the "
& "information from a name"));
GC.Define_Switch (Config => Config,
Output => Context.Member_Content_Name'Access,
Long_Switch => "--member-content=",
Argument => "NAME",
Help => -("Define the name data structure member holding "
& "the content"));
GC.Define_Switch (Config => Config,
Output => Context.Member_Length_Name'Access,
Long_Switch => "--member-length=",
Argument => "NAME",
Help => -("Define the name data structure member holding "
& "the length"));
GC.Define_Switch (Config => Config,
Output => Context.Member_Modtime_Name'Access,
Long_Switch => "--member-modtime=",
Argument => "NAME",
Help => -("Define the name data structure member holding "
& "the modification time"));
GC.Define_Switch (Config => Config,
Output => Context.Member_Format_Name'Access,
Long_Switch => "--member-format=",
Argument => "NAME",
Help => -("Define the name data structure member holding "
& "the content format"));
Ada_Generator.Setup (Config);
GC.Getopt (Config => Config);
if Context.Version then
Ada.Text_IO.Put_Line (Get_Title);
return;
end if;
if Context.Verbose or Context.Debug then
Are.Configure_Logs (Verbose => Context.Verbose,
Debug => Context.Debug);
end if;
-- Emulate the Define_Switch with the Callback support
if Context.Resource_Name /= null and then Context.Resource_Name'Length > 0 then
Add_Option ("--resource", Context.Resource_Name.all);
end if;
if Context.Fileset_Pattern /= null and then Context.Fileset_Pattern'Length > 0 then
Add_Option ("--fileset", Context.Fileset_Pattern.all);
end if;
if Context.Var_Prefix'Length > 0 then
Context.Declare_Var := True;
end if;
-- Read the rule definitions.
if Context.Rule_File'Length > 0 then
Installer.Read_Package (Context.Rule_File.all, Context);
if Context.Status /= 0 then
Ada.Command_Line.Set_Exit_Status (Context.Status);
return;
end if;
end if;
-- Step #1: collect the files by scanning the directories and files passed as argument.
loop
declare
use Ada.Directories;
S : constant String := GC.Get_Argument;
begin
exit when S'Length = 0;
Has_Files := True;
if not Ada.Directories.Exists (S) then
Context.Error ("path {0} does not exist", S);
elsif Ada.Directories.Kind (S) = Ada.Directories.Directory then
Installer.Scan_Directory (S, Context);
else
Context.Error ("path {0} is not a directory", S);
end if;
end;
end loop;
if not Has_Files then
Usage;
return;
end if;
-- Step #2: apply the package rules to load the files and optionally apply some
-- specific transformations on them (such as running a Javascript minifier).
Installer.Execute (Context);
if Context.Status = 0 then
-- Step #3: run the code generator.
if Context.Language.all = "c" then
C_Generator.Generate (Context.Resources, Context);
elsif Context.Language.all = "go" then
Go_Generator.Generate (Context.Resources, Context);
elsif Context.Language.all = "Ada" or Context.Language'Length = 0 then
Ada_Generator.Generate (Context.Resources, Context);
else
Context.Error ("language {0} not recognized", Context.Language.all);
end if;
end if;
if not Context.Keep_Temporary then
declare
Path : constant String := Context.Get_Generation_Path ("");
begin
if Ada.Directories.Exists (Path) then
Ada.Directories.Delete_Tree (Path);
end if;
end;
end if;
Ada.Command_Line.Set_Exit_Status (Context.Status);
end Main;
end Are.Generator;
| true | -----------------------------------------------------------------------
-- are-generator -- Advanced Resource Embedder Generator
-- Copyright (C) 2021 PI:NAME:<NAME>END_PI
-- Written by PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
--
-- 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.Directories;
with Ada.Command_Line;
with Ada.Text_IO;
with Are.Generator.Ada2012;
with Are.Generator.C;
with Are.Generator.Go;
with Are.Installer;
package body Are.Generator is
use type GNAT.Strings.String_Access;
use type Ada.Command_Line.Exit_Status;
Ada_Generator : Are.Generator.Ada2012.Generator_Type;
C_Generator : Are.Generator.C.Generator_Type;
Go_Generator : Are.Generator.Go.Generator_Type;
Installer : Are.Installer.Installer_Type;
Config : GC.Command_Line_Configuration;
Context : Are.Context_Type;
Cur_Resource : Are.Resource_Access;
procedure Add_Option (Switch, Value : in String) is
begin
if Switch = "--resource" then
Are.Create_Resource (List => Context.Resources,
Name => Value,
Resource => Cur_Resource);
else
Installer.Add_Rule (Resource => Cur_Resource,
Pattern => Value);
end if;
end Add_Option;
procedure Specific_Options (Config : in out GC.Command_Line_Configuration;
Context : in out Are.Context_Type'Class) is separate;
-- ------------------------------
-- Return a string that identifies the program.
-- ------------------------------
function Get_Title return String is
begin
return "Advanced Resource Embedder 1.2.0";
end Get_Title;
-- ------------------------------
-- Print the command usage.
-- ------------------------------
procedure Usage is
begin
GC.Display_Help (Config);
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end Usage;
procedure Main is
Has_Files : Boolean := False;
begin
GC.Set_Usage (Config => Config,
Usage => "[switchs] {file|directory}",
Help => -("are - resource embedder to include files "
& "in your Ada,C/C++,Go binaries"));
GC.Define_Switch (Config => Config,
Output => Context.Verbose'Access,
Switch => "-v",
Long_Switch => "--verbose",
Help => -("Verbose execution mode"));
GC.Define_Switch (Config => Config,
Output => Context.Debug'Access,
Switch => "-vv",
Long_Switch => "--debug",
Help => -("Enable debug execution"));
GC.Define_Switch (Config => Config,
Output => Context.Version'Access,
Switch => "-V",
Long_Switch => "--version",
Help => -("Print the program version"));
GC.Define_Switch (Config => Config,
Output => Context.Tmp_Dir'Access,
Long_Switch => "--tmp=",
Argument => "DIRECTORY",
Help => -("Use the directory to build the resource files"));
GC.Define_Switch (Config => Config,
Output => Context.Keep_Temporary'Access,
Switch => "-k",
Long_Switch => "--keep",
Help => -("Keep the directory used to prepare the resource files"));
GC.Define_Switch (Config => Config,
Output => Context.Output'Access,
Switch => "-o:",
Long_Switch => "--output=",
Argument => "DIRECTORY",
Help => -("Set the output directory path where generators "
& "write the code"));
GC.Define_Switch (Config => Config,
Output => Context.Language'Access,
Switch => "-l:",
Long_Switch => "--lang=",
Argument => "NAME",
Help => -("Select the target generator language"));
GC.Define_Switch (Config => Config,
Output => Context.Rule_File'Access,
Switch => "-r:",
Long_Switch => "--rule=",
Argument => "PATH",
Help => -("Read the XML file that describe the resources to generate"));
-- Hack to cope with different implementations of GNAT.Command_Line package.
Specific_Options (Config, Context);
GC.Define_Switch (Config => Config,
Output => Context.Ignore_Case'Access,
Long_Switch => "--ignore-case",
Help => -("Ignore the case when comparing names"));
GC.Define_Switch (Config => Config,
Output => Context.Name_Index'Access,
Long_Switch => "--name-access",
Help => -("Generate support to query content with a name"));
GC.Define_Switch (Config => Config,
Output => Context.List_Content'Access,
Long_Switch => "--list-access",
Help => -("Generate support to list the content names"));
GC.Define_Switch (Config => Config,
Output => Context.Declare_Var'Access,
Long_Switch => "--var-access",
Help => -("Declare a variable to give access to each content"));
GC.Define_Switch (Config => Config,
Output => Context.Var_Prefix'Access,
Long_Switch => "--var-prefix=",
Argument => "PREFIX",
Help => -("Defines the prefix to be used for variable names"));
GC.Define_Switch (Config => Config,
Output => Context.No_Type_Declaration'Access,
Long_Switch => "--no-type-declaration",
Help => -("Do not declare any type in the package "
& "specification (assume they are inherited)"));
GC.Define_Switch (Config => Config,
Output => Context.Type_Name'Access,
Long_Switch => "--type-name=",
Argument => "NAME",
Help => -("Define the name of the type used to hold the information"));
GC.Define_Switch (Config => Config,
Output => Context.Function_Name'Access,
Long_Switch => "--function-name=",
Argument => "NAME",
Help => -("Define the name of the function to get the "
& "information from a name"));
GC.Define_Switch (Config => Config,
Output => Context.Member_Content_Name'Access,
Long_Switch => "--member-content=",
Argument => "NAME",
Help => -("Define the name data structure member holding "
& "the content"));
GC.Define_Switch (Config => Config,
Output => Context.Member_Length_Name'Access,
Long_Switch => "--member-length=",
Argument => "NAME",
Help => -("Define the name data structure member holding "
& "the length"));
GC.Define_Switch (Config => Config,
Output => Context.Member_Modtime_Name'Access,
Long_Switch => "--member-modtime=",
Argument => "NAME",
Help => -("Define the name data structure member holding "
& "the modification time"));
GC.Define_Switch (Config => Config,
Output => Context.Member_Format_Name'Access,
Long_Switch => "--member-format=",
Argument => "NAME",
Help => -("Define the name data structure member holding "
& "the content format"));
Ada_Generator.Setup (Config);
GC.Getopt (Config => Config);
if Context.Version then
Ada.Text_IO.Put_Line (Get_Title);
return;
end if;
if Context.Verbose or Context.Debug then
Are.Configure_Logs (Verbose => Context.Verbose,
Debug => Context.Debug);
end if;
-- Emulate the Define_Switch with the Callback support
if Context.Resource_Name /= null and then Context.Resource_Name'Length > 0 then
Add_Option ("--resource", Context.Resource_Name.all);
end if;
if Context.Fileset_Pattern /= null and then Context.Fileset_Pattern'Length > 0 then
Add_Option ("--fileset", Context.Fileset_Pattern.all);
end if;
if Context.Var_Prefix'Length > 0 then
Context.Declare_Var := True;
end if;
-- Read the rule definitions.
if Context.Rule_File'Length > 0 then
Installer.Read_Package (Context.Rule_File.all, Context);
if Context.Status /= 0 then
Ada.Command_Line.Set_Exit_Status (Context.Status);
return;
end if;
end if;
-- Step #1: collect the files by scanning the directories and files passed as argument.
loop
declare
use Ada.Directories;
S : constant String := GC.Get_Argument;
begin
exit when S'Length = 0;
Has_Files := True;
if not Ada.Directories.Exists (S) then
Context.Error ("path {0} does not exist", S);
elsif Ada.Directories.Kind (S) = Ada.Directories.Directory then
Installer.Scan_Directory (S, Context);
else
Context.Error ("path {0} is not a directory", S);
end if;
end;
end loop;
if not Has_Files then
Usage;
return;
end if;
-- Step #2: apply the package rules to load the files and optionally apply some
-- specific transformations on them (such as running a Javascript minifier).
Installer.Execute (Context);
if Context.Status = 0 then
-- Step #3: run the code generator.
if Context.Language.all = "c" then
C_Generator.Generate (Context.Resources, Context);
elsif Context.Language.all = "go" then
Go_Generator.Generate (Context.Resources, Context);
elsif Context.Language.all = "Ada" or Context.Language'Length = 0 then
Ada_Generator.Generate (Context.Resources, Context);
else
Context.Error ("language {0} not recognized", Context.Language.all);
end if;
end if;
if not Context.Keep_Temporary then
declare
Path : constant String := Context.Get_Generation_Path ("");
begin
if Ada.Directories.Exists (Path) then
Ada.Directories.Delete_Tree (Path);
end if;
end;
end if;
Ada.Command_Line.Set_Exit_Status (Context.Status);
end Main;
end Are.Generator;
|
[
{
"context": "served.\n--\n-- The primary authors of ayacc were David Taback and Deepak Tolani.\n-- Enhancements were made b",
"end": 142,
"score": 0.9998661875724792,
"start": 130,
"tag": "NAME",
"value": "David Taback"
},
{
"context": "The primary authors of ayacc were David Taback and Deepak Tolani.\n-- Enhancements were made by Ronald J. Schmal",
"end": 160,
"score": 0.999881386756897,
"start": 147,
"tag": "NAME",
"value": "Deepak Tolani"
},
{
"context": "and Deepak Tolani.\n-- Enhancements were made by Ronald J. Schmalz.\n--\n-- Send requests for ayacc information to ",
"end": 211,
"score": 0.9998485445976257,
"start": 194,
"tag": "NAME",
"value": "Ronald J. Schmalz"
},
{
"context": "z.\n--\n-- Send requests for ayacc information to ayacc-info@ics.uci.edu\n-- Send bug reports for ayacc to ayacc-bugs@ic",
"end": 283,
"score": 0.9999288320541382,
"start": 261,
"tag": "EMAIL",
"value": "ayacc-info@ics.uci.edu"
},
{
"context": "fo@ics.uci.edu\n-- Send bug reports for ayacc to ayacc-bugs@ics.uci.edu\n--\n-- Redistribution and use in source and binary",
"end": 342,
"score": 0.9999289512634277,
"start": 320,
"tag": "EMAIL",
"value": "ayacc-bugs@ics.uci.edu"
},
{
"context": "al version of Ayacc\n-- designed and implemented by David Taback and Deepak Tolani.\n-- Ayacc has been compiled and",
"end": 1671,
"score": 0.999833881855011,
"start": 1659,
"tag": "NAME",
"value": "David Taback"
},
{
"context": "cc\n-- designed and implemented by David Taback and Deepak Tolani.\n-- Ayacc has been compiled and tested under the ",
"end": 1689,
"score": 0.9998754262924194,
"start": 1676,
"tag": "NAME",
"value": "Deepak Tolani"
}
] | tools/ayacc/src/set_pack.ads | svn2github/matreshka | 24 | -- Copyright (c) 1990 Regents of the University of California.
-- All rights reserved.
--
-- The primary authors of ayacc were David Taback and Deepak Tolani.
-- Enhancements were made by Ronald J. Schmalz.
--
-- Send requests for ayacc information to ayacc-info@ics.uci.edu
-- Send bug reports for ayacc to ayacc-bugs@ics.uci.edu
--
-- Redistribution and use in source and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by the University of California, Irvine. The name of the
-- University may not be used to endorse or promote products derived
-- from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-- Module : set_pack.ada
-- Component of : ayacc
-- Version : 1.2
-- Date : 11/21/86 12:34:47
-- SCCS File : disk21~/rschm/hasee/sccs/ayacc/sccs/sxset_pack.ada
-- $Header: set_pack.a,v 0.1 86/04/01 15:11:51 ada Exp $
-- $Log: set_pack.a,v $
-- Revision 0.1 86/04/01 15:11:51 ada
-- This version fixes some minor bugs with empty grammars
-- and $$ expansion. It also uses vads5.1b enhancements
-- such as pragma inline.
--
--
-- Revision 0.0 86/02/19 18:41:22 ada
--
-- These files comprise the initial version of Ayacc
-- designed and implemented by David Taback and Deepak Tolani.
-- Ayacc has been compiled and tested under the Verdix Ada compiler
-- version 4.06 on a vax 11/750 running Unix 4.2BSD.
--
-- Uses the predefined equality operator "=" on variables of type Universe
generic
type Universe is private;
with function "<" (Element_1, Element_2: Universe) return Boolean;
package Set_Pack is
type Set is limited private;
procedure Make_Null (Set_1: in out Set);
procedure Insert (Element : in Universe; Into : in out Set);
procedure Insert (Set_1 : in Set; Into : in out Set);
procedure Delete (Element : in Universe; From : in out Set);
procedure Assign (Object : in out Set; Value : in Set);
-- Nulls value !
procedure Fassign(Object : in out Set; Value : in out Set);
function Is_Member (Element: Universe; Of_Set: Set) return Boolean;
function Is_Empty (Set_1: Set) return Boolean;
function Size_of (Set_1: Set) return Natural;
function "=" (Set_1 : Set; Set_2 : Set) return Boolean;
type Set_Iterator is limited private;
procedure Initialize (Iterator : in out Set_Iterator; Using : in Set);
function More (Iterator: Set_Iterator) return Boolean;
procedure Next (Iterator: in out Set_Iterator; Element: out Universe);
No_More_Elements : exception;
-- raised if you call NEXT when MORE is false.
--RJS
pragma inline(is_empty, size_of, more, next);
private
type Cell;
type Link is access Cell;
type Set is
record
Size : Natural;
Head : Link := null;
end record;
type Set_Iterator is new Link;
end Set_Pack;
| 19188 | -- Copyright (c) 1990 Regents of the University of California.
-- All rights reserved.
--
-- The primary authors of ayacc were <NAME> and <NAME>.
-- Enhancements were made by <NAME>.
--
-- Send requests for ayacc information to <EMAIL>
-- Send bug reports for ayacc to <EMAIL>
--
-- Redistribution and use in source and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by the University of California, Irvine. The name of the
-- University may not be used to endorse or promote products derived
-- from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-- Module : set_pack.ada
-- Component of : ayacc
-- Version : 1.2
-- Date : 11/21/86 12:34:47
-- SCCS File : disk21~/rschm/hasee/sccs/ayacc/sccs/sxset_pack.ada
-- $Header: set_pack.a,v 0.1 86/04/01 15:11:51 ada Exp $
-- $Log: set_pack.a,v $
-- Revision 0.1 86/04/01 15:11:51 ada
-- This version fixes some minor bugs with empty grammars
-- and $$ expansion. It also uses vads5.1b enhancements
-- such as pragma inline.
--
--
-- Revision 0.0 86/02/19 18:41:22 ada
--
-- These files comprise the initial version of Ayacc
-- designed and implemented by <NAME> and <NAME>.
-- Ayacc has been compiled and tested under the Verdix Ada compiler
-- version 4.06 on a vax 11/750 running Unix 4.2BSD.
--
-- Uses the predefined equality operator "=" on variables of type Universe
generic
type Universe is private;
with function "<" (Element_1, Element_2: Universe) return Boolean;
package Set_Pack is
type Set is limited private;
procedure Make_Null (Set_1: in out Set);
procedure Insert (Element : in Universe; Into : in out Set);
procedure Insert (Set_1 : in Set; Into : in out Set);
procedure Delete (Element : in Universe; From : in out Set);
procedure Assign (Object : in out Set; Value : in Set);
-- Nulls value !
procedure Fassign(Object : in out Set; Value : in out Set);
function Is_Member (Element: Universe; Of_Set: Set) return Boolean;
function Is_Empty (Set_1: Set) return Boolean;
function Size_of (Set_1: Set) return Natural;
function "=" (Set_1 : Set; Set_2 : Set) return Boolean;
type Set_Iterator is limited private;
procedure Initialize (Iterator : in out Set_Iterator; Using : in Set);
function More (Iterator: Set_Iterator) return Boolean;
procedure Next (Iterator: in out Set_Iterator; Element: out Universe);
No_More_Elements : exception;
-- raised if you call NEXT when MORE is false.
--RJS
pragma inline(is_empty, size_of, more, next);
private
type Cell;
type Link is access Cell;
type Set is
record
Size : Natural;
Head : Link := null;
end record;
type Set_Iterator is new Link;
end Set_Pack;
| true | -- Copyright (c) 1990 Regents of the University of California.
-- All rights reserved.
--
-- The primary authors of ayacc were PI:NAME:<NAME>END_PI and PI:NAME:<NAME>END_PI.
-- Enhancements were made by PI:NAME:<NAME>END_PI.
--
-- Send requests for ayacc information to PI:EMAIL:<EMAIL>END_PI
-- Send bug reports for ayacc to PI:EMAIL:<EMAIL>END_PI
--
-- Redistribution and use in source and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by the University of California, Irvine. The name of the
-- University may not be used to endorse or promote products derived
-- from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-- Module : set_pack.ada
-- Component of : ayacc
-- Version : 1.2
-- Date : 11/21/86 12:34:47
-- SCCS File : disk21~/rschm/hasee/sccs/ayacc/sccs/sxset_pack.ada
-- $Header: set_pack.a,v 0.1 86/04/01 15:11:51 ada Exp $
-- $Log: set_pack.a,v $
-- Revision 0.1 86/04/01 15:11:51 ada
-- This version fixes some minor bugs with empty grammars
-- and $$ expansion. It also uses vads5.1b enhancements
-- such as pragma inline.
--
--
-- Revision 0.0 86/02/19 18:41:22 ada
--
-- These files comprise the initial version of Ayacc
-- designed and implemented by PI:NAME:<NAME>END_PI and PI:NAME:<NAME>END_PI.
-- Ayacc has been compiled and tested under the Verdix Ada compiler
-- version 4.06 on a vax 11/750 running Unix 4.2BSD.
--
-- Uses the predefined equality operator "=" on variables of type Universe
generic
type Universe is private;
with function "<" (Element_1, Element_2: Universe) return Boolean;
package Set_Pack is
type Set is limited private;
procedure Make_Null (Set_1: in out Set);
procedure Insert (Element : in Universe; Into : in out Set);
procedure Insert (Set_1 : in Set; Into : in out Set);
procedure Delete (Element : in Universe; From : in out Set);
procedure Assign (Object : in out Set; Value : in Set);
-- Nulls value !
procedure Fassign(Object : in out Set; Value : in out Set);
function Is_Member (Element: Universe; Of_Set: Set) return Boolean;
function Is_Empty (Set_1: Set) return Boolean;
function Size_of (Set_1: Set) return Natural;
function "=" (Set_1 : Set; Set_2 : Set) return Boolean;
type Set_Iterator is limited private;
procedure Initialize (Iterator : in out Set_Iterator; Using : in Set);
function More (Iterator: Set_Iterator) return Boolean;
procedure Next (Iterator: in out Set_Iterator; Element: out Universe);
No_More_Elements : exception;
-- raised if you call NEXT when MORE is false.
--RJS
pragma inline(is_empty, size_of, more, next);
private
type Cell;
type Link is access Cell;
type Set is
record
Size : Natural;
Head : Link := null;
end record;
type Set_Iterator is new Link;
end Set_Pack;
|
[
{
"context": "right (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@g",
"end": 193,
"score": 0.9998823404312134,
"start": 178,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "2, 2013, 2014, 2015 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under",
"end": 224,
"score": 0.9998939633369446,
"start": 209,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "5 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under the Apache License, Versio",
"end": 251,
"score": 0.9999292492866516,
"start": 226,
"tag": "EMAIL",
"value": "Stephane.Carrez@gmail.com"
}
] | awa/src/awa-users-modules.ads | fuzzysloth/ada-awa | 0 | -----------------------------------------------------------------------
-- awa-users-module -- User management module
-- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 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.Applications;
with AWA.Modules;
with AWA.Users.Services;
with AWA.Users.Filters;
with AWA.Users.Servlets;
-- == Introduction ==
--
-- == Configuration ==
-- The *users* module uses a set of configuration properties to configure the OpenID
-- integration.
--
-- @include users.xml
--
-- @include awa-users-services.ads
--
-- @include users.xml
--
-- == Model ==
-- [images/awa_user_model.png]
--
package AWA.Users.Modules is
NAME : constant String := "users";
type User_Module is new AWA.Modules.Module with private;
type User_Module_Access is access all User_Module'Class;
-- Initialize the user module.
overriding
procedure Initialize (Plugin : in out User_Module;
App : in AWA.Modules.Application_Access;
Props : in ASF.Applications.Config);
-- Get the user manager.
function Get_User_Manager (Plugin : in User_Module) return Services.User_Service_Access;
-- Create a user manager. This operation can be overriden to provide another
-- user service implementation.
function Create_User_Manager (Plugin : in User_Module) return Services.User_Service_Access;
-- Get the user module instance associated with the current application.
function Get_User_Module return User_Module_Access;
-- Get the user manager instance associated with the current application.
function Get_User_Manager return Services.User_Service_Access;
private
type User_Module is new AWA.Modules.Module with record
Manager : Services.User_Service_Access := null;
Key_Filter : aliased AWA.Users.Filters.Verify_Filter;
Auth_Filter : aliased AWA.Users.Filters.Auth_Filter;
Auth : aliased AWA.Users.Servlets.Request_Auth_Servlet;
Verify_Auth : aliased AWA.Users.Servlets.Verify_Auth_Servlet;
end record;
end AWA.Users.Modules;
| 3715 | -----------------------------------------------------------------------
-- awa-users-module -- User management module
-- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with ASF.Applications;
with AWA.Modules;
with AWA.Users.Services;
with AWA.Users.Filters;
with AWA.Users.Servlets;
-- == Introduction ==
--
-- == Configuration ==
-- The *users* module uses a set of configuration properties to configure the OpenID
-- integration.
--
-- @include users.xml
--
-- @include awa-users-services.ads
--
-- @include users.xml
--
-- == Model ==
-- [images/awa_user_model.png]
--
package AWA.Users.Modules is
NAME : constant String := "users";
type User_Module is new AWA.Modules.Module with private;
type User_Module_Access is access all User_Module'Class;
-- Initialize the user module.
overriding
procedure Initialize (Plugin : in out User_Module;
App : in AWA.Modules.Application_Access;
Props : in ASF.Applications.Config);
-- Get the user manager.
function Get_User_Manager (Plugin : in User_Module) return Services.User_Service_Access;
-- Create a user manager. This operation can be overriden to provide another
-- user service implementation.
function Create_User_Manager (Plugin : in User_Module) return Services.User_Service_Access;
-- Get the user module instance associated with the current application.
function Get_User_Module return User_Module_Access;
-- Get the user manager instance associated with the current application.
function Get_User_Manager return Services.User_Service_Access;
private
type User_Module is new AWA.Modules.Module with record
Manager : Services.User_Service_Access := null;
Key_Filter : aliased AWA.Users.Filters.Verify_Filter;
Auth_Filter : aliased AWA.Users.Filters.Auth_Filter;
Auth : aliased AWA.Users.Servlets.Request_Auth_Servlet;
Verify_Auth : aliased AWA.Users.Servlets.Verify_Auth_Servlet;
end record;
end AWA.Users.Modules;
| true | -----------------------------------------------------------------------
-- awa-users-module -- User management module
-- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 PI:NAME:<NAME>END_PI
-- Written by PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
--
-- 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.Applications;
with AWA.Modules;
with AWA.Users.Services;
with AWA.Users.Filters;
with AWA.Users.Servlets;
-- == Introduction ==
--
-- == Configuration ==
-- The *users* module uses a set of configuration properties to configure the OpenID
-- integration.
--
-- @include users.xml
--
-- @include awa-users-services.ads
--
-- @include users.xml
--
-- == Model ==
-- [images/awa_user_model.png]
--
package AWA.Users.Modules is
NAME : constant String := "users";
type User_Module is new AWA.Modules.Module with private;
type User_Module_Access is access all User_Module'Class;
-- Initialize the user module.
overriding
procedure Initialize (Plugin : in out User_Module;
App : in AWA.Modules.Application_Access;
Props : in ASF.Applications.Config);
-- Get the user manager.
function Get_User_Manager (Plugin : in User_Module) return Services.User_Service_Access;
-- Create a user manager. This operation can be overriden to provide another
-- user service implementation.
function Create_User_Manager (Plugin : in User_Module) return Services.User_Service_Access;
-- Get the user module instance associated with the current application.
function Get_User_Module return User_Module_Access;
-- Get the user manager instance associated with the current application.
function Get_User_Manager return Services.User_Service_Access;
private
type User_Module is new AWA.Modules.Module with record
Manager : Services.User_Service_Access := null;
Key_Filter : aliased AWA.Users.Filters.Verify_Filter;
Auth_Filter : aliased AWA.Users.Filters.Auth_Filter;
Auth : aliased AWA.Users.Servlets.Request_Auth_Servlet;
Verify_Auth : aliased AWA.Users.Servlets.Verify_Auth_Servlet;
end record;
end AWA.Users.Modules;
|
[
{
"context": "der\n-- Copyright (C) 2009, 2010, 2011, 2012, 2013 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@g",
"end": 158,
"score": 0.9998706579208374,
"start": 143,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "0, 2011, 2012, 2013 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under",
"end": 189,
"score": 0.999881386756897,
"start": 174,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "3 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under the Apache License, Versio",
"end": 216,
"score": 0.9999292492866516,
"start": 191,
"tag": "EMAIL",
"value": "Stephane.Carrez@gmail.com"
}
] | src/asf-views-nodes-reader.adb | Letractively/ada-asf | 0 | -----------------------------------------------------------------------
-- asf -- XHTML Reader
-- Copyright (C) 2009, 2010, 2011, 2012, 2013 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.Unchecked_Deallocation;
with Unicode;
with Ada.Exceptions;
with Ada.Strings.Fixed;
with Util.Log.Loggers;
with Util.Serialize.IO.XML;
package body ASF.Views.Nodes.Reader is
use Sax.Readers;
use Sax.Exceptions;
use Sax.Locators;
use Sax.Attributes;
use Unicode;
use Unicode.CES;
use Ada.Strings.Fixed;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("ASF.Views.Nodes.Reader");
procedure Free is
new Ada.Unchecked_Deallocation (Element_Context_Array,
Element_Context_Array_Access);
procedure Push (Handler : in out Xhtml_Reader'Class);
procedure Pop (Handler : in out Xhtml_Reader'Class);
-- Freeze the current Text_Tag node, counting the number of elements it contains.
procedure Finish_Text_Node (Handler : in out Xhtml_Reader'Class);
-- ------------------------------
-- Push the current context when entering in an element.
-- ------------------------------
procedure Push (Handler : in out Xhtml_Reader'Class) is
begin
if Handler.Stack = null then
Handler.Stack := new Element_Context_Array (1 .. 100);
elsif Handler.Stack_Pos = Handler.Stack'Last then
declare
Old : Element_Context_Array_Access := Handler.Stack;
begin
Handler.Stack := new Element_Context_Array (1 .. Old'Last + 100);
Handler.Stack (1 .. Old'Last) := Old (1 .. Old'Last);
Free (Old);
end;
end if;
if Handler.Stack_Pos /= Handler.Stack'First then
Handler.Stack (Handler.Stack_Pos + 1) := Handler.Stack (Handler.Stack_Pos);
end if;
Handler.Stack_Pos := Handler.Stack_Pos + 1;
Handler.Current := Handler.Stack (Handler.Stack_Pos)'Access;
end Push;
-- ------------------------------
-- Pop the context and restore the previous context when leaving an element
-- ------------------------------
procedure Pop (Handler : in out Xhtml_Reader'Class) is
begin
Handler.Stack_Pos := Handler.Stack_Pos - 1;
Handler.Current := Handler.Stack (Handler.Stack_Pos)'Access;
end Pop;
-- ------------------------------
-- Find the function knowing its name.
-- ------------------------------
overriding
function Get_Function (Mapper : NS_Function_Mapper;
Namespace : String;
Name : String) return Function_Access is
use NS_Mapping;
Pos : constant NS_Mapping.Cursor := NS_Mapping.Find (Mapper.Mapping, Namespace);
begin
if Has_Element (Pos) then
return Mapper.Mapper.Get_Function (Element (Pos), Name);
end if;
raise No_Function with "Function '" & Namespace & ':' & Name & "' not found";
end Get_Function;
-- ------------------------------
-- Bind a name to a function in the given namespace.
-- ------------------------------
overriding
procedure Set_Function (Mapper : in out NS_Function_Mapper;
Namespace : in String;
Name : in String;
Func : in Function_Access) is
begin
null;
end Set_Function;
-- ------------------------------
-- Find the create function bound to the name in the given namespace.
-- Returns null if no such binding exist.
-- ------------------------------
function Find (Mapper : NS_Function_Mapper;
Namespace : String;
Name : String) return ASF.Views.Nodes.Binding_Access is
use NS_Mapping;
begin
return ASF.Factory.Find (Mapper.Factory.all, Namespace, Name);
end Find;
procedure Set_Namespace (Mapper : in out NS_Function_Mapper;
Prefix : in String;
URI : in String) is
use NS_Mapping;
begin
Log.Debug ("Add namespace {0}:{1}", Prefix, URI);
Mapper.Mapping.Include (Prefix, URI);
end Set_Namespace;
-- ------------------------------
-- Remove the namespace prefix binding.
-- ------------------------------
procedure Remove_Namespace (Mapper : in out NS_Function_Mapper;
Prefix : in String) is
use NS_Mapping;
Pos : NS_Mapping.Cursor := NS_Mapping.Find (Mapper.Mapping, Prefix);
begin
Log.Debug ("Remove namespace {0}", Prefix);
if Has_Element (Pos) then
NS_Mapping.Delete (Mapper.Mapping, Pos);
end if;
end Remove_Namespace;
-- ------------------------------
-- Warning
-- ------------------------------
overriding
procedure Warning (Handler : in out Xhtml_Reader;
Except : Sax.Exceptions.Sax_Parse_Exception'Class) is
pragma Warnings (Off, Handler);
begin
Log.Warn ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except));
end Warning;
-- ------------------------------
-- Error
-- ------------------------------
overriding
procedure Error (Handler : in out Xhtml_Reader;
Except : in Sax.Exceptions.Sax_Parse_Exception'Class) is
pragma Warnings (Off, Handler);
begin
Log.Error ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except));
end Error;
-- ------------------------------
-- Fatal_Error
-- ------------------------------
overriding
procedure Fatal_Error (Handler : in out Xhtml_Reader;
Except : in Sax.Exceptions.Sax_Parse_Exception'Class) is
pragma Unreferenced (Handler);
begin
Log.Error ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except));
end Fatal_Error;
-- ------------------------------
-- Set_Document_Locator
-- ------------------------------
overriding
procedure Set_Document_Locator (Handler : in out Xhtml_Reader;
Loc : in out Sax.Locators.Locator) is
begin
Handler.Locator := Loc;
end Set_Document_Locator;
-- ------------------------------
-- Start_Document
-- ------------------------------
overriding
procedure Start_Document (Handler : in out Xhtml_Reader) is
begin
null;
end Start_Document;
-- ------------------------------
-- End_Document
-- ------------------------------
overriding
procedure End_Document (Handler : in out Xhtml_Reader) is
begin
null;
end End_Document;
-- ------------------------------
-- Start_Prefix_Mapping
-- ------------------------------
overriding
procedure Start_Prefix_Mapping (Handler : in out Xhtml_Reader;
Prefix : in Unicode.CES.Byte_Sequence;
URI : in Unicode.CES.Byte_Sequence) is
begin
if Prefix = "" then
Handler.Add_NS := To_Unbounded_String (URI);
else
Handler.Functions.Set_Namespace (Prefix => Prefix, URI => URI);
end if;
end Start_Prefix_Mapping;
-- ------------------------------
-- End_Prefix_Mapping
-- ------------------------------
overriding
procedure End_Prefix_Mapping (Handler : in out Xhtml_Reader;
Prefix : in Unicode.CES.Byte_Sequence) is
begin
Handler.Functions.Remove_Namespace (Prefix => Prefix);
end End_Prefix_Mapping;
-- ------------------------------
-- Collect the text for an EL expression. The EL expression starts
-- with either '#{' or with '${' and ends with the matching '}'.
-- If the <b>Value</b> string does not contain the whole EL experssion
-- the <b>Expr_Buffer</b> stored in the reader is used to collect
-- that expression.
-- ------------------------------
procedure Collect_Expression (Handler : in out Xhtml_Reader) is
use Ada.Exceptions;
Expr : constant String := To_String (Handler.Expr_Buffer);
Content : constant Tag_Content_Access := Handler.Text.Last;
begin
Handler.Expr_Buffer := Null_Unbounded_String;
Content.Expr := EL.Expressions.Create_Expression (Expr, Handler.ELContext.all);
Content.Next := new Tag_Content;
Handler.Text.Last := Content.Next;
exception
when E : EL.Functions.No_Function | EL.Expressions.Invalid_Expression =>
Log.Error ("{0}: Invalid expression: {1}",
To_String (Handler.Locator),
Exception_Message (E));
Log.Error ("{0}: {1}",
To_String (Handler.Locator),
Expr);
when E : others =>
Log.Error ("{0}: Internal error: {1}:{2}",
To_String (Handler.Locator),
Exception_Name (E),
Exception_Message (E));
end Collect_Expression;
-- ------------------------------
-- Collect the raw-text in a buffer. The text must be flushed
-- when a new element is started or when an exiting element is closed.
-- ------------------------------
procedure Collect_Text (Handler : in out Xhtml_Reader;
Value : in Unicode.CES.Byte_Sequence) is
Pos : Natural := Value'First;
C : Character;
Content : Tag_Content_Access;
Start_Pos : Natural;
Last_Pos : Natural;
begin
while Pos <= Value'Last loop
case Handler.State is
-- Collect the white spaces and newlines in the 'Spaces'
-- buffer to ignore empty lines but still honor indentation.
when NO_CONTENT =>
loop
C := Value (Pos);
if C = ASCII.CR or C = ASCII.LF then
Handler.Spaces := Null_Unbounded_String;
elsif C = ' ' or C = ASCII.HT then
Append (Handler.Spaces, C);
else
Handler.State := HAS_CONTENT;
exit;
end if;
Pos := Pos + 1;
exit when Pos > Value'Last;
end loop;
-- Collect an EL expression until the end of that
-- expression. Evaluate the expression.
when PARSE_EXPR =>
Start_Pos := Pos;
loop
C := Value (Pos);
Last_Pos := Pos;
Pos := Pos + 1;
if C = '}' then
Handler.State := HAS_CONTENT;
exit;
end if;
exit when Pos > Value'Last;
end loop;
Append (Handler.Expr_Buffer, Value (Start_Pos .. Last_Pos));
if Handler.State /= PARSE_EXPR then
Handler.Collect_Expression;
end if;
-- Collect the raw text in the current content buffer
when HAS_CONTENT =>
if Handler.Text = null then
Handler.Text := new Text_Tag_Node;
Initialize (Handler.Text.all'Access, null,
Handler.Line, Handler.Current.Parent, null);
Handler.Text.Last := Handler.Text.Content'Access;
elsif Length (Handler.Expr_Buffer) > 0 then
Handler.Collect_Expression;
Pos := Pos + 1;
end if;
Content := Handler.Text.Last;
-- Scan until we find the start of an EL expression
-- or we have a new line.
Start_Pos := Pos;
loop
C := Value (Pos);
-- Check for the EL start #{ or ${
if (C = '#' or C = '$')
and then Pos + 1 <= Value'Last
and then Value (Pos + 1) = '{' then
Handler.State := PARSE_EXPR;
Append (Handler.Expr_Buffer, C);
Append (Handler.Expr_Buffer, '{');
Last_Pos := Pos - 1;
Pos := Pos + 2;
exit;
-- Handle \#{ and \${ as escape sequence
elsif C = '\' and then Pos + 2 <= Value'Last
and then Value (Pos + 2) = '{'
and then (Value (Pos + 1) = '#' or Value (Pos + 1) = '$') then
-- Since we have to strip the '\', flush the spaces and append the text
-- but ignore the '\'.
Append (Content.Text, Handler.Spaces);
Handler.Spaces := Null_Unbounded_String;
if Start_Pos < Pos then
Append (Content.Text, Value (Start_Pos .. Pos - 1));
end if;
Start_Pos := Pos + 1;
Pos := Pos + 2;
elsif (C = ASCII.CR or C = ASCII.LF) and Handler.Ignore_Empty_Lines then
Last_Pos := Pos;
Handler.State := NO_CONTENT;
exit;
end if;
Last_Pos := Pos;
Pos := Pos + 1;
exit when Pos > Value'Last;
end loop;
-- If we have some pending spaces, add them in the text stream.
if Length (Handler.Spaces) > 0 then
Append (Content.Text, Handler.Spaces);
Handler.Spaces := Null_Unbounded_String;
end if;
-- If we have some text, append to the current content buffer.
if Start_Pos <= Last_Pos then
Append (Content.Text, Value (Start_Pos .. Last_Pos));
end if;
end case;
end loop;
end Collect_Text;
-- ------------------------------
-- Freeze the current Text_Tag node, counting the number of elements it contains.
-- ------------------------------
procedure Finish_Text_Node (Handler : in out Xhtml_Reader'Class) is
begin
if Handler.Text /= null then
Handler.Text.Freeze;
Handler.Text := null;
end if;
end Finish_Text_Node;
-- ------------------------------
-- Start_Element
-- ------------------------------
overriding
procedure Start_Element (Handler : in out Xhtml_Reader;
Namespace_URI : in Unicode.CES.Byte_Sequence := "";
Local_Name : in Unicode.CES.Byte_Sequence := "";
Qname : in Unicode.CES.Byte_Sequence := "";
Atts : in Sax.Attributes.Attributes'Class) is
use ASF.Factory;
use Ada.Exceptions;
Attr_Count : Natural;
Attributes : Tag_Attribute_Array_Access;
Node : Tag_Node_Access;
Factory : ASF.Views.Nodes.Binding_Access;
begin
Handler.Line.Line := Sax.Locators.Get_Line_Number (Handler.Locator);
Handler.Line.Column := Sax.Locators.Get_Column_Number (Handler.Locator);
-- Push the current context to keep track where we are.
Push (Handler);
Attr_Count := Get_Length (Atts);
Factory := Handler.Functions.Find (Namespace => Namespace_URI,
Name => Local_Name);
if Factory /= null then
if Length (Handler.Add_NS) > 0 then
Attributes := new Tag_Attribute_Array (0 .. Attr_Count);
Attributes (0).Name := To_Unbounded_String ("xmlns");
Attributes (0).Value := Handler.Add_NS;
Handler.Add_NS := To_Unbounded_String ("");
else
Attributes := new Tag_Attribute_Array (1 .. Attr_Count);
end if;
for I in 0 .. Attr_Count - 1 loop
declare
Attr : constant Tag_Attribute_Access := Attributes (I + 1)'Access;
Value : constant String := Get_Value (Atts, I);
Name : constant String := Get_Qname (Atts, I);
Expr : EL.Expressions.Expression_Access;
begin
Attr.Name := To_Unbounded_String (Name);
if Index (Value, "#{") > 0 or Index (Value, "${") > 0 then
begin
Expr := new EL.Expressions.Expression;
Attr.Binding := Expr.all'Access;
EL.Expressions.Expression (Expr.all) := EL.Expressions.Create_Expression
(Value, Handler.ELContext.all);
exception
when E : EL.Functions.No_Function =>
Log.Error ("{0}: Invalid expression: {1}",
To_String (Handler.Locator),
Exception_Message (E));
Attr.Binding := null;
Attr.Value := To_Unbounded_String ("");
when E : EL.Expressions.Invalid_Expression =>
Log.Error ("{0}: Invalid expression: {1}",
To_String (Handler.Locator),
Exception_Message (E));
Attr.Binding := null;
Attr.Value := To_Unbounded_String ("");
end;
else
Attr.Value := To_Unbounded_String (Value);
end if;
end;
end loop;
Node := Factory.Tag (Binding => Factory,
Line => Handler.Line,
Parent => Handler.Current.Parent,
Attributes => Attributes);
Handler.Current.Parent := Node;
Handler.Current.Text := False;
Finish_Text_Node (Handler);
Handler.Spaces := Null_Unbounded_String;
Handler.State := Handler.Default_State;
else
declare
Is_Unknown : constant Boolean := Namespace_URI /= "" and Index (Qname, ":") > 0;
begin
-- Optimization: we know in which state we are.
Handler.State := HAS_CONTENT;
Handler.Current.Text := True;
if Is_Unknown then
Log.Error ("{0}: Element '{1}' not found",
To_String (Handler.Locator), Qname);
end if;
if Handler.Escape_Unknown_Tags and Is_Unknown then
Handler.Collect_Text ("<");
else
Handler.Collect_Text ("<");
end if;
Handler.Collect_Text (Qname);
if Length (Handler.Add_NS) > 0 then
Handler.Collect_Text (" xmlns=""");
Handler.Collect_Text (To_String (Handler.Add_NS));
Handler.Collect_Text ("""");
Handler.Add_NS := To_Unbounded_String ("");
end if;
if Attr_Count /= 0 then
for I in 0 .. Attr_Count - 1 loop
Handler.Collect_Text (" ");
Handler.Collect_Text (Get_Qname (Atts, I));
Handler.Collect_Text ("=""");
declare
Value : constant String := Get_Value (Atts, I);
begin
Handler.Collect_Text (Value);
end;
Handler.Collect_Text ("""");
end loop;
end if;
if Handler.Escape_Unknown_Tags and Is_Unknown then
Handler.Collect_Text (">");
else
Handler.Collect_Text (">");
end if;
end;
end if;
end Start_Element;
-- ------------------------------
-- End_Element
-- ------------------------------
overriding
procedure End_Element (Handler : in out Xhtml_Reader;
Namespace_URI : in Unicode.CES.Byte_Sequence := "";
Local_Name : in Unicode.CES.Byte_Sequence := "";
Qname : in Unicode.CES.Byte_Sequence := "") is
pragma Unreferenced (Local_Name);
begin
if Handler.Current.Parent = null then
Finish_Text_Node (Handler);
elsif not Handler.Current.Text then
Finish_Text_Node (Handler);
Handler.Current.Parent.Freeze;
end if;
if Handler.Current.Text or Handler.Text /= null then
declare
Is_Unknown : constant Boolean := Namespace_URI /= "" and Index (Qname, ":") > 0;
begin
-- Optimization: we know in which state we are.
Handler.State := HAS_CONTENT;
if Handler.Escape_Unknown_Tags and Is_Unknown then
Handler.Collect_Text ("</");
Handler.Collect_Text (Qname);
Handler.Collect_Text (">");
else
Handler.Collect_Text ("</");
Handler.Collect_Text (Qname);
Handler.Collect_Text (">");
end if;
end;
else
Handler.Spaces := Null_Unbounded_String;
end if;
-- Pop the current context to restore the last context.
Pop (Handler);
end End_Element;
-- ------------------------------
-- Characters
-- ------------------------------
overriding
procedure Characters (Handler : in out Xhtml_Reader;
Ch : in Unicode.CES.Byte_Sequence) is
begin
Collect_Text (Handler, Ch);
end Characters;
-- ------------------------------
-- Ignorable_Whitespace
-- ------------------------------
overriding
procedure Ignorable_Whitespace (Handler : in out Xhtml_Reader;
Ch : in Unicode.CES.Byte_Sequence) is
begin
if not Handler.Ignore_White_Spaces then
Collect_Text (Handler, Ch);
end if;
end Ignorable_Whitespace;
-- ------------------------------
-- Processing_Instruction
-- ------------------------------
overriding
procedure Processing_Instruction (Handler : in out Xhtml_Reader;
Target : in Unicode.CES.Byte_Sequence;
Data : in Unicode.CES.Byte_Sequence) is
pragma Unreferenced (Handler);
begin
Log.Error ("Processing instruction: {0}: {1}", Target, Data);
null;
end Processing_Instruction;
-- ------------------------------
-- Skipped_Entity
-- ------------------------------
overriding
procedure Skipped_Entity (Handler : in out Xhtml_Reader;
Name : in Unicode.CES.Byte_Sequence) is
pragma Unmodified (Handler);
begin
null;
end Skipped_Entity;
-- ------------------------------
-- Start_Cdata
-- ------------------------------
overriding
procedure Start_Cdata (Handler : in out Xhtml_Reader) is
pragma Unreferenced (Handler);
begin
Log.Info ("Start CDATA");
end Start_Cdata;
-- ------------------------------
-- End_Cdata
-- ------------------------------
overriding
procedure End_Cdata (Handler : in out Xhtml_Reader) is
pragma Unreferenced (Handler);
begin
Log.Info ("End CDATA");
end End_Cdata;
-- ------------------------------
-- Resolve_Entity
-- ------------------------------
overriding
function Resolve_Entity (Handler : Xhtml_Reader;
Public_Id : Unicode.CES.Byte_Sequence;
System_Id : Unicode.CES.Byte_Sequence)
return Input_Sources.Input_Source_Access is
pragma Unreferenced (Handler);
begin
Log.Error ("Cannot resolve entity {0} - {1}", Public_Id, System_Id);
return null;
end Resolve_Entity;
overriding
procedure Start_DTD (Handler : in out Xhtml_Reader;
Name : Unicode.CES.Byte_Sequence;
Public_Id : Unicode.CES.Byte_Sequence := "";
System_Id : Unicode.CES.Byte_Sequence := "") is
begin
if Handler.Text = null then
Handler.Text := new Text_Tag_Node;
Initialize (Handler.Text.all'Access, null,
Handler.Line, Handler.Current.Parent, null);
Handler.Text.Last := Handler.Text.Content'Access;
end if;
declare
Content : constant Tag_Content_Access := Handler.Text.Last;
begin
Append (Content.Text, "<!DOCTYPE ");
Append (Content.Text, Name);
Append (Content.Text, " ");
if Public_Id'Length > 0 then
Append (Content.Text, " PUBLIC """);
Append (Content.Text, Public_Id);
Append (Content.Text, """ ");
if System_Id'Length > 0 then
Append (Content.Text, '"');
Append (Content.Text, System_Id);
Append (Content.Text, '"');
end if;
elsif System_Id'Length > 0 then
Append (Content.Text, " SYSTEM """);
Append (Content.Text, System_Id);
Append (Content.Text, """ ");
end if;
Append (Content.Text, " >" & ASCII.LF);
end;
end Start_DTD;
-- ------------------------------
-- Get the root node that was created upon parsing of the XHTML file.
-- ------------------------------
function Get_Root (Reader : Xhtml_Reader) return Tag_Node_Access is
begin
return Reader.Root;
end Get_Root;
-- ------------------------------
-- Set the XHTML reader to ignore or not the white spaces.
-- When set to True, the ignorable white spaces will not be kept.
-- ------------------------------
procedure Set_Ignore_White_Spaces (Reader : in out Xhtml_Reader;
Value : in Boolean) is
begin
Reader.Ignore_White_Spaces := Value;
end Set_Ignore_White_Spaces;
-- ------------------------------
-- Set the XHTML reader to ignore empty lines.
-- ------------------------------
procedure Set_Ignore_Empty_Lines (Reader : in out Xhtml_Reader;
Value : in Boolean) is
begin
Reader.Ignore_Empty_Lines := Value;
end Set_Ignore_Empty_Lines;
-- ------------------------------
-- Set the XHTML reader to escape or not the unknown tags.
-- When set to True, the tags which are not recognized will be
-- emitted as a raw text component and they will be escaped using
-- the XML escape rules.
-- ------------------------------
procedure Set_Escape_Unknown_Tags (Reader : in out Xhtml_Reader;
Value : in Boolean) is
begin
Reader.Escape_Unknown_Tags := Value;
end Set_Escape_Unknown_Tags;
-- ------------------------------
-- Parse an XML stream, and calls the appropriate SAX callbacks for each
-- event.
-- This is not re-entrant: you can not call Parse with the same Parser
-- argument in one of the SAX callbacks. This has undefined behavior.
-- ------------------------------
procedure Parse (Parser : in out Xhtml_Reader;
Name : in ASF.Views.File_Info_Access;
Input : in out Input_Sources.Input_Source'Class;
Factory : access ASF.Factory.Component_Factory;
Context : in EL.Contexts.ELContext_Access) is
begin
Parser.Stack_Pos := 1;
Push (Parser);
Parser.Line.File := Name;
Parser.Root := new Tag_Node;
Parser.Functions.Factory := Factory;
Parser.Current.Parent := Parser.Root;
Parser.ELContext := Parser.Context'Unchecked_Access;
Parser.Context.Set_Function_Mapper (Parser.Functions'Unchecked_Access);
Parser.Functions.Mapper := Context.Get_Function_Mapper;
if Parser.Functions.Mapper = null then
Log.Warn ("There is no function mapper");
end if;
Sax.Readers.Reader (Parser).Parse (Input);
Finish_Text_Node (Parser);
Parser.Functions.Factory := null;
Parser.ELContext := null;
if Parser.Ignore_Empty_Lines then
Parser.Default_State := NO_CONTENT;
else
Parser.Default_State := HAS_CONTENT;
end if;
Parser.State := Parser.Default_State;
Free (Parser.Stack);
exception
when others =>
Free (Parser.Stack);
raise;
end Parse;
end ASF.Views.Nodes.Reader;
| 53 | -----------------------------------------------------------------------
-- asf -- XHTML Reader
-- Copyright (C) 2009, 2010, 2011, 2012, 2013 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Unicode;
with Ada.Exceptions;
with Ada.Strings.Fixed;
with Util.Log.Loggers;
with Util.Serialize.IO.XML;
package body ASF.Views.Nodes.Reader is
use Sax.Readers;
use Sax.Exceptions;
use Sax.Locators;
use Sax.Attributes;
use Unicode;
use Unicode.CES;
use Ada.Strings.Fixed;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("ASF.Views.Nodes.Reader");
procedure Free is
new Ada.Unchecked_Deallocation (Element_Context_Array,
Element_Context_Array_Access);
procedure Push (Handler : in out Xhtml_Reader'Class);
procedure Pop (Handler : in out Xhtml_Reader'Class);
-- Freeze the current Text_Tag node, counting the number of elements it contains.
procedure Finish_Text_Node (Handler : in out Xhtml_Reader'Class);
-- ------------------------------
-- Push the current context when entering in an element.
-- ------------------------------
procedure Push (Handler : in out Xhtml_Reader'Class) is
begin
if Handler.Stack = null then
Handler.Stack := new Element_Context_Array (1 .. 100);
elsif Handler.Stack_Pos = Handler.Stack'Last then
declare
Old : Element_Context_Array_Access := Handler.Stack;
begin
Handler.Stack := new Element_Context_Array (1 .. Old'Last + 100);
Handler.Stack (1 .. Old'Last) := Old (1 .. Old'Last);
Free (Old);
end;
end if;
if Handler.Stack_Pos /= Handler.Stack'First then
Handler.Stack (Handler.Stack_Pos + 1) := Handler.Stack (Handler.Stack_Pos);
end if;
Handler.Stack_Pos := Handler.Stack_Pos + 1;
Handler.Current := Handler.Stack (Handler.Stack_Pos)'Access;
end Push;
-- ------------------------------
-- Pop the context and restore the previous context when leaving an element
-- ------------------------------
procedure Pop (Handler : in out Xhtml_Reader'Class) is
begin
Handler.Stack_Pos := Handler.Stack_Pos - 1;
Handler.Current := Handler.Stack (Handler.Stack_Pos)'Access;
end Pop;
-- ------------------------------
-- Find the function knowing its name.
-- ------------------------------
overriding
function Get_Function (Mapper : NS_Function_Mapper;
Namespace : String;
Name : String) return Function_Access is
use NS_Mapping;
Pos : constant NS_Mapping.Cursor := NS_Mapping.Find (Mapper.Mapping, Namespace);
begin
if Has_Element (Pos) then
return Mapper.Mapper.Get_Function (Element (Pos), Name);
end if;
raise No_Function with "Function '" & Namespace & ':' & Name & "' not found";
end Get_Function;
-- ------------------------------
-- Bind a name to a function in the given namespace.
-- ------------------------------
overriding
procedure Set_Function (Mapper : in out NS_Function_Mapper;
Namespace : in String;
Name : in String;
Func : in Function_Access) is
begin
null;
end Set_Function;
-- ------------------------------
-- Find the create function bound to the name in the given namespace.
-- Returns null if no such binding exist.
-- ------------------------------
function Find (Mapper : NS_Function_Mapper;
Namespace : String;
Name : String) return ASF.Views.Nodes.Binding_Access is
use NS_Mapping;
begin
return ASF.Factory.Find (Mapper.Factory.all, Namespace, Name);
end Find;
procedure Set_Namespace (Mapper : in out NS_Function_Mapper;
Prefix : in String;
URI : in String) is
use NS_Mapping;
begin
Log.Debug ("Add namespace {0}:{1}", Prefix, URI);
Mapper.Mapping.Include (Prefix, URI);
end Set_Namespace;
-- ------------------------------
-- Remove the namespace prefix binding.
-- ------------------------------
procedure Remove_Namespace (Mapper : in out NS_Function_Mapper;
Prefix : in String) is
use NS_Mapping;
Pos : NS_Mapping.Cursor := NS_Mapping.Find (Mapper.Mapping, Prefix);
begin
Log.Debug ("Remove namespace {0}", Prefix);
if Has_Element (Pos) then
NS_Mapping.Delete (Mapper.Mapping, Pos);
end if;
end Remove_Namespace;
-- ------------------------------
-- Warning
-- ------------------------------
overriding
procedure Warning (Handler : in out Xhtml_Reader;
Except : Sax.Exceptions.Sax_Parse_Exception'Class) is
pragma Warnings (Off, Handler);
begin
Log.Warn ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except));
end Warning;
-- ------------------------------
-- Error
-- ------------------------------
overriding
procedure Error (Handler : in out Xhtml_Reader;
Except : in Sax.Exceptions.Sax_Parse_Exception'Class) is
pragma Warnings (Off, Handler);
begin
Log.Error ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except));
end Error;
-- ------------------------------
-- Fatal_Error
-- ------------------------------
overriding
procedure Fatal_Error (Handler : in out Xhtml_Reader;
Except : in Sax.Exceptions.Sax_Parse_Exception'Class) is
pragma Unreferenced (Handler);
begin
Log.Error ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except));
end Fatal_Error;
-- ------------------------------
-- Set_Document_Locator
-- ------------------------------
overriding
procedure Set_Document_Locator (Handler : in out Xhtml_Reader;
Loc : in out Sax.Locators.Locator) is
begin
Handler.Locator := Loc;
end Set_Document_Locator;
-- ------------------------------
-- Start_Document
-- ------------------------------
overriding
procedure Start_Document (Handler : in out Xhtml_Reader) is
begin
null;
end Start_Document;
-- ------------------------------
-- End_Document
-- ------------------------------
overriding
procedure End_Document (Handler : in out Xhtml_Reader) is
begin
null;
end End_Document;
-- ------------------------------
-- Start_Prefix_Mapping
-- ------------------------------
overriding
procedure Start_Prefix_Mapping (Handler : in out Xhtml_Reader;
Prefix : in Unicode.CES.Byte_Sequence;
URI : in Unicode.CES.Byte_Sequence) is
begin
if Prefix = "" then
Handler.Add_NS := To_Unbounded_String (URI);
else
Handler.Functions.Set_Namespace (Prefix => Prefix, URI => URI);
end if;
end Start_Prefix_Mapping;
-- ------------------------------
-- End_Prefix_Mapping
-- ------------------------------
overriding
procedure End_Prefix_Mapping (Handler : in out Xhtml_Reader;
Prefix : in Unicode.CES.Byte_Sequence) is
begin
Handler.Functions.Remove_Namespace (Prefix => Prefix);
end End_Prefix_Mapping;
-- ------------------------------
-- Collect the text for an EL expression. The EL expression starts
-- with either '#{' or with '${' and ends with the matching '}'.
-- If the <b>Value</b> string does not contain the whole EL experssion
-- the <b>Expr_Buffer</b> stored in the reader is used to collect
-- that expression.
-- ------------------------------
procedure Collect_Expression (Handler : in out Xhtml_Reader) is
use Ada.Exceptions;
Expr : constant String := To_String (Handler.Expr_Buffer);
Content : constant Tag_Content_Access := Handler.Text.Last;
begin
Handler.Expr_Buffer := Null_Unbounded_String;
Content.Expr := EL.Expressions.Create_Expression (Expr, Handler.ELContext.all);
Content.Next := new Tag_Content;
Handler.Text.Last := Content.Next;
exception
when E : EL.Functions.No_Function | EL.Expressions.Invalid_Expression =>
Log.Error ("{0}: Invalid expression: {1}",
To_String (Handler.Locator),
Exception_Message (E));
Log.Error ("{0}: {1}",
To_String (Handler.Locator),
Expr);
when E : others =>
Log.Error ("{0}: Internal error: {1}:{2}",
To_String (Handler.Locator),
Exception_Name (E),
Exception_Message (E));
end Collect_Expression;
-- ------------------------------
-- Collect the raw-text in a buffer. The text must be flushed
-- when a new element is started or when an exiting element is closed.
-- ------------------------------
procedure Collect_Text (Handler : in out Xhtml_Reader;
Value : in Unicode.CES.Byte_Sequence) is
Pos : Natural := Value'First;
C : Character;
Content : Tag_Content_Access;
Start_Pos : Natural;
Last_Pos : Natural;
begin
while Pos <= Value'Last loop
case Handler.State is
-- Collect the white spaces and newlines in the 'Spaces'
-- buffer to ignore empty lines but still honor indentation.
when NO_CONTENT =>
loop
C := Value (Pos);
if C = ASCII.CR or C = ASCII.LF then
Handler.Spaces := Null_Unbounded_String;
elsif C = ' ' or C = ASCII.HT then
Append (Handler.Spaces, C);
else
Handler.State := HAS_CONTENT;
exit;
end if;
Pos := Pos + 1;
exit when Pos > Value'Last;
end loop;
-- Collect an EL expression until the end of that
-- expression. Evaluate the expression.
when PARSE_EXPR =>
Start_Pos := Pos;
loop
C := Value (Pos);
Last_Pos := Pos;
Pos := Pos + 1;
if C = '}' then
Handler.State := HAS_CONTENT;
exit;
end if;
exit when Pos > Value'Last;
end loop;
Append (Handler.Expr_Buffer, Value (Start_Pos .. Last_Pos));
if Handler.State /= PARSE_EXPR then
Handler.Collect_Expression;
end if;
-- Collect the raw text in the current content buffer
when HAS_CONTENT =>
if Handler.Text = null then
Handler.Text := new Text_Tag_Node;
Initialize (Handler.Text.all'Access, null,
Handler.Line, Handler.Current.Parent, null);
Handler.Text.Last := Handler.Text.Content'Access;
elsif Length (Handler.Expr_Buffer) > 0 then
Handler.Collect_Expression;
Pos := Pos + 1;
end if;
Content := Handler.Text.Last;
-- Scan until we find the start of an EL expression
-- or we have a new line.
Start_Pos := Pos;
loop
C := Value (Pos);
-- Check for the EL start #{ or ${
if (C = '#' or C = '$')
and then Pos + 1 <= Value'Last
and then Value (Pos + 1) = '{' then
Handler.State := PARSE_EXPR;
Append (Handler.Expr_Buffer, C);
Append (Handler.Expr_Buffer, '{');
Last_Pos := Pos - 1;
Pos := Pos + 2;
exit;
-- Handle \#{ and \${ as escape sequence
elsif C = '\' and then Pos + 2 <= Value'Last
and then Value (Pos + 2) = '{'
and then (Value (Pos + 1) = '#' or Value (Pos + 1) = '$') then
-- Since we have to strip the '\', flush the spaces and append the text
-- but ignore the '\'.
Append (Content.Text, Handler.Spaces);
Handler.Spaces := Null_Unbounded_String;
if Start_Pos < Pos then
Append (Content.Text, Value (Start_Pos .. Pos - 1));
end if;
Start_Pos := Pos + 1;
Pos := Pos + 2;
elsif (C = ASCII.CR or C = ASCII.LF) and Handler.Ignore_Empty_Lines then
Last_Pos := Pos;
Handler.State := NO_CONTENT;
exit;
end if;
Last_Pos := Pos;
Pos := Pos + 1;
exit when Pos > Value'Last;
end loop;
-- If we have some pending spaces, add them in the text stream.
if Length (Handler.Spaces) > 0 then
Append (Content.Text, Handler.Spaces);
Handler.Spaces := Null_Unbounded_String;
end if;
-- If we have some text, append to the current content buffer.
if Start_Pos <= Last_Pos then
Append (Content.Text, Value (Start_Pos .. Last_Pos));
end if;
end case;
end loop;
end Collect_Text;
-- ------------------------------
-- Freeze the current Text_Tag node, counting the number of elements it contains.
-- ------------------------------
procedure Finish_Text_Node (Handler : in out Xhtml_Reader'Class) is
begin
if Handler.Text /= null then
Handler.Text.Freeze;
Handler.Text := null;
end if;
end Finish_Text_Node;
-- ------------------------------
-- Start_Element
-- ------------------------------
overriding
procedure Start_Element (Handler : in out Xhtml_Reader;
Namespace_URI : in Unicode.CES.Byte_Sequence := "";
Local_Name : in Unicode.CES.Byte_Sequence := "";
Qname : in Unicode.CES.Byte_Sequence := "";
Atts : in Sax.Attributes.Attributes'Class) is
use ASF.Factory;
use Ada.Exceptions;
Attr_Count : Natural;
Attributes : Tag_Attribute_Array_Access;
Node : Tag_Node_Access;
Factory : ASF.Views.Nodes.Binding_Access;
begin
Handler.Line.Line := Sax.Locators.Get_Line_Number (Handler.Locator);
Handler.Line.Column := Sax.Locators.Get_Column_Number (Handler.Locator);
-- Push the current context to keep track where we are.
Push (Handler);
Attr_Count := Get_Length (Atts);
Factory := Handler.Functions.Find (Namespace => Namespace_URI,
Name => Local_Name);
if Factory /= null then
if Length (Handler.Add_NS) > 0 then
Attributes := new Tag_Attribute_Array (0 .. Attr_Count);
Attributes (0).Name := To_Unbounded_String ("xmlns");
Attributes (0).Value := Handler.Add_NS;
Handler.Add_NS := To_Unbounded_String ("");
else
Attributes := new Tag_Attribute_Array (1 .. Attr_Count);
end if;
for I in 0 .. Attr_Count - 1 loop
declare
Attr : constant Tag_Attribute_Access := Attributes (I + 1)'Access;
Value : constant String := Get_Value (Atts, I);
Name : constant String := Get_Qname (Atts, I);
Expr : EL.Expressions.Expression_Access;
begin
Attr.Name := To_Unbounded_String (Name);
if Index (Value, "#{") > 0 or Index (Value, "${") > 0 then
begin
Expr := new EL.Expressions.Expression;
Attr.Binding := Expr.all'Access;
EL.Expressions.Expression (Expr.all) := EL.Expressions.Create_Expression
(Value, Handler.ELContext.all);
exception
when E : EL.Functions.No_Function =>
Log.Error ("{0}: Invalid expression: {1}",
To_String (Handler.Locator),
Exception_Message (E));
Attr.Binding := null;
Attr.Value := To_Unbounded_String ("");
when E : EL.Expressions.Invalid_Expression =>
Log.Error ("{0}: Invalid expression: {1}",
To_String (Handler.Locator),
Exception_Message (E));
Attr.Binding := null;
Attr.Value := To_Unbounded_String ("");
end;
else
Attr.Value := To_Unbounded_String (Value);
end if;
end;
end loop;
Node := Factory.Tag (Binding => Factory,
Line => Handler.Line,
Parent => Handler.Current.Parent,
Attributes => Attributes);
Handler.Current.Parent := Node;
Handler.Current.Text := False;
Finish_Text_Node (Handler);
Handler.Spaces := Null_Unbounded_String;
Handler.State := Handler.Default_State;
else
declare
Is_Unknown : constant Boolean := Namespace_URI /= "" and Index (Qname, ":") > 0;
begin
-- Optimization: we know in which state we are.
Handler.State := HAS_CONTENT;
Handler.Current.Text := True;
if Is_Unknown then
Log.Error ("{0}: Element '{1}' not found",
To_String (Handler.Locator), Qname);
end if;
if Handler.Escape_Unknown_Tags and Is_Unknown then
Handler.Collect_Text ("<");
else
Handler.Collect_Text ("<");
end if;
Handler.Collect_Text (Qname);
if Length (Handler.Add_NS) > 0 then
Handler.Collect_Text (" xmlns=""");
Handler.Collect_Text (To_String (Handler.Add_NS));
Handler.Collect_Text ("""");
Handler.Add_NS := To_Unbounded_String ("");
end if;
if Attr_Count /= 0 then
for I in 0 .. Attr_Count - 1 loop
Handler.Collect_Text (" ");
Handler.Collect_Text (Get_Qname (Atts, I));
Handler.Collect_Text ("=""");
declare
Value : constant String := Get_Value (Atts, I);
begin
Handler.Collect_Text (Value);
end;
Handler.Collect_Text ("""");
end loop;
end if;
if Handler.Escape_Unknown_Tags and Is_Unknown then
Handler.Collect_Text (">");
else
Handler.Collect_Text (">");
end if;
end;
end if;
end Start_Element;
-- ------------------------------
-- End_Element
-- ------------------------------
overriding
procedure End_Element (Handler : in out Xhtml_Reader;
Namespace_URI : in Unicode.CES.Byte_Sequence := "";
Local_Name : in Unicode.CES.Byte_Sequence := "";
Qname : in Unicode.CES.Byte_Sequence := "") is
pragma Unreferenced (Local_Name);
begin
if Handler.Current.Parent = null then
Finish_Text_Node (Handler);
elsif not Handler.Current.Text then
Finish_Text_Node (Handler);
Handler.Current.Parent.Freeze;
end if;
if Handler.Current.Text or Handler.Text /= null then
declare
Is_Unknown : constant Boolean := Namespace_URI /= "" and Index (Qname, ":") > 0;
begin
-- Optimization: we know in which state we are.
Handler.State := HAS_CONTENT;
if Handler.Escape_Unknown_Tags and Is_Unknown then
Handler.Collect_Text ("</");
Handler.Collect_Text (Qname);
Handler.Collect_Text (">");
else
Handler.Collect_Text ("</");
Handler.Collect_Text (Qname);
Handler.Collect_Text (">");
end if;
end;
else
Handler.Spaces := Null_Unbounded_String;
end if;
-- Pop the current context to restore the last context.
Pop (Handler);
end End_Element;
-- ------------------------------
-- Characters
-- ------------------------------
overriding
procedure Characters (Handler : in out Xhtml_Reader;
Ch : in Unicode.CES.Byte_Sequence) is
begin
Collect_Text (Handler, Ch);
end Characters;
-- ------------------------------
-- Ignorable_Whitespace
-- ------------------------------
overriding
procedure Ignorable_Whitespace (Handler : in out Xhtml_Reader;
Ch : in Unicode.CES.Byte_Sequence) is
begin
if not Handler.Ignore_White_Spaces then
Collect_Text (Handler, Ch);
end if;
end Ignorable_Whitespace;
-- ------------------------------
-- Processing_Instruction
-- ------------------------------
overriding
procedure Processing_Instruction (Handler : in out Xhtml_Reader;
Target : in Unicode.CES.Byte_Sequence;
Data : in Unicode.CES.Byte_Sequence) is
pragma Unreferenced (Handler);
begin
Log.Error ("Processing instruction: {0}: {1}", Target, Data);
null;
end Processing_Instruction;
-- ------------------------------
-- Skipped_Entity
-- ------------------------------
overriding
procedure Skipped_Entity (Handler : in out Xhtml_Reader;
Name : in Unicode.CES.Byte_Sequence) is
pragma Unmodified (Handler);
begin
null;
end Skipped_Entity;
-- ------------------------------
-- Start_Cdata
-- ------------------------------
overriding
procedure Start_Cdata (Handler : in out Xhtml_Reader) is
pragma Unreferenced (Handler);
begin
Log.Info ("Start CDATA");
end Start_Cdata;
-- ------------------------------
-- End_Cdata
-- ------------------------------
overriding
procedure End_Cdata (Handler : in out Xhtml_Reader) is
pragma Unreferenced (Handler);
begin
Log.Info ("End CDATA");
end End_Cdata;
-- ------------------------------
-- Resolve_Entity
-- ------------------------------
overriding
function Resolve_Entity (Handler : Xhtml_Reader;
Public_Id : Unicode.CES.Byte_Sequence;
System_Id : Unicode.CES.Byte_Sequence)
return Input_Sources.Input_Source_Access is
pragma Unreferenced (Handler);
begin
Log.Error ("Cannot resolve entity {0} - {1}", Public_Id, System_Id);
return null;
end Resolve_Entity;
overriding
procedure Start_DTD (Handler : in out Xhtml_Reader;
Name : Unicode.CES.Byte_Sequence;
Public_Id : Unicode.CES.Byte_Sequence := "";
System_Id : Unicode.CES.Byte_Sequence := "") is
begin
if Handler.Text = null then
Handler.Text := new Text_Tag_Node;
Initialize (Handler.Text.all'Access, null,
Handler.Line, Handler.Current.Parent, null);
Handler.Text.Last := Handler.Text.Content'Access;
end if;
declare
Content : constant Tag_Content_Access := Handler.Text.Last;
begin
Append (Content.Text, "<!DOCTYPE ");
Append (Content.Text, Name);
Append (Content.Text, " ");
if Public_Id'Length > 0 then
Append (Content.Text, " PUBLIC """);
Append (Content.Text, Public_Id);
Append (Content.Text, """ ");
if System_Id'Length > 0 then
Append (Content.Text, '"');
Append (Content.Text, System_Id);
Append (Content.Text, '"');
end if;
elsif System_Id'Length > 0 then
Append (Content.Text, " SYSTEM """);
Append (Content.Text, System_Id);
Append (Content.Text, """ ");
end if;
Append (Content.Text, " >" & ASCII.LF);
end;
end Start_DTD;
-- ------------------------------
-- Get the root node that was created upon parsing of the XHTML file.
-- ------------------------------
function Get_Root (Reader : Xhtml_Reader) return Tag_Node_Access is
begin
return Reader.Root;
end Get_Root;
-- ------------------------------
-- Set the XHTML reader to ignore or not the white spaces.
-- When set to True, the ignorable white spaces will not be kept.
-- ------------------------------
procedure Set_Ignore_White_Spaces (Reader : in out Xhtml_Reader;
Value : in Boolean) is
begin
Reader.Ignore_White_Spaces := Value;
end Set_Ignore_White_Spaces;
-- ------------------------------
-- Set the XHTML reader to ignore empty lines.
-- ------------------------------
procedure Set_Ignore_Empty_Lines (Reader : in out Xhtml_Reader;
Value : in Boolean) is
begin
Reader.Ignore_Empty_Lines := Value;
end Set_Ignore_Empty_Lines;
-- ------------------------------
-- Set the XHTML reader to escape or not the unknown tags.
-- When set to True, the tags which are not recognized will be
-- emitted as a raw text component and they will be escaped using
-- the XML escape rules.
-- ------------------------------
procedure Set_Escape_Unknown_Tags (Reader : in out Xhtml_Reader;
Value : in Boolean) is
begin
Reader.Escape_Unknown_Tags := Value;
end Set_Escape_Unknown_Tags;
-- ------------------------------
-- Parse an XML stream, and calls the appropriate SAX callbacks for each
-- event.
-- This is not re-entrant: you can not call Parse with the same Parser
-- argument in one of the SAX callbacks. This has undefined behavior.
-- ------------------------------
procedure Parse (Parser : in out Xhtml_Reader;
Name : in ASF.Views.File_Info_Access;
Input : in out Input_Sources.Input_Source'Class;
Factory : access ASF.Factory.Component_Factory;
Context : in EL.Contexts.ELContext_Access) is
begin
Parser.Stack_Pos := 1;
Push (Parser);
Parser.Line.File := Name;
Parser.Root := new Tag_Node;
Parser.Functions.Factory := Factory;
Parser.Current.Parent := Parser.Root;
Parser.ELContext := Parser.Context'Unchecked_Access;
Parser.Context.Set_Function_Mapper (Parser.Functions'Unchecked_Access);
Parser.Functions.Mapper := Context.Get_Function_Mapper;
if Parser.Functions.Mapper = null then
Log.Warn ("There is no function mapper");
end if;
Sax.Readers.Reader (Parser).Parse (Input);
Finish_Text_Node (Parser);
Parser.Functions.Factory := null;
Parser.ELContext := null;
if Parser.Ignore_Empty_Lines then
Parser.Default_State := NO_CONTENT;
else
Parser.Default_State := HAS_CONTENT;
end if;
Parser.State := Parser.Default_State;
Free (Parser.Stack);
exception
when others =>
Free (Parser.Stack);
raise;
end Parse;
end ASF.Views.Nodes.Reader;
| true | -----------------------------------------------------------------------
-- asf -- XHTML Reader
-- Copyright (C) 2009, 2010, 2011, 2012, 2013 PI:NAME:<NAME>END_PI
-- Written by PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Unicode;
with Ada.Exceptions;
with Ada.Strings.Fixed;
with Util.Log.Loggers;
with Util.Serialize.IO.XML;
package body ASF.Views.Nodes.Reader is
use Sax.Readers;
use Sax.Exceptions;
use Sax.Locators;
use Sax.Attributes;
use Unicode;
use Unicode.CES;
use Ada.Strings.Fixed;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("ASF.Views.Nodes.Reader");
procedure Free is
new Ada.Unchecked_Deallocation (Element_Context_Array,
Element_Context_Array_Access);
procedure Push (Handler : in out Xhtml_Reader'Class);
procedure Pop (Handler : in out Xhtml_Reader'Class);
-- Freeze the current Text_Tag node, counting the number of elements it contains.
procedure Finish_Text_Node (Handler : in out Xhtml_Reader'Class);
-- ------------------------------
-- Push the current context when entering in an element.
-- ------------------------------
procedure Push (Handler : in out Xhtml_Reader'Class) is
begin
if Handler.Stack = null then
Handler.Stack := new Element_Context_Array (1 .. 100);
elsif Handler.Stack_Pos = Handler.Stack'Last then
declare
Old : Element_Context_Array_Access := Handler.Stack;
begin
Handler.Stack := new Element_Context_Array (1 .. Old'Last + 100);
Handler.Stack (1 .. Old'Last) := Old (1 .. Old'Last);
Free (Old);
end;
end if;
if Handler.Stack_Pos /= Handler.Stack'First then
Handler.Stack (Handler.Stack_Pos + 1) := Handler.Stack (Handler.Stack_Pos);
end if;
Handler.Stack_Pos := Handler.Stack_Pos + 1;
Handler.Current := Handler.Stack (Handler.Stack_Pos)'Access;
end Push;
-- ------------------------------
-- Pop the context and restore the previous context when leaving an element
-- ------------------------------
procedure Pop (Handler : in out Xhtml_Reader'Class) is
begin
Handler.Stack_Pos := Handler.Stack_Pos - 1;
Handler.Current := Handler.Stack (Handler.Stack_Pos)'Access;
end Pop;
-- ------------------------------
-- Find the function knowing its name.
-- ------------------------------
overriding
function Get_Function (Mapper : NS_Function_Mapper;
Namespace : String;
Name : String) return Function_Access is
use NS_Mapping;
Pos : constant NS_Mapping.Cursor := NS_Mapping.Find (Mapper.Mapping, Namespace);
begin
if Has_Element (Pos) then
return Mapper.Mapper.Get_Function (Element (Pos), Name);
end if;
raise No_Function with "Function '" & Namespace & ':' & Name & "' not found";
end Get_Function;
-- ------------------------------
-- Bind a name to a function in the given namespace.
-- ------------------------------
overriding
procedure Set_Function (Mapper : in out NS_Function_Mapper;
Namespace : in String;
Name : in String;
Func : in Function_Access) is
begin
null;
end Set_Function;
-- ------------------------------
-- Find the create function bound to the name in the given namespace.
-- Returns null if no such binding exist.
-- ------------------------------
function Find (Mapper : NS_Function_Mapper;
Namespace : String;
Name : String) return ASF.Views.Nodes.Binding_Access is
use NS_Mapping;
begin
return ASF.Factory.Find (Mapper.Factory.all, Namespace, Name);
end Find;
procedure Set_Namespace (Mapper : in out NS_Function_Mapper;
Prefix : in String;
URI : in String) is
use NS_Mapping;
begin
Log.Debug ("Add namespace {0}:{1}", Prefix, URI);
Mapper.Mapping.Include (Prefix, URI);
end Set_Namespace;
-- ------------------------------
-- Remove the namespace prefix binding.
-- ------------------------------
procedure Remove_Namespace (Mapper : in out NS_Function_Mapper;
Prefix : in String) is
use NS_Mapping;
Pos : NS_Mapping.Cursor := NS_Mapping.Find (Mapper.Mapping, Prefix);
begin
Log.Debug ("Remove namespace {0}", Prefix);
if Has_Element (Pos) then
NS_Mapping.Delete (Mapper.Mapping, Pos);
end if;
end Remove_Namespace;
-- ------------------------------
-- Warning
-- ------------------------------
overriding
procedure Warning (Handler : in out Xhtml_Reader;
Except : Sax.Exceptions.Sax_Parse_Exception'Class) is
pragma Warnings (Off, Handler);
begin
Log.Warn ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except));
end Warning;
-- ------------------------------
-- Error
-- ------------------------------
overriding
procedure Error (Handler : in out Xhtml_Reader;
Except : in Sax.Exceptions.Sax_Parse_Exception'Class) is
pragma Warnings (Off, Handler);
begin
Log.Error ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except));
end Error;
-- ------------------------------
-- Fatal_Error
-- ------------------------------
overriding
procedure Fatal_Error (Handler : in out Xhtml_Reader;
Except : in Sax.Exceptions.Sax_Parse_Exception'Class) is
pragma Unreferenced (Handler);
begin
Log.Error ("{0}: {1}", Util.Serialize.IO.XML.Get_Location (Except), Get_Message (Except));
end Fatal_Error;
-- ------------------------------
-- Set_Document_Locator
-- ------------------------------
overriding
procedure Set_Document_Locator (Handler : in out Xhtml_Reader;
Loc : in out Sax.Locators.Locator) is
begin
Handler.Locator := Loc;
end Set_Document_Locator;
-- ------------------------------
-- Start_Document
-- ------------------------------
overriding
procedure Start_Document (Handler : in out Xhtml_Reader) is
begin
null;
end Start_Document;
-- ------------------------------
-- End_Document
-- ------------------------------
overriding
procedure End_Document (Handler : in out Xhtml_Reader) is
begin
null;
end End_Document;
-- ------------------------------
-- Start_Prefix_Mapping
-- ------------------------------
overriding
procedure Start_Prefix_Mapping (Handler : in out Xhtml_Reader;
Prefix : in Unicode.CES.Byte_Sequence;
URI : in Unicode.CES.Byte_Sequence) is
begin
if Prefix = "" then
Handler.Add_NS := To_Unbounded_String (URI);
else
Handler.Functions.Set_Namespace (Prefix => Prefix, URI => URI);
end if;
end Start_Prefix_Mapping;
-- ------------------------------
-- End_Prefix_Mapping
-- ------------------------------
overriding
procedure End_Prefix_Mapping (Handler : in out Xhtml_Reader;
Prefix : in Unicode.CES.Byte_Sequence) is
begin
Handler.Functions.Remove_Namespace (Prefix => Prefix);
end End_Prefix_Mapping;
-- ------------------------------
-- Collect the text for an EL expression. The EL expression starts
-- with either '#{' or with '${' and ends with the matching '}'.
-- If the <b>Value</b> string does not contain the whole EL experssion
-- the <b>Expr_Buffer</b> stored in the reader is used to collect
-- that expression.
-- ------------------------------
procedure Collect_Expression (Handler : in out Xhtml_Reader) is
use Ada.Exceptions;
Expr : constant String := To_String (Handler.Expr_Buffer);
Content : constant Tag_Content_Access := Handler.Text.Last;
begin
Handler.Expr_Buffer := Null_Unbounded_String;
Content.Expr := EL.Expressions.Create_Expression (Expr, Handler.ELContext.all);
Content.Next := new Tag_Content;
Handler.Text.Last := Content.Next;
exception
when E : EL.Functions.No_Function | EL.Expressions.Invalid_Expression =>
Log.Error ("{0}: Invalid expression: {1}",
To_String (Handler.Locator),
Exception_Message (E));
Log.Error ("{0}: {1}",
To_String (Handler.Locator),
Expr);
when E : others =>
Log.Error ("{0}: Internal error: {1}:{2}",
To_String (Handler.Locator),
Exception_Name (E),
Exception_Message (E));
end Collect_Expression;
-- ------------------------------
-- Collect the raw-text in a buffer. The text must be flushed
-- when a new element is started or when an exiting element is closed.
-- ------------------------------
procedure Collect_Text (Handler : in out Xhtml_Reader;
Value : in Unicode.CES.Byte_Sequence) is
Pos : Natural := Value'First;
C : Character;
Content : Tag_Content_Access;
Start_Pos : Natural;
Last_Pos : Natural;
begin
while Pos <= Value'Last loop
case Handler.State is
-- Collect the white spaces and newlines in the 'Spaces'
-- buffer to ignore empty lines but still honor indentation.
when NO_CONTENT =>
loop
C := Value (Pos);
if C = ASCII.CR or C = ASCII.LF then
Handler.Spaces := Null_Unbounded_String;
elsif C = ' ' or C = ASCII.HT then
Append (Handler.Spaces, C);
else
Handler.State := HAS_CONTENT;
exit;
end if;
Pos := Pos + 1;
exit when Pos > Value'Last;
end loop;
-- Collect an EL expression until the end of that
-- expression. Evaluate the expression.
when PARSE_EXPR =>
Start_Pos := Pos;
loop
C := Value (Pos);
Last_Pos := Pos;
Pos := Pos + 1;
if C = '}' then
Handler.State := HAS_CONTENT;
exit;
end if;
exit when Pos > Value'Last;
end loop;
Append (Handler.Expr_Buffer, Value (Start_Pos .. Last_Pos));
if Handler.State /= PARSE_EXPR then
Handler.Collect_Expression;
end if;
-- Collect the raw text in the current content buffer
when HAS_CONTENT =>
if Handler.Text = null then
Handler.Text := new Text_Tag_Node;
Initialize (Handler.Text.all'Access, null,
Handler.Line, Handler.Current.Parent, null);
Handler.Text.Last := Handler.Text.Content'Access;
elsif Length (Handler.Expr_Buffer) > 0 then
Handler.Collect_Expression;
Pos := Pos + 1;
end if;
Content := Handler.Text.Last;
-- Scan until we find the start of an EL expression
-- or we have a new line.
Start_Pos := Pos;
loop
C := Value (Pos);
-- Check for the EL start #{ or ${
if (C = '#' or C = '$')
and then Pos + 1 <= Value'Last
and then Value (Pos + 1) = '{' then
Handler.State := PARSE_EXPR;
Append (Handler.Expr_Buffer, C);
Append (Handler.Expr_Buffer, '{');
Last_Pos := Pos - 1;
Pos := Pos + 2;
exit;
-- Handle \#{ and \${ as escape sequence
elsif C = '\' and then Pos + 2 <= Value'Last
and then Value (Pos + 2) = '{'
and then (Value (Pos + 1) = '#' or Value (Pos + 1) = '$') then
-- Since we have to strip the '\', flush the spaces and append the text
-- but ignore the '\'.
Append (Content.Text, Handler.Spaces);
Handler.Spaces := Null_Unbounded_String;
if Start_Pos < Pos then
Append (Content.Text, Value (Start_Pos .. Pos - 1));
end if;
Start_Pos := Pos + 1;
Pos := Pos + 2;
elsif (C = ASCII.CR or C = ASCII.LF) and Handler.Ignore_Empty_Lines then
Last_Pos := Pos;
Handler.State := NO_CONTENT;
exit;
end if;
Last_Pos := Pos;
Pos := Pos + 1;
exit when Pos > Value'Last;
end loop;
-- If we have some pending spaces, add them in the text stream.
if Length (Handler.Spaces) > 0 then
Append (Content.Text, Handler.Spaces);
Handler.Spaces := Null_Unbounded_String;
end if;
-- If we have some text, append to the current content buffer.
if Start_Pos <= Last_Pos then
Append (Content.Text, Value (Start_Pos .. Last_Pos));
end if;
end case;
end loop;
end Collect_Text;
-- ------------------------------
-- Freeze the current Text_Tag node, counting the number of elements it contains.
-- ------------------------------
procedure Finish_Text_Node (Handler : in out Xhtml_Reader'Class) is
begin
if Handler.Text /= null then
Handler.Text.Freeze;
Handler.Text := null;
end if;
end Finish_Text_Node;
-- ------------------------------
-- Start_Element
-- ------------------------------
overriding
procedure Start_Element (Handler : in out Xhtml_Reader;
Namespace_URI : in Unicode.CES.Byte_Sequence := "";
Local_Name : in Unicode.CES.Byte_Sequence := "";
Qname : in Unicode.CES.Byte_Sequence := "";
Atts : in Sax.Attributes.Attributes'Class) is
use ASF.Factory;
use Ada.Exceptions;
Attr_Count : Natural;
Attributes : Tag_Attribute_Array_Access;
Node : Tag_Node_Access;
Factory : ASF.Views.Nodes.Binding_Access;
begin
Handler.Line.Line := Sax.Locators.Get_Line_Number (Handler.Locator);
Handler.Line.Column := Sax.Locators.Get_Column_Number (Handler.Locator);
-- Push the current context to keep track where we are.
Push (Handler);
Attr_Count := Get_Length (Atts);
Factory := Handler.Functions.Find (Namespace => Namespace_URI,
Name => Local_Name);
if Factory /= null then
if Length (Handler.Add_NS) > 0 then
Attributes := new Tag_Attribute_Array (0 .. Attr_Count);
Attributes (0).Name := To_Unbounded_String ("xmlns");
Attributes (0).Value := Handler.Add_NS;
Handler.Add_NS := To_Unbounded_String ("");
else
Attributes := new Tag_Attribute_Array (1 .. Attr_Count);
end if;
for I in 0 .. Attr_Count - 1 loop
declare
Attr : constant Tag_Attribute_Access := Attributes (I + 1)'Access;
Value : constant String := Get_Value (Atts, I);
Name : constant String := Get_Qname (Atts, I);
Expr : EL.Expressions.Expression_Access;
begin
Attr.Name := To_Unbounded_String (Name);
if Index (Value, "#{") > 0 or Index (Value, "${") > 0 then
begin
Expr := new EL.Expressions.Expression;
Attr.Binding := Expr.all'Access;
EL.Expressions.Expression (Expr.all) := EL.Expressions.Create_Expression
(Value, Handler.ELContext.all);
exception
when E : EL.Functions.No_Function =>
Log.Error ("{0}: Invalid expression: {1}",
To_String (Handler.Locator),
Exception_Message (E));
Attr.Binding := null;
Attr.Value := To_Unbounded_String ("");
when E : EL.Expressions.Invalid_Expression =>
Log.Error ("{0}: Invalid expression: {1}",
To_String (Handler.Locator),
Exception_Message (E));
Attr.Binding := null;
Attr.Value := To_Unbounded_String ("");
end;
else
Attr.Value := To_Unbounded_String (Value);
end if;
end;
end loop;
Node := Factory.Tag (Binding => Factory,
Line => Handler.Line,
Parent => Handler.Current.Parent,
Attributes => Attributes);
Handler.Current.Parent := Node;
Handler.Current.Text := False;
Finish_Text_Node (Handler);
Handler.Spaces := Null_Unbounded_String;
Handler.State := Handler.Default_State;
else
declare
Is_Unknown : constant Boolean := Namespace_URI /= "" and Index (Qname, ":") > 0;
begin
-- Optimization: we know in which state we are.
Handler.State := HAS_CONTENT;
Handler.Current.Text := True;
if Is_Unknown then
Log.Error ("{0}: Element '{1}' not found",
To_String (Handler.Locator), Qname);
end if;
if Handler.Escape_Unknown_Tags and Is_Unknown then
Handler.Collect_Text ("<");
else
Handler.Collect_Text ("<");
end if;
Handler.Collect_Text (Qname);
if Length (Handler.Add_NS) > 0 then
Handler.Collect_Text (" xmlns=""");
Handler.Collect_Text (To_String (Handler.Add_NS));
Handler.Collect_Text ("""");
Handler.Add_NS := To_Unbounded_String ("");
end if;
if Attr_Count /= 0 then
for I in 0 .. Attr_Count - 1 loop
Handler.Collect_Text (" ");
Handler.Collect_Text (Get_Qname (Atts, I));
Handler.Collect_Text ("=""");
declare
Value : constant String := Get_Value (Atts, I);
begin
Handler.Collect_Text (Value);
end;
Handler.Collect_Text ("""");
end loop;
end if;
if Handler.Escape_Unknown_Tags and Is_Unknown then
Handler.Collect_Text (">");
else
Handler.Collect_Text (">");
end if;
end;
end if;
end Start_Element;
-- ------------------------------
-- End_Element
-- ------------------------------
overriding
procedure End_Element (Handler : in out Xhtml_Reader;
Namespace_URI : in Unicode.CES.Byte_Sequence := "";
Local_Name : in Unicode.CES.Byte_Sequence := "";
Qname : in Unicode.CES.Byte_Sequence := "") is
pragma Unreferenced (Local_Name);
begin
if Handler.Current.Parent = null then
Finish_Text_Node (Handler);
elsif not Handler.Current.Text then
Finish_Text_Node (Handler);
Handler.Current.Parent.Freeze;
end if;
if Handler.Current.Text or Handler.Text /= null then
declare
Is_Unknown : constant Boolean := Namespace_URI /= "" and Index (Qname, ":") > 0;
begin
-- Optimization: we know in which state we are.
Handler.State := HAS_CONTENT;
if Handler.Escape_Unknown_Tags and Is_Unknown then
Handler.Collect_Text ("</");
Handler.Collect_Text (Qname);
Handler.Collect_Text (">");
else
Handler.Collect_Text ("</");
Handler.Collect_Text (Qname);
Handler.Collect_Text (">");
end if;
end;
else
Handler.Spaces := Null_Unbounded_String;
end if;
-- Pop the current context to restore the last context.
Pop (Handler);
end End_Element;
-- ------------------------------
-- Characters
-- ------------------------------
overriding
procedure Characters (Handler : in out Xhtml_Reader;
Ch : in Unicode.CES.Byte_Sequence) is
begin
Collect_Text (Handler, Ch);
end Characters;
-- ------------------------------
-- Ignorable_Whitespace
-- ------------------------------
overriding
procedure Ignorable_Whitespace (Handler : in out Xhtml_Reader;
Ch : in Unicode.CES.Byte_Sequence) is
begin
if not Handler.Ignore_White_Spaces then
Collect_Text (Handler, Ch);
end if;
end Ignorable_Whitespace;
-- ------------------------------
-- Processing_Instruction
-- ------------------------------
overriding
procedure Processing_Instruction (Handler : in out Xhtml_Reader;
Target : in Unicode.CES.Byte_Sequence;
Data : in Unicode.CES.Byte_Sequence) is
pragma Unreferenced (Handler);
begin
Log.Error ("Processing instruction: {0}: {1}", Target, Data);
null;
end Processing_Instruction;
-- ------------------------------
-- Skipped_Entity
-- ------------------------------
overriding
procedure Skipped_Entity (Handler : in out Xhtml_Reader;
Name : in Unicode.CES.Byte_Sequence) is
pragma Unmodified (Handler);
begin
null;
end Skipped_Entity;
-- ------------------------------
-- Start_Cdata
-- ------------------------------
overriding
procedure Start_Cdata (Handler : in out Xhtml_Reader) is
pragma Unreferenced (Handler);
begin
Log.Info ("Start CDATA");
end Start_Cdata;
-- ------------------------------
-- End_Cdata
-- ------------------------------
overriding
procedure End_Cdata (Handler : in out Xhtml_Reader) is
pragma Unreferenced (Handler);
begin
Log.Info ("End CDATA");
end End_Cdata;
-- ------------------------------
-- Resolve_Entity
-- ------------------------------
overriding
function Resolve_Entity (Handler : Xhtml_Reader;
Public_Id : Unicode.CES.Byte_Sequence;
System_Id : Unicode.CES.Byte_Sequence)
return Input_Sources.Input_Source_Access is
pragma Unreferenced (Handler);
begin
Log.Error ("Cannot resolve entity {0} - {1}", Public_Id, System_Id);
return null;
end Resolve_Entity;
overriding
procedure Start_DTD (Handler : in out Xhtml_Reader;
Name : Unicode.CES.Byte_Sequence;
Public_Id : Unicode.CES.Byte_Sequence := "";
System_Id : Unicode.CES.Byte_Sequence := "") is
begin
if Handler.Text = null then
Handler.Text := new Text_Tag_Node;
Initialize (Handler.Text.all'Access, null,
Handler.Line, Handler.Current.Parent, null);
Handler.Text.Last := Handler.Text.Content'Access;
end if;
declare
Content : constant Tag_Content_Access := Handler.Text.Last;
begin
Append (Content.Text, "<!DOCTYPE ");
Append (Content.Text, Name);
Append (Content.Text, " ");
if Public_Id'Length > 0 then
Append (Content.Text, " PUBLIC """);
Append (Content.Text, Public_Id);
Append (Content.Text, """ ");
if System_Id'Length > 0 then
Append (Content.Text, '"');
Append (Content.Text, System_Id);
Append (Content.Text, '"');
end if;
elsif System_Id'Length > 0 then
Append (Content.Text, " SYSTEM """);
Append (Content.Text, System_Id);
Append (Content.Text, """ ");
end if;
Append (Content.Text, " >" & ASCII.LF);
end;
end Start_DTD;
-- ------------------------------
-- Get the root node that was created upon parsing of the XHTML file.
-- ------------------------------
function Get_Root (Reader : Xhtml_Reader) return Tag_Node_Access is
begin
return Reader.Root;
end Get_Root;
-- ------------------------------
-- Set the XHTML reader to ignore or not the white spaces.
-- When set to True, the ignorable white spaces will not be kept.
-- ------------------------------
procedure Set_Ignore_White_Spaces (Reader : in out Xhtml_Reader;
Value : in Boolean) is
begin
Reader.Ignore_White_Spaces := Value;
end Set_Ignore_White_Spaces;
-- ------------------------------
-- Set the XHTML reader to ignore empty lines.
-- ------------------------------
procedure Set_Ignore_Empty_Lines (Reader : in out Xhtml_Reader;
Value : in Boolean) is
begin
Reader.Ignore_Empty_Lines := Value;
end Set_Ignore_Empty_Lines;
-- ------------------------------
-- Set the XHTML reader to escape or not the unknown tags.
-- When set to True, the tags which are not recognized will be
-- emitted as a raw text component and they will be escaped using
-- the XML escape rules.
-- ------------------------------
procedure Set_Escape_Unknown_Tags (Reader : in out Xhtml_Reader;
Value : in Boolean) is
begin
Reader.Escape_Unknown_Tags := Value;
end Set_Escape_Unknown_Tags;
-- ------------------------------
-- Parse an XML stream, and calls the appropriate SAX callbacks for each
-- event.
-- This is not re-entrant: you can not call Parse with the same Parser
-- argument in one of the SAX callbacks. This has undefined behavior.
-- ------------------------------
procedure Parse (Parser : in out Xhtml_Reader;
Name : in ASF.Views.File_Info_Access;
Input : in out Input_Sources.Input_Source'Class;
Factory : access ASF.Factory.Component_Factory;
Context : in EL.Contexts.ELContext_Access) is
begin
Parser.Stack_Pos := 1;
Push (Parser);
Parser.Line.File := Name;
Parser.Root := new Tag_Node;
Parser.Functions.Factory := Factory;
Parser.Current.Parent := Parser.Root;
Parser.ELContext := Parser.Context'Unchecked_Access;
Parser.Context.Set_Function_Mapper (Parser.Functions'Unchecked_Access);
Parser.Functions.Mapper := Context.Get_Function_Mapper;
if Parser.Functions.Mapper = null then
Log.Warn ("There is no function mapper");
end if;
Sax.Readers.Reader (Parser).Parse (Input);
Finish_Text_Node (Parser);
Parser.Functions.Factory := null;
Parser.ELContext := null;
if Parser.Ignore_Empty_Lines then
Parser.Default_State := NO_CONTENT;
else
Parser.Default_State := HAS_CONTENT;
end if;
Parser.State := Parser.Default_State;
Free (Parser.Stack);
exception
when others =>
Free (Parser.Stack);
raise;
end Parse;
end ASF.Views.Nodes.Reader;
|
[
{
"context": " mappings\n-- Copyright (C) 2010, 2011, 2012, 2014 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@g",
"end": 177,
"score": 0.9998821020126343,
"start": 162,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "0, 2011, 2012, 2014 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under",
"end": 208,
"score": 0.9998824000358582,
"start": 193,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "4 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under the Apache License, Versio",
"end": 235,
"score": 0.9999291300773621,
"start": 210,
"tag": "EMAIL",
"value": "Stephane.Carrez@gmail.com"
},
{
"context": "zip>..</zip>\n -- </address>\n -- <name>John</name>\n -- <last_name>Harry</last_name>\n ",
"end": 8698,
"score": 0.9997826814651489,
"start": 8694,
"tag": "NAME",
"value": "John"
},
{
"context": "\n -- <name>John</name>\n -- <last_name>Harry</last_name>\n -- <age>23</age>\n -- <in",
"end": 8732,
"score": 0.9997666478157043,
"start": 8727,
"tag": "NAME",
"value": "Harry"
}
] | samples/mapping.adb | Letractively/ada-util | 60 | -----------------------------------------------------------------------
-- mapping -- Example of serialization mappings
-- Copyright (C) 2010, 2011, 2012, 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 Util.Log.Loggers;
package body Mapping is
use Util.Beans.Objects;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Mapping");
type Property_Fields is (FIELD_NAME, FIELD_VALUE);
type Property_Access is access all Property;
type Address_Fields is (FIELD_CITY, FIELD_STREET, FIELD_COUNTRY, FIELD_ZIP);
type Address_Access is access all Address;
procedure Proxy_Address (Attr : in Util.Serialize.Mappers.Mapping'Class;
Element : in out Person;
Value : in Util.Beans.Objects.Object);
function Get_Address_Member (Addr : in Address;
Field : in Address_Fields) return Util.Beans.Objects.Object;
procedure Set_Member (Addr : in out Address;
Field : in Address_Fields;
Value : in Util.Beans.Objects.Object);
procedure Set_Member (P : in out Property;
Field : in Property_Fields;
Value : in Util.Beans.Objects.Object);
procedure Set_Member (P : in out Property;
Field : in Property_Fields;
Value : in Util.Beans.Objects.Object) is
begin
case Field is
when FIELD_NAME =>
P.Name := To_Unbounded_String (Value);
when FIELD_VALUE =>
P.Value := To_Unbounded_String (Value);
end case;
end Set_Member;
package Property_Mapper is
new Util.Serialize.Mappers.Record_Mapper (Element_Type => Property,
Element_Type_Access => Property_Access,
Fields => Property_Fields,
Set_Member => Set_Member);
-- ------------------------------
-- Set the name/value pair on the current object.
-- ------------------------------
procedure Set_Member (P : in out Person;
Field : in Person_Fields;
Value : in Util.Beans.Objects.Object) is
begin
Log.Debug ("Person field {0} - {0}", Person_Fields'Image (Field), To_String (Value));
case Field is
when FIELD_FIRST_NAME =>
P.First_Name := To_Unbounded_String (Value);
when FIELD_LAST_NAME =>
P.Last_Name := To_Unbounded_String (Value);
when FIELD_AGE =>
P.Age := To_Integer (Value);
when FIELD_ID =>
P.Id := To_Long_Long_Integer (Value);
when FIELD_NAME =>
P.Name := To_Unbounded_String (Value);
when FIELD_USER_NAME =>
P.Username := To_Unbounded_String (Value);
when FIELD_GENDER =>
P.Gender := To_Unbounded_String (Value);
when FIELD_LINK =>
P.Link := To_Unbounded_String (Value);
end case;
end Set_Member;
-- ------------------------------
-- Set the name/value pair on the current object.
-- ------------------------------
function Get_Person_Member (From : in Person;
Field : in Person_Fields) return Util.Beans.Objects.Object is
begin
case Field is
when FIELD_FIRST_NAME =>
return Util.Beans.Objects.To_Object (From.First_Name);
when FIELD_LAST_NAME =>
return Util.Beans.Objects.To_Object (From.Last_Name);
when FIELD_AGE =>
return Util.Beans.Objects.To_Object (From.Age);
when FIELD_NAME =>
return Util.Beans.Objects.To_Object (From.Name);
when FIELD_USER_NAME =>
return Util.Beans.Objects.To_Object (From.Username);
when FIELD_LINK =>
return Util.Beans.Objects.To_Object (From.Link);
when FIELD_GENDER =>
return Util.Beans.Objects.To_Object (From.Gender);
when FIELD_ID =>
return Util.Beans.Objects.To_Object (From.Id);
end case;
end Get_Person_Member;
-- ------------------------------
-- Set the name/value pair on the current object.
-- ------------------------------
procedure Set_Member (Addr : in out Address;
Field : in Address_Fields;
Value : in Util.Beans.Objects.Object) is
begin
case Field is
when FIELD_CITY =>
Addr.City := To_Unbounded_String (Value);
when FIELD_STREET =>
Addr.Street := To_Unbounded_String (Value);
when FIELD_COUNTRY =>
Addr.Country := To_Unbounded_String (Value);
when FIELD_ZIP =>
Addr.Zip := To_Integer (Value);
end case;
end Set_Member;
function Get_Address_Member (Addr : in Address;
Field : in Address_Fields) return Util.Beans.Objects.Object is
begin
case Field is
when FIELD_CITY =>
return Util.Beans.Objects.To_Object (Addr.City);
when FIELD_STREET =>
return Util.Beans.Objects.To_Object (Addr.Street);
when FIELD_COUNTRY =>
return Util.Beans.Objects.To_Object (Addr.Country);
when FIELD_ZIP =>
return Util.Beans.Objects.To_Object (Addr.Zip);
end case;
end Get_Address_Member;
package Address_Mapper is
new Util.Serialize.Mappers.Record_Mapper (Element_Type => Address,
Element_Type_Access => Address_Access,
Fields => Address_Fields,
Set_Member => Set_Member);
-- Mapping for the Property record.
Property_Mapping : aliased Property_Mapper.Mapper;
-- Mapping for the Address record.
Address_Mapping : aliased Address_Mapper.Mapper;
-- Mapping for the Person record.
Person_Mapping : aliased Person_Mapper.Mapper;
-- ------------------------------
-- Get the address mapper which describes how to load an Address.
-- ------------------------------
function Get_Address_Mapper return Util.Serialize.Mappers.Mapper_Access is
begin
return Address_Mapping'Access;
end Get_Address_Mapper;
-- ------------------------------
-- Get the person mapper which describes how to load a Person.
-- ------------------------------
function Get_Person_Mapper return Person_Mapper.Mapper_Access is
begin
return Person_Mapping'Access;
end Get_Person_Mapper;
-- ------------------------------
-- Helper to give access to the <b>Address</b> member of a <b>Person</b>.
-- ------------------------------
procedure Proxy_Address (Attr : in Util.Serialize.Mappers.Mapping'Class;
Element : in out Person;
Value : in Util.Beans.Objects.Object) is
begin
Address_Mapper.Set_Member (Attr, Element.Addr, Value);
end Proxy_Address;
begin
Property_Mapping.Add_Default_Mapping;
-- XML: JSON:
-- ---- -----
-- <city>Paris</city> "city" : "Paris"
-- <street>Champs de Mars</street> "street" : "Champs de Mars"
-- <country>France</country> "country" : "France"
-- <zip>75</zip> "zip" : 75
Address_Mapping.Bind (Get_Address_Member'Access);
-- Address_Mapping.Add_Mapping ("info", Property_Mapping'Access, Proxy_Info'Access);
Address_Mapping.Add_Default_Mapping;
-- XML:
-- ----
-- <xxx id='23'>
-- <address>
-- <city>...</city>
-- <street number='44'>..</street>
-- <country>..</country>
-- <zip>..</zip>
-- </address>
-- <name>John</name>
-- <last_name>Harry</last_name>
-- <age>23</age>
-- <info><facebook><id>...</id></facebook></info>
-- </xxx>
-- Person_Mapper.Add_Mapping ("@id");
Person_Mapping.Bind (Get_Person_Member'Access);
Person_Mapping.Add_Mapping ("address", Address_Mapping'Access, Proxy_Address'Access);
Person_Mapping.Add_Default_Mapping;
-- Person_Mapper.Add_Mapping ("info/*");
-- Person_Mapper.Add_Mapping ("address/street/@number");
end Mapping;
| 27704 | -----------------------------------------------------------------------
-- mapping -- Example of serialization mappings
-- Copyright (C) 2010, 2011, 2012, 2014 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Log.Loggers;
package body Mapping is
use Util.Beans.Objects;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Mapping");
type Property_Fields is (FIELD_NAME, FIELD_VALUE);
type Property_Access is access all Property;
type Address_Fields is (FIELD_CITY, FIELD_STREET, FIELD_COUNTRY, FIELD_ZIP);
type Address_Access is access all Address;
procedure Proxy_Address (Attr : in Util.Serialize.Mappers.Mapping'Class;
Element : in out Person;
Value : in Util.Beans.Objects.Object);
function Get_Address_Member (Addr : in Address;
Field : in Address_Fields) return Util.Beans.Objects.Object;
procedure Set_Member (Addr : in out Address;
Field : in Address_Fields;
Value : in Util.Beans.Objects.Object);
procedure Set_Member (P : in out Property;
Field : in Property_Fields;
Value : in Util.Beans.Objects.Object);
procedure Set_Member (P : in out Property;
Field : in Property_Fields;
Value : in Util.Beans.Objects.Object) is
begin
case Field is
when FIELD_NAME =>
P.Name := To_Unbounded_String (Value);
when FIELD_VALUE =>
P.Value := To_Unbounded_String (Value);
end case;
end Set_Member;
package Property_Mapper is
new Util.Serialize.Mappers.Record_Mapper (Element_Type => Property,
Element_Type_Access => Property_Access,
Fields => Property_Fields,
Set_Member => Set_Member);
-- ------------------------------
-- Set the name/value pair on the current object.
-- ------------------------------
procedure Set_Member (P : in out Person;
Field : in Person_Fields;
Value : in Util.Beans.Objects.Object) is
begin
Log.Debug ("Person field {0} - {0}", Person_Fields'Image (Field), To_String (Value));
case Field is
when FIELD_FIRST_NAME =>
P.First_Name := To_Unbounded_String (Value);
when FIELD_LAST_NAME =>
P.Last_Name := To_Unbounded_String (Value);
when FIELD_AGE =>
P.Age := To_Integer (Value);
when FIELD_ID =>
P.Id := To_Long_Long_Integer (Value);
when FIELD_NAME =>
P.Name := To_Unbounded_String (Value);
when FIELD_USER_NAME =>
P.Username := To_Unbounded_String (Value);
when FIELD_GENDER =>
P.Gender := To_Unbounded_String (Value);
when FIELD_LINK =>
P.Link := To_Unbounded_String (Value);
end case;
end Set_Member;
-- ------------------------------
-- Set the name/value pair on the current object.
-- ------------------------------
function Get_Person_Member (From : in Person;
Field : in Person_Fields) return Util.Beans.Objects.Object is
begin
case Field is
when FIELD_FIRST_NAME =>
return Util.Beans.Objects.To_Object (From.First_Name);
when FIELD_LAST_NAME =>
return Util.Beans.Objects.To_Object (From.Last_Name);
when FIELD_AGE =>
return Util.Beans.Objects.To_Object (From.Age);
when FIELD_NAME =>
return Util.Beans.Objects.To_Object (From.Name);
when FIELD_USER_NAME =>
return Util.Beans.Objects.To_Object (From.Username);
when FIELD_LINK =>
return Util.Beans.Objects.To_Object (From.Link);
when FIELD_GENDER =>
return Util.Beans.Objects.To_Object (From.Gender);
when FIELD_ID =>
return Util.Beans.Objects.To_Object (From.Id);
end case;
end Get_Person_Member;
-- ------------------------------
-- Set the name/value pair on the current object.
-- ------------------------------
procedure Set_Member (Addr : in out Address;
Field : in Address_Fields;
Value : in Util.Beans.Objects.Object) is
begin
case Field is
when FIELD_CITY =>
Addr.City := To_Unbounded_String (Value);
when FIELD_STREET =>
Addr.Street := To_Unbounded_String (Value);
when FIELD_COUNTRY =>
Addr.Country := To_Unbounded_String (Value);
when FIELD_ZIP =>
Addr.Zip := To_Integer (Value);
end case;
end Set_Member;
function Get_Address_Member (Addr : in Address;
Field : in Address_Fields) return Util.Beans.Objects.Object is
begin
case Field is
when FIELD_CITY =>
return Util.Beans.Objects.To_Object (Addr.City);
when FIELD_STREET =>
return Util.Beans.Objects.To_Object (Addr.Street);
when FIELD_COUNTRY =>
return Util.Beans.Objects.To_Object (Addr.Country);
when FIELD_ZIP =>
return Util.Beans.Objects.To_Object (Addr.Zip);
end case;
end Get_Address_Member;
package Address_Mapper is
new Util.Serialize.Mappers.Record_Mapper (Element_Type => Address,
Element_Type_Access => Address_Access,
Fields => Address_Fields,
Set_Member => Set_Member);
-- Mapping for the Property record.
Property_Mapping : aliased Property_Mapper.Mapper;
-- Mapping for the Address record.
Address_Mapping : aliased Address_Mapper.Mapper;
-- Mapping for the Person record.
Person_Mapping : aliased Person_Mapper.Mapper;
-- ------------------------------
-- Get the address mapper which describes how to load an Address.
-- ------------------------------
function Get_Address_Mapper return Util.Serialize.Mappers.Mapper_Access is
begin
return Address_Mapping'Access;
end Get_Address_Mapper;
-- ------------------------------
-- Get the person mapper which describes how to load a Person.
-- ------------------------------
function Get_Person_Mapper return Person_Mapper.Mapper_Access is
begin
return Person_Mapping'Access;
end Get_Person_Mapper;
-- ------------------------------
-- Helper to give access to the <b>Address</b> member of a <b>Person</b>.
-- ------------------------------
procedure Proxy_Address (Attr : in Util.Serialize.Mappers.Mapping'Class;
Element : in out Person;
Value : in Util.Beans.Objects.Object) is
begin
Address_Mapper.Set_Member (Attr, Element.Addr, Value);
end Proxy_Address;
begin
Property_Mapping.Add_Default_Mapping;
-- XML: JSON:
-- ---- -----
-- <city>Paris</city> "city" : "Paris"
-- <street>Champs de Mars</street> "street" : "Champs de Mars"
-- <country>France</country> "country" : "France"
-- <zip>75</zip> "zip" : 75
Address_Mapping.Bind (Get_Address_Member'Access);
-- Address_Mapping.Add_Mapping ("info", Property_Mapping'Access, Proxy_Info'Access);
Address_Mapping.Add_Default_Mapping;
-- XML:
-- ----
-- <xxx id='23'>
-- <address>
-- <city>...</city>
-- <street number='44'>..</street>
-- <country>..</country>
-- <zip>..</zip>
-- </address>
-- <name><NAME></name>
-- <last_name><NAME></last_name>
-- <age>23</age>
-- <info><facebook><id>...</id></facebook></info>
-- </xxx>
-- Person_Mapper.Add_Mapping ("@id");
Person_Mapping.Bind (Get_Person_Member'Access);
Person_Mapping.Add_Mapping ("address", Address_Mapping'Access, Proxy_Address'Access);
Person_Mapping.Add_Default_Mapping;
-- Person_Mapper.Add_Mapping ("info/*");
-- Person_Mapper.Add_Mapping ("address/street/@number");
end Mapping;
| true | -----------------------------------------------------------------------
-- mapping -- Example of serialization mappings
-- Copyright (C) 2010, 2011, 2012, 2014 PI:NAME:<NAME>END_PI
-- Written by PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Log.Loggers;
package body Mapping is
use Util.Beans.Objects;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Mapping");
type Property_Fields is (FIELD_NAME, FIELD_VALUE);
type Property_Access is access all Property;
type Address_Fields is (FIELD_CITY, FIELD_STREET, FIELD_COUNTRY, FIELD_ZIP);
type Address_Access is access all Address;
procedure Proxy_Address (Attr : in Util.Serialize.Mappers.Mapping'Class;
Element : in out Person;
Value : in Util.Beans.Objects.Object);
function Get_Address_Member (Addr : in Address;
Field : in Address_Fields) return Util.Beans.Objects.Object;
procedure Set_Member (Addr : in out Address;
Field : in Address_Fields;
Value : in Util.Beans.Objects.Object);
procedure Set_Member (P : in out Property;
Field : in Property_Fields;
Value : in Util.Beans.Objects.Object);
procedure Set_Member (P : in out Property;
Field : in Property_Fields;
Value : in Util.Beans.Objects.Object) is
begin
case Field is
when FIELD_NAME =>
P.Name := To_Unbounded_String (Value);
when FIELD_VALUE =>
P.Value := To_Unbounded_String (Value);
end case;
end Set_Member;
package Property_Mapper is
new Util.Serialize.Mappers.Record_Mapper (Element_Type => Property,
Element_Type_Access => Property_Access,
Fields => Property_Fields,
Set_Member => Set_Member);
-- ------------------------------
-- Set the name/value pair on the current object.
-- ------------------------------
procedure Set_Member (P : in out Person;
Field : in Person_Fields;
Value : in Util.Beans.Objects.Object) is
begin
Log.Debug ("Person field {0} - {0}", Person_Fields'Image (Field), To_String (Value));
case Field is
when FIELD_FIRST_NAME =>
P.First_Name := To_Unbounded_String (Value);
when FIELD_LAST_NAME =>
P.Last_Name := To_Unbounded_String (Value);
when FIELD_AGE =>
P.Age := To_Integer (Value);
when FIELD_ID =>
P.Id := To_Long_Long_Integer (Value);
when FIELD_NAME =>
P.Name := To_Unbounded_String (Value);
when FIELD_USER_NAME =>
P.Username := To_Unbounded_String (Value);
when FIELD_GENDER =>
P.Gender := To_Unbounded_String (Value);
when FIELD_LINK =>
P.Link := To_Unbounded_String (Value);
end case;
end Set_Member;
-- ------------------------------
-- Set the name/value pair on the current object.
-- ------------------------------
function Get_Person_Member (From : in Person;
Field : in Person_Fields) return Util.Beans.Objects.Object is
begin
case Field is
when FIELD_FIRST_NAME =>
return Util.Beans.Objects.To_Object (From.First_Name);
when FIELD_LAST_NAME =>
return Util.Beans.Objects.To_Object (From.Last_Name);
when FIELD_AGE =>
return Util.Beans.Objects.To_Object (From.Age);
when FIELD_NAME =>
return Util.Beans.Objects.To_Object (From.Name);
when FIELD_USER_NAME =>
return Util.Beans.Objects.To_Object (From.Username);
when FIELD_LINK =>
return Util.Beans.Objects.To_Object (From.Link);
when FIELD_GENDER =>
return Util.Beans.Objects.To_Object (From.Gender);
when FIELD_ID =>
return Util.Beans.Objects.To_Object (From.Id);
end case;
end Get_Person_Member;
-- ------------------------------
-- Set the name/value pair on the current object.
-- ------------------------------
procedure Set_Member (Addr : in out Address;
Field : in Address_Fields;
Value : in Util.Beans.Objects.Object) is
begin
case Field is
when FIELD_CITY =>
Addr.City := To_Unbounded_String (Value);
when FIELD_STREET =>
Addr.Street := To_Unbounded_String (Value);
when FIELD_COUNTRY =>
Addr.Country := To_Unbounded_String (Value);
when FIELD_ZIP =>
Addr.Zip := To_Integer (Value);
end case;
end Set_Member;
function Get_Address_Member (Addr : in Address;
Field : in Address_Fields) return Util.Beans.Objects.Object is
begin
case Field is
when FIELD_CITY =>
return Util.Beans.Objects.To_Object (Addr.City);
when FIELD_STREET =>
return Util.Beans.Objects.To_Object (Addr.Street);
when FIELD_COUNTRY =>
return Util.Beans.Objects.To_Object (Addr.Country);
when FIELD_ZIP =>
return Util.Beans.Objects.To_Object (Addr.Zip);
end case;
end Get_Address_Member;
package Address_Mapper is
new Util.Serialize.Mappers.Record_Mapper (Element_Type => Address,
Element_Type_Access => Address_Access,
Fields => Address_Fields,
Set_Member => Set_Member);
-- Mapping for the Property record.
Property_Mapping : aliased Property_Mapper.Mapper;
-- Mapping for the Address record.
Address_Mapping : aliased Address_Mapper.Mapper;
-- Mapping for the Person record.
Person_Mapping : aliased Person_Mapper.Mapper;
-- ------------------------------
-- Get the address mapper which describes how to load an Address.
-- ------------------------------
function Get_Address_Mapper return Util.Serialize.Mappers.Mapper_Access is
begin
return Address_Mapping'Access;
end Get_Address_Mapper;
-- ------------------------------
-- Get the person mapper which describes how to load a Person.
-- ------------------------------
function Get_Person_Mapper return Person_Mapper.Mapper_Access is
begin
return Person_Mapping'Access;
end Get_Person_Mapper;
-- ------------------------------
-- Helper to give access to the <b>Address</b> member of a <b>Person</b>.
-- ------------------------------
procedure Proxy_Address (Attr : in Util.Serialize.Mappers.Mapping'Class;
Element : in out Person;
Value : in Util.Beans.Objects.Object) is
begin
Address_Mapper.Set_Member (Attr, Element.Addr, Value);
end Proxy_Address;
begin
Property_Mapping.Add_Default_Mapping;
-- XML: JSON:
-- ---- -----
-- <city>Paris</city> "city" : "Paris"
-- <street>Champs de Mars</street> "street" : "Champs de Mars"
-- <country>France</country> "country" : "France"
-- <zip>75</zip> "zip" : 75
Address_Mapping.Bind (Get_Address_Member'Access);
-- Address_Mapping.Add_Mapping ("info", Property_Mapping'Access, Proxy_Info'Access);
Address_Mapping.Add_Default_Mapping;
-- XML:
-- ----
-- <xxx id='23'>
-- <address>
-- <city>...</city>
-- <street number='44'>..</street>
-- <country>..</country>
-- <zip>..</zip>
-- </address>
-- <name>PI:NAME:<NAME>END_PI</name>
-- <last_name>PI:NAME:<NAME>END_PI</last_name>
-- <age>23</age>
-- <info><facebook><id>...</id></facebook></info>
-- </xxx>
-- Person_Mapper.Add_Mapping ("@id");
Person_Mapping.Bind (Get_Person_Member'Access);
Person_Mapping.Add_Mapping ("address", Address_Mapping'Access, Proxy_Address'Access);
Person_Mapping.Add_Default_Mapping;
-- Person_Mapper.Add_Mapping ("info/*");
-- Person_Mapper.Add_Mapping ("address/street/@number");
end Mapping;
|
[
{
"context": " --\n-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --\n-- All rig",
"end": 829,
"score": 0.9998864531517029,
"start": 816,
"tag": "NAME",
"value": "Vadim Godunko"
},
{
"context": " --\n-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --\n-- All rights reserved. ",
"end": 849,
"score": 0.9999328851699829,
"start": 831,
"tag": "EMAIL",
"value": "vgodunko@gmail.com"
}
] | source/amf/uml/amf-umldi-uml_association_or_connector_or_link_shapes-collections.ads | svn2github/matreshka | 24 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, 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 file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UMLDI.UML_Association_Or_Connector_Or_Link_Shapes.Collections is
pragma Preelaborate;
package UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections is
new AMF.Generic_Collections
(UMLDI_UML_Association_Or_Connector_Or_Link_Shape,
UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Access);
type Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape is
new UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Set with null record;
Empty_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape;
type Ordered_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape is
new UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Ordered_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape;
type Bag_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape is
new UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Bag with null record;
Empty_Bag_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Bag_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape;
type Sequence_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape is
new UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Sequence with null record;
Empty_Sequence_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Sequence_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape;
private
Empty_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape
:= (UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Set with null record);
Empty_Ordered_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Ordered_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape
:= (UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Ordered_Set with null record);
Empty_Bag_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Bag_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape
:= (UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Bag with null record);
Empty_Sequence_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Sequence_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape
:= (UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Sequence with null record);
end AMF.UMLDI.UML_Association_Or_Connector_Or_Link_Shapes.Collections;
| 9020 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UMLDI.UML_Association_Or_Connector_Or_Link_Shapes.Collections is
pragma Preelaborate;
package UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections is
new AMF.Generic_Collections
(UMLDI_UML_Association_Or_Connector_Or_Link_Shape,
UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Access);
type Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape is
new UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Set with null record;
Empty_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape;
type Ordered_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape is
new UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Ordered_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape;
type Bag_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape is
new UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Bag with null record;
Empty_Bag_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Bag_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape;
type Sequence_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape is
new UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Sequence with null record;
Empty_Sequence_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Sequence_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape;
private
Empty_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape
:= (UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Set with null record);
Empty_Ordered_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Ordered_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape
:= (UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Ordered_Set with null record);
Empty_Bag_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Bag_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape
:= (UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Bag with null record);
Empty_Sequence_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Sequence_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape
:= (UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Sequence with null record);
end AMF.UMLDI.UML_Association_Or_Connector_Or_Link_Shapes.Collections;
| true | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UMLDI.UML_Association_Or_Connector_Or_Link_Shapes.Collections is
pragma Preelaborate;
package UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections is
new AMF.Generic_Collections
(UMLDI_UML_Association_Or_Connector_Or_Link_Shape,
UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Access);
type Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape is
new UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Set with null record;
Empty_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape;
type Ordered_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape is
new UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Ordered_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape;
type Bag_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape is
new UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Bag with null record;
Empty_Bag_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Bag_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape;
type Sequence_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape is
new UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Sequence with null record;
Empty_Sequence_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Sequence_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape;
private
Empty_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape
:= (UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Set with null record);
Empty_Ordered_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Ordered_Set_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape
:= (UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Ordered_Set with null record);
Empty_Bag_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Bag_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape
:= (UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Bag with null record);
Empty_Sequence_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape : constant Sequence_Of_UMLDI_UML_Association_Or_Connector_Or_Link_Shape
:= (UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Collections.Sequence with null record);
end AMF.UMLDI.UML_Association_Or_Connector_Or_Link_Shapes.Collections;
|
[
{
"context": "-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifi",
"end": 43,
"score": 0.999861478805542,
"start": 33,
"tag": "NAME",
"value": "Max Reznik"
},
{
"context": "-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifier: MIT\n------------",
"end": 63,
"score": 0.9999303817749023,
"start": 45,
"tag": "EMAIL",
"value": "reznikmm@gmail.com"
}
] | source/nodes/program-nodes-object_renaming_declarations.ads | reznikmm/gela | 0 | -- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Elements.Defining_Identifiers;
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Aspect_Specifications;
with Program.Elements.Object_Renaming_Declarations;
with Program.Element_Visitors;
package Program.Nodes.Object_Renaming_Declarations is
pragma Preelaborate;
type Object_Renaming_Declaration is
new Program.Nodes.Node
and Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration
and Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration_Text
with private;
function Create
(Names : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Vector_Access;
Colon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
Object_Subtype : not null Program.Elements.Element_Access;
Renames_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Renamed_Object : not null Program.Elements.Expressions.Expression_Access;
With_Token : Program.Lexical_Elements.Lexical_Element_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Object_Renaming_Declaration;
type Implicit_Object_Renaming_Declaration is
new Program.Nodes.Node
and Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration
with private;
function Create
(Names : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Vector_Access;
Object_Subtype : not null Program.Elements.Element_Access;
Renamed_Object : not null Program.Elements.Expressions
.Expression_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Not_Null : Boolean := False)
return Implicit_Object_Renaming_Declaration
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Object_Renaming_Declaration is
abstract new Program.Nodes.Node
and Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration
with record
Names : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Vector_Access;
Object_Subtype : not null Program.Elements.Element_Access;
Renamed_Object : not null Program.Elements.Expressions
.Expression_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
end record;
procedure Initialize (Self : in out Base_Object_Renaming_Declaration'Class);
overriding procedure Visit
(Self : not null access Base_Object_Renaming_Declaration;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Names
(Self : Base_Object_Renaming_Declaration)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Vector_Access;
overriding function Object_Subtype
(Self : Base_Object_Renaming_Declaration)
return not null Program.Elements.Element_Access;
overriding function Renamed_Object
(Self : Base_Object_Renaming_Declaration)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Aspects
(Self : Base_Object_Renaming_Declaration)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
overriding function Is_Object_Renaming_Declaration
(Self : Base_Object_Renaming_Declaration)
return Boolean;
overriding function Is_Declaration
(Self : Base_Object_Renaming_Declaration)
return Boolean;
type Object_Renaming_Declaration is
new Base_Object_Renaming_Declaration
and Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration_Text
with record
Colon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
Renames_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
With_Token : Program.Lexical_Elements.Lexical_Element_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Object_Renaming_Declaration_Text
(Self : in out Object_Renaming_Declaration)
return Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration_Text_Access;
overriding function Colon_Token
(Self : Object_Renaming_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Not_Token
(Self : Object_Renaming_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Null_Token
(Self : Object_Renaming_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Renames_Token
(Self : Object_Renaming_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function With_Token
(Self : Object_Renaming_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Semicolon_Token
(Self : Object_Renaming_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Has_Not_Null
(Self : Object_Renaming_Declaration)
return Boolean;
type Implicit_Object_Renaming_Declaration is
new Base_Object_Renaming_Declaration
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
Has_Not_Null : Boolean;
end record;
overriding function To_Object_Renaming_Declaration_Text
(Self : in out Implicit_Object_Renaming_Declaration)
return Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Object_Renaming_Declaration)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Object_Renaming_Declaration)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Object_Renaming_Declaration)
return Boolean;
overriding function Has_Not_Null
(Self : Implicit_Object_Renaming_Declaration)
return Boolean;
end Program.Nodes.Object_Renaming_Declarations;
| 15482 | -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Elements.Defining_Identifiers;
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Aspect_Specifications;
with Program.Elements.Object_Renaming_Declarations;
with Program.Element_Visitors;
package Program.Nodes.Object_Renaming_Declarations is
pragma Preelaborate;
type Object_Renaming_Declaration is
new Program.Nodes.Node
and Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration
and Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration_Text
with private;
function Create
(Names : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Vector_Access;
Colon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
Object_Subtype : not null Program.Elements.Element_Access;
Renames_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Renamed_Object : not null Program.Elements.Expressions.Expression_Access;
With_Token : Program.Lexical_Elements.Lexical_Element_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Object_Renaming_Declaration;
type Implicit_Object_Renaming_Declaration is
new Program.Nodes.Node
and Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration
with private;
function Create
(Names : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Vector_Access;
Object_Subtype : not null Program.Elements.Element_Access;
Renamed_Object : not null Program.Elements.Expressions
.Expression_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Not_Null : Boolean := False)
return Implicit_Object_Renaming_Declaration
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Object_Renaming_Declaration is
abstract new Program.Nodes.Node
and Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration
with record
Names : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Vector_Access;
Object_Subtype : not null Program.Elements.Element_Access;
Renamed_Object : not null Program.Elements.Expressions
.Expression_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
end record;
procedure Initialize (Self : in out Base_Object_Renaming_Declaration'Class);
overriding procedure Visit
(Self : not null access Base_Object_Renaming_Declaration;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Names
(Self : Base_Object_Renaming_Declaration)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Vector_Access;
overriding function Object_Subtype
(Self : Base_Object_Renaming_Declaration)
return not null Program.Elements.Element_Access;
overriding function Renamed_Object
(Self : Base_Object_Renaming_Declaration)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Aspects
(Self : Base_Object_Renaming_Declaration)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
overriding function Is_Object_Renaming_Declaration
(Self : Base_Object_Renaming_Declaration)
return Boolean;
overriding function Is_Declaration
(Self : Base_Object_Renaming_Declaration)
return Boolean;
type Object_Renaming_Declaration is
new Base_Object_Renaming_Declaration
and Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration_Text
with record
Colon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
Renames_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
With_Token : Program.Lexical_Elements.Lexical_Element_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Object_Renaming_Declaration_Text
(Self : in out Object_Renaming_Declaration)
return Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration_Text_Access;
overriding function Colon_Token
(Self : Object_Renaming_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Not_Token
(Self : Object_Renaming_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Null_Token
(Self : Object_Renaming_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Renames_Token
(Self : Object_Renaming_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function With_Token
(Self : Object_Renaming_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Semicolon_Token
(Self : Object_Renaming_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Has_Not_Null
(Self : Object_Renaming_Declaration)
return Boolean;
type Implicit_Object_Renaming_Declaration is
new Base_Object_Renaming_Declaration
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
Has_Not_Null : Boolean;
end record;
overriding function To_Object_Renaming_Declaration_Text
(Self : in out Implicit_Object_Renaming_Declaration)
return Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Object_Renaming_Declaration)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Object_Renaming_Declaration)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Object_Renaming_Declaration)
return Boolean;
overriding function Has_Not_Null
(Self : Implicit_Object_Renaming_Declaration)
return Boolean;
end Program.Nodes.Object_Renaming_Declarations;
| true | -- SPDX-FileCopyrightText: 2019 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Elements.Defining_Identifiers;
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Aspect_Specifications;
with Program.Elements.Object_Renaming_Declarations;
with Program.Element_Visitors;
package Program.Nodes.Object_Renaming_Declarations is
pragma Preelaborate;
type Object_Renaming_Declaration is
new Program.Nodes.Node
and Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration
and Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration_Text
with private;
function Create
(Names : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Vector_Access;
Colon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
Object_Subtype : not null Program.Elements.Element_Access;
Renames_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Renamed_Object : not null Program.Elements.Expressions.Expression_Access;
With_Token : Program.Lexical_Elements.Lexical_Element_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Object_Renaming_Declaration;
type Implicit_Object_Renaming_Declaration is
new Program.Nodes.Node
and Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration
with private;
function Create
(Names : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Vector_Access;
Object_Subtype : not null Program.Elements.Element_Access;
Renamed_Object : not null Program.Elements.Expressions
.Expression_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Not_Null : Boolean := False)
return Implicit_Object_Renaming_Declaration
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Object_Renaming_Declaration is
abstract new Program.Nodes.Node
and Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration
with record
Names : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Vector_Access;
Object_Subtype : not null Program.Elements.Element_Access;
Renamed_Object : not null Program.Elements.Expressions
.Expression_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
end record;
procedure Initialize (Self : in out Base_Object_Renaming_Declaration'Class);
overriding procedure Visit
(Self : not null access Base_Object_Renaming_Declaration;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Names
(Self : Base_Object_Renaming_Declaration)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Vector_Access;
overriding function Object_Subtype
(Self : Base_Object_Renaming_Declaration)
return not null Program.Elements.Element_Access;
overriding function Renamed_Object
(Self : Base_Object_Renaming_Declaration)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Aspects
(Self : Base_Object_Renaming_Declaration)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
overriding function Is_Object_Renaming_Declaration
(Self : Base_Object_Renaming_Declaration)
return Boolean;
overriding function Is_Declaration
(Self : Base_Object_Renaming_Declaration)
return Boolean;
type Object_Renaming_Declaration is
new Base_Object_Renaming_Declaration
and Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration_Text
with record
Colon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
Renames_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
With_Token : Program.Lexical_Elements.Lexical_Element_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Object_Renaming_Declaration_Text
(Self : in out Object_Renaming_Declaration)
return Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration_Text_Access;
overriding function Colon_Token
(Self : Object_Renaming_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Not_Token
(Self : Object_Renaming_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Null_Token
(Self : Object_Renaming_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Renames_Token
(Self : Object_Renaming_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function With_Token
(Self : Object_Renaming_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Semicolon_Token
(Self : Object_Renaming_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Has_Not_Null
(Self : Object_Renaming_Declaration)
return Boolean;
type Implicit_Object_Renaming_Declaration is
new Base_Object_Renaming_Declaration
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
Has_Not_Null : Boolean;
end record;
overriding function To_Object_Renaming_Declaration_Text
(Self : in out Implicit_Object_Renaming_Declaration)
return Program.Elements.Object_Renaming_Declarations
.Object_Renaming_Declaration_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Object_Renaming_Declaration)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Object_Renaming_Declaration)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Object_Renaming_Declaration)
return Boolean;
overriding function Has_Not_Null
(Self : Implicit_Object_Renaming_Declaration)
return Boolean;
end Program.Nodes.Object_Renaming_Declarations;
|
[
{
"context": "pes cache\n-- Copyright (C) 2011, 2012, 2017, 2018 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@g",
"end": 175,
"score": 0.9998680353164673,
"start": 160,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "1, 2012, 2017, 2018 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under",
"end": 206,
"score": 0.9998809695243835,
"start": 191,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "8 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under the Apache License, Versio",
"end": 233,
"score": 0.9999281167984009,
"start": 208,
"tag": "EMAIL",
"value": "Stephane.Carrez@gmail.com"
}
] | src/ado-schemas-entities.adb | My-Colaborations/ada-ado | 0 | -----------------------------------------------------------------------
-- ado-schemas-entities -- Entity types cache
-- Copyright (C) 2011, 2012, 2017, 2018 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 Util.Log.Loggers;
with Util.Strings;
with ADO.SQL;
with ADO.Statements;
with ADO.Model;
package body ADO.Schemas.Entities is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("ADO.Schemas.Entities");
-- ------------------------------
-- Expand the name into a target parameter value to be used in the SQL query.
-- The Expander can return a T_NULL when a value is not found or
-- it may also raise some exception.
-- ------------------------------
overriding
function Expand (Instance : in out Entity_Cache;
Name : in String) return ADO.Parameters.Parameter is
Pos : constant Entity_Map.Cursor := Instance.Entities.Find (Name);
begin
if not Entity_Map.Has_Element (Pos) then
Log.Error ("No entity type associated with table {0}", Name);
raise No_Entity_Type with "No entity type associated with table " & Name;
end if;
return ADO.Parameters.Parameter '(T => ADO.Parameters.T_INTEGER,
Len => 0, Value_Len => 0, Position => 0,
Name => "",
Num => Entity_Type'Pos (Entity_Map.Element (Pos)));
end Expand;
-- ------------------------------
-- Find the entity type index associated with the given database table.
-- Raises the No_Entity_Type exception if no such mapping exist.
-- ------------------------------
function Find_Entity_Type (Cache : in Entity_Cache;
Table : in Class_Mapping_Access) return ADO.Entity_Type is
begin
return Find_Entity_Type (Cache, Table.Table);
end Find_Entity_Type;
-- ------------------------------
-- Find the entity type index associated with the given database table.
-- Raises the No_Entity_Type exception if no such mapping exist.
-- ------------------------------
function Find_Entity_Type (Cache : in Entity_Cache;
Name : in Util.Strings.Name_Access) return ADO.Entity_Type is
Pos : constant Entity_Map.Cursor := Cache.Entities.Find (Name.all);
begin
if not Entity_Map.Has_Element (Pos) then
Log.Error ("No entity type associated with table {0}", Name.all);
raise No_Entity_Type with "No entity type associated with table " & Name.all;
end if;
return Entity_Type (Entity_Map.Element (Pos));
end Find_Entity_Type;
-- ------------------------------
-- Initialize the entity cache by reading the database entity table.
-- ------------------------------
procedure Initialize (Cache : in out Entity_Cache;
Session : in out ADO.Sessions.Session'Class) is
Query : ADO.SQL.Query;
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (ADO.Model.ENTITY_TYPE_TABLE'Access);
Count : Natural := 0;
begin
Stmt.Set_Parameters (Query);
Stmt.Execute;
while Stmt.Has_Elements loop
declare
Id : constant ADO.Entity_Type := ADO.Entity_Type (Stmt.Get_Integer (0));
Name : constant String := Stmt.Get_String (1);
begin
Cache.Entities.Insert (Key => Name, New_Item => Id);
end;
Count := Count + 1;
Stmt.Next;
end loop;
Log.Info ("Loaded {0} table entities", Util.Strings.Image (Count));
exception
when others =>
null;
end Initialize;
end ADO.Schemas.Entities;
| 7545 | -----------------------------------------------------------------------
-- ado-schemas-entities -- Entity types cache
-- Copyright (C) 2011, 2012, 2017, 2018 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Log.Loggers;
with Util.Strings;
with ADO.SQL;
with ADO.Statements;
with ADO.Model;
package body ADO.Schemas.Entities is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("ADO.Schemas.Entities");
-- ------------------------------
-- Expand the name into a target parameter value to be used in the SQL query.
-- The Expander can return a T_NULL when a value is not found or
-- it may also raise some exception.
-- ------------------------------
overriding
function Expand (Instance : in out Entity_Cache;
Name : in String) return ADO.Parameters.Parameter is
Pos : constant Entity_Map.Cursor := Instance.Entities.Find (Name);
begin
if not Entity_Map.Has_Element (Pos) then
Log.Error ("No entity type associated with table {0}", Name);
raise No_Entity_Type with "No entity type associated with table " & Name;
end if;
return ADO.Parameters.Parameter '(T => ADO.Parameters.T_INTEGER,
Len => 0, Value_Len => 0, Position => 0,
Name => "",
Num => Entity_Type'Pos (Entity_Map.Element (Pos)));
end Expand;
-- ------------------------------
-- Find the entity type index associated with the given database table.
-- Raises the No_Entity_Type exception if no such mapping exist.
-- ------------------------------
function Find_Entity_Type (Cache : in Entity_Cache;
Table : in Class_Mapping_Access) return ADO.Entity_Type is
begin
return Find_Entity_Type (Cache, Table.Table);
end Find_Entity_Type;
-- ------------------------------
-- Find the entity type index associated with the given database table.
-- Raises the No_Entity_Type exception if no such mapping exist.
-- ------------------------------
function Find_Entity_Type (Cache : in Entity_Cache;
Name : in Util.Strings.Name_Access) return ADO.Entity_Type is
Pos : constant Entity_Map.Cursor := Cache.Entities.Find (Name.all);
begin
if not Entity_Map.Has_Element (Pos) then
Log.Error ("No entity type associated with table {0}", Name.all);
raise No_Entity_Type with "No entity type associated with table " & Name.all;
end if;
return Entity_Type (Entity_Map.Element (Pos));
end Find_Entity_Type;
-- ------------------------------
-- Initialize the entity cache by reading the database entity table.
-- ------------------------------
procedure Initialize (Cache : in out Entity_Cache;
Session : in out ADO.Sessions.Session'Class) is
Query : ADO.SQL.Query;
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (ADO.Model.ENTITY_TYPE_TABLE'Access);
Count : Natural := 0;
begin
Stmt.Set_Parameters (Query);
Stmt.Execute;
while Stmt.Has_Elements loop
declare
Id : constant ADO.Entity_Type := ADO.Entity_Type (Stmt.Get_Integer (0));
Name : constant String := Stmt.Get_String (1);
begin
Cache.Entities.Insert (Key => Name, New_Item => Id);
end;
Count := Count + 1;
Stmt.Next;
end loop;
Log.Info ("Loaded {0} table entities", Util.Strings.Image (Count));
exception
when others =>
null;
end Initialize;
end ADO.Schemas.Entities;
| true | -----------------------------------------------------------------------
-- ado-schemas-entities -- Entity types cache
-- Copyright (C) 2011, 2012, 2017, 2018 PI:NAME:<NAME>END_PI
-- Written by PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Log.Loggers;
with Util.Strings;
with ADO.SQL;
with ADO.Statements;
with ADO.Model;
package body ADO.Schemas.Entities is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("ADO.Schemas.Entities");
-- ------------------------------
-- Expand the name into a target parameter value to be used in the SQL query.
-- The Expander can return a T_NULL when a value is not found or
-- it may also raise some exception.
-- ------------------------------
overriding
function Expand (Instance : in out Entity_Cache;
Name : in String) return ADO.Parameters.Parameter is
Pos : constant Entity_Map.Cursor := Instance.Entities.Find (Name);
begin
if not Entity_Map.Has_Element (Pos) then
Log.Error ("No entity type associated with table {0}", Name);
raise No_Entity_Type with "No entity type associated with table " & Name;
end if;
return ADO.Parameters.Parameter '(T => ADO.Parameters.T_INTEGER,
Len => 0, Value_Len => 0, Position => 0,
Name => "",
Num => Entity_Type'Pos (Entity_Map.Element (Pos)));
end Expand;
-- ------------------------------
-- Find the entity type index associated with the given database table.
-- Raises the No_Entity_Type exception if no such mapping exist.
-- ------------------------------
function Find_Entity_Type (Cache : in Entity_Cache;
Table : in Class_Mapping_Access) return ADO.Entity_Type is
begin
return Find_Entity_Type (Cache, Table.Table);
end Find_Entity_Type;
-- ------------------------------
-- Find the entity type index associated with the given database table.
-- Raises the No_Entity_Type exception if no such mapping exist.
-- ------------------------------
function Find_Entity_Type (Cache : in Entity_Cache;
Name : in Util.Strings.Name_Access) return ADO.Entity_Type is
Pos : constant Entity_Map.Cursor := Cache.Entities.Find (Name.all);
begin
if not Entity_Map.Has_Element (Pos) then
Log.Error ("No entity type associated with table {0}", Name.all);
raise No_Entity_Type with "No entity type associated with table " & Name.all;
end if;
return Entity_Type (Entity_Map.Element (Pos));
end Find_Entity_Type;
-- ------------------------------
-- Initialize the entity cache by reading the database entity table.
-- ------------------------------
procedure Initialize (Cache : in out Entity_Cache;
Session : in out ADO.Sessions.Session'Class) is
Query : ADO.SQL.Query;
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (ADO.Model.ENTITY_TYPE_TABLE'Access);
Count : Natural := 0;
begin
Stmt.Set_Parameters (Query);
Stmt.Execute;
while Stmt.Has_Elements loop
declare
Id : constant ADO.Entity_Type := ADO.Entity_Type (Stmt.Get_Integer (0));
Name : constant String := Stmt.Get_String (1);
begin
Cache.Entities.Insert (Key => Name, New_Item => Id);
end;
Count := Count + 1;
Stmt.Next;
end loop;
Log.Info ("Loaded {0} table entities", Util.Strings.Image (Count));
exception
when others =>
null;
end Initialize;
end ADO.Schemas.Entities;
|
[
{
"context": "-- Copyright 2017-2021 Bartek thindil Jasicki\n--\n-- This file is part of Steam Sky.\n--\n-- ",
"end": 48,
"score": 0.9998650550842285,
"start": 26,
"tag": "NAME",
"value": "Bartek thindil Jasicki"
}
] | src/mobs.adb | thindil/steamsky | 80 | -- Copyright 2017-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.Characters.Handling; use Ada.Characters.Handling;
with DOM.Core; use DOM.Core;
with DOM.Core.Documents;
with DOM.Core.Nodes; use DOM.Core.Nodes;
with DOM.Core.Elements; use DOM.Core.Elements;
with Items; use Items;
with Log; use Log;
with Utils; use Utils;
package body Mobs is
procedure LoadMobs(Reader: Tree_Reader) is
MobsData: Document;
NodesList, ChildNodes: Node_List;
TempRecord: ProtoMobRecord
(Amount_Of_Attributes => Attributes_Amount,
Amount_Of_Skills => Skills_Amount);
TempSkills: Skills_Container.Vector;
TempInventory: MobInventory_Container.Vector;
TempPriorities: constant Natural_Array(1 .. 12) := (others => 0);
TempEquipment: constant Equipment_Array := (others => 0);
OrdersNames: constant array(1 .. 11) of Unbounded_String :=
(To_Unbounded_String("Piloting"), To_Unbounded_String("Engineering"),
To_Unbounded_String("Operating guns"),
To_Unbounded_String("Repair ship"),
To_Unbounded_String("Manufacturing"),
To_Unbounded_String("Upgrading ship"),
To_Unbounded_String("Talking in bases"),
To_Unbounded_String("Healing wounded"),
To_Unbounded_String("Cleaning ship"),
To_Unbounded_String("Defend ship"),
To_Unbounded_String("Board enemy ship"));
EquipmentNames: constant array(1 .. 7) of Unbounded_String :=
(To_Unbounded_String("Weapon"), To_Unbounded_String("Shield"),
To_Unbounded_String("Head"), To_Unbounded_String("Torso"),
To_Unbounded_String("Arms"), To_Unbounded_String("Legs"),
To_Unbounded_String("Tool"));
Action, SubAction: Data_Action;
MobNode, ChildNode: Node;
ChildIndex: Natural;
DeleteIndex: Positive;
MobIndex, ItemIndex: Unbounded_String;
begin
MobsData := Get_Tree(Reader);
NodesList :=
DOM.Core.Documents.Get_Elements_By_Tag_Name(MobsData, "mobile");
Load_Mobs_Loop :
for I in 0 .. Length(NodesList) - 1 loop
TempRecord :=
(Amount_Of_Attributes => Attributes_Amount,
Amount_Of_Skills => Skills_Amount, Skills => TempSkills,
Attributes => (others => <>), Order => Rest,
Priorities => TempPriorities, Inventory => TempInventory,
Equipment => TempEquipment);
MobNode := Item(NodesList, I);
MobIndex := To_Unbounded_String(Get_Attribute(MobNode, "index"));
Action :=
(if Get_Attribute(MobNode, "action")'Length > 0 then
Data_Action'Value(Get_Attribute(MobNode, "action"))
else ADD);
if Action in UPDATE | REMOVE then
if not ProtoMobs_Container.Contains(ProtoMobs_List, MobIndex) then
raise Data_Loading_Error
with "Can't " & To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
"', there is no mob with that index.";
end if;
elsif ProtoMobs_Container.Contains(ProtoMobs_List, MobIndex) then
raise Data_Loading_Error
with "Can't add mob '" & To_String(MobIndex) &
"', there is already a mob with that index.";
end if;
if Action /= REMOVE then
if Action = UPDATE then
TempRecord := ProtoMobs_List(MobIndex);
end if;
ChildNodes :=
DOM.Core.Elements.Get_Elements_By_Tag_Name(MobNode, "skill");
Load_Skills_Loop :
for J in 0 .. Length(ChildNodes) - 1 loop
ChildNode := Item(ChildNodes, J);
ChildIndex :=
Find_Skill_Index(Get_Attribute(ChildNode, "name"));
if Get_Attribute(ChildNode, "name") = "WeaponSkill" then
ChildIndex :=
Natural(SkillsData_Container.Length(Skills_List)) + 1;
end if;
if ChildIndex = 0 then
raise Data_Loading_Error
with "Can't " & To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
"', there no skill named '" &
Get_Attribute(ChildNode, "name") & "'.";
end if;
SubAction :=
(if Get_Attribute(ChildNode, "action")'Length > 0 then
Data_Action'Value(Get_Attribute(ChildNode, "action"))
else ADD);
case SubAction is
when ADD =>
if Get_Attribute(ChildNode, "level")'Length /= 0 then
TempRecord.Skills.Append
(New_Item =>
(ChildIndex,
Integer'Value(Get_Attribute(ChildNode, "level")),
0));
else
if Integer'Value
(Get_Attribute(ChildNode, "minlevel")) >
Integer'Value
(Get_Attribute(ChildNode, "maxlevel")) then
raise Data_Loading_Error
with "Can't " &
To_Lower(Data_Action'Image(Action)) & " mob '" &
To_String(MobIndex) &
" invalid range for skill '" &
Get_Attribute(ChildNode, "name") & "'";
end if;
TempRecord.Skills.Append
(New_Item =>
(ChildIndex,
Integer'Value
(Get_Attribute(ChildNode, "minlevel")),
Integer'Value
(Get_Attribute(ChildNode, "maxlevel"))));
end if;
when UPDATE =>
for Skill of TempRecord.Skills loop
if Skill.Index = ChildIndex then
if Get_Attribute(ChildNode, "level")'Length /=
0 then
Skill :=
(ChildIndex,
Integer'Value
(Get_Attribute(ChildNode, "level")),
0);
else
if Integer'Value
(Get_Attribute(ChildNode, "minlevel")) >
Integer'Value
(Get_Attribute(ChildNode, "maxlevel")) then
raise Data_Loading_Error
with "Can't " &
To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
" invalid range for skill '" &
Get_Attribute(ChildNode, "name") & "'";
end if;
Skill :=
(ChildIndex,
Integer'Value
(Get_Attribute(ChildNode, "minlevel")),
Integer'Value
(Get_Attribute(ChildNode, "maxlevel")));
end if;
exit;
end if;
end loop;
when REMOVE =>
Remove_Skill_Loop :
for K in TempRecord.Skills.Iterate loop
if TempRecord.Skills(K).Index = ChildIndex then
DeleteIndex := Skills_Container.To_Index(K);
exit Remove_Skill_Loop;
end if;
end loop Remove_Skill_Loop;
TempRecord.Skills.Delete(Index => DeleteIndex);
end case;
end loop Load_Skills_Loop;
ChildNodes :=
DOM.Core.Elements.Get_Elements_By_Tag_Name(MobNode, "attribute");
if Length(ChildNodes) > 0 and Action = UPDATE then
TempRecord.Attributes := (others => <>);
end if;
Load_Attributes_Loop :
for J in 0 .. Length(ChildNodes) - 1 loop
ChildNode := Item(ChildNodes, J);
if Get_Attribute(ChildNode, "level") /= "" then
TempRecord.Attributes(J + 1) :=
(Integer'Value(Get_Attribute(ChildNode, "level")), 0);
else
if Integer'Value(Get_Attribute(ChildNode, "minlevel")) >
Integer'Value(Get_Attribute(ChildNode, "maxlevel")) then
raise Data_Loading_Error
with "Can't " & To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
" invalid range for attribute.";
end if;
TempRecord.Attributes(J + 1) :=
(Integer'Value(Get_Attribute(ChildNode, "minlevel")),
Integer'Value(Get_Attribute(ChildNode, "maxlevel")));
end if;
exit Load_Attributes_Loop when J + 1 =
Positive
(AttributesData_Container.Length
(Container => Attributes_List));
end loop Load_Attributes_Loop;
ChildNodes :=
DOM.Core.Elements.Get_Elements_By_Tag_Name(MobNode, "priority");
Load_Orders_Loop :
for J in 0 .. Length(ChildNodes) - 1 loop
ChildNode := Item(ChildNodes, J);
Set_Priorities_Loop :
for K in OrdersNames'Range loop
if OrdersNames(K) =
To_Unbounded_String(Get_Attribute(ChildNode, "name")) then
TempRecord.Priorities(K) :=
(if Get_Attribute(ChildNode, "value") = "Normal" then 1
else 2);
exit Set_Priorities_Loop;
end if;
end loop Set_Priorities_Loop;
end loop Load_Orders_Loop;
if Get_Attribute(MobNode, "order")'Length > 0 then
TempRecord.Order :=
Crew_Orders'Value(Get_Attribute(MobNode, "order"));
end if;
ChildNodes :=
DOM.Core.Elements.Get_Elements_By_Tag_Name(MobNode, "item");
Load_Items_Loop :
for J in 0 .. Length(ChildNodes) - 1 loop
ChildNode := Item(ChildNodes, J);
ItemIndex :=
To_Unbounded_String(Get_Attribute(ChildNode, "index"));
if not Objects_Container.Contains(Items_List, ItemIndex) then
raise Data_Loading_Error
with "Can't " & To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
"', there is no item with index '" &
Get_Attribute(ChildNode, "index") & "'.";
end if;
SubAction :=
(if Get_Attribute(ChildNode, "action")'Length > 0 then
Data_Action'Value(Get_Attribute(ChildNode, "action"))
else ADD);
case SubAction is
when ADD =>
if Get_Attribute(ChildNode, "amount")'Length /= 0 then
TempRecord.Inventory.Append
(New_Item =>
(ItemIndex,
Integer'Value
(Get_Attribute(ChildNode, "amount")),
0));
else
if Integer'Value
(Get_Attribute(ChildNode, "minamount")) >
Integer'Value
(Get_Attribute(ChildNode, "maxamount")) then
raise Data_Loading_Error
with "Can't " &
To_Lower(Data_Action'Image(Action)) & " mob '" &
To_String(MobIndex) &
" invalid range for amount of '" &
Get_Attribute(ChildNode, "index") & "'.";
end if;
TempRecord.Inventory.Append
(New_Item =>
(ItemIndex,
Integer'Value
(Get_Attribute(ChildNode, "minamount")),
Integer'Value
(Get_Attribute(ChildNode, "maxamount"))));
end if;
when UPDATE =>
Update_Items_Loop :
for Item of TempRecord.Inventory loop
if Item.ProtoIndex = ItemIndex then
if Get_Attribute(ChildNode, "amount")'Length /=
0 then
Item :=
(ItemIndex,
Integer'Value
(Get_Attribute(ChildNode, "amount")),
0);
else
if Integer'Value
(Get_Attribute(ChildNode, "minamount")) >
Integer'Value
(Get_Attribute(ChildNode, "maxamount")) then
raise Data_Loading_Error
with "Can't " &
To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
" invalid range for amount of '" &
Get_Attribute(ChildNode, "index") & "'.";
end if;
Item :=
(ItemIndex,
Integer'Value
(Get_Attribute(ChildNode, "minamount")),
Integer'Value
(Get_Attribute(ChildNode, "maxamount")));
end if;
exit Update_Items_Loop;
end if;
end loop Update_Items_Loop;
when REMOVE =>
declare
DeleteIndex: Natural := 0;
begin
Remove_Items_Loop :
for K in
TempRecord.Inventory.First_Index ..
TempRecord.Inventory.Last_Index loop
if TempRecord.Inventory(K).ProtoIndex =
ItemIndex then
DeleteIndex := K;
exit Remove_Items_Loop;
end if;
end loop Remove_Items_Loop;
if DeleteIndex > 0 then
TempRecord.Inventory.Delete(DeleteIndex);
end if;
end;
end case;
end loop Load_Items_Loop;
ChildNodes :=
DOM.Core.Elements.Get_Elements_By_Tag_Name(MobNode, "equipment");
Equipment_Loop :
for J in 0 .. Length(ChildNodes) - 1 loop
ChildNode := Item(ChildNodes, J);
Update_Equipment_Loop :
for K in EquipmentNames'Range loop
if EquipmentNames(K) =
To_Unbounded_String(Get_Attribute(ChildNode, "slot")) then
TempRecord.Equipment(K) :=
Positive'Value(Get_Attribute(ChildNode, "index"));
exit Update_Equipment_Loop;
end if;
end loop Update_Equipment_Loop;
end loop Equipment_Loop;
if Action /= UPDATE then
ProtoMobs_Container.Include
(ProtoMobs_List, MobIndex, TempRecord);
Log_Message("Mob added: " & To_String(MobIndex), EVERYTHING);
else
ProtoMobs_List(MobIndex) := TempRecord;
Log_Message("Mob updated: " & To_String(MobIndex), EVERYTHING);
end if;
else
ProtoMobs_Container.Exclude(ProtoMobs_List, MobIndex);
Log_Message("Mob removed: " & To_String(MobIndex), EVERYTHING);
end if;
end loop Load_Mobs_Loop;
end LoadMobs;
function GenerateMob
(MobIndex, FactionIndex: Unbounded_String) return Member_Data is
Mob: Member_Data
(Amount_Of_Attributes => Attributes_Amount,
Amount_Of_Skills => Skills_Amount);
ProtoMob: constant ProtoMobRecord := ProtoMobs_List(MobIndex);
Amount: Natural;
HighestSkillLevel, WeaponSkillLevel: Skill_Range := 1;
SkillIndex: Skills_Container.Extended_Index;
begin
Mob.Faction :=
(if Get_Random(1, 100) < 99 then FactionIndex else GetRandomFaction);
Mob.Gender := 'M';
if not Factions_List(Mob.Faction).Flags.Contains
(To_Unbounded_String("nogender"))
and then Get_Random(1, 100) > 50 then
Mob.Gender := 'F';
end if;
Mob.Name := GenerateMemberName(Mob.Gender, Mob.Faction);
Skills_Loop :
for Skill of ProtoMob.Skills loop
SkillIndex :=
(if Skill.Index = Skills_Amount + 1 then
Factions_List(Mob.Faction).WeaponSkill
else Skill.Index);
if Skill.Experience = 0 then
Mob.Skills.Append(New_Item => (SkillIndex, Skill.Level, 0));
else
Mob.Skills.Append
(New_Item =>
(SkillIndex, Get_Random(Skill.Level, Skill.Experience), 0));
end if;
if SkillIndex = Factions_List(Mob.Faction).WeaponSkill then
WeaponSkillLevel := Mob.Skills(Mob.Skills.Last_Index).Level;
end if;
if Mob.Skills(Mob.Skills.Last_Index).Level > HighestSkillLevel then
HighestSkillLevel := Mob.Skills(Mob.Skills.Last_Index).Level;
end if;
end loop Skills_Loop;
Attributes_Loop :
for Attribute in ProtoMob.Attributes'Range loop
if ProtoMob.Attributes(Attribute).Experience = 0 then
Mob.Attributes(Attribute) := ProtoMob.Attributes(Attribute);
else
Mob.Attributes(Attribute) :=
(Get_Random
(ProtoMob.Attributes(Attribute).Level,
ProtoMob.Attributes(Attribute).Experience),
0);
end if;
end loop Attributes_Loop;
Inventory_Loop :
for I in ProtoMob.Inventory.Iterate loop
Amount :=
(if ProtoMob.Inventory(I).MaxAmount > 0 then
Get_Random
(ProtoMob.Inventory(I).MinAmount,
ProtoMob.Inventory(I).MaxAmount)
else ProtoMob.Inventory(I).MinAmount);
Mob.Inventory.Append
(New_Item =>
(ProtoIndex => ProtoMob.Inventory(I).ProtoIndex,
Amount => Amount, Name => Null_Unbounded_String,
Durability => 100, Price => 0));
end loop Inventory_Loop;
Mob.Equipment := ProtoMob.Equipment;
declare
ItemsList: UnboundedString_Container.Vector;
ItemIndex: Unbounded_String;
begin
Equipment_Loop :
for I in 1 .. 6 loop
ItemsList :=
(case I is when 1 => Weapons_List, when 2 => Shields_List,
when 3 => HeadArmors_List, when 4 => ChestArmors_List,
when 5 => ArmsArmors_List, when 6 => LegsArmors_List);
if Mob.Equipment(I) = 0 then
ItemIndex := Null_Unbounded_String;
if Get_Random(1, 100) < 95 then
ItemIndex :=
GetRandomItem
(ItemsList, I, HighestSkillLevel, WeaponSkillLevel,
Mob.Faction);
end if;
if ItemIndex /= Null_Unbounded_String then
Mob.Inventory.Append
(New_Item =>
(ProtoIndex => ItemIndex, Amount => 1,
Name => Null_Unbounded_String, Durability => 100,
Price => 0));
Mob.Equipment(I) := Mob.Inventory.Last_Index;
end if;
end if;
end loop Equipment_Loop;
end;
Mob.Orders := ProtoMob.Priorities;
Mob.Order := ProtoMob.Order;
Mob.OrderTime := 15;
Mob.PreviousOrder := Rest;
Mob.Health := 100;
Mob.Tired := 0;
Mob.Hunger := 0;
Mob.Thirst := 0;
Mob.Payment := (20, 0);
Mob.ContractLength := -1;
Mob.Morale := (50, 0);
Mob.Loyalty := 100;
Mob.HomeBase := 1;
return Mob;
end GenerateMob;
function GetRandomItem
(ItemsIndexes: UnboundedString_Container.Vector;
EquipIndex, HighestLevel, WeaponSkillLevel: Positive;
FactionIndex: Unbounded_String) return Unbounded_String is
ItemIndex, MaxIndex: Positive;
NewIndexes: UnboundedString_Container.Vector;
Added: Boolean;
begin
if EquipIndex > 1 then
Equipment_Item_Loop :
for I in ItemsIndexes.First_Index .. ItemsIndexes.Last_Index loop
Added := False;
Add_Equipment_Item_Loop :
for J in NewIndexes.First_Index .. NewIndexes.Last_Index loop
if Items_List(ItemsIndexes(I)).Price <
Items_List(NewIndexes(J)).Price then
NewIndexes.Insert(J, ItemsIndexes(I));
Added := True;
exit Add_Equipment_Item_Loop;
end if;
end loop Add_Equipment_Item_Loop;
if not Added then
NewIndexes.Append(ItemsIndexes(I));
end if;
end loop Equipment_Item_Loop;
MaxIndex :=
Positive
((Float(NewIndexes.Last_Index) * (Float(HighestLevel) / 100.0)) +
1.0);
if MaxIndex > NewIndexes.Last_Index then
MaxIndex := NewIndexes.Last_Index;
end if;
ItemIndex := Get_Random(NewIndexes.First_Index, MaxIndex);
else
Proto_Items_Loop :
for I in ItemsIndexes.First_Index .. ItemsIndexes.Last_Index loop
Added := False;
Add_Proto_Item_Loop :
for J in NewIndexes.First_Index .. NewIndexes.Last_Index loop
if Items_List(ItemsIndexes(I)).Price <
Items_List(NewIndexes(J)).Price and
Items_List(ItemsIndexes(I)).Value(3) =
Factions_List(FactionIndex).WeaponSkill then
NewIndexes.Insert(J, ItemsIndexes(I));
Added := True;
exit Add_Proto_Item_Loop;
end if;
end loop Add_Proto_Item_Loop;
if not Added and
Items_List(ItemsIndexes(I)).Value(3) =
Factions_List(FactionIndex).WeaponSkill then
NewIndexes.Append(ItemsIndexes(I));
end if;
end loop Proto_Items_Loop;
if NewIndexes.Length = 0 then
return Null_Unbounded_String;
end if;
MaxIndex :=
Positive
((Float(NewIndexes.Last_Index) *
(Float(WeaponSkillLevel) / 100.0)) +
1.0);
if MaxIndex > NewIndexes.Last_Index then
MaxIndex := NewIndexes.Last_Index;
end if;
Get_Weapon_Loop :
loop
ItemIndex := Get_Random(NewIndexes.First_Index, MaxIndex);
exit Get_Weapon_Loop when Items_List(NewIndexes(ItemIndex)).Value
(3) =
Factions_List(FactionIndex).WeaponSkill;
end loop Get_Weapon_Loop;
end if;
Get_Item_Index_Loop :
for Index of ItemsIndexes loop
if Index = NewIndexes(ItemIndex) then
return Index;
end if;
end loop Get_Item_Index_Loop;
return Null_Unbounded_String;
end GetRandomItem;
end Mobs;
| 11199 | -- Copyright 2017-2021 <NAME>
--
-- 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.Characters.Handling; use Ada.Characters.Handling;
with DOM.Core; use DOM.Core;
with DOM.Core.Documents;
with DOM.Core.Nodes; use DOM.Core.Nodes;
with DOM.Core.Elements; use DOM.Core.Elements;
with Items; use Items;
with Log; use Log;
with Utils; use Utils;
package body Mobs is
procedure LoadMobs(Reader: Tree_Reader) is
MobsData: Document;
NodesList, ChildNodes: Node_List;
TempRecord: ProtoMobRecord
(Amount_Of_Attributes => Attributes_Amount,
Amount_Of_Skills => Skills_Amount);
TempSkills: Skills_Container.Vector;
TempInventory: MobInventory_Container.Vector;
TempPriorities: constant Natural_Array(1 .. 12) := (others => 0);
TempEquipment: constant Equipment_Array := (others => 0);
OrdersNames: constant array(1 .. 11) of Unbounded_String :=
(To_Unbounded_String("Piloting"), To_Unbounded_String("Engineering"),
To_Unbounded_String("Operating guns"),
To_Unbounded_String("Repair ship"),
To_Unbounded_String("Manufacturing"),
To_Unbounded_String("Upgrading ship"),
To_Unbounded_String("Talking in bases"),
To_Unbounded_String("Healing wounded"),
To_Unbounded_String("Cleaning ship"),
To_Unbounded_String("Defend ship"),
To_Unbounded_String("Board enemy ship"));
EquipmentNames: constant array(1 .. 7) of Unbounded_String :=
(To_Unbounded_String("Weapon"), To_Unbounded_String("Shield"),
To_Unbounded_String("Head"), To_Unbounded_String("Torso"),
To_Unbounded_String("Arms"), To_Unbounded_String("Legs"),
To_Unbounded_String("Tool"));
Action, SubAction: Data_Action;
MobNode, ChildNode: Node;
ChildIndex: Natural;
DeleteIndex: Positive;
MobIndex, ItemIndex: Unbounded_String;
begin
MobsData := Get_Tree(Reader);
NodesList :=
DOM.Core.Documents.Get_Elements_By_Tag_Name(MobsData, "mobile");
Load_Mobs_Loop :
for I in 0 .. Length(NodesList) - 1 loop
TempRecord :=
(Amount_Of_Attributes => Attributes_Amount,
Amount_Of_Skills => Skills_Amount, Skills => TempSkills,
Attributes => (others => <>), Order => Rest,
Priorities => TempPriorities, Inventory => TempInventory,
Equipment => TempEquipment);
MobNode := Item(NodesList, I);
MobIndex := To_Unbounded_String(Get_Attribute(MobNode, "index"));
Action :=
(if Get_Attribute(MobNode, "action")'Length > 0 then
Data_Action'Value(Get_Attribute(MobNode, "action"))
else ADD);
if Action in UPDATE | REMOVE then
if not ProtoMobs_Container.Contains(ProtoMobs_List, MobIndex) then
raise Data_Loading_Error
with "Can't " & To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
"', there is no mob with that index.";
end if;
elsif ProtoMobs_Container.Contains(ProtoMobs_List, MobIndex) then
raise Data_Loading_Error
with "Can't add mob '" & To_String(MobIndex) &
"', there is already a mob with that index.";
end if;
if Action /= REMOVE then
if Action = UPDATE then
TempRecord := ProtoMobs_List(MobIndex);
end if;
ChildNodes :=
DOM.Core.Elements.Get_Elements_By_Tag_Name(MobNode, "skill");
Load_Skills_Loop :
for J in 0 .. Length(ChildNodes) - 1 loop
ChildNode := Item(ChildNodes, J);
ChildIndex :=
Find_Skill_Index(Get_Attribute(ChildNode, "name"));
if Get_Attribute(ChildNode, "name") = "WeaponSkill" then
ChildIndex :=
Natural(SkillsData_Container.Length(Skills_List)) + 1;
end if;
if ChildIndex = 0 then
raise Data_Loading_Error
with "Can't " & To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
"', there no skill named '" &
Get_Attribute(ChildNode, "name") & "'.";
end if;
SubAction :=
(if Get_Attribute(ChildNode, "action")'Length > 0 then
Data_Action'Value(Get_Attribute(ChildNode, "action"))
else ADD);
case SubAction is
when ADD =>
if Get_Attribute(ChildNode, "level")'Length /= 0 then
TempRecord.Skills.Append
(New_Item =>
(ChildIndex,
Integer'Value(Get_Attribute(ChildNode, "level")),
0));
else
if Integer'Value
(Get_Attribute(ChildNode, "minlevel")) >
Integer'Value
(Get_Attribute(ChildNode, "maxlevel")) then
raise Data_Loading_Error
with "Can't " &
To_Lower(Data_Action'Image(Action)) & " mob '" &
To_String(MobIndex) &
" invalid range for skill '" &
Get_Attribute(ChildNode, "name") & "'";
end if;
TempRecord.Skills.Append
(New_Item =>
(ChildIndex,
Integer'Value
(Get_Attribute(ChildNode, "minlevel")),
Integer'Value
(Get_Attribute(ChildNode, "maxlevel"))));
end if;
when UPDATE =>
for Skill of TempRecord.Skills loop
if Skill.Index = ChildIndex then
if Get_Attribute(ChildNode, "level")'Length /=
0 then
Skill :=
(ChildIndex,
Integer'Value
(Get_Attribute(ChildNode, "level")),
0);
else
if Integer'Value
(Get_Attribute(ChildNode, "minlevel")) >
Integer'Value
(Get_Attribute(ChildNode, "maxlevel")) then
raise Data_Loading_Error
with "Can't " &
To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
" invalid range for skill '" &
Get_Attribute(ChildNode, "name") & "'";
end if;
Skill :=
(ChildIndex,
Integer'Value
(Get_Attribute(ChildNode, "minlevel")),
Integer'Value
(Get_Attribute(ChildNode, "maxlevel")));
end if;
exit;
end if;
end loop;
when REMOVE =>
Remove_Skill_Loop :
for K in TempRecord.Skills.Iterate loop
if TempRecord.Skills(K).Index = ChildIndex then
DeleteIndex := Skills_Container.To_Index(K);
exit Remove_Skill_Loop;
end if;
end loop Remove_Skill_Loop;
TempRecord.Skills.Delete(Index => DeleteIndex);
end case;
end loop Load_Skills_Loop;
ChildNodes :=
DOM.Core.Elements.Get_Elements_By_Tag_Name(MobNode, "attribute");
if Length(ChildNodes) > 0 and Action = UPDATE then
TempRecord.Attributes := (others => <>);
end if;
Load_Attributes_Loop :
for J in 0 .. Length(ChildNodes) - 1 loop
ChildNode := Item(ChildNodes, J);
if Get_Attribute(ChildNode, "level") /= "" then
TempRecord.Attributes(J + 1) :=
(Integer'Value(Get_Attribute(ChildNode, "level")), 0);
else
if Integer'Value(Get_Attribute(ChildNode, "minlevel")) >
Integer'Value(Get_Attribute(ChildNode, "maxlevel")) then
raise Data_Loading_Error
with "Can't " & To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
" invalid range for attribute.";
end if;
TempRecord.Attributes(J + 1) :=
(Integer'Value(Get_Attribute(ChildNode, "minlevel")),
Integer'Value(Get_Attribute(ChildNode, "maxlevel")));
end if;
exit Load_Attributes_Loop when J + 1 =
Positive
(AttributesData_Container.Length
(Container => Attributes_List));
end loop Load_Attributes_Loop;
ChildNodes :=
DOM.Core.Elements.Get_Elements_By_Tag_Name(MobNode, "priority");
Load_Orders_Loop :
for J in 0 .. Length(ChildNodes) - 1 loop
ChildNode := Item(ChildNodes, J);
Set_Priorities_Loop :
for K in OrdersNames'Range loop
if OrdersNames(K) =
To_Unbounded_String(Get_Attribute(ChildNode, "name")) then
TempRecord.Priorities(K) :=
(if Get_Attribute(ChildNode, "value") = "Normal" then 1
else 2);
exit Set_Priorities_Loop;
end if;
end loop Set_Priorities_Loop;
end loop Load_Orders_Loop;
if Get_Attribute(MobNode, "order")'Length > 0 then
TempRecord.Order :=
Crew_Orders'Value(Get_Attribute(MobNode, "order"));
end if;
ChildNodes :=
DOM.Core.Elements.Get_Elements_By_Tag_Name(MobNode, "item");
Load_Items_Loop :
for J in 0 .. Length(ChildNodes) - 1 loop
ChildNode := Item(ChildNodes, J);
ItemIndex :=
To_Unbounded_String(Get_Attribute(ChildNode, "index"));
if not Objects_Container.Contains(Items_List, ItemIndex) then
raise Data_Loading_Error
with "Can't " & To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
"', there is no item with index '" &
Get_Attribute(ChildNode, "index") & "'.";
end if;
SubAction :=
(if Get_Attribute(ChildNode, "action")'Length > 0 then
Data_Action'Value(Get_Attribute(ChildNode, "action"))
else ADD);
case SubAction is
when ADD =>
if Get_Attribute(ChildNode, "amount")'Length /= 0 then
TempRecord.Inventory.Append
(New_Item =>
(ItemIndex,
Integer'Value
(Get_Attribute(ChildNode, "amount")),
0));
else
if Integer'Value
(Get_Attribute(ChildNode, "minamount")) >
Integer'Value
(Get_Attribute(ChildNode, "maxamount")) then
raise Data_Loading_Error
with "Can't " &
To_Lower(Data_Action'Image(Action)) & " mob '" &
To_String(MobIndex) &
" invalid range for amount of '" &
Get_Attribute(ChildNode, "index") & "'.";
end if;
TempRecord.Inventory.Append
(New_Item =>
(ItemIndex,
Integer'Value
(Get_Attribute(ChildNode, "minamount")),
Integer'Value
(Get_Attribute(ChildNode, "maxamount"))));
end if;
when UPDATE =>
Update_Items_Loop :
for Item of TempRecord.Inventory loop
if Item.ProtoIndex = ItemIndex then
if Get_Attribute(ChildNode, "amount")'Length /=
0 then
Item :=
(ItemIndex,
Integer'Value
(Get_Attribute(ChildNode, "amount")),
0);
else
if Integer'Value
(Get_Attribute(ChildNode, "minamount")) >
Integer'Value
(Get_Attribute(ChildNode, "maxamount")) then
raise Data_Loading_Error
with "Can't " &
To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
" invalid range for amount of '" &
Get_Attribute(ChildNode, "index") & "'.";
end if;
Item :=
(ItemIndex,
Integer'Value
(Get_Attribute(ChildNode, "minamount")),
Integer'Value
(Get_Attribute(ChildNode, "maxamount")));
end if;
exit Update_Items_Loop;
end if;
end loop Update_Items_Loop;
when REMOVE =>
declare
DeleteIndex: Natural := 0;
begin
Remove_Items_Loop :
for K in
TempRecord.Inventory.First_Index ..
TempRecord.Inventory.Last_Index loop
if TempRecord.Inventory(K).ProtoIndex =
ItemIndex then
DeleteIndex := K;
exit Remove_Items_Loop;
end if;
end loop Remove_Items_Loop;
if DeleteIndex > 0 then
TempRecord.Inventory.Delete(DeleteIndex);
end if;
end;
end case;
end loop Load_Items_Loop;
ChildNodes :=
DOM.Core.Elements.Get_Elements_By_Tag_Name(MobNode, "equipment");
Equipment_Loop :
for J in 0 .. Length(ChildNodes) - 1 loop
ChildNode := Item(ChildNodes, J);
Update_Equipment_Loop :
for K in EquipmentNames'Range loop
if EquipmentNames(K) =
To_Unbounded_String(Get_Attribute(ChildNode, "slot")) then
TempRecord.Equipment(K) :=
Positive'Value(Get_Attribute(ChildNode, "index"));
exit Update_Equipment_Loop;
end if;
end loop Update_Equipment_Loop;
end loop Equipment_Loop;
if Action /= UPDATE then
ProtoMobs_Container.Include
(ProtoMobs_List, MobIndex, TempRecord);
Log_Message("Mob added: " & To_String(MobIndex), EVERYTHING);
else
ProtoMobs_List(MobIndex) := TempRecord;
Log_Message("Mob updated: " & To_String(MobIndex), EVERYTHING);
end if;
else
ProtoMobs_Container.Exclude(ProtoMobs_List, MobIndex);
Log_Message("Mob removed: " & To_String(MobIndex), EVERYTHING);
end if;
end loop Load_Mobs_Loop;
end LoadMobs;
function GenerateMob
(MobIndex, FactionIndex: Unbounded_String) return Member_Data is
Mob: Member_Data
(Amount_Of_Attributes => Attributes_Amount,
Amount_Of_Skills => Skills_Amount);
ProtoMob: constant ProtoMobRecord := ProtoMobs_List(MobIndex);
Amount: Natural;
HighestSkillLevel, WeaponSkillLevel: Skill_Range := 1;
SkillIndex: Skills_Container.Extended_Index;
begin
Mob.Faction :=
(if Get_Random(1, 100) < 99 then FactionIndex else GetRandomFaction);
Mob.Gender := 'M';
if not Factions_List(Mob.Faction).Flags.Contains
(To_Unbounded_String("nogender"))
and then Get_Random(1, 100) > 50 then
Mob.Gender := 'F';
end if;
Mob.Name := GenerateMemberName(Mob.Gender, Mob.Faction);
Skills_Loop :
for Skill of ProtoMob.Skills loop
SkillIndex :=
(if Skill.Index = Skills_Amount + 1 then
Factions_List(Mob.Faction).WeaponSkill
else Skill.Index);
if Skill.Experience = 0 then
Mob.Skills.Append(New_Item => (SkillIndex, Skill.Level, 0));
else
Mob.Skills.Append
(New_Item =>
(SkillIndex, Get_Random(Skill.Level, Skill.Experience), 0));
end if;
if SkillIndex = Factions_List(Mob.Faction).WeaponSkill then
WeaponSkillLevel := Mob.Skills(Mob.Skills.Last_Index).Level;
end if;
if Mob.Skills(Mob.Skills.Last_Index).Level > HighestSkillLevel then
HighestSkillLevel := Mob.Skills(Mob.Skills.Last_Index).Level;
end if;
end loop Skills_Loop;
Attributes_Loop :
for Attribute in ProtoMob.Attributes'Range loop
if ProtoMob.Attributes(Attribute).Experience = 0 then
Mob.Attributes(Attribute) := ProtoMob.Attributes(Attribute);
else
Mob.Attributes(Attribute) :=
(Get_Random
(ProtoMob.Attributes(Attribute).Level,
ProtoMob.Attributes(Attribute).Experience),
0);
end if;
end loop Attributes_Loop;
Inventory_Loop :
for I in ProtoMob.Inventory.Iterate loop
Amount :=
(if ProtoMob.Inventory(I).MaxAmount > 0 then
Get_Random
(ProtoMob.Inventory(I).MinAmount,
ProtoMob.Inventory(I).MaxAmount)
else ProtoMob.Inventory(I).MinAmount);
Mob.Inventory.Append
(New_Item =>
(ProtoIndex => ProtoMob.Inventory(I).ProtoIndex,
Amount => Amount, Name => Null_Unbounded_String,
Durability => 100, Price => 0));
end loop Inventory_Loop;
Mob.Equipment := ProtoMob.Equipment;
declare
ItemsList: UnboundedString_Container.Vector;
ItemIndex: Unbounded_String;
begin
Equipment_Loop :
for I in 1 .. 6 loop
ItemsList :=
(case I is when 1 => Weapons_List, when 2 => Shields_List,
when 3 => HeadArmors_List, when 4 => ChestArmors_List,
when 5 => ArmsArmors_List, when 6 => LegsArmors_List);
if Mob.Equipment(I) = 0 then
ItemIndex := Null_Unbounded_String;
if Get_Random(1, 100) < 95 then
ItemIndex :=
GetRandomItem
(ItemsList, I, HighestSkillLevel, WeaponSkillLevel,
Mob.Faction);
end if;
if ItemIndex /= Null_Unbounded_String then
Mob.Inventory.Append
(New_Item =>
(ProtoIndex => ItemIndex, Amount => 1,
Name => Null_Unbounded_String, Durability => 100,
Price => 0));
Mob.Equipment(I) := Mob.Inventory.Last_Index;
end if;
end if;
end loop Equipment_Loop;
end;
Mob.Orders := ProtoMob.Priorities;
Mob.Order := ProtoMob.Order;
Mob.OrderTime := 15;
Mob.PreviousOrder := Rest;
Mob.Health := 100;
Mob.Tired := 0;
Mob.Hunger := 0;
Mob.Thirst := 0;
Mob.Payment := (20, 0);
Mob.ContractLength := -1;
Mob.Morale := (50, 0);
Mob.Loyalty := 100;
Mob.HomeBase := 1;
return Mob;
end GenerateMob;
function GetRandomItem
(ItemsIndexes: UnboundedString_Container.Vector;
EquipIndex, HighestLevel, WeaponSkillLevel: Positive;
FactionIndex: Unbounded_String) return Unbounded_String is
ItemIndex, MaxIndex: Positive;
NewIndexes: UnboundedString_Container.Vector;
Added: Boolean;
begin
if EquipIndex > 1 then
Equipment_Item_Loop :
for I in ItemsIndexes.First_Index .. ItemsIndexes.Last_Index loop
Added := False;
Add_Equipment_Item_Loop :
for J in NewIndexes.First_Index .. NewIndexes.Last_Index loop
if Items_List(ItemsIndexes(I)).Price <
Items_List(NewIndexes(J)).Price then
NewIndexes.Insert(J, ItemsIndexes(I));
Added := True;
exit Add_Equipment_Item_Loop;
end if;
end loop Add_Equipment_Item_Loop;
if not Added then
NewIndexes.Append(ItemsIndexes(I));
end if;
end loop Equipment_Item_Loop;
MaxIndex :=
Positive
((Float(NewIndexes.Last_Index) * (Float(HighestLevel) / 100.0)) +
1.0);
if MaxIndex > NewIndexes.Last_Index then
MaxIndex := NewIndexes.Last_Index;
end if;
ItemIndex := Get_Random(NewIndexes.First_Index, MaxIndex);
else
Proto_Items_Loop :
for I in ItemsIndexes.First_Index .. ItemsIndexes.Last_Index loop
Added := False;
Add_Proto_Item_Loop :
for J in NewIndexes.First_Index .. NewIndexes.Last_Index loop
if Items_List(ItemsIndexes(I)).Price <
Items_List(NewIndexes(J)).Price and
Items_List(ItemsIndexes(I)).Value(3) =
Factions_List(FactionIndex).WeaponSkill then
NewIndexes.Insert(J, ItemsIndexes(I));
Added := True;
exit Add_Proto_Item_Loop;
end if;
end loop Add_Proto_Item_Loop;
if not Added and
Items_List(ItemsIndexes(I)).Value(3) =
Factions_List(FactionIndex).WeaponSkill then
NewIndexes.Append(ItemsIndexes(I));
end if;
end loop Proto_Items_Loop;
if NewIndexes.Length = 0 then
return Null_Unbounded_String;
end if;
MaxIndex :=
Positive
((Float(NewIndexes.Last_Index) *
(Float(WeaponSkillLevel) / 100.0)) +
1.0);
if MaxIndex > NewIndexes.Last_Index then
MaxIndex := NewIndexes.Last_Index;
end if;
Get_Weapon_Loop :
loop
ItemIndex := Get_Random(NewIndexes.First_Index, MaxIndex);
exit Get_Weapon_Loop when Items_List(NewIndexes(ItemIndex)).Value
(3) =
Factions_List(FactionIndex).WeaponSkill;
end loop Get_Weapon_Loop;
end if;
Get_Item_Index_Loop :
for Index of ItemsIndexes loop
if Index = NewIndexes(ItemIndex) then
return Index;
end if;
end loop Get_Item_Index_Loop;
return Null_Unbounded_String;
end GetRandomItem;
end Mobs;
| true | -- Copyright 2017-2021 PI:NAME:<NAME>END_PI
--
-- 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.Characters.Handling; use Ada.Characters.Handling;
with DOM.Core; use DOM.Core;
with DOM.Core.Documents;
with DOM.Core.Nodes; use DOM.Core.Nodes;
with DOM.Core.Elements; use DOM.Core.Elements;
with Items; use Items;
with Log; use Log;
with Utils; use Utils;
package body Mobs is
procedure LoadMobs(Reader: Tree_Reader) is
MobsData: Document;
NodesList, ChildNodes: Node_List;
TempRecord: ProtoMobRecord
(Amount_Of_Attributes => Attributes_Amount,
Amount_Of_Skills => Skills_Amount);
TempSkills: Skills_Container.Vector;
TempInventory: MobInventory_Container.Vector;
TempPriorities: constant Natural_Array(1 .. 12) := (others => 0);
TempEquipment: constant Equipment_Array := (others => 0);
OrdersNames: constant array(1 .. 11) of Unbounded_String :=
(To_Unbounded_String("Piloting"), To_Unbounded_String("Engineering"),
To_Unbounded_String("Operating guns"),
To_Unbounded_String("Repair ship"),
To_Unbounded_String("Manufacturing"),
To_Unbounded_String("Upgrading ship"),
To_Unbounded_String("Talking in bases"),
To_Unbounded_String("Healing wounded"),
To_Unbounded_String("Cleaning ship"),
To_Unbounded_String("Defend ship"),
To_Unbounded_String("Board enemy ship"));
EquipmentNames: constant array(1 .. 7) of Unbounded_String :=
(To_Unbounded_String("Weapon"), To_Unbounded_String("Shield"),
To_Unbounded_String("Head"), To_Unbounded_String("Torso"),
To_Unbounded_String("Arms"), To_Unbounded_String("Legs"),
To_Unbounded_String("Tool"));
Action, SubAction: Data_Action;
MobNode, ChildNode: Node;
ChildIndex: Natural;
DeleteIndex: Positive;
MobIndex, ItemIndex: Unbounded_String;
begin
MobsData := Get_Tree(Reader);
NodesList :=
DOM.Core.Documents.Get_Elements_By_Tag_Name(MobsData, "mobile");
Load_Mobs_Loop :
for I in 0 .. Length(NodesList) - 1 loop
TempRecord :=
(Amount_Of_Attributes => Attributes_Amount,
Amount_Of_Skills => Skills_Amount, Skills => TempSkills,
Attributes => (others => <>), Order => Rest,
Priorities => TempPriorities, Inventory => TempInventory,
Equipment => TempEquipment);
MobNode := Item(NodesList, I);
MobIndex := To_Unbounded_String(Get_Attribute(MobNode, "index"));
Action :=
(if Get_Attribute(MobNode, "action")'Length > 0 then
Data_Action'Value(Get_Attribute(MobNode, "action"))
else ADD);
if Action in UPDATE | REMOVE then
if not ProtoMobs_Container.Contains(ProtoMobs_List, MobIndex) then
raise Data_Loading_Error
with "Can't " & To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
"', there is no mob with that index.";
end if;
elsif ProtoMobs_Container.Contains(ProtoMobs_List, MobIndex) then
raise Data_Loading_Error
with "Can't add mob '" & To_String(MobIndex) &
"', there is already a mob with that index.";
end if;
if Action /= REMOVE then
if Action = UPDATE then
TempRecord := ProtoMobs_List(MobIndex);
end if;
ChildNodes :=
DOM.Core.Elements.Get_Elements_By_Tag_Name(MobNode, "skill");
Load_Skills_Loop :
for J in 0 .. Length(ChildNodes) - 1 loop
ChildNode := Item(ChildNodes, J);
ChildIndex :=
Find_Skill_Index(Get_Attribute(ChildNode, "name"));
if Get_Attribute(ChildNode, "name") = "WeaponSkill" then
ChildIndex :=
Natural(SkillsData_Container.Length(Skills_List)) + 1;
end if;
if ChildIndex = 0 then
raise Data_Loading_Error
with "Can't " & To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
"', there no skill named '" &
Get_Attribute(ChildNode, "name") & "'.";
end if;
SubAction :=
(if Get_Attribute(ChildNode, "action")'Length > 0 then
Data_Action'Value(Get_Attribute(ChildNode, "action"))
else ADD);
case SubAction is
when ADD =>
if Get_Attribute(ChildNode, "level")'Length /= 0 then
TempRecord.Skills.Append
(New_Item =>
(ChildIndex,
Integer'Value(Get_Attribute(ChildNode, "level")),
0));
else
if Integer'Value
(Get_Attribute(ChildNode, "minlevel")) >
Integer'Value
(Get_Attribute(ChildNode, "maxlevel")) then
raise Data_Loading_Error
with "Can't " &
To_Lower(Data_Action'Image(Action)) & " mob '" &
To_String(MobIndex) &
" invalid range for skill '" &
Get_Attribute(ChildNode, "name") & "'";
end if;
TempRecord.Skills.Append
(New_Item =>
(ChildIndex,
Integer'Value
(Get_Attribute(ChildNode, "minlevel")),
Integer'Value
(Get_Attribute(ChildNode, "maxlevel"))));
end if;
when UPDATE =>
for Skill of TempRecord.Skills loop
if Skill.Index = ChildIndex then
if Get_Attribute(ChildNode, "level")'Length /=
0 then
Skill :=
(ChildIndex,
Integer'Value
(Get_Attribute(ChildNode, "level")),
0);
else
if Integer'Value
(Get_Attribute(ChildNode, "minlevel")) >
Integer'Value
(Get_Attribute(ChildNode, "maxlevel")) then
raise Data_Loading_Error
with "Can't " &
To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
" invalid range for skill '" &
Get_Attribute(ChildNode, "name") & "'";
end if;
Skill :=
(ChildIndex,
Integer'Value
(Get_Attribute(ChildNode, "minlevel")),
Integer'Value
(Get_Attribute(ChildNode, "maxlevel")));
end if;
exit;
end if;
end loop;
when REMOVE =>
Remove_Skill_Loop :
for K in TempRecord.Skills.Iterate loop
if TempRecord.Skills(K).Index = ChildIndex then
DeleteIndex := Skills_Container.To_Index(K);
exit Remove_Skill_Loop;
end if;
end loop Remove_Skill_Loop;
TempRecord.Skills.Delete(Index => DeleteIndex);
end case;
end loop Load_Skills_Loop;
ChildNodes :=
DOM.Core.Elements.Get_Elements_By_Tag_Name(MobNode, "attribute");
if Length(ChildNodes) > 0 and Action = UPDATE then
TempRecord.Attributes := (others => <>);
end if;
Load_Attributes_Loop :
for J in 0 .. Length(ChildNodes) - 1 loop
ChildNode := Item(ChildNodes, J);
if Get_Attribute(ChildNode, "level") /= "" then
TempRecord.Attributes(J + 1) :=
(Integer'Value(Get_Attribute(ChildNode, "level")), 0);
else
if Integer'Value(Get_Attribute(ChildNode, "minlevel")) >
Integer'Value(Get_Attribute(ChildNode, "maxlevel")) then
raise Data_Loading_Error
with "Can't " & To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
" invalid range for attribute.";
end if;
TempRecord.Attributes(J + 1) :=
(Integer'Value(Get_Attribute(ChildNode, "minlevel")),
Integer'Value(Get_Attribute(ChildNode, "maxlevel")));
end if;
exit Load_Attributes_Loop when J + 1 =
Positive
(AttributesData_Container.Length
(Container => Attributes_List));
end loop Load_Attributes_Loop;
ChildNodes :=
DOM.Core.Elements.Get_Elements_By_Tag_Name(MobNode, "priority");
Load_Orders_Loop :
for J in 0 .. Length(ChildNodes) - 1 loop
ChildNode := Item(ChildNodes, J);
Set_Priorities_Loop :
for K in OrdersNames'Range loop
if OrdersNames(K) =
To_Unbounded_String(Get_Attribute(ChildNode, "name")) then
TempRecord.Priorities(K) :=
(if Get_Attribute(ChildNode, "value") = "Normal" then 1
else 2);
exit Set_Priorities_Loop;
end if;
end loop Set_Priorities_Loop;
end loop Load_Orders_Loop;
if Get_Attribute(MobNode, "order")'Length > 0 then
TempRecord.Order :=
Crew_Orders'Value(Get_Attribute(MobNode, "order"));
end if;
ChildNodes :=
DOM.Core.Elements.Get_Elements_By_Tag_Name(MobNode, "item");
Load_Items_Loop :
for J in 0 .. Length(ChildNodes) - 1 loop
ChildNode := Item(ChildNodes, J);
ItemIndex :=
To_Unbounded_String(Get_Attribute(ChildNode, "index"));
if not Objects_Container.Contains(Items_List, ItemIndex) then
raise Data_Loading_Error
with "Can't " & To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
"', there is no item with index '" &
Get_Attribute(ChildNode, "index") & "'.";
end if;
SubAction :=
(if Get_Attribute(ChildNode, "action")'Length > 0 then
Data_Action'Value(Get_Attribute(ChildNode, "action"))
else ADD);
case SubAction is
when ADD =>
if Get_Attribute(ChildNode, "amount")'Length /= 0 then
TempRecord.Inventory.Append
(New_Item =>
(ItemIndex,
Integer'Value
(Get_Attribute(ChildNode, "amount")),
0));
else
if Integer'Value
(Get_Attribute(ChildNode, "minamount")) >
Integer'Value
(Get_Attribute(ChildNode, "maxamount")) then
raise Data_Loading_Error
with "Can't " &
To_Lower(Data_Action'Image(Action)) & " mob '" &
To_String(MobIndex) &
" invalid range for amount of '" &
Get_Attribute(ChildNode, "index") & "'.";
end if;
TempRecord.Inventory.Append
(New_Item =>
(ItemIndex,
Integer'Value
(Get_Attribute(ChildNode, "minamount")),
Integer'Value
(Get_Attribute(ChildNode, "maxamount"))));
end if;
when UPDATE =>
Update_Items_Loop :
for Item of TempRecord.Inventory loop
if Item.ProtoIndex = ItemIndex then
if Get_Attribute(ChildNode, "amount")'Length /=
0 then
Item :=
(ItemIndex,
Integer'Value
(Get_Attribute(ChildNode, "amount")),
0);
else
if Integer'Value
(Get_Attribute(ChildNode, "minamount")) >
Integer'Value
(Get_Attribute(ChildNode, "maxamount")) then
raise Data_Loading_Error
with "Can't " &
To_Lower(Data_Action'Image(Action)) &
" mob '" & To_String(MobIndex) &
" invalid range for amount of '" &
Get_Attribute(ChildNode, "index") & "'.";
end if;
Item :=
(ItemIndex,
Integer'Value
(Get_Attribute(ChildNode, "minamount")),
Integer'Value
(Get_Attribute(ChildNode, "maxamount")));
end if;
exit Update_Items_Loop;
end if;
end loop Update_Items_Loop;
when REMOVE =>
declare
DeleteIndex: Natural := 0;
begin
Remove_Items_Loop :
for K in
TempRecord.Inventory.First_Index ..
TempRecord.Inventory.Last_Index loop
if TempRecord.Inventory(K).ProtoIndex =
ItemIndex then
DeleteIndex := K;
exit Remove_Items_Loop;
end if;
end loop Remove_Items_Loop;
if DeleteIndex > 0 then
TempRecord.Inventory.Delete(DeleteIndex);
end if;
end;
end case;
end loop Load_Items_Loop;
ChildNodes :=
DOM.Core.Elements.Get_Elements_By_Tag_Name(MobNode, "equipment");
Equipment_Loop :
for J in 0 .. Length(ChildNodes) - 1 loop
ChildNode := Item(ChildNodes, J);
Update_Equipment_Loop :
for K in EquipmentNames'Range loop
if EquipmentNames(K) =
To_Unbounded_String(Get_Attribute(ChildNode, "slot")) then
TempRecord.Equipment(K) :=
Positive'Value(Get_Attribute(ChildNode, "index"));
exit Update_Equipment_Loop;
end if;
end loop Update_Equipment_Loop;
end loop Equipment_Loop;
if Action /= UPDATE then
ProtoMobs_Container.Include
(ProtoMobs_List, MobIndex, TempRecord);
Log_Message("Mob added: " & To_String(MobIndex), EVERYTHING);
else
ProtoMobs_List(MobIndex) := TempRecord;
Log_Message("Mob updated: " & To_String(MobIndex), EVERYTHING);
end if;
else
ProtoMobs_Container.Exclude(ProtoMobs_List, MobIndex);
Log_Message("Mob removed: " & To_String(MobIndex), EVERYTHING);
end if;
end loop Load_Mobs_Loop;
end LoadMobs;
function GenerateMob
(MobIndex, FactionIndex: Unbounded_String) return Member_Data is
Mob: Member_Data
(Amount_Of_Attributes => Attributes_Amount,
Amount_Of_Skills => Skills_Amount);
ProtoMob: constant ProtoMobRecord := ProtoMobs_List(MobIndex);
Amount: Natural;
HighestSkillLevel, WeaponSkillLevel: Skill_Range := 1;
SkillIndex: Skills_Container.Extended_Index;
begin
Mob.Faction :=
(if Get_Random(1, 100) < 99 then FactionIndex else GetRandomFaction);
Mob.Gender := 'M';
if not Factions_List(Mob.Faction).Flags.Contains
(To_Unbounded_String("nogender"))
and then Get_Random(1, 100) > 50 then
Mob.Gender := 'F';
end if;
Mob.Name := GenerateMemberName(Mob.Gender, Mob.Faction);
Skills_Loop :
for Skill of ProtoMob.Skills loop
SkillIndex :=
(if Skill.Index = Skills_Amount + 1 then
Factions_List(Mob.Faction).WeaponSkill
else Skill.Index);
if Skill.Experience = 0 then
Mob.Skills.Append(New_Item => (SkillIndex, Skill.Level, 0));
else
Mob.Skills.Append
(New_Item =>
(SkillIndex, Get_Random(Skill.Level, Skill.Experience), 0));
end if;
if SkillIndex = Factions_List(Mob.Faction).WeaponSkill then
WeaponSkillLevel := Mob.Skills(Mob.Skills.Last_Index).Level;
end if;
if Mob.Skills(Mob.Skills.Last_Index).Level > HighestSkillLevel then
HighestSkillLevel := Mob.Skills(Mob.Skills.Last_Index).Level;
end if;
end loop Skills_Loop;
Attributes_Loop :
for Attribute in ProtoMob.Attributes'Range loop
if ProtoMob.Attributes(Attribute).Experience = 0 then
Mob.Attributes(Attribute) := ProtoMob.Attributes(Attribute);
else
Mob.Attributes(Attribute) :=
(Get_Random
(ProtoMob.Attributes(Attribute).Level,
ProtoMob.Attributes(Attribute).Experience),
0);
end if;
end loop Attributes_Loop;
Inventory_Loop :
for I in ProtoMob.Inventory.Iterate loop
Amount :=
(if ProtoMob.Inventory(I).MaxAmount > 0 then
Get_Random
(ProtoMob.Inventory(I).MinAmount,
ProtoMob.Inventory(I).MaxAmount)
else ProtoMob.Inventory(I).MinAmount);
Mob.Inventory.Append
(New_Item =>
(ProtoIndex => ProtoMob.Inventory(I).ProtoIndex,
Amount => Amount, Name => Null_Unbounded_String,
Durability => 100, Price => 0));
end loop Inventory_Loop;
Mob.Equipment := ProtoMob.Equipment;
declare
ItemsList: UnboundedString_Container.Vector;
ItemIndex: Unbounded_String;
begin
Equipment_Loop :
for I in 1 .. 6 loop
ItemsList :=
(case I is when 1 => Weapons_List, when 2 => Shields_List,
when 3 => HeadArmors_List, when 4 => ChestArmors_List,
when 5 => ArmsArmors_List, when 6 => LegsArmors_List);
if Mob.Equipment(I) = 0 then
ItemIndex := Null_Unbounded_String;
if Get_Random(1, 100) < 95 then
ItemIndex :=
GetRandomItem
(ItemsList, I, HighestSkillLevel, WeaponSkillLevel,
Mob.Faction);
end if;
if ItemIndex /= Null_Unbounded_String then
Mob.Inventory.Append
(New_Item =>
(ProtoIndex => ItemIndex, Amount => 1,
Name => Null_Unbounded_String, Durability => 100,
Price => 0));
Mob.Equipment(I) := Mob.Inventory.Last_Index;
end if;
end if;
end loop Equipment_Loop;
end;
Mob.Orders := ProtoMob.Priorities;
Mob.Order := ProtoMob.Order;
Mob.OrderTime := 15;
Mob.PreviousOrder := Rest;
Mob.Health := 100;
Mob.Tired := 0;
Mob.Hunger := 0;
Mob.Thirst := 0;
Mob.Payment := (20, 0);
Mob.ContractLength := -1;
Mob.Morale := (50, 0);
Mob.Loyalty := 100;
Mob.HomeBase := 1;
return Mob;
end GenerateMob;
function GetRandomItem
(ItemsIndexes: UnboundedString_Container.Vector;
EquipIndex, HighestLevel, WeaponSkillLevel: Positive;
FactionIndex: Unbounded_String) return Unbounded_String is
ItemIndex, MaxIndex: Positive;
NewIndexes: UnboundedString_Container.Vector;
Added: Boolean;
begin
if EquipIndex > 1 then
Equipment_Item_Loop :
for I in ItemsIndexes.First_Index .. ItemsIndexes.Last_Index loop
Added := False;
Add_Equipment_Item_Loop :
for J in NewIndexes.First_Index .. NewIndexes.Last_Index loop
if Items_List(ItemsIndexes(I)).Price <
Items_List(NewIndexes(J)).Price then
NewIndexes.Insert(J, ItemsIndexes(I));
Added := True;
exit Add_Equipment_Item_Loop;
end if;
end loop Add_Equipment_Item_Loop;
if not Added then
NewIndexes.Append(ItemsIndexes(I));
end if;
end loop Equipment_Item_Loop;
MaxIndex :=
Positive
((Float(NewIndexes.Last_Index) * (Float(HighestLevel) / 100.0)) +
1.0);
if MaxIndex > NewIndexes.Last_Index then
MaxIndex := NewIndexes.Last_Index;
end if;
ItemIndex := Get_Random(NewIndexes.First_Index, MaxIndex);
else
Proto_Items_Loop :
for I in ItemsIndexes.First_Index .. ItemsIndexes.Last_Index loop
Added := False;
Add_Proto_Item_Loop :
for J in NewIndexes.First_Index .. NewIndexes.Last_Index loop
if Items_List(ItemsIndexes(I)).Price <
Items_List(NewIndexes(J)).Price and
Items_List(ItemsIndexes(I)).Value(3) =
Factions_List(FactionIndex).WeaponSkill then
NewIndexes.Insert(J, ItemsIndexes(I));
Added := True;
exit Add_Proto_Item_Loop;
end if;
end loop Add_Proto_Item_Loop;
if not Added and
Items_List(ItemsIndexes(I)).Value(3) =
Factions_List(FactionIndex).WeaponSkill then
NewIndexes.Append(ItemsIndexes(I));
end if;
end loop Proto_Items_Loop;
if NewIndexes.Length = 0 then
return Null_Unbounded_String;
end if;
MaxIndex :=
Positive
((Float(NewIndexes.Last_Index) *
(Float(WeaponSkillLevel) / 100.0)) +
1.0);
if MaxIndex > NewIndexes.Last_Index then
MaxIndex := NewIndexes.Last_Index;
end if;
Get_Weapon_Loop :
loop
ItemIndex := Get_Random(NewIndexes.First_Index, MaxIndex);
exit Get_Weapon_Loop when Items_List(NewIndexes(ItemIndex)).Value
(3) =
Factions_List(FactionIndex).WeaponSkill;
end loop Get_Weapon_Loop;
end if;
Get_Item_Index_Loop :
for Index of ItemsIndexes loop
if Index = NewIndexes(ItemIndex) then
return Index;
end if;
end loop Get_Item_Index_Loop;
return Null_Unbounded_String;
end GetRandomItem;
end Mobs;
|
[
{
"context": "-- SPDX-FileCopyrightText: 2010-2021 Max Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifi",
"end": 48,
"score": 0.9998513460159302,
"start": 38,
"tag": "NAME",
"value": "Max Reznik"
},
{
"context": "-- SPDX-FileCopyrightText: 2010-2021 Max Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifier: MIT\n------------",
"end": 68,
"score": 0.9999300837516785,
"start": 50,
"tag": "EMAIL",
"value": "reznikmm@gmail.com"
}
] | source/lexer/webidl-abstract_sources.ads | reznikmm/webidl | 0 | -- SPDX-FileCopyrightText: 2010-2021 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Matreshka.Internals.Unicode;
package WebIDL.Abstract_Sources is
pragma Preelaborate;
subtype Code_Unit_32 is Matreshka.Internals.Unicode.Code_Unit_32;
type Abstract_Source is limited interface;
Error : constant Code_Unit_32 := 16#7FFFFFFF#;
End_Of_Input : constant Code_Unit_32 := 16#7FFFFFFE#;
End_Of_Data : constant Code_Unit_32 := 16#7FFFFFFD#;
End_Of_Buffer : constant Code_Unit_32 := 16#7FFFFFFC#;
type Source_Access is access all Abstract_Source'Class;
not overriding function Get_Next
(Self : not null access Abstract_Source) return Code_Unit_32 is abstract;
end WebIDL.Abstract_Sources;
| 10468 | -- SPDX-FileCopyrightText: 2010-2021 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Matreshka.Internals.Unicode;
package WebIDL.Abstract_Sources is
pragma Preelaborate;
subtype Code_Unit_32 is Matreshka.Internals.Unicode.Code_Unit_32;
type Abstract_Source is limited interface;
Error : constant Code_Unit_32 := 16#7FFFFFFF#;
End_Of_Input : constant Code_Unit_32 := 16#7FFFFFFE#;
End_Of_Data : constant Code_Unit_32 := 16#7FFFFFFD#;
End_Of_Buffer : constant Code_Unit_32 := 16#7FFFFFFC#;
type Source_Access is access all Abstract_Source'Class;
not overriding function Get_Next
(Self : not null access Abstract_Source) return Code_Unit_32 is abstract;
end WebIDL.Abstract_Sources;
| true | -- SPDX-FileCopyrightText: 2010-2021 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Matreshka.Internals.Unicode;
package WebIDL.Abstract_Sources is
pragma Preelaborate;
subtype Code_Unit_32 is Matreshka.Internals.Unicode.Code_Unit_32;
type Abstract_Source is limited interface;
Error : constant Code_Unit_32 := 16#7FFFFFFF#;
End_Of_Input : constant Code_Unit_32 := 16#7FFFFFFE#;
End_Of_Data : constant Code_Unit_32 := 16#7FFFFFFD#;
End_Of_Buffer : constant Code_Unit_32 := 16#7FFFFFFC#;
type Source_Access is access all Abstract_Source'Class;
not overriding function Get_Next
(Self : not null access Abstract_Source) return Code_Unit_32 is abstract;
end WebIDL.Abstract_Sources;
|
[
{
"context": "h and\n-- Half Siphash\n\n-- Copyright (c) 2015-2016, James Humphry - see LICENSE file for details\n\nwith Ada.Unchecke",
"end": 147,
"score": 0.9998432397842407,
"start": 134,
"tag": "NAME",
"value": "James Humphry"
}
] | src/tests/siphash24_c.ads | jhumphry/SPARK_SipHash | 5 | -- SipHash24_C
-- an Ada specification for the reference C implementation of SipHash and
-- Half Siphash
-- Copyright (c) 2015-2016, James Humphry - see LICENSE file for details
with Ada.Unchecked_Conversion;
with Interfaces, Interfaces.C, Interfaces.C.Strings;
use Interfaces;
package SipHash24_c is
subtype U8 is Interfaces.Unsigned_8;
type U8_Access is access all U8;
subtype U32 is Interfaces.Unsigned_32;
subtype U64 is Interfaces.Unsigned_64;
type U8_Array is array (Natural range <>) of aliased U8;
subtype U8_Array4 is U8_Array(0..3);
subtype U8_Array8 is U8_Array(0..7);
function chars_ptr_to_U8_Access is
new Ada.Unchecked_Conversion(Source => Interfaces.C.Strings.chars_ptr,
Target => U8_Access);
function C_SipHash24
(
c_in : access Interfaces.Unsigned_8;
inlen : Interfaces.C.size_t;
k : access Interfaces.Unsigned_8;
c_out : access Interfaces.Unsigned_8;
outlen : Interfaces.C.size_t
) return C.int;
pragma Import (C, C_SipHash24, "siphash");
function C_HalfSipHash24
(
c_in : access Interfaces.Unsigned_8;
inlen : Interfaces.C.size_t;
k : access Interfaces.Unsigned_8;
c_out : access Interfaces.Unsigned_8;
outlen : Interfaces.C.size_t
) return C.int;
pragma Import (C, C_HalfSipHash24, "halfsiphash");
function U8_Array4_to_U32 (c : U8_Array4) return U32 is
(U32(c(0))
or Shift_Left(U32(c(1)), 8)
or Shift_Left(U32(c(2)), 16)
or Shift_Left(U32(c(3)), 24));
function U8_Array8_to_U64 (c : U8_Array8) return U64 is
(U64(c(0))
or Shift_Left(U64(c(1)), 8)
or Shift_Left(U64(c(2)), 16)
or Shift_Left(U64(c(3)), 24)
or Shift_Left(U64(c(4)), 32)
or Shift_Left(U64(c(5)), 40)
or Shift_Left(U64(c(6)), 48)
or Shift_Left(U64(c(7)), 56));
end SipHash24_c;
| 29683 | -- SipHash24_C
-- an Ada specification for the reference C implementation of SipHash and
-- Half Siphash
-- Copyright (c) 2015-2016, <NAME> - see LICENSE file for details
with Ada.Unchecked_Conversion;
with Interfaces, Interfaces.C, Interfaces.C.Strings;
use Interfaces;
package SipHash24_c is
subtype U8 is Interfaces.Unsigned_8;
type U8_Access is access all U8;
subtype U32 is Interfaces.Unsigned_32;
subtype U64 is Interfaces.Unsigned_64;
type U8_Array is array (Natural range <>) of aliased U8;
subtype U8_Array4 is U8_Array(0..3);
subtype U8_Array8 is U8_Array(0..7);
function chars_ptr_to_U8_Access is
new Ada.Unchecked_Conversion(Source => Interfaces.C.Strings.chars_ptr,
Target => U8_Access);
function C_SipHash24
(
c_in : access Interfaces.Unsigned_8;
inlen : Interfaces.C.size_t;
k : access Interfaces.Unsigned_8;
c_out : access Interfaces.Unsigned_8;
outlen : Interfaces.C.size_t
) return C.int;
pragma Import (C, C_SipHash24, "siphash");
function C_HalfSipHash24
(
c_in : access Interfaces.Unsigned_8;
inlen : Interfaces.C.size_t;
k : access Interfaces.Unsigned_8;
c_out : access Interfaces.Unsigned_8;
outlen : Interfaces.C.size_t
) return C.int;
pragma Import (C, C_HalfSipHash24, "halfsiphash");
function U8_Array4_to_U32 (c : U8_Array4) return U32 is
(U32(c(0))
or Shift_Left(U32(c(1)), 8)
or Shift_Left(U32(c(2)), 16)
or Shift_Left(U32(c(3)), 24));
function U8_Array8_to_U64 (c : U8_Array8) return U64 is
(U64(c(0))
or Shift_Left(U64(c(1)), 8)
or Shift_Left(U64(c(2)), 16)
or Shift_Left(U64(c(3)), 24)
or Shift_Left(U64(c(4)), 32)
or Shift_Left(U64(c(5)), 40)
or Shift_Left(U64(c(6)), 48)
or Shift_Left(U64(c(7)), 56));
end SipHash24_c;
| true | -- SipHash24_C
-- an Ada specification for the reference C implementation of SipHash and
-- Half Siphash
-- Copyright (c) 2015-2016, PI:NAME:<NAME>END_PI - see LICENSE file for details
with Ada.Unchecked_Conversion;
with Interfaces, Interfaces.C, Interfaces.C.Strings;
use Interfaces;
package SipHash24_c is
subtype U8 is Interfaces.Unsigned_8;
type U8_Access is access all U8;
subtype U32 is Interfaces.Unsigned_32;
subtype U64 is Interfaces.Unsigned_64;
type U8_Array is array (Natural range <>) of aliased U8;
subtype U8_Array4 is U8_Array(0..3);
subtype U8_Array8 is U8_Array(0..7);
function chars_ptr_to_U8_Access is
new Ada.Unchecked_Conversion(Source => Interfaces.C.Strings.chars_ptr,
Target => U8_Access);
function C_SipHash24
(
c_in : access Interfaces.Unsigned_8;
inlen : Interfaces.C.size_t;
k : access Interfaces.Unsigned_8;
c_out : access Interfaces.Unsigned_8;
outlen : Interfaces.C.size_t
) return C.int;
pragma Import (C, C_SipHash24, "siphash");
function C_HalfSipHash24
(
c_in : access Interfaces.Unsigned_8;
inlen : Interfaces.C.size_t;
k : access Interfaces.Unsigned_8;
c_out : access Interfaces.Unsigned_8;
outlen : Interfaces.C.size_t
) return C.int;
pragma Import (C, C_HalfSipHash24, "halfsiphash");
function U8_Array4_to_U32 (c : U8_Array4) return U32 is
(U32(c(0))
or Shift_Left(U32(c(1)), 8)
or Shift_Left(U32(c(2)), 16)
or Shift_Left(U32(c(3)), 24));
function U8_Array8_to_U64 (c : U8_Array8) return U64 is
(U64(c(0))
or Shift_Left(U64(c(1)), 8)
or Shift_Left(U64(c(2)), 16)
or Shift_Left(U64(c(3)), 24)
or Shift_Left(U64(c(4)), 32)
or Shift_Left(U64(c(5)), 40)
or Shift_Left(U64(c(6)), 48)
or Shift_Left(U64(c(7)), 56));
end SipHash24_c;
|
[
{
"context": "--\n-- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr>\n-- - Ryad Benadjila\n-- - Arnauld Michel",
"end": 64,
"score": 0.9999324083328247,
"start": 46,
"tag": "EMAIL",
"value": "wookey@ssi.gouv.fr"
},
{
"context": "he wookey project team <wookey@ssi.gouv.fr>\n-- - Ryad Benadjila\n-- - Arnauld Michelizza\n-- - Mathieu Renard",
"end": 91,
"score": 0.9983742833137512,
"start": 73,
"tag": "NAME",
"value": "Ryad Benadjila"
},
{
"context": "okey@ssi.gouv.fr>\n-- - Ryad Benadjila\n-- - Arnauld Michelizza\n-- - Mathieu Renard\n-- - Philippe Thierry\n--",
"end": 118,
"score": 0.98482346534729,
"start": 99,
"tag": "NAME",
"value": "Arnauld Michelizza"
},
{
"context": "ad Benadjila\n-- - Arnauld Michelizza\n-- - Mathieu Renard\n-- - Philippe Thierry\n-- - Philippe Trebuchet",
"end": 141,
"score": 0.909562885761261,
"start": 126,
"tag": "NAME",
"value": "Mathieu Renard"
},
{
"context": " Arnauld Michelizza\n-- - Mathieu Renard\n-- - Philippe Thierry\n-- - Philippe Trebuchet\n--\n-- Licensed under th",
"end": 165,
"score": 0.9998365640640259,
"start": 149,
"tag": "NAME",
"value": "Philippe Thierry"
},
{
"context": " - Mathieu Renard\n-- - Philippe Thierry\n-- - Philippe Trebuchet\n--\n-- Licensed under the Apache License, Version ",
"end": 191,
"score": 0.9998639225959778,
"start": 173,
"tag": "NAME",
"value": "Philippe Trebuchet"
}
] | src/main.adb | PThierry/ewok-kernel | 0 | --
-- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with interfaces;
with types; use types;
with m4.cpu.instructions;
with m4.systick;
with soc.dwt;
with soc.rng;
with soc.system;
with ewok.debug;
with ewok.dma;
with ewok.exti;
with ewok.interrupts;
with ewok.mpu;
with ewok.softirq;
with ewok.sched;
with ewok.tasks;
procedure main
is
VTOR_address : system_address
with
import,
convention => assembly,
external_name => "VTOR_address";
ok : boolean;
begin
m4.cpu.disable_irq;
-- Initialize interrupts, handlers & priorities
ewok.interrupts.init;
-- Initialize system Clock
m4.systick.init;
-- Configure the USART for debugging purpose
#if CONFIG_KERNEL_SERIAL
#if CONFIG_KERNEL_USART = 1
ewok.debug.init (1);
#elsif CONFIG_KERNEL_USART = 4
ewok.debug.init (4);
#elsif CONFIG_KERNEL_USART = 6
ewok.debug.init (6);
#else
raise program_error;
#end if;
#end if;
-- Initialize DWT (required for precise time measurement)
soc.dwt.init;
-- Initialize the platform TRNG
soc.rng.init (ok);
if not ok then
pragma DEBUG (ewok.debug.log (ewok.debug.ERROR, "Unable to use TRNG"));
end if;
-- Initialize DMA controllers
ewok.dma.init;
-- Initialize the EXTIs
ewok.exti.init;
-- The kernel is a PIE executable. Its base address is given in first
-- argument, based on the loader informations
soc.system.init (VTOR_address);
-- Initialize the MPU
-- After this sequence, the kernel is executed with the MPU activated and
-- can generate memory fault in case of invalid access.
ewok.mpu.init (ok);
if not ok then
ewok.debug.panic ("MPU configuration failed!");
end if;
m4.cpu.instructions.full_memory_barrier;
-- Create user tasks
ewok.tasks.task_init;
-- Initialize SOFTIRQ thread
ewok.softirq.init;
-- Let's run tasks!
ewok.sched.init;
ewok.debug.panic ("Why am I here?");
end main;
| 20778 | --
-- Copyright 2018 The wookey project team <<EMAIL>>
-- - <NAME>
-- - <NAME>
-- - <NAME>
-- - <NAME>
-- - <NAME>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with interfaces;
with types; use types;
with m4.cpu.instructions;
with m4.systick;
with soc.dwt;
with soc.rng;
with soc.system;
with ewok.debug;
with ewok.dma;
with ewok.exti;
with ewok.interrupts;
with ewok.mpu;
with ewok.softirq;
with ewok.sched;
with ewok.tasks;
procedure main
is
VTOR_address : system_address
with
import,
convention => assembly,
external_name => "VTOR_address";
ok : boolean;
begin
m4.cpu.disable_irq;
-- Initialize interrupts, handlers & priorities
ewok.interrupts.init;
-- Initialize system Clock
m4.systick.init;
-- Configure the USART for debugging purpose
#if CONFIG_KERNEL_SERIAL
#if CONFIG_KERNEL_USART = 1
ewok.debug.init (1);
#elsif CONFIG_KERNEL_USART = 4
ewok.debug.init (4);
#elsif CONFIG_KERNEL_USART = 6
ewok.debug.init (6);
#else
raise program_error;
#end if;
#end if;
-- Initialize DWT (required for precise time measurement)
soc.dwt.init;
-- Initialize the platform TRNG
soc.rng.init (ok);
if not ok then
pragma DEBUG (ewok.debug.log (ewok.debug.ERROR, "Unable to use TRNG"));
end if;
-- Initialize DMA controllers
ewok.dma.init;
-- Initialize the EXTIs
ewok.exti.init;
-- The kernel is a PIE executable. Its base address is given in first
-- argument, based on the loader informations
soc.system.init (VTOR_address);
-- Initialize the MPU
-- After this sequence, the kernel is executed with the MPU activated and
-- can generate memory fault in case of invalid access.
ewok.mpu.init (ok);
if not ok then
ewok.debug.panic ("MPU configuration failed!");
end if;
m4.cpu.instructions.full_memory_barrier;
-- Create user tasks
ewok.tasks.task_init;
-- Initialize SOFTIRQ thread
ewok.softirq.init;
-- Let's run tasks!
ewok.sched.init;
ewok.debug.panic ("Why am I here?");
end main;
| true | --
-- Copyright 2018 The wookey project team <PI:EMAIL:<EMAIL>END_PI>
-- - PI:NAME:<NAME>END_PI
-- - PI:NAME:<NAME>END_PI
-- - PI:NAME:<NAME>END_PI
-- - PI:NAME:<NAME>END_PI
-- - PI:NAME:<NAME>END_PI
--
-- 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;
with types; use types;
with m4.cpu.instructions;
with m4.systick;
with soc.dwt;
with soc.rng;
with soc.system;
with ewok.debug;
with ewok.dma;
with ewok.exti;
with ewok.interrupts;
with ewok.mpu;
with ewok.softirq;
with ewok.sched;
with ewok.tasks;
procedure main
is
VTOR_address : system_address
with
import,
convention => assembly,
external_name => "VTOR_address";
ok : boolean;
begin
m4.cpu.disable_irq;
-- Initialize interrupts, handlers & priorities
ewok.interrupts.init;
-- Initialize system Clock
m4.systick.init;
-- Configure the USART for debugging purpose
#if CONFIG_KERNEL_SERIAL
#if CONFIG_KERNEL_USART = 1
ewok.debug.init (1);
#elsif CONFIG_KERNEL_USART = 4
ewok.debug.init (4);
#elsif CONFIG_KERNEL_USART = 6
ewok.debug.init (6);
#else
raise program_error;
#end if;
#end if;
-- Initialize DWT (required for precise time measurement)
soc.dwt.init;
-- Initialize the platform TRNG
soc.rng.init (ok);
if not ok then
pragma DEBUG (ewok.debug.log (ewok.debug.ERROR, "Unable to use TRNG"));
end if;
-- Initialize DMA controllers
ewok.dma.init;
-- Initialize the EXTIs
ewok.exti.init;
-- The kernel is a PIE executable. Its base address is given in first
-- argument, based on the loader informations
soc.system.init (VTOR_address);
-- Initialize the MPU
-- After this sequence, the kernel is executed with the MPU activated and
-- can generate memory fault in case of invalid access.
ewok.mpu.init (ok);
if not ok then
ewok.debug.panic ("MPU configuration failed!");
end if;
m4.cpu.instructions.full_memory_barrier;
-- Create user tasks
ewok.tasks.task_init;
-- Initialize SOFTIRQ thread
ewok.softirq.init;
-- Let's run tasks!
ewok.sched.init;
ewok.debug.panic ("Why am I here?");
end main;
|
[
{
"context": "\n -- GStreamer RIFF I/O\n -- * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>\n -- *\n -- * riff-",
"end": 551,
"score": 0.9998931288719177,
"start": 538,
"tag": "NAME",
"value": "Ronald Bultje"
},
{
"context": "RIFF I/O\n -- * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>\n -- *\n -- * riff-read.h: function declarations",
"end": 580,
"score": 0.9999361634254456,
"start": 553,
"tag": "EMAIL",
"value": "rbultje@ronald.bitfreak.net"
}
] | src/gen/gstreamer-gst_low_level-gstreamer_0_10_gst_riff_riff_read_h.ads | persan/A-gst | 1 | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
with System;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h;
with glib;
with glib.Values;
with System;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_riff_riff_read_h is
-- GStreamer RIFF I/O
-- * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
-- *
-- * riff-read.h: function declarations for parsing a RIFF file
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
-- * Operate using pull_range().
--
function gst_riff_read_chunk
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad;
offset : access GLIB.guint64;
tag : access GLIB.guint32;
chunk_data : System.Address) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn; -- gst/riff/riff-read.h:36
pragma Import (C, gst_riff_read_chunk, "gst_riff_read_chunk");
-- * These functions operate on provided data (the caller is
-- * supposed to strip the chunk headers). The buffer is
-- * provided by the caller, the strf/strh/data are filled in
-- * by the function.
--
function gst_riff_parse_chunk
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
offset : access GLIB.guint;
fourcc : access GLIB.guint32;
chunk_data : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:49
pragma Import (C, gst_riff_parse_chunk, "gst_riff_parse_chunk");
function gst_riff_parse_file_header
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
doctype : access GLIB.guint32) return GLIB.gboolean; -- gst/riff/riff-read.h:55
pragma Import (C, gst_riff_parse_file_header, "gst_riff_parse_file_header");
function gst_riff_parse_strh
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
strh : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:59
pragma Import (C, gst_riff_parse_strh, "gst_riff_parse_strh");
function gst_riff_parse_strf_vids
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
strf : System.Address;
data : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:63
pragma Import (C, gst_riff_parse_strf_vids, "gst_riff_parse_strf_vids");
function gst_riff_parse_strf_auds
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
strf : System.Address;
data : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:67
pragma Import (C, gst_riff_parse_strf_auds, "gst_riff_parse_strf_auds");
function gst_riff_parse_strf_iavs
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
strf : System.Address;
data : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:71
pragma Import (C, gst_riff_parse_strf_iavs, "gst_riff_parse_strf_iavs");
procedure gst_riff_parse_info
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
taglist : System.Address); -- gst/riff/riff-read.h:76
pragma Import (C, gst_riff_parse_info, "gst_riff_parse_info");
-- * Init.
--
procedure gst_riff_init; -- gst/riff/riff-read.h:83
pragma Import (C, gst_riff_init, "gst_riff_init");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_riff_riff_read_h;
| 17551 | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
with System;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h;
with glib;
with glib.Values;
with System;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_riff_riff_read_h is
-- GStreamer RIFF I/O
-- * Copyright (C) 2003 <NAME> <<EMAIL>>
-- *
-- * riff-read.h: function declarations for parsing a RIFF file
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
-- * Operate using pull_range().
--
function gst_riff_read_chunk
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad;
offset : access GLIB.guint64;
tag : access GLIB.guint32;
chunk_data : System.Address) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn; -- gst/riff/riff-read.h:36
pragma Import (C, gst_riff_read_chunk, "gst_riff_read_chunk");
-- * These functions operate on provided data (the caller is
-- * supposed to strip the chunk headers). The buffer is
-- * provided by the caller, the strf/strh/data are filled in
-- * by the function.
--
function gst_riff_parse_chunk
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
offset : access GLIB.guint;
fourcc : access GLIB.guint32;
chunk_data : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:49
pragma Import (C, gst_riff_parse_chunk, "gst_riff_parse_chunk");
function gst_riff_parse_file_header
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
doctype : access GLIB.guint32) return GLIB.gboolean; -- gst/riff/riff-read.h:55
pragma Import (C, gst_riff_parse_file_header, "gst_riff_parse_file_header");
function gst_riff_parse_strh
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
strh : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:59
pragma Import (C, gst_riff_parse_strh, "gst_riff_parse_strh");
function gst_riff_parse_strf_vids
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
strf : System.Address;
data : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:63
pragma Import (C, gst_riff_parse_strf_vids, "gst_riff_parse_strf_vids");
function gst_riff_parse_strf_auds
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
strf : System.Address;
data : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:67
pragma Import (C, gst_riff_parse_strf_auds, "gst_riff_parse_strf_auds");
function gst_riff_parse_strf_iavs
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
strf : System.Address;
data : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:71
pragma Import (C, gst_riff_parse_strf_iavs, "gst_riff_parse_strf_iavs");
procedure gst_riff_parse_info
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
taglist : System.Address); -- gst/riff/riff-read.h:76
pragma Import (C, gst_riff_parse_info, "gst_riff_parse_info");
-- * Init.
--
procedure gst_riff_init; -- gst/riff/riff-read.h:83
pragma Import (C, gst_riff_init, "gst_riff_init");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_riff_riff_read_h;
| true | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
with System;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h;
with glib;
with glib.Values;
with System;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_riff_riff_read_h is
-- GStreamer RIFF I/O
-- * Copyright (C) 2003 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
-- *
-- * riff-read.h: function declarations for parsing a RIFF file
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
-- * Operate using pull_range().
--
function gst_riff_read_chunk
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad;
offset : access GLIB.guint64;
tag : access GLIB.guint32;
chunk_data : System.Address) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn; -- gst/riff/riff-read.h:36
pragma Import (C, gst_riff_read_chunk, "gst_riff_read_chunk");
-- * These functions operate on provided data (the caller is
-- * supposed to strip the chunk headers). The buffer is
-- * provided by the caller, the strf/strh/data are filled in
-- * by the function.
--
function gst_riff_parse_chunk
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
offset : access GLIB.guint;
fourcc : access GLIB.guint32;
chunk_data : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:49
pragma Import (C, gst_riff_parse_chunk, "gst_riff_parse_chunk");
function gst_riff_parse_file_header
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
doctype : access GLIB.guint32) return GLIB.gboolean; -- gst/riff/riff-read.h:55
pragma Import (C, gst_riff_parse_file_header, "gst_riff_parse_file_header");
function gst_riff_parse_strh
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
strh : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:59
pragma Import (C, gst_riff_parse_strh, "gst_riff_parse_strh");
function gst_riff_parse_strf_vids
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
strf : System.Address;
data : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:63
pragma Import (C, gst_riff_parse_strf_vids, "gst_riff_parse_strf_vids");
function gst_riff_parse_strf_auds
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
strf : System.Address;
data : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:67
pragma Import (C, gst_riff_parse_strf_auds, "gst_riff_parse_strf_auds");
function gst_riff_parse_strf_iavs
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
strf : System.Address;
data : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:71
pragma Import (C, gst_riff_parse_strf_iavs, "gst_riff_parse_strf_iavs");
procedure gst_riff_parse_info
(element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement;
buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
taglist : System.Address); -- gst/riff/riff-read.h:76
pragma Import (C, gst_riff_parse_info, "gst_riff_parse_info");
-- * Init.
--
procedure gst_riff_init; -- gst/riff/riff-read.h:83
pragma Import (C, gst_riff_init, "gst_riff_init");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_riff_riff_read_h;
|
[
{
"context": "lause License\n -- *\n -- * Copyright © 2008-2021, Jice and the libtcod contributors.\n -- * All rights r",
"end": 179,
"score": 0.9457497596740723,
"start": 175,
"tag": "NAME",
"value": "Jice"
}
] | src/generated/mersenne_types_h.ads | csb6/libtcod-ada | 0 | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package mersenne_types_h is
-- BSD 3-Clause License
-- *
-- * Copyright © 2008-2021, Jice and the libtcod contributors.
-- * All rights reserved.
-- *
-- * Redistribution and use in source and binary forms, with or without
-- * modification, are permitted provided that the following conditions are met:
-- *
-- * 1. Redistributions of source code must retain the above copyright notice,
-- * this list of conditions and the following disclaimer.
-- *
-- * 2. Redistributions in binary form must reproduce the above copyright notice,
-- * this list of conditions and the following disclaimer in the documentation
-- * and/or other materials provided with the distribution.
-- *
-- * 3. Neither the name of the copyright holder nor the names of its
-- * contributors may be used to endorse or promote products derived from
-- * this software without specific prior written permission.
-- *
-- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- * POSSIBILITY OF SUCH DAMAGE.
--
type TCOD_Random is null record; -- incomplete struct
type TCOD_random_t is access all TCOD_Random; -- mersenne_types.h:36
-- dice roll
type TCOD_dice_t is record
nb_rolls : aliased int; -- mersenne_types.h:40
nb_faces : aliased int; -- mersenne_types.h:41
multiplier : aliased float; -- mersenne_types.h:42
addsub : aliased float; -- mersenne_types.h:43
end record
with Convention => C_Pass_By_Copy; -- mersenne_types.h:44
-- PRNG algorithms
type TCOD_random_algo_t is
(TCOD_RNG_MT,
TCOD_RNG_CMWC)
with Convention => C; -- mersenne_types.h:47
type TCOD_distribution_t is
(TCOD_DISTRIBUTION_LINEAR,
TCOD_DISTRIBUTION_GAUSSIAN,
TCOD_DISTRIBUTION_GAUSSIAN_RANGE,
TCOD_DISTRIBUTION_GAUSSIAN_INVERSE,
TCOD_DISTRIBUTION_GAUSSIAN_RANGE_INVERSE)
with Convention => C; -- mersenne_types.h:55
end mersenne_types_h;
| 26521 | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package mersenne_types_h is
-- BSD 3-Clause License
-- *
-- * Copyright © 2008-2021, <NAME> and the libtcod contributors.
-- * All rights reserved.
-- *
-- * Redistribution and use in source and binary forms, with or without
-- * modification, are permitted provided that the following conditions are met:
-- *
-- * 1. Redistributions of source code must retain the above copyright notice,
-- * this list of conditions and the following disclaimer.
-- *
-- * 2. Redistributions in binary form must reproduce the above copyright notice,
-- * this list of conditions and the following disclaimer in the documentation
-- * and/or other materials provided with the distribution.
-- *
-- * 3. Neither the name of the copyright holder nor the names of its
-- * contributors may be used to endorse or promote products derived from
-- * this software without specific prior written permission.
-- *
-- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- * POSSIBILITY OF SUCH DAMAGE.
--
type TCOD_Random is null record; -- incomplete struct
type TCOD_random_t is access all TCOD_Random; -- mersenne_types.h:36
-- dice roll
type TCOD_dice_t is record
nb_rolls : aliased int; -- mersenne_types.h:40
nb_faces : aliased int; -- mersenne_types.h:41
multiplier : aliased float; -- mersenne_types.h:42
addsub : aliased float; -- mersenne_types.h:43
end record
with Convention => C_Pass_By_Copy; -- mersenne_types.h:44
-- PRNG algorithms
type TCOD_random_algo_t is
(TCOD_RNG_MT,
TCOD_RNG_CMWC)
with Convention => C; -- mersenne_types.h:47
type TCOD_distribution_t is
(TCOD_DISTRIBUTION_LINEAR,
TCOD_DISTRIBUTION_GAUSSIAN,
TCOD_DISTRIBUTION_GAUSSIAN_RANGE,
TCOD_DISTRIBUTION_GAUSSIAN_INVERSE,
TCOD_DISTRIBUTION_GAUSSIAN_RANGE_INVERSE)
with Convention => C; -- mersenne_types.h:55
end mersenne_types_h;
| true | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package mersenne_types_h is
-- BSD 3-Clause License
-- *
-- * Copyright © 2008-2021, PI:NAME:<NAME>END_PI and the libtcod contributors.
-- * All rights reserved.
-- *
-- * Redistribution and use in source and binary forms, with or without
-- * modification, are permitted provided that the following conditions are met:
-- *
-- * 1. Redistributions of source code must retain the above copyright notice,
-- * this list of conditions and the following disclaimer.
-- *
-- * 2. Redistributions in binary form must reproduce the above copyright notice,
-- * this list of conditions and the following disclaimer in the documentation
-- * and/or other materials provided with the distribution.
-- *
-- * 3. Neither the name of the copyright holder nor the names of its
-- * contributors may be used to endorse or promote products derived from
-- * this software without specific prior written permission.
-- *
-- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- * POSSIBILITY OF SUCH DAMAGE.
--
type TCOD_Random is null record; -- incomplete struct
type TCOD_random_t is access all TCOD_Random; -- mersenne_types.h:36
-- dice roll
type TCOD_dice_t is record
nb_rolls : aliased int; -- mersenne_types.h:40
nb_faces : aliased int; -- mersenne_types.h:41
multiplier : aliased float; -- mersenne_types.h:42
addsub : aliased float; -- mersenne_types.h:43
end record
with Convention => C_Pass_By_Copy; -- mersenne_types.h:44
-- PRNG algorithms
type TCOD_random_algo_t is
(TCOD_RNG_MT,
TCOD_RNG_CMWC)
with Convention => C; -- mersenne_types.h:47
type TCOD_distribution_t is
(TCOD_DISTRIBUTION_LINEAR,
TCOD_DISTRIBUTION_GAUSSIAN,
TCOD_DISTRIBUTION_GAUSSIAN_RANGE,
TCOD_DISTRIBUTION_GAUSSIAN_INVERSE,
TCOD_DISTRIBUTION_GAUSSIAN_RANGE_INVERSE)
with Convention => C; -- mersenne_types.h:55
end mersenne_types_h;
|
[
{
"context": " --\n-- Copyright © 2014-2015, Vadim Godunko <vgodunko@gmail.com> --\n-- All rig",
"end": 829,
"score": 0.9998884201049805,
"start": 816,
"tag": "NAME",
"value": "Vadim Godunko"
},
{
"context": " --\n-- Copyright © 2014-2015, Vadim Godunko <vgodunko@gmail.com> --\n-- All rights reserved. ",
"end": 849,
"score": 0.9999316930770874,
"start": 831,
"tag": "EMAIL",
"value": "vgodunko@gmail.com"
}
] | source/web/tools/a2js/webapi/dom/webapi-dom-parent_nodes.ads | svn2github/matreshka | 24 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Web API Definition --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2015, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This package provides binding to interface ParentNode.
------------------------------------------------------------------------------
limited with WebAPI.DOM.Elements;
with WebAPI.DOM.HTML_Collections;
with WebAPI.DOM.Node_Lists;
package WebAPI.DOM.Parent_Nodes is
pragma Preelaborate;
type Parent_Node is limited interface;
not overriding function Get_Children
(Self : not null access constant Parent_Node)
return WebAPI.DOM.HTML_Collections.HTML_Collection
is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "children";
-- Returns the child elements.
--
-- The children attribute must return an HTMLCollection collection rooted
-- at the context object matching only element children.
not overriding function Get_First_Element_Child
(Self : not null access constant Parent_Node)
return WebAPI.DOM.Elements.Element_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "firstElementChild";
-- Returns the first child that is an element, and null otherwise.
--
-- The firstElementChild attribute must return the first child that is an
-- element, and null otherwise.
not overriding function Get_Last_Element_Child
(Self : not null access constant Parent_Node)
return WebAPI.DOM.Elements.Element_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "lastElementChild";
-- Returns the last child that is an element, and null otherwise.
--
-- The lastElementChild attribute must return the last child that is an
-- element, and null otherwise.
not overriding function Get_Child_Element_Count
(Self : not null access constant Parent_Node)
return Natural is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "childElementCount";
-- The childElementCount attribute must return the number of children of
-- the context object that are elements.
not overriding function Query_Selector
(Self : not null access constant Parent_Node;
Selectors : WebAPI.DOM_String)
return WebAPI.DOM.Elements.Element_Access is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "querySelector";
-- Returns the first element that is a descendant of node that matches
-- selectors.
--
-- The querySelector(selectors) method must return the first result of
-- running scope-match a selectors string selectors against the context
-- object, and null if the result is an empty list otherwise.
not overriding function Query_Selector_All
(Self : not null access constant Parent_Node;
Selectors : WebAPI.DOM_String)
return WebAPI.DOM.Node_Lists.Node_List is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "querySelectorAll";
-- Returns all element descendants of node that match selectors.
--
-- The querySelectorAll(selectors) method must return the static result of
-- running scope-match a selectors string selectors against the context
-- object.
end WebAPI.DOM.Parent_Nodes;
| 30266 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Web API Definition --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2015, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This package provides binding to interface ParentNode.
------------------------------------------------------------------------------
limited with WebAPI.DOM.Elements;
with WebAPI.DOM.HTML_Collections;
with WebAPI.DOM.Node_Lists;
package WebAPI.DOM.Parent_Nodes is
pragma Preelaborate;
type Parent_Node is limited interface;
not overriding function Get_Children
(Self : not null access constant Parent_Node)
return WebAPI.DOM.HTML_Collections.HTML_Collection
is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "children";
-- Returns the child elements.
--
-- The children attribute must return an HTMLCollection collection rooted
-- at the context object matching only element children.
not overriding function Get_First_Element_Child
(Self : not null access constant Parent_Node)
return WebAPI.DOM.Elements.Element_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "firstElementChild";
-- Returns the first child that is an element, and null otherwise.
--
-- The firstElementChild attribute must return the first child that is an
-- element, and null otherwise.
not overriding function Get_Last_Element_Child
(Self : not null access constant Parent_Node)
return WebAPI.DOM.Elements.Element_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "lastElementChild";
-- Returns the last child that is an element, and null otherwise.
--
-- The lastElementChild attribute must return the last child that is an
-- element, and null otherwise.
not overriding function Get_Child_Element_Count
(Self : not null access constant Parent_Node)
return Natural is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "childElementCount";
-- The childElementCount attribute must return the number of children of
-- the context object that are elements.
not overriding function Query_Selector
(Self : not null access constant Parent_Node;
Selectors : WebAPI.DOM_String)
return WebAPI.DOM.Elements.Element_Access is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "querySelector";
-- Returns the first element that is a descendant of node that matches
-- selectors.
--
-- The querySelector(selectors) method must return the first result of
-- running scope-match a selectors string selectors against the context
-- object, and null if the result is an empty list otherwise.
not overriding function Query_Selector_All
(Self : not null access constant Parent_Node;
Selectors : WebAPI.DOM_String)
return WebAPI.DOM.Node_Lists.Node_List is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "querySelectorAll";
-- Returns all element descendants of node that match selectors.
--
-- The querySelectorAll(selectors) method must return the static result of
-- running scope-match a selectors string selectors against the context
-- object.
end WebAPI.DOM.Parent_Nodes;
| true | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Web API Definition --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2015, PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> --
-- 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 binding to interface ParentNode.
------------------------------------------------------------------------------
limited with WebAPI.DOM.Elements;
with WebAPI.DOM.HTML_Collections;
with WebAPI.DOM.Node_Lists;
package WebAPI.DOM.Parent_Nodes is
pragma Preelaborate;
type Parent_Node is limited interface;
not overriding function Get_Children
(Self : not null access constant Parent_Node)
return WebAPI.DOM.HTML_Collections.HTML_Collection
is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "children";
-- Returns the child elements.
--
-- The children attribute must return an HTMLCollection collection rooted
-- at the context object matching only element children.
not overriding function Get_First_Element_Child
(Self : not null access constant Parent_Node)
return WebAPI.DOM.Elements.Element_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "firstElementChild";
-- Returns the first child that is an element, and null otherwise.
--
-- The firstElementChild attribute must return the first child that is an
-- element, and null otherwise.
not overriding function Get_Last_Element_Child
(Self : not null access constant Parent_Node)
return WebAPI.DOM.Elements.Element_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "lastElementChild";
-- Returns the last child that is an element, and null otherwise.
--
-- The lastElementChild attribute must return the last child that is an
-- element, and null otherwise.
not overriding function Get_Child_Element_Count
(Self : not null access constant Parent_Node)
return Natural is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "childElementCount";
-- The childElementCount attribute must return the number of children of
-- the context object that are elements.
not overriding function Query_Selector
(Self : not null access constant Parent_Node;
Selectors : WebAPI.DOM_String)
return WebAPI.DOM.Elements.Element_Access is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "querySelector";
-- Returns the first element that is a descendant of node that matches
-- selectors.
--
-- The querySelector(selectors) method must return the first result of
-- running scope-match a selectors string selectors against the context
-- object, and null if the result is an empty list otherwise.
not overriding function Query_Selector_All
(Self : not null access constant Parent_Node;
Selectors : WebAPI.DOM_String)
return WebAPI.DOM.Node_Lists.Node_List is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "querySelectorAll";
-- Returns all element descendants of node that match selectors.
--
-- The querySelectorAll(selectors) method must return the static result of
-- running scope-match a selectors string selectors against the context
-- object.
end WebAPI.DOM.Parent_Nodes;
|
[
{
"context": "--\n-- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr>\n-- - Ryad Benadjila\n-- - Arnauld Michel",
"end": 64,
"score": 0.9999327659606934,
"start": 46,
"tag": "EMAIL",
"value": "wookey@ssi.gouv.fr"
},
{
"context": "he wookey project team <wookey@ssi.gouv.fr>\n-- - Ryad Benadjila\n-- - Arnauld Michelizza\n-- - Mathieu Renard",
"end": 91,
"score": 0.9946148991584778,
"start": 73,
"tag": "NAME",
"value": "Ryad Benadjila"
},
{
"context": "okey@ssi.gouv.fr>\n-- - Ryad Benadjila\n-- - Arnauld Michelizza\n-- - Mathieu Renard\n-- - Philippe",
"end": 106,
"score": 0.9925621747970581,
"start": 99,
"tag": "NAME",
"value": "Arnauld"
},
{
"context": "gouv.fr>\n-- - Ryad Benadjila\n-- - Arnauld Michelizza\n-- - Mathieu Renard\n-- - Philippe Thierry\n--",
"end": 118,
"score": 0.9161235094070435,
"start": 108,
"tag": "NAME",
"value": "Michelizza"
},
{
"context": "ad Benadjila\n-- - Arnauld Michelizza\n-- - Mathieu Renard\n-- - Philippe Thierry\n-- - Philippe Trebuchet",
"end": 141,
"score": 0.868796706199646,
"start": 126,
"tag": "NAME",
"value": "Mathieu Renard"
},
{
"context": " Arnauld Michelizza\n-- - Mathieu Renard\n-- - Philippe Thierry\n-- - Philippe Trebuchet\n--\n-- Licensed under th",
"end": 165,
"score": 0.9998170137405396,
"start": 149,
"tag": "NAME",
"value": "Philippe Thierry"
},
{
"context": " - Mathieu Renard\n-- - Philippe Thierry\n-- - Philippe Trebuchet\n--\n-- Licensed under the Apache License, Version ",
"end": 191,
"score": 0.9998615980148315,
"start": 173,
"tag": "NAME",
"value": "Philippe Trebuchet"
}
] | src/arch/socs/stm32f439/soc-exti.ads | PThierry/ewok-kernel | 65 | --
-- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with system;
package soc.exti
with spark_mode => on
is
subtype t_exti_line_index is natural range 0 .. 22;
type t_exti_trigger is
(EXTI_TRIGGER_NONE,
EXTI_TRIGGER_RISE,
EXTI_TRIGGER_FALL,
EXTI_TRIGGER_BOTH);
-- Initialize EXTI by enabling SYSCFG.APB2 clock
procedure init;
function is_line_pending
(line : t_exti_line_index)
return boolean;
procedure clear_pending
(line : in t_exti_line_index);
procedure enable
(line : in t_exti_line_index);
procedure disable
(line : in t_exti_line_index)
with inline;
function is_enabled
(line : in t_exti_line_index)
return boolean;
type t_mask is (MASKED, NOT_MASKED) with size => 1;
for t_mask use (MASKED => 0, NOT_MASKED => 1);
type t_masks is array (t_exti_line_index) of t_mask
with volatile_components, pack, size => 23;
----------------------------------------
-- Interrupt mask register (EXTI_IMR) --
----------------------------------------
type t_EXTI_IMR is record
line : t_masks;
end record
with volatile_full_access, size => 32;
for t_EXTI_IMR use record
line at 0 range 0 .. 22;
end record;
------------------------------------
-- Event mask register (EXTI_EMR) --
------------------------------------
type t_EXTI_EMR is record
line : t_masks;
end record
with volatile_full_access, size => 32;
for t_EXTI_EMR use record
line at 0 range 0 .. 22;
end record;
---------------------------------------------------
-- Rising trigger selection register (EXTI_RTSR) --
---------------------------------------------------
type t_trigger is (TRIGGER_DISABLED, TRIGGER_ENABLED) with size => 1;
for t_trigger use (TRIGGER_DISABLED => 0, TRIGGER_ENABLED => 1);
type t_triggers is array (t_exti_line_index) of t_trigger
with pack, size => 23;
type t_EXTI_RTSR is record
line : t_triggers;
end record
with volatile_full_access, size => 32;
for t_EXTI_RTSR use record
line at 0 range 0 .. 22;
end record;
----------------------------------------------------
-- Falling trigger selection register (EXTI_FTSR) --
----------------------------------------------------
type t_EXTI_FTSR is record
line : t_triggers;
end record
with volatile_full_access, size => 32;
for t_EXTI_FTSR use record
line at 0 range 0 .. 22;
end record;
----------------------------------------------------
-- Software interrupt event register (EXTI_SWIER) --
----------------------------------------------------
type t_exti_lines is array (t_exti_line_index) of bit
with pack, size => 23;
type t_EXTI_SWIER is record
line : t_exti_lines;
end record
with volatile_full_access, size => 32;
for t_EXTI_SWIER use record
line at 0 range 0 .. 22;
end record;
--------------------------------
-- Pending register (EXTI_PR) --
--------------------------------
type t_request is (NO_REQUEST, PENDING_REQUEST) with size => 1;
for t_request use (NO_REQUEST => 0, PENDING_REQUEST => 1);
-- Set the bit to '1' to clear it!
CLEAR_REQUEST : constant t_request := PENDING_REQUEST;
type t_requests is array (t_exti_line_index) of t_request
with pack, size => 23;
type t_EXTI_PR is record
line : t_requests;
end record
with volatile_full_access, size => 32;
for t_EXTI_PR use record
line at 0 range 0 .. 22;
end record;
---------------------
-- EXTI peripheral --
---------------------
type t_EXTI_periph is record
IMR : t_EXTI_IMR;
EMR : t_EXTI_EMR;
RTSR : t_EXTI_RTSR;
FTSR : t_EXTI_FTSR;
SWIER : t_EXTI_SWIER;
PR : t_EXTI_PR;
end record
with volatile;
for t_EXTI_periph use record
IMR at 16#00# range 0 .. 31;
EMR at 16#04# range 0 .. 31;
RTSR at 16#08# range 0 .. 31;
FTSR at 16#0C# range 0 .. 31;
SWIER at 16#10# range 0 .. 31;
PR at 16#14# range 0 .. 31;
end record;
EXTI : t_EXTI_periph
with
import,
volatile,
address => system'to_address (16#4001_3C00#); -- 0x40013C00
end soc.exti;
| 1454 | --
-- Copyright 2018 The wookey project team <<EMAIL>>
-- - <NAME>
-- - <NAME> <NAME>
-- - <NAME>
-- - <NAME>
-- - <NAME>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with system;
package soc.exti
with spark_mode => on
is
subtype t_exti_line_index is natural range 0 .. 22;
type t_exti_trigger is
(EXTI_TRIGGER_NONE,
EXTI_TRIGGER_RISE,
EXTI_TRIGGER_FALL,
EXTI_TRIGGER_BOTH);
-- Initialize EXTI by enabling SYSCFG.APB2 clock
procedure init;
function is_line_pending
(line : t_exti_line_index)
return boolean;
procedure clear_pending
(line : in t_exti_line_index);
procedure enable
(line : in t_exti_line_index);
procedure disable
(line : in t_exti_line_index)
with inline;
function is_enabled
(line : in t_exti_line_index)
return boolean;
type t_mask is (MASKED, NOT_MASKED) with size => 1;
for t_mask use (MASKED => 0, NOT_MASKED => 1);
type t_masks is array (t_exti_line_index) of t_mask
with volatile_components, pack, size => 23;
----------------------------------------
-- Interrupt mask register (EXTI_IMR) --
----------------------------------------
type t_EXTI_IMR is record
line : t_masks;
end record
with volatile_full_access, size => 32;
for t_EXTI_IMR use record
line at 0 range 0 .. 22;
end record;
------------------------------------
-- Event mask register (EXTI_EMR) --
------------------------------------
type t_EXTI_EMR is record
line : t_masks;
end record
with volatile_full_access, size => 32;
for t_EXTI_EMR use record
line at 0 range 0 .. 22;
end record;
---------------------------------------------------
-- Rising trigger selection register (EXTI_RTSR) --
---------------------------------------------------
type t_trigger is (TRIGGER_DISABLED, TRIGGER_ENABLED) with size => 1;
for t_trigger use (TRIGGER_DISABLED => 0, TRIGGER_ENABLED => 1);
type t_triggers is array (t_exti_line_index) of t_trigger
with pack, size => 23;
type t_EXTI_RTSR is record
line : t_triggers;
end record
with volatile_full_access, size => 32;
for t_EXTI_RTSR use record
line at 0 range 0 .. 22;
end record;
----------------------------------------------------
-- Falling trigger selection register (EXTI_FTSR) --
----------------------------------------------------
type t_EXTI_FTSR is record
line : t_triggers;
end record
with volatile_full_access, size => 32;
for t_EXTI_FTSR use record
line at 0 range 0 .. 22;
end record;
----------------------------------------------------
-- Software interrupt event register (EXTI_SWIER) --
----------------------------------------------------
type t_exti_lines is array (t_exti_line_index) of bit
with pack, size => 23;
type t_EXTI_SWIER is record
line : t_exti_lines;
end record
with volatile_full_access, size => 32;
for t_EXTI_SWIER use record
line at 0 range 0 .. 22;
end record;
--------------------------------
-- Pending register (EXTI_PR) --
--------------------------------
type t_request is (NO_REQUEST, PENDING_REQUEST) with size => 1;
for t_request use (NO_REQUEST => 0, PENDING_REQUEST => 1);
-- Set the bit to '1' to clear it!
CLEAR_REQUEST : constant t_request := PENDING_REQUEST;
type t_requests is array (t_exti_line_index) of t_request
with pack, size => 23;
type t_EXTI_PR is record
line : t_requests;
end record
with volatile_full_access, size => 32;
for t_EXTI_PR use record
line at 0 range 0 .. 22;
end record;
---------------------
-- EXTI peripheral --
---------------------
type t_EXTI_periph is record
IMR : t_EXTI_IMR;
EMR : t_EXTI_EMR;
RTSR : t_EXTI_RTSR;
FTSR : t_EXTI_FTSR;
SWIER : t_EXTI_SWIER;
PR : t_EXTI_PR;
end record
with volatile;
for t_EXTI_periph use record
IMR at 16#00# range 0 .. 31;
EMR at 16#04# range 0 .. 31;
RTSR at 16#08# range 0 .. 31;
FTSR at 16#0C# range 0 .. 31;
SWIER at 16#10# range 0 .. 31;
PR at 16#14# range 0 .. 31;
end record;
EXTI : t_EXTI_periph
with
import,
volatile,
address => system'to_address (16#4001_3C00#); -- 0x40013C00
end soc.exti;
| true | --
-- Copyright 2018 The wookey project team <PI:EMAIL:<EMAIL>END_PI>
-- - PI:NAME:<NAME>END_PI
-- - PI:NAME:<NAME>END_PI PI:NAME:<NAME>END_PI
-- - PI:NAME:<NAME>END_PI
-- - PI:NAME:<NAME>END_PI
-- - PI:NAME:<NAME>END_PI
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with system;
package soc.exti
with spark_mode => on
is
subtype t_exti_line_index is natural range 0 .. 22;
type t_exti_trigger is
(EXTI_TRIGGER_NONE,
EXTI_TRIGGER_RISE,
EXTI_TRIGGER_FALL,
EXTI_TRIGGER_BOTH);
-- Initialize EXTI by enabling SYSCFG.APB2 clock
procedure init;
function is_line_pending
(line : t_exti_line_index)
return boolean;
procedure clear_pending
(line : in t_exti_line_index);
procedure enable
(line : in t_exti_line_index);
procedure disable
(line : in t_exti_line_index)
with inline;
function is_enabled
(line : in t_exti_line_index)
return boolean;
type t_mask is (MASKED, NOT_MASKED) with size => 1;
for t_mask use (MASKED => 0, NOT_MASKED => 1);
type t_masks is array (t_exti_line_index) of t_mask
with volatile_components, pack, size => 23;
----------------------------------------
-- Interrupt mask register (EXTI_IMR) --
----------------------------------------
type t_EXTI_IMR is record
line : t_masks;
end record
with volatile_full_access, size => 32;
for t_EXTI_IMR use record
line at 0 range 0 .. 22;
end record;
------------------------------------
-- Event mask register (EXTI_EMR) --
------------------------------------
type t_EXTI_EMR is record
line : t_masks;
end record
with volatile_full_access, size => 32;
for t_EXTI_EMR use record
line at 0 range 0 .. 22;
end record;
---------------------------------------------------
-- Rising trigger selection register (EXTI_RTSR) --
---------------------------------------------------
type t_trigger is (TRIGGER_DISABLED, TRIGGER_ENABLED) with size => 1;
for t_trigger use (TRIGGER_DISABLED => 0, TRIGGER_ENABLED => 1);
type t_triggers is array (t_exti_line_index) of t_trigger
with pack, size => 23;
type t_EXTI_RTSR is record
line : t_triggers;
end record
with volatile_full_access, size => 32;
for t_EXTI_RTSR use record
line at 0 range 0 .. 22;
end record;
----------------------------------------------------
-- Falling trigger selection register (EXTI_FTSR) --
----------------------------------------------------
type t_EXTI_FTSR is record
line : t_triggers;
end record
with volatile_full_access, size => 32;
for t_EXTI_FTSR use record
line at 0 range 0 .. 22;
end record;
----------------------------------------------------
-- Software interrupt event register (EXTI_SWIER) --
----------------------------------------------------
type t_exti_lines is array (t_exti_line_index) of bit
with pack, size => 23;
type t_EXTI_SWIER is record
line : t_exti_lines;
end record
with volatile_full_access, size => 32;
for t_EXTI_SWIER use record
line at 0 range 0 .. 22;
end record;
--------------------------------
-- Pending register (EXTI_PR) --
--------------------------------
type t_request is (NO_REQUEST, PENDING_REQUEST) with size => 1;
for t_request use (NO_REQUEST => 0, PENDING_REQUEST => 1);
-- Set the bit to '1' to clear it!
CLEAR_REQUEST : constant t_request := PENDING_REQUEST;
type t_requests is array (t_exti_line_index) of t_request
with pack, size => 23;
type t_EXTI_PR is record
line : t_requests;
end record
with volatile_full_access, size => 32;
for t_EXTI_PR use record
line at 0 range 0 .. 22;
end record;
---------------------
-- EXTI peripheral --
---------------------
type t_EXTI_periph is record
IMR : t_EXTI_IMR;
EMR : t_EXTI_EMR;
RTSR : t_EXTI_RTSR;
FTSR : t_EXTI_FTSR;
SWIER : t_EXTI_SWIER;
PR : t_EXTI_PR;
end record
with volatile;
for t_EXTI_periph use record
IMR at 16#00# range 0 .. 31;
EMR at 16#04# range 0 .. 31;
RTSR at 16#08# range 0 .. 31;
FTSR at 16#0C# range 0 .. 31;
SWIER at 16#10# range 0 .. 31;
PR at 16#14# range 0 .. 31;
end record;
EXTI : t_EXTI_periph
with
import,
volatile,
address => system'to_address (16#4001_3C00#); -- 0x40013C00
end soc.exti;
|
[
{
"context": "--------------------------\n-- Copyright (c) 2019, Daniel King\n-- All rights reserved.\n--\n-- Redistribution an",
"end": 115,
"score": 0.999783992767334,
"start": 104,
"tag": "NAME",
"value": "Daniel King"
}
] | src/common/keccak-padding.ads | damaki/libkeccak | 26 | -------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- 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.
-- * The name of the copyright holder may not 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 BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with Keccak.Types;
-- @summary
-- Implements padding rules.
--
-- @description
-- This package contains the implementation of the pad10*1 padding rule.
--
package Keccak.Padding
with SPARK_Mode => On
is
---------------
-- Pad1*01 --
---------------
-- These padding rules append a 1 bit, followed by zero or more 0 bits,
-- and ending with a final 1 bit.
Pad101_Min_Bits : constant := 2;
-- The pad10*1 rule appends at least 2 bits
procedure Pad101_Multi_Blocks (First_Block : in out Keccak.Types.Byte_Array;
Num_Used_Bits : in Natural;
Max_Bit_Length : in Natural;
Next_Block : out Keccak.Types.Byte_Array;
Spilled : out Boolean)
with Global => null,
Depends => (First_Block =>+ (Num_Used_Bits, Max_Bit_Length),
Next_Block =>+ (Num_Used_Bits, Max_Bit_Length),
Spilled => (Num_Used_Bits, Max_Bit_Length)),
Pre => (Next_Block'Length = First_Block'Length
and then First_Block'Length <= Natural'Last / 8
and then Max_Bit_Length <= Natural'Last - 7
and then First_Block'Length = (Max_Bit_Length + 7) / 8
and then Num_Used_Bits < Max_Bit_Length),
Post => Spilled = ((Num_Used_Bits + Pad101_Min_Bits) > Max_Bit_Length);
-- pad10*1 padding rule
--
-- This procedure is used in cases where there might not be enough free space
-- in a block for all the padding bits, in which case the padding spills
-- over into a second block.
--
-- @param First_Block The block which is to be padded. At least 1 padding bit
-- is applied to this block.
--
-- @param Num_Used_Bits The number of bits which are in-use in First_Block.
-- The padding bits will be applied immediately after this length.
--
-- @param Max_Bit_Length The maximum number of bits that can be stored in
-- First_Block and Next_Block. Padding will only be appended up to this
-- length.
--
-- @param Next_Block If there is less than 2 bits of unused bits in
-- First_Block then the padding continues into this block. If there
-- are at least 2 unused bits in First_Block then Next_Block is not used
-- and is filled with zeroes.
--
-- @param Spilled Set to True if there was not enough unused bits in
-- First_Block to store all of the padding bits. When Spilled is True then
-- both First_Block and Next_Block contain the padded data.
-- Otherwise, Spilled is set to False if there is enough free space in
-- First_Block for all of the padding bits. When Spilled is False then
-- Next_Block is not used.
procedure Pad101_Single_Block (Block : in out Keccak.Types.Byte_Array;
Num_Used_Bits : in Natural;
Max_Bit_Length : in Natural)
with Global => null,
Depends => (Block =>+ (Num_Used_Bits, Max_Bit_Length)),
Pre => (Block'Length <= Natural'Last / 8
and then Max_Bit_Length <= Natural'Last - 7
and then Block'Length = (Max_Bit_Length + 7) / 8
and then Max_Bit_Length >= Pad101_Min_Bits
and then Num_Used_Bits <= (Max_Bit_Length - Pad101_Min_Bits));
-- pad10*1 padding rule
--
-- This procedure is used in cases where there is always enough space for
-- the padding bits (at least 2 bits free in the block).
--
-- Before calling this function there must be at least 2 bits free in the
-- block. I.e. Num_Used_Bits <= (Max_Bit_Length - 2).
--
-- @param Block The byte array which is to be padded.
--
-- @param Num_Used_Bits The number of bits which are currently in-use in the
-- block. The padding bits are appended after these in-use bits.
--
-- @param Max_Bit_Length The maximum bit-size of the block. Padding bits
-- are applied up to the end of this length.
generic
State_Size_Bits : Positive;
type State_Type is private;
with procedure XOR_Byte_Into_State (State : in out State_Type;
Offset : in Natural;
Value : in Keccak.Types.Byte);
procedure XOR_Pad101_Into_State (State : in out State_Type;
First_Bit : in Natural;
Last_Bit : in Natural)
with Global => null,
Depends => (State =>+ (First_Bit, Last_Bit)),
Pre => (Last_Bit < State_Size_Bits and First_Bit < Last_Bit);
--------------
-- Pad10 --*
--------------
-- The Pad10* rule only appends a 1 bit followed by at least one 0 bit.
Pad10_Min_Bits : constant := 2;
-- The pad10*1 rule appends at least 2 bits
procedure Pad10_Multi_Blocks_Big_Endian (First_Block : in out Keccak.Types.Byte_Array;
Num_Used_Bits : in Natural;
Max_Bit_Length : in Natural;
Next_Block : out Keccak.Types.Byte_Array;
Spilled : out Boolean)
with Global => null,
Pre => (Next_Block'Length = First_Block'Length
and then First_Block'Length <= Natural'Last / 8
and then Max_Bit_Length <= Natural'Last - 7
and then First_Block'Length = (Max_Bit_Length + 7) / 8
and then Num_Used_Bits < Max_Bit_Length),
Post => Spilled = ((Num_Used_Bits + Pad10_Min_Bits) > Max_Bit_Length);
-- pad10* padding rule
--
-- This procedure is used in cases where there might not be enough free space
-- in a block for all the padding bits, in which case the padding spills
-- over into a second block.
--
-- This is a big endian version intended for use in Ascon-Hash. This means
-- that the padding bit added starts from the MSB (16#80#) instead of the
-- LSB (16#01#). In the case where Num_Used_Bits is not a multiple of 8,
-- the partial byte of the block is shifted towards the MSB.
--
-- For example, if the last byte of the input data is 2#0000_0011# then
-- it is shifted to align to the MSB and becomes 2#1100_0000#. Next, the
-- padding bit is added: 2#1110_0000#.
--
-- @param First_Block The block which is to be padded. At least 1 padding bit
-- is applied to this block.
--
-- @param Num_Used_Bits The number of bits which are in-use in First_Block.
-- The padding bits will be applied immediately after this length.
--
-- @param Max_Bit_Length The maximum number of bits that can be stored in
-- First_Block and Next_Block. Padding will only be appended up to this
-- length.
--
-- @param Next_Block If there is less than 2 bits of unused bits in
-- First_Block then the padding continues into this block. If there
-- are at least 2 unused bits in First_Block then Next_Block is not used
-- and is filled with zeroes.
--
-- @param Spilled Set to True if there was not enough unused bits in
-- First_Block to store all of the padding bits. When Spilled is True then
-- both First_Block and Next_Block contain the padded data.
-- Otherwise, Spilled is set to False if there is enough free space in
-- First_Block for all of the padding bits. When Spilled is False then
-- Next_Block is not used.
end Keccak.Padding;
| 18629 | -------------------------------------------------------------------------------
-- Copyright (c) 2019, <NAME>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not 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 BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with Keccak.Types;
-- @summary
-- Implements padding rules.
--
-- @description
-- This package contains the implementation of the pad10*1 padding rule.
--
package Keccak.Padding
with SPARK_Mode => On
is
---------------
-- Pad1*01 --
---------------
-- These padding rules append a 1 bit, followed by zero or more 0 bits,
-- and ending with a final 1 bit.
Pad101_Min_Bits : constant := 2;
-- The pad10*1 rule appends at least 2 bits
procedure Pad101_Multi_Blocks (First_Block : in out Keccak.Types.Byte_Array;
Num_Used_Bits : in Natural;
Max_Bit_Length : in Natural;
Next_Block : out Keccak.Types.Byte_Array;
Spilled : out Boolean)
with Global => null,
Depends => (First_Block =>+ (Num_Used_Bits, Max_Bit_Length),
Next_Block =>+ (Num_Used_Bits, Max_Bit_Length),
Spilled => (Num_Used_Bits, Max_Bit_Length)),
Pre => (Next_Block'Length = First_Block'Length
and then First_Block'Length <= Natural'Last / 8
and then Max_Bit_Length <= Natural'Last - 7
and then First_Block'Length = (Max_Bit_Length + 7) / 8
and then Num_Used_Bits < Max_Bit_Length),
Post => Spilled = ((Num_Used_Bits + Pad101_Min_Bits) > Max_Bit_Length);
-- pad10*1 padding rule
--
-- This procedure is used in cases where there might not be enough free space
-- in a block for all the padding bits, in which case the padding spills
-- over into a second block.
--
-- @param First_Block The block which is to be padded. At least 1 padding bit
-- is applied to this block.
--
-- @param Num_Used_Bits The number of bits which are in-use in First_Block.
-- The padding bits will be applied immediately after this length.
--
-- @param Max_Bit_Length The maximum number of bits that can be stored in
-- First_Block and Next_Block. Padding will only be appended up to this
-- length.
--
-- @param Next_Block If there is less than 2 bits of unused bits in
-- First_Block then the padding continues into this block. If there
-- are at least 2 unused bits in First_Block then Next_Block is not used
-- and is filled with zeroes.
--
-- @param Spilled Set to True if there was not enough unused bits in
-- First_Block to store all of the padding bits. When Spilled is True then
-- both First_Block and Next_Block contain the padded data.
-- Otherwise, Spilled is set to False if there is enough free space in
-- First_Block for all of the padding bits. When Spilled is False then
-- Next_Block is not used.
procedure Pad101_Single_Block (Block : in out Keccak.Types.Byte_Array;
Num_Used_Bits : in Natural;
Max_Bit_Length : in Natural)
with Global => null,
Depends => (Block =>+ (Num_Used_Bits, Max_Bit_Length)),
Pre => (Block'Length <= Natural'Last / 8
and then Max_Bit_Length <= Natural'Last - 7
and then Block'Length = (Max_Bit_Length + 7) / 8
and then Max_Bit_Length >= Pad101_Min_Bits
and then Num_Used_Bits <= (Max_Bit_Length - Pad101_Min_Bits));
-- pad10*1 padding rule
--
-- This procedure is used in cases where there is always enough space for
-- the padding bits (at least 2 bits free in the block).
--
-- Before calling this function there must be at least 2 bits free in the
-- block. I.e. Num_Used_Bits <= (Max_Bit_Length - 2).
--
-- @param Block The byte array which is to be padded.
--
-- @param Num_Used_Bits The number of bits which are currently in-use in the
-- block. The padding bits are appended after these in-use bits.
--
-- @param Max_Bit_Length The maximum bit-size of the block. Padding bits
-- are applied up to the end of this length.
generic
State_Size_Bits : Positive;
type State_Type is private;
with procedure XOR_Byte_Into_State (State : in out State_Type;
Offset : in Natural;
Value : in Keccak.Types.Byte);
procedure XOR_Pad101_Into_State (State : in out State_Type;
First_Bit : in Natural;
Last_Bit : in Natural)
with Global => null,
Depends => (State =>+ (First_Bit, Last_Bit)),
Pre => (Last_Bit < State_Size_Bits and First_Bit < Last_Bit);
--------------
-- Pad10 --*
--------------
-- The Pad10* rule only appends a 1 bit followed by at least one 0 bit.
Pad10_Min_Bits : constant := 2;
-- The pad10*1 rule appends at least 2 bits
procedure Pad10_Multi_Blocks_Big_Endian (First_Block : in out Keccak.Types.Byte_Array;
Num_Used_Bits : in Natural;
Max_Bit_Length : in Natural;
Next_Block : out Keccak.Types.Byte_Array;
Spilled : out Boolean)
with Global => null,
Pre => (Next_Block'Length = First_Block'Length
and then First_Block'Length <= Natural'Last / 8
and then Max_Bit_Length <= Natural'Last - 7
and then First_Block'Length = (Max_Bit_Length + 7) / 8
and then Num_Used_Bits < Max_Bit_Length),
Post => Spilled = ((Num_Used_Bits + Pad10_Min_Bits) > Max_Bit_Length);
-- pad10* padding rule
--
-- This procedure is used in cases where there might not be enough free space
-- in a block for all the padding bits, in which case the padding spills
-- over into a second block.
--
-- This is a big endian version intended for use in Ascon-Hash. This means
-- that the padding bit added starts from the MSB (16#80#) instead of the
-- LSB (16#01#). In the case where Num_Used_Bits is not a multiple of 8,
-- the partial byte of the block is shifted towards the MSB.
--
-- For example, if the last byte of the input data is 2#0000_0011# then
-- it is shifted to align to the MSB and becomes 2#1100_0000#. Next, the
-- padding bit is added: 2#1110_0000#.
--
-- @param First_Block The block which is to be padded. At least 1 padding bit
-- is applied to this block.
--
-- @param Num_Used_Bits The number of bits which are in-use in First_Block.
-- The padding bits will be applied immediately after this length.
--
-- @param Max_Bit_Length The maximum number of bits that can be stored in
-- First_Block and Next_Block. Padding will only be appended up to this
-- length.
--
-- @param Next_Block If there is less than 2 bits of unused bits in
-- First_Block then the padding continues into this block. If there
-- are at least 2 unused bits in First_Block then Next_Block is not used
-- and is filled with zeroes.
--
-- @param Spilled Set to True if there was not enough unused bits in
-- First_Block to store all of the padding bits. When Spilled is True then
-- both First_Block and Next_Block contain the padded data.
-- Otherwise, Spilled is set to False if there is enough free space in
-- First_Block for all of the padding bits. When Spilled is False then
-- Next_Block is not used.
end Keccak.Padding;
| true | -------------------------------------------------------------------------------
-- Copyright (c) 2019, PI:NAME:<NAME>END_PI
-- 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.
-- * The name of the copyright holder may not 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 BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with Keccak.Types;
-- @summary
-- Implements padding rules.
--
-- @description
-- This package contains the implementation of the pad10*1 padding rule.
--
package Keccak.Padding
with SPARK_Mode => On
is
---------------
-- Pad1*01 --
---------------
-- These padding rules append a 1 bit, followed by zero or more 0 bits,
-- and ending with a final 1 bit.
Pad101_Min_Bits : constant := 2;
-- The pad10*1 rule appends at least 2 bits
procedure Pad101_Multi_Blocks (First_Block : in out Keccak.Types.Byte_Array;
Num_Used_Bits : in Natural;
Max_Bit_Length : in Natural;
Next_Block : out Keccak.Types.Byte_Array;
Spilled : out Boolean)
with Global => null,
Depends => (First_Block =>+ (Num_Used_Bits, Max_Bit_Length),
Next_Block =>+ (Num_Used_Bits, Max_Bit_Length),
Spilled => (Num_Used_Bits, Max_Bit_Length)),
Pre => (Next_Block'Length = First_Block'Length
and then First_Block'Length <= Natural'Last / 8
and then Max_Bit_Length <= Natural'Last - 7
and then First_Block'Length = (Max_Bit_Length + 7) / 8
and then Num_Used_Bits < Max_Bit_Length),
Post => Spilled = ((Num_Used_Bits + Pad101_Min_Bits) > Max_Bit_Length);
-- pad10*1 padding rule
--
-- This procedure is used in cases where there might not be enough free space
-- in a block for all the padding bits, in which case the padding spills
-- over into a second block.
--
-- @param First_Block The block which is to be padded. At least 1 padding bit
-- is applied to this block.
--
-- @param Num_Used_Bits The number of bits which are in-use in First_Block.
-- The padding bits will be applied immediately after this length.
--
-- @param Max_Bit_Length The maximum number of bits that can be stored in
-- First_Block and Next_Block. Padding will only be appended up to this
-- length.
--
-- @param Next_Block If there is less than 2 bits of unused bits in
-- First_Block then the padding continues into this block. If there
-- are at least 2 unused bits in First_Block then Next_Block is not used
-- and is filled with zeroes.
--
-- @param Spilled Set to True if there was not enough unused bits in
-- First_Block to store all of the padding bits. When Spilled is True then
-- both First_Block and Next_Block contain the padded data.
-- Otherwise, Spilled is set to False if there is enough free space in
-- First_Block for all of the padding bits. When Spilled is False then
-- Next_Block is not used.
procedure Pad101_Single_Block (Block : in out Keccak.Types.Byte_Array;
Num_Used_Bits : in Natural;
Max_Bit_Length : in Natural)
with Global => null,
Depends => (Block =>+ (Num_Used_Bits, Max_Bit_Length)),
Pre => (Block'Length <= Natural'Last / 8
and then Max_Bit_Length <= Natural'Last - 7
and then Block'Length = (Max_Bit_Length + 7) / 8
and then Max_Bit_Length >= Pad101_Min_Bits
and then Num_Used_Bits <= (Max_Bit_Length - Pad101_Min_Bits));
-- pad10*1 padding rule
--
-- This procedure is used in cases where there is always enough space for
-- the padding bits (at least 2 bits free in the block).
--
-- Before calling this function there must be at least 2 bits free in the
-- block. I.e. Num_Used_Bits <= (Max_Bit_Length - 2).
--
-- @param Block The byte array which is to be padded.
--
-- @param Num_Used_Bits The number of bits which are currently in-use in the
-- block. The padding bits are appended after these in-use bits.
--
-- @param Max_Bit_Length The maximum bit-size of the block. Padding bits
-- are applied up to the end of this length.
generic
State_Size_Bits : Positive;
type State_Type is private;
with procedure XOR_Byte_Into_State (State : in out State_Type;
Offset : in Natural;
Value : in Keccak.Types.Byte);
procedure XOR_Pad101_Into_State (State : in out State_Type;
First_Bit : in Natural;
Last_Bit : in Natural)
with Global => null,
Depends => (State =>+ (First_Bit, Last_Bit)),
Pre => (Last_Bit < State_Size_Bits and First_Bit < Last_Bit);
--------------
-- Pad10 --*
--------------
-- The Pad10* rule only appends a 1 bit followed by at least one 0 bit.
Pad10_Min_Bits : constant := 2;
-- The pad10*1 rule appends at least 2 bits
procedure Pad10_Multi_Blocks_Big_Endian (First_Block : in out Keccak.Types.Byte_Array;
Num_Used_Bits : in Natural;
Max_Bit_Length : in Natural;
Next_Block : out Keccak.Types.Byte_Array;
Spilled : out Boolean)
with Global => null,
Pre => (Next_Block'Length = First_Block'Length
and then First_Block'Length <= Natural'Last / 8
and then Max_Bit_Length <= Natural'Last - 7
and then First_Block'Length = (Max_Bit_Length + 7) / 8
and then Num_Used_Bits < Max_Bit_Length),
Post => Spilled = ((Num_Used_Bits + Pad10_Min_Bits) > Max_Bit_Length);
-- pad10* padding rule
--
-- This procedure is used in cases where there might not be enough free space
-- in a block for all the padding bits, in which case the padding spills
-- over into a second block.
--
-- This is a big endian version intended for use in Ascon-Hash. This means
-- that the padding bit added starts from the MSB (16#80#) instead of the
-- LSB (16#01#). In the case where Num_Used_Bits is not a multiple of 8,
-- the partial byte of the block is shifted towards the MSB.
--
-- For example, if the last byte of the input data is 2#0000_0011# then
-- it is shifted to align to the MSB and becomes 2#1100_0000#. Next, the
-- padding bit is added: 2#1110_0000#.
--
-- @param First_Block The block which is to be padded. At least 1 padding bit
-- is applied to this block.
--
-- @param Num_Used_Bits The number of bits which are in-use in First_Block.
-- The padding bits will be applied immediately after this length.
--
-- @param Max_Bit_Length The maximum number of bits that can be stored in
-- First_Block and Next_Block. Padding will only be appended up to this
-- length.
--
-- @param Next_Block If there is less than 2 bits of unused bits in
-- First_Block then the padding continues into this block. If there
-- are at least 2 unused bits in First_Block then Next_Block is not used
-- and is filled with zeroes.
--
-- @param Spilled Set to True if there was not enough unused bits in
-- First_Block to store all of the padding bits. When Spilled is True then
-- both First_Block and Next_Block contain the padded data.
-- Otherwise, Spilled is set to False if there is enough free space in
-- First_Block for all of the padding bits. When Spilled is False then
-- Next_Block is not used.
end Keccak.Padding;
|
[
{
"context": "mer with Snowball generator\n-- Copyright (C) 2020 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@g",
"end": 172,
"score": 0.9998782873153687,
"start": 157,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": " Copyright (C) 2020 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under",
"end": 203,
"score": 0.9998812675476074,
"start": 188,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "0 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under the Apache License, Versio",
"end": 230,
"score": 0.9999281167984009,
"start": 205,
"tag": "EMAIL",
"value": "Stephane.Carrez@gmail.com"
}
] | src/stemmer.ads | stcarrez/ada-stemmer | 3 | -----------------------------------------------------------------------
-- stemmer -- Multi-language stemmer with Snowball generator
-- 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.
-----------------------------------------------------------------------
package Stemmer with SPARK_Mode is
WORD_MAX_LENGTH : constant := 1024;
type Context_Type is abstract tagged private;
-- Apply the stemming algorithm on the word initialized in the context.
procedure Stem (Context : in out Context_Type;
Result : out Boolean) is abstract;
-- Stem the word and return True if it was reduced.
procedure Stem_Word (Context : in out Context_Type'Class;
Word : in String;
Result : out Boolean) with
Global => null,
Pre => Word'Length < WORD_MAX_LENGTH;
-- Get the stem or the input word unmodified.
function Get_Result (Context : in Context_Type'Class) return String with
Global => null,
Post => Get_Result'Result'Length < WORD_MAX_LENGTH;
private
type Mask_Type is mod 2**32;
-- A 32-bit character value that was read from UTF-8 sequence.
-- A modular value is used because shift and logical arithmetic is necessary.
type Utf8_Type is mod 2**32;
-- Index of the Grouping_Array. The index comes from the 32-bit character value
-- minus a starting offset. We don't expect large tables and we check against
-- a maximum value.
subtype Grouping_Index is Utf8_Type range 0 .. 16384;
type Grouping_Array is array (Grouping_Index range <>) of Boolean with Pack;
subtype Among_Index is Natural range 0 .. 65535;
subtype Among_Start_Index is Among_Index range 1 .. Among_Index'Last;
subtype Operation_Index is Natural range 0 .. 65535;
subtype Result_Index is Integer range -1 .. WORD_MAX_LENGTH - 1;
subtype Char_Index is Result_Index range 0 .. Result_Index'Last;
type Among_Type is record
First : Among_Start_Index;
Last : Among_Index;
Substring_I : Integer;
Result : Integer;
Operation : Operation_Index;
end record;
type Among_Array_Type is array (Natural range <>) of Among_Type;
function Eq_S (Context : in Context_Type'Class;
S : in String) return Char_Index with
Global => null,
Pre => S'Length > 0,
Post => Eq_S'Result = 0 or Eq_S'Result = S'Length;
function Eq_S_Backward (Context : in Context_Type'Class;
S : in String) return Char_Index with
Global => null,
Pre => S'Length > 0,
Post => Eq_S_Backward'Result = 0 or Eq_S_Backward'Result = S'Length;
procedure Find_Among (Context : in out Context_Type'Class;
Amongs : in Among_Array_Type;
Pattern : in String;
Execute : access procedure
(Ctx : in out Context_Type'Class;
Operation : in Operation_Index;
Status : out Boolean);
Result : out Integer) with
Global => null,
Pre => Pattern'Length > 0 and Amongs'Length > 0;
procedure Find_Among_Backward (Context : in out Context_Type'Class;
Amongs : in Among_Array_Type;
Pattern : in String;
Execute : access procedure
(Ctx : in out Context_Type'Class;
Operation : in Operation_Index;
Status : out Boolean);
Result : out Integer) with
Global => null,
Pre => Pattern'Length > 0 and Amongs'Length > 0;
function Skip_Utf8 (Context : in Context_Type'Class) return Result_Index with
Global => null;
function Skip_Utf8 (Context : in Context_Type'Class;
N : in Positive) return Result_Index with
Global => null;
function Skip_Utf8_Backward (Context : in Context_Type'Class) return Result_Index with
Global => null;
function Skip_Utf8_Backward (Context : in Context_Type'Class;
N : in Positive) return Result_Index with
Global => null;
procedure Get_Utf8 (Context : in Context_Type'Class;
Value : out Utf8_Type;
Count : out Natural);
procedure Get_Utf8_Backward (Context : in Context_Type'Class;
Value : out Utf8_Type;
Count : out Natural);
function Length (Context : in Context_Type'Class) return Natural;
function Length_Utf8 (Context : in Context_Type'Class) return Natural;
function Check_Among (Context : in Context_Type'Class;
Pos : in Char_Index;
Shift : in Natural;
Mask : in Mask_Type) return Boolean;
procedure Out_Grouping (Context : in out Context_Type'Class;
S : in Grouping_Array;
Min : in Utf8_Type;
Max : in Utf8_Type;
Repeat : in Boolean;
Result : out Result_Index);
procedure Out_Grouping_Backward (Context : in out Context_Type'Class;
S : in Grouping_Array;
Min : in Utf8_Type;
Max : in Utf8_Type;
Repeat : in Boolean;
Result : out Result_Index);
procedure In_Grouping (Context : in out Context_Type'Class;
S : in Grouping_Array;
Min : in Utf8_Type;
Max : in Utf8_Type;
Repeat : in Boolean;
Result : out Result_Index);
procedure In_Grouping_Backward (Context : in out Context_Type'Class;
S : in Grouping_Array;
Min : in Utf8_Type;
Max : in Utf8_Type;
Repeat : in Boolean;
Result : out Result_Index);
procedure Replace (Context : in out Context_Type'Class;
C_Bra : in Char_Index;
C_Ket : in Char_Index;
S : in String;
Adjustment : out Integer) with
Global => null,
Pre => C_Bra >= Context.Lb and C_Ket >= C_Bra and C_Ket <= Context.L;
procedure Slice_Del (Context : in out Context_Type'Class) with
Global => null,
Pre => Context.Bra >= Context.Lb and Context.Ket >= Context.Bra
and Context.Ket <= Context.L;
procedure Slice_From (Context : in out Context_Type'Class;
Text : in String) with
Global => null,
Pre => Context.Bra >= Context.Lb and Context.Ket >= Context.Bra
and Context.Ket <= Context.L
and Context.L - Context.Lb + Text'Length + Context.Ket - Context.Bra < Context.P'Length;
function Slice_To (Context : in Context_Type'Class) return String;
procedure Insert (Context : in out Context_Type'Class;
C_Bra : in Char_Index;
C_Ket : in Char_Index;
S : in String) with
Global => null,
Pre => C_Bra >= Context.Lb and C_Ket >= C_Bra and C_Ket <= Context.L;
-- The context indexes follow the C paradigm: they start at 0 for the first character.
-- This is necessary because several algorithms rely on this when they compare the
-- cursor position ('C') or setup some markers from the cursor.
type Context_Type is abstract tagged record
C : Char_Index := 0;
L : Char_Index := 0;
Lb : Char_Index := 0;
Bra : Char_Index := 0;
Ket : Char_Index := 0;
P : String (1 .. WORD_MAX_LENGTH);
end record;
end Stemmer;
| 26486 | -----------------------------------------------------------------------
-- stemmer -- Multi-language stemmer with Snowball generator
-- Copyright (C) 2020 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package Stemmer with SPARK_Mode is
WORD_MAX_LENGTH : constant := 1024;
type Context_Type is abstract tagged private;
-- Apply the stemming algorithm on the word initialized in the context.
procedure Stem (Context : in out Context_Type;
Result : out Boolean) is abstract;
-- Stem the word and return True if it was reduced.
procedure Stem_Word (Context : in out Context_Type'Class;
Word : in String;
Result : out Boolean) with
Global => null,
Pre => Word'Length < WORD_MAX_LENGTH;
-- Get the stem or the input word unmodified.
function Get_Result (Context : in Context_Type'Class) return String with
Global => null,
Post => Get_Result'Result'Length < WORD_MAX_LENGTH;
private
type Mask_Type is mod 2**32;
-- A 32-bit character value that was read from UTF-8 sequence.
-- A modular value is used because shift and logical arithmetic is necessary.
type Utf8_Type is mod 2**32;
-- Index of the Grouping_Array. The index comes from the 32-bit character value
-- minus a starting offset. We don't expect large tables and we check against
-- a maximum value.
subtype Grouping_Index is Utf8_Type range 0 .. 16384;
type Grouping_Array is array (Grouping_Index range <>) of Boolean with Pack;
subtype Among_Index is Natural range 0 .. 65535;
subtype Among_Start_Index is Among_Index range 1 .. Among_Index'Last;
subtype Operation_Index is Natural range 0 .. 65535;
subtype Result_Index is Integer range -1 .. WORD_MAX_LENGTH - 1;
subtype Char_Index is Result_Index range 0 .. Result_Index'Last;
type Among_Type is record
First : Among_Start_Index;
Last : Among_Index;
Substring_I : Integer;
Result : Integer;
Operation : Operation_Index;
end record;
type Among_Array_Type is array (Natural range <>) of Among_Type;
function Eq_S (Context : in Context_Type'Class;
S : in String) return Char_Index with
Global => null,
Pre => S'Length > 0,
Post => Eq_S'Result = 0 or Eq_S'Result = S'Length;
function Eq_S_Backward (Context : in Context_Type'Class;
S : in String) return Char_Index with
Global => null,
Pre => S'Length > 0,
Post => Eq_S_Backward'Result = 0 or Eq_S_Backward'Result = S'Length;
procedure Find_Among (Context : in out Context_Type'Class;
Amongs : in Among_Array_Type;
Pattern : in String;
Execute : access procedure
(Ctx : in out Context_Type'Class;
Operation : in Operation_Index;
Status : out Boolean);
Result : out Integer) with
Global => null,
Pre => Pattern'Length > 0 and Amongs'Length > 0;
procedure Find_Among_Backward (Context : in out Context_Type'Class;
Amongs : in Among_Array_Type;
Pattern : in String;
Execute : access procedure
(Ctx : in out Context_Type'Class;
Operation : in Operation_Index;
Status : out Boolean);
Result : out Integer) with
Global => null,
Pre => Pattern'Length > 0 and Amongs'Length > 0;
function Skip_Utf8 (Context : in Context_Type'Class) return Result_Index with
Global => null;
function Skip_Utf8 (Context : in Context_Type'Class;
N : in Positive) return Result_Index with
Global => null;
function Skip_Utf8_Backward (Context : in Context_Type'Class) return Result_Index with
Global => null;
function Skip_Utf8_Backward (Context : in Context_Type'Class;
N : in Positive) return Result_Index with
Global => null;
procedure Get_Utf8 (Context : in Context_Type'Class;
Value : out Utf8_Type;
Count : out Natural);
procedure Get_Utf8_Backward (Context : in Context_Type'Class;
Value : out Utf8_Type;
Count : out Natural);
function Length (Context : in Context_Type'Class) return Natural;
function Length_Utf8 (Context : in Context_Type'Class) return Natural;
function Check_Among (Context : in Context_Type'Class;
Pos : in Char_Index;
Shift : in Natural;
Mask : in Mask_Type) return Boolean;
procedure Out_Grouping (Context : in out Context_Type'Class;
S : in Grouping_Array;
Min : in Utf8_Type;
Max : in Utf8_Type;
Repeat : in Boolean;
Result : out Result_Index);
procedure Out_Grouping_Backward (Context : in out Context_Type'Class;
S : in Grouping_Array;
Min : in Utf8_Type;
Max : in Utf8_Type;
Repeat : in Boolean;
Result : out Result_Index);
procedure In_Grouping (Context : in out Context_Type'Class;
S : in Grouping_Array;
Min : in Utf8_Type;
Max : in Utf8_Type;
Repeat : in Boolean;
Result : out Result_Index);
procedure In_Grouping_Backward (Context : in out Context_Type'Class;
S : in Grouping_Array;
Min : in Utf8_Type;
Max : in Utf8_Type;
Repeat : in Boolean;
Result : out Result_Index);
procedure Replace (Context : in out Context_Type'Class;
C_Bra : in Char_Index;
C_Ket : in Char_Index;
S : in String;
Adjustment : out Integer) with
Global => null,
Pre => C_Bra >= Context.Lb and C_Ket >= C_Bra and C_Ket <= Context.L;
procedure Slice_Del (Context : in out Context_Type'Class) with
Global => null,
Pre => Context.Bra >= Context.Lb and Context.Ket >= Context.Bra
and Context.Ket <= Context.L;
procedure Slice_From (Context : in out Context_Type'Class;
Text : in String) with
Global => null,
Pre => Context.Bra >= Context.Lb and Context.Ket >= Context.Bra
and Context.Ket <= Context.L
and Context.L - Context.Lb + Text'Length + Context.Ket - Context.Bra < Context.P'Length;
function Slice_To (Context : in Context_Type'Class) return String;
procedure Insert (Context : in out Context_Type'Class;
C_Bra : in Char_Index;
C_Ket : in Char_Index;
S : in String) with
Global => null,
Pre => C_Bra >= Context.Lb and C_Ket >= C_Bra and C_Ket <= Context.L;
-- The context indexes follow the C paradigm: they start at 0 for the first character.
-- This is necessary because several algorithms rely on this when they compare the
-- cursor position ('C') or setup some markers from the cursor.
type Context_Type is abstract tagged record
C : Char_Index := 0;
L : Char_Index := 0;
Lb : Char_Index := 0;
Bra : Char_Index := 0;
Ket : Char_Index := 0;
P : String (1 .. WORD_MAX_LENGTH);
end record;
end Stemmer;
| true | -----------------------------------------------------------------------
-- stemmer -- Multi-language stemmer with Snowball generator
-- Copyright (C) 2020 PI:NAME:<NAME>END_PI
-- Written by PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package Stemmer with SPARK_Mode is
WORD_MAX_LENGTH : constant := 1024;
type Context_Type is abstract tagged private;
-- Apply the stemming algorithm on the word initialized in the context.
procedure Stem (Context : in out Context_Type;
Result : out Boolean) is abstract;
-- Stem the word and return True if it was reduced.
procedure Stem_Word (Context : in out Context_Type'Class;
Word : in String;
Result : out Boolean) with
Global => null,
Pre => Word'Length < WORD_MAX_LENGTH;
-- Get the stem or the input word unmodified.
function Get_Result (Context : in Context_Type'Class) return String with
Global => null,
Post => Get_Result'Result'Length < WORD_MAX_LENGTH;
private
type Mask_Type is mod 2**32;
-- A 32-bit character value that was read from UTF-8 sequence.
-- A modular value is used because shift and logical arithmetic is necessary.
type Utf8_Type is mod 2**32;
-- Index of the Grouping_Array. The index comes from the 32-bit character value
-- minus a starting offset. We don't expect large tables and we check against
-- a maximum value.
subtype Grouping_Index is Utf8_Type range 0 .. 16384;
type Grouping_Array is array (Grouping_Index range <>) of Boolean with Pack;
subtype Among_Index is Natural range 0 .. 65535;
subtype Among_Start_Index is Among_Index range 1 .. Among_Index'Last;
subtype Operation_Index is Natural range 0 .. 65535;
subtype Result_Index is Integer range -1 .. WORD_MAX_LENGTH - 1;
subtype Char_Index is Result_Index range 0 .. Result_Index'Last;
type Among_Type is record
First : Among_Start_Index;
Last : Among_Index;
Substring_I : Integer;
Result : Integer;
Operation : Operation_Index;
end record;
type Among_Array_Type is array (Natural range <>) of Among_Type;
function Eq_S (Context : in Context_Type'Class;
S : in String) return Char_Index with
Global => null,
Pre => S'Length > 0,
Post => Eq_S'Result = 0 or Eq_S'Result = S'Length;
function Eq_S_Backward (Context : in Context_Type'Class;
S : in String) return Char_Index with
Global => null,
Pre => S'Length > 0,
Post => Eq_S_Backward'Result = 0 or Eq_S_Backward'Result = S'Length;
procedure Find_Among (Context : in out Context_Type'Class;
Amongs : in Among_Array_Type;
Pattern : in String;
Execute : access procedure
(Ctx : in out Context_Type'Class;
Operation : in Operation_Index;
Status : out Boolean);
Result : out Integer) with
Global => null,
Pre => Pattern'Length > 0 and Amongs'Length > 0;
procedure Find_Among_Backward (Context : in out Context_Type'Class;
Amongs : in Among_Array_Type;
Pattern : in String;
Execute : access procedure
(Ctx : in out Context_Type'Class;
Operation : in Operation_Index;
Status : out Boolean);
Result : out Integer) with
Global => null,
Pre => Pattern'Length > 0 and Amongs'Length > 0;
function Skip_Utf8 (Context : in Context_Type'Class) return Result_Index with
Global => null;
function Skip_Utf8 (Context : in Context_Type'Class;
N : in Positive) return Result_Index with
Global => null;
function Skip_Utf8_Backward (Context : in Context_Type'Class) return Result_Index with
Global => null;
function Skip_Utf8_Backward (Context : in Context_Type'Class;
N : in Positive) return Result_Index with
Global => null;
procedure Get_Utf8 (Context : in Context_Type'Class;
Value : out Utf8_Type;
Count : out Natural);
procedure Get_Utf8_Backward (Context : in Context_Type'Class;
Value : out Utf8_Type;
Count : out Natural);
function Length (Context : in Context_Type'Class) return Natural;
function Length_Utf8 (Context : in Context_Type'Class) return Natural;
function Check_Among (Context : in Context_Type'Class;
Pos : in Char_Index;
Shift : in Natural;
Mask : in Mask_Type) return Boolean;
procedure Out_Grouping (Context : in out Context_Type'Class;
S : in Grouping_Array;
Min : in Utf8_Type;
Max : in Utf8_Type;
Repeat : in Boolean;
Result : out Result_Index);
procedure Out_Grouping_Backward (Context : in out Context_Type'Class;
S : in Grouping_Array;
Min : in Utf8_Type;
Max : in Utf8_Type;
Repeat : in Boolean;
Result : out Result_Index);
procedure In_Grouping (Context : in out Context_Type'Class;
S : in Grouping_Array;
Min : in Utf8_Type;
Max : in Utf8_Type;
Repeat : in Boolean;
Result : out Result_Index);
procedure In_Grouping_Backward (Context : in out Context_Type'Class;
S : in Grouping_Array;
Min : in Utf8_Type;
Max : in Utf8_Type;
Repeat : in Boolean;
Result : out Result_Index);
procedure Replace (Context : in out Context_Type'Class;
C_Bra : in Char_Index;
C_Ket : in Char_Index;
S : in String;
Adjustment : out Integer) with
Global => null,
Pre => C_Bra >= Context.Lb and C_Ket >= C_Bra and C_Ket <= Context.L;
procedure Slice_Del (Context : in out Context_Type'Class) with
Global => null,
Pre => Context.Bra >= Context.Lb and Context.Ket >= Context.Bra
and Context.Ket <= Context.L;
procedure Slice_From (Context : in out Context_Type'Class;
Text : in String) with
Global => null,
Pre => Context.Bra >= Context.Lb and Context.Ket >= Context.Bra
and Context.Ket <= Context.L
and Context.L - Context.Lb + Text'Length + Context.Ket - Context.Bra < Context.P'Length;
function Slice_To (Context : in Context_Type'Class) return String;
procedure Insert (Context : in out Context_Type'Class;
C_Bra : in Char_Index;
C_Ket : in Char_Index;
S : in String) with
Global => null,
Pre => C_Bra >= Context.Lb and C_Ket >= C_Bra and C_Ket <= Context.L;
-- The context indexes follow the C paradigm: they start at 0 for the first character.
-- This is necessary because several algorithms rely on this when they compare the
-- cursor position ('C') or setup some markers from the cursor.
type Context_Type is abstract tagged record
C : Char_Index := 0;
L : Char_Index := 0;
Lb : Char_Index := 0;
Bra : Char_Index := 0;
Ket : Char_Index := 0;
P : String (1 .. WORD_MAX_LENGTH);
end record;
end Stemmer;
|
[
{
"context": "perations\n-- Copyright (C) 2011, 2012, 2018, 2019 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@g",
"end": 194,
"score": 0.9998763799667358,
"start": 179,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "1, 2012, 2018, 2019 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under",
"end": 225,
"score": 0.9998849630355835,
"start": 210,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "9 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under the Apache License, Versio",
"end": 252,
"score": 0.9999297261238098,
"start": 227,
"tag": "EMAIL",
"value": "Stephane.Carrez@gmail.com"
}
] | src/sys/os-windows/util-processes-os.adb | My-Colaborations/ada-util | 0 | -----------------------------------------------------------------------
-- util-processes-os -- System specific and low level operations
-- Copyright (C) 2011, 2012, 2018, 2019 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 System;
with Ada.Unchecked_Deallocation;
with Ada.Characters.Conversions;
with Ada.Directories;
with Util.Log.Loggers;
package body Util.Processes.Os is
use type Interfaces.C.size_t;
use type Util.Systems.Os.HANDLE;
use type Ada.Directories.File_Kind;
use type System.Address;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Processes.Os");
procedure Free is
new Ada.Unchecked_Deallocation (Object => Interfaces.C.wchar_array,
Name => Wchar_Ptr);
procedure Prepare_Working_Directory (Sys : in out System_Process;
Proc : in out Process'Class);
procedure Redirect_Output (Path : in Wchar_Ptr;
Append : in Boolean;
Output : out HANDLE);
procedure Redirect_Input (Path : in Wchar_Ptr;
Input : out HANDLE);
-- ------------------------------
-- Wait for the process to exit.
-- ------------------------------
overriding
procedure Wait (Sys : in out System_Process;
Proc : in out Process'Class;
Timeout : in Duration) is
use type Util.Streams.Output_Stream_Access;
Result : DWORD;
T : DWORD;
Code : aliased DWORD;
Status : BOOL;
begin
-- Close the input stream pipe if there is one.
if Proc.Input /= null then
Util.Streams.Raw.Raw_Stream'Class (Proc.Input.all).Close;
end if;
if Timeout < 0.0 then
T := DWORD'Last;
else
T := DWORD (Timeout * 1000.0);
Log.Debug ("Waiting {0} ms", DWORD'Image (T));
end if;
Result := Wait_For_Single_Object (H => Sys.Process_Info.hProcess,
Time => T);
Log.Debug ("Status {0}", DWORD'Image (Result));
Status := Get_Exit_Code_Process (Proc => Sys.Process_Info.hProcess,
Code => Code'Unchecked_Access);
if Status = 0 then
Log.Error ("Process is still running. Error {0}", Integer'Image (Get_Last_Error));
end if;
Proc.Exit_Value := Integer (Code);
Log.Debug ("Process exit is: {0}", Integer'Image (Proc.Exit_Value));
end Wait;
-- ------------------------------
-- Terminate the process by sending a signal on Unix and exiting the process on Windows.
-- This operation is not portable and has a different behavior between Unix and Windows.
-- Its intent is to stop the process.
-- ------------------------------
overriding
procedure Stop (Sys : in out System_Process;
Proc : in out Process'Class;
Signal : in Positive := 15) is
pragma Unreferenced (Proc);
Result : Integer;
pragma Unreferenced (Result);
begin
Result := Terminate_Process (Sys.Process_Info.hProcess, DWORD (Signal));
end Stop;
procedure Prepare_Working_Directory (Sys : in out System_Process;
Proc : in out Process'Class) is
Dir : constant String := Ada.Strings.Unbounded.To_String (Proc.Dir);
begin
Free (Sys.Dir);
if Dir'Length > 0 then
if not Ada.Directories.Exists (Dir)
or else Ada.Directories.Kind (Dir) /= Ada.Directories.Directory
then
raise Ada.Directories.Name_Error with "Invalid directory: " & Dir;
end if;
Sys.Dir := To_WSTR (Dir);
end if;
end Prepare_Working_Directory;
procedure Redirect_Output (Path : in Wchar_Ptr;
Append : in Boolean;
Output : out HANDLE) is
Sec : aliased Security_Attributes;
begin
Sec.Length := Security_Attributes'Size / 8;
Sec.Security_Descriptor := System.Null_Address;
Sec.Inherit := 1;
Output := Create_File (Path.all'Address,
(if Append then FILE_APPEND_DATA else GENERIC_WRITE),
FILE_SHARE_WRITE + FILE_SHARE_READ,
Sec'Unchecked_Access,
(if Append then OPEN_ALWAYS else CREATE_ALWAYS),
FILE_ATTRIBUTE_NORMAL,
NO_FILE);
if Output = INVALID_HANDLE_VALUE then
Log.Error ("Cannot create process output file: {0}", Integer'Image (Get_Last_Error));
raise Process_Error with "Cannot create process output file";
end if;
end Redirect_Output;
procedure Redirect_Input (Path : in Wchar_Ptr;
Input : out HANDLE) is
Sec : aliased Security_Attributes;
begin
Sec.Length := Security_Attributes'Size / 8;
Sec.Security_Descriptor := System.Null_Address;
Sec.Inherit := 1;
Input := Create_File (Path.all'Address,
GENERIC_READ,
FILE_SHARE_READ,
Sec'Unchecked_Access,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NO_FILE);
if Input = INVALID_HANDLE_VALUE then
Log.Error ("Cannot open process input file: {0}", Integer'Image (Get_Last_Error));
raise Process_Error with "Cannot open process input file";
end if;
end Redirect_Input;
-- ------------------------------
-- Spawn a new process.
-- ------------------------------
overriding
procedure Spawn (Sys : in out System_Process;
Proc : in out Process'Class;
Mode : in Pipe_Mode := NONE) is
use Interfaces.C;
Result : Integer;
Startup : aliased Startup_Info;
R : BOOL with Unreferenced;
begin
Sys.Prepare_Working_Directory (Proc);
-- Since checks are disabled, verify by hand that the argv table is correct.
if Sys.Command = null or else Sys.Command'Length < 1 then
raise Program_Error with "Invalid process argument list";
end if;
Startup.cb := Startup'Size / 8;
Startup.hStdInput := Get_Std_Handle (STD_INPUT_HANDLE);
Startup.hStdOutput := Get_Std_Handle (STD_OUTPUT_HANDLE);
Startup.hStdError := Get_Std_Handle (STD_ERROR_HANDLE);
if Sys.Out_File /= null then
Redirect_Output (Sys.Out_File, Sys.Out_Append, Startup.hStdOutput);
Startup.dwFlags := 16#100#;
end if;
if Sys.Err_File /= null then
Redirect_Output (Sys.Err_File, Sys.Err_Append, Startup.hStdError);
Startup.dwFlags := 16#100#;
end if;
if Sys.In_File /= null then
Redirect_Input (Sys.In_File, Startup.hStdInput);
Startup.dwFlags := 16#100#;
end if;
if Mode = WRITE or Mode = READ_WRITE or Mode = READ_WRITE_ALL then
Build_Input_Pipe (Sys, Proc, Startup);
end if;
if Mode = READ or Mode = READ_WRITE or Mode = READ_ALL or Mode = READ_WRITE_ALL then
Build_Output_Pipe (Sys, Proc, Startup, Mode);
end if;
-- Start the child process.
if Sys.Dir /= null then
Result := Create_Process (System.Null_Address,
Sys.Command.all'Address,
null,
null,
1,
16#0#,
System.Null_Address,
Sys.Dir.all'Address,
Startup'Unchecked_Access,
Sys.Process_Info'Unchecked_Access);
else
Result := Create_Process (System.Null_Address,
Sys.Command.all'Address,
null,
null,
1,
16#0#,
System.Null_Address,
System.Null_Address,
Startup'Unchecked_Access,
Sys.Process_Info'Unchecked_Access);
end if;
-- Close the handles which are not necessary.
if Startup.hStdInput /= Get_Std_Handle (STD_INPUT_HANDLE) then
R := Close_Handle (Startup.hStdInput);
end if;
if Startup.hStdOutput /= Get_Std_Handle (STD_OUTPUT_HANDLE) then
R := Close_Handle (Startup.hStdOutput);
end if;
if Startup.hStdError /= Get_Std_Handle (STD_ERROR_HANDLE) then
R := Close_Handle (Startup.hStdError);
end if;
if Result /= 1 then
Result := Get_Last_Error;
Log.Error ("Process creation failed: {0}", Integer'Image (Result));
raise Process_Error with "Cannot create process " & Integer'Image (Result);
end if;
Proc.Pid := Process_Identifier (Sys.Process_Info.dwProcessId);
end Spawn;
-- ------------------------------
-- Create the output stream to read/write on the process input/output.
-- Setup the file to be closed on exec.
-- ------------------------------
function Create_Stream (File : in Util.Streams.Raw.File_Type)
return Util.Streams.Raw.Raw_Stream_Access is
Stream : constant Util.Streams.Raw.Raw_Stream_Access := new Util.Streams.Raw.Raw_Stream;
begin
Stream.Initialize (File);
return Stream;
end Create_Stream;
-- ------------------------------
-- Build the output pipe redirection to read the process output.
-- ------------------------------
procedure Build_Output_Pipe (Sys : in out System_Process;
Proc : in out Process'Class;
Into : in out Startup_Info;
Mode : in Pipe_Mode) is
Sec : aliased Security_Attributes;
Read_Handle : aliased HANDLE;
Write_Handle : aliased HANDLE;
Read_Pipe_Handle : aliased HANDLE;
Error_Handle : aliased HANDLE;
Result : BOOL;
R : BOOL with Unreferenced;
Current_Proc : constant HANDLE := Get_Current_Process;
Redirect_Error : constant Boolean := Mode = READ_ALL or Mode = READ_WRITE_ALL;
begin
Sec.Length := Sec'Size / 8;
Sec.Inherit := 1;
Sec.Security_Descriptor := System.Null_Address;
Result := Create_Pipe (Read_Handle => Read_Handle'Unchecked_Access,
Write_Handle => Write_Handle'Unchecked_Access,
Attributes => Sec'Unchecked_Access,
Buf_Size => 0);
if Result = 0 then
Log.Error ("Cannot create pipe: {0}", Integer'Image (Get_Last_Error));
raise Program_Error with "Cannot create pipe";
end if;
Result := Duplicate_Handle (SourceProcessHandle => Current_Proc,
SourceHandle => Read_Handle,
TargetProcessHandle => Current_Proc,
TargetHandle => Read_Pipe_Handle'Unchecked_Access,
DesiredAccess => 0,
InheritHandle => 0,
Options => 2);
if Result = 0 then
Log.Error ("Cannot create pipe: {0}", Integer'Image (Get_Last_Error));
raise Program_Error with "Cannot create pipe";
end if;
R := Close_Handle (Read_Handle);
if Redirect_Error and Sys.Out_File = null and Sys.Err_File = null then
Result := Duplicate_Handle (SourceProcessHandle => Current_Proc,
SourceHandle => Write_Handle,
TargetProcessHandle => Current_Proc,
TargetHandle => Error_Handle'Unchecked_Access,
DesiredAccess => 0,
InheritHandle => 1,
Options => 2);
if Result = 0 then
Log.Error ("Cannot create pipe: {0}", Integer'Image (Get_Last_Error));
raise Program_Error with "Cannot create pipe";
end if;
elsif Sys.Out_File /= null then
Error_Handle := Write_Handle;
end if;
Into.dwFlags := 16#100#;
if Sys.Out_File = null then
Into.hStdOutput := Write_Handle;
end if;
if Redirect_Error and Sys.Err_File = null then
Into.hStdError := Error_Handle;
end if;
Proc.Output := Create_Stream (Read_Pipe_Handle).all'Access;
end Build_Output_Pipe;
-- ------------------------------
-- Build the input pipe redirection to write the process standard input.
-- ------------------------------
procedure Build_Input_Pipe (Sys : in out System_Process;
Proc : in out Process'Class;
Into : in out Startup_Info) is
pragma Unreferenced (Sys);
Sec : aliased Security_Attributes;
Read_Handle : aliased HANDLE;
Write_Handle : aliased HANDLE;
Write_Pipe_Handle : aliased HANDLE;
Result : BOOL;
R : BOOL with Unreferenced;
Current_Proc : constant HANDLE := Get_Current_Process;
begin
Sec.Length := Sec'Size / 8;
Sec.Inherit := 1;
Sec.Security_Descriptor := System.Null_Address;
Result := Create_Pipe (Read_Handle => Read_Handle'Unchecked_Access,
Write_Handle => Write_Handle'Unchecked_Access,
Attributes => Sec'Unchecked_Access,
Buf_Size => 0);
if Result = 0 then
Log.Error ("Cannot create pipe: {0}", Integer'Image (Get_Last_Error));
raise Program_Error with "Cannot create pipe";
end if;
Result := Duplicate_Handle (SourceProcessHandle => Current_Proc,
SourceHandle => Write_Handle,
TargetProcessHandle => Current_Proc,
TargetHandle => Write_Pipe_Handle'Unchecked_Access,
DesiredAccess => 0,
InheritHandle => 0,
Options => 2);
if Result = 0 then
Log.Error ("Cannot create pipe: {0}", Integer'Image (Get_Last_Error));
raise Program_Error with "Cannot create pipe";
end if;
R := Close_Handle (Write_Handle);
Into.dwFlags := 16#100#;
Into.hStdInput := Read_Handle;
Proc.Input := Create_Stream (Write_Pipe_Handle).all'Access;
end Build_Input_Pipe;
-- ------------------------------
-- Append the argument to the process argument list.
-- ------------------------------
overriding
procedure Append_Argument (Sys : in out System_Process;
Arg : in String) is
Len : Interfaces.C.size_t := Arg'Length;
begin
if Sys.Command /= null then
Len := Len + Sys.Command'Length + 2;
declare
S : constant Wchar_Ptr := new Interfaces.C.wchar_array (0 .. Len);
begin
S (Sys.Command'Range) := Sys.Command.all;
Free (Sys.Command);
Sys.Command := S;
end;
Sys.Command (Sys.Pos) := Interfaces.C.To_C (' ');
Sys.Pos := Sys.Pos + 1;
else
Sys.Command := new Interfaces.C.wchar_array (0 .. Len + 1);
Sys.Pos := 0;
end if;
for I in Arg'Range loop
Sys.Command (Sys.Pos)
:= Interfaces.C.To_C (Ada.Characters.Conversions.To_Wide_Character (Arg (I)));
Sys.Pos := Sys.Pos + 1;
end loop;
Sys.Command (Sys.Pos) := Interfaces.C.wide_nul;
end Append_Argument;
-- ------------------------------
-- Set the process input, output and error streams to redirect and use specified files.
-- ------------------------------
overriding
procedure Set_Streams (Sys : in out System_Process;
Input : in String;
Output : in String;
Error : in String;
Append_Output : in Boolean;
Append_Error : in Boolean;
To_Close : in File_Type_Array_Access) is
begin
if Input'Length > 0 then
Log.Info ("Redirect input {0}", Input);
Sys.In_File := To_WSTR (Input);
end if;
if Output'Length > 0 then
Log.Info ("Redirect output {0}", Output);
Sys.Out_File := To_WSTR (Output);
Sys.Out_Append := Append_Output;
end if;
if Error'Length > 0 then
Sys.Err_File := To_WSTR (Error);
Sys.Err_Append := Append_Error;
end if;
Sys.To_Close := To_Close;
end Set_Streams;
-- ------------------------------
-- Deletes the storage held by the system process.
-- ------------------------------
overriding
procedure Finalize (Sys : in out System_Process) is
Result : BOOL;
pragma Unreferenced (Result);
begin
if Sys.Process_Info.hProcess /= NO_FILE then
Result := Close_Handle (Sys.Process_Info.hProcess);
Sys.Process_Info.hProcess := NO_FILE;
end if;
if Sys.Process_Info.hThread /= NO_FILE then
Result := Close_Handle (Sys.Process_Info.hThread);
Sys.Process_Info.hThread := NO_FILE;
end if;
Free (Sys.In_File);
Free (Sys.Out_File);
Free (Sys.Err_File);
Free (Sys.Dir);
Free (Sys.Command);
end Finalize;
end Util.Processes.Os;
| 19367 | -----------------------------------------------------------------------
-- util-processes-os -- System specific and low level operations
-- Copyright (C) 2011, 2012, 2018, 2019 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with System;
with Ada.Unchecked_Deallocation;
with Ada.Characters.Conversions;
with Ada.Directories;
with Util.Log.Loggers;
package body Util.Processes.Os is
use type Interfaces.C.size_t;
use type Util.Systems.Os.HANDLE;
use type Ada.Directories.File_Kind;
use type System.Address;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Processes.Os");
procedure Free is
new Ada.Unchecked_Deallocation (Object => Interfaces.C.wchar_array,
Name => Wchar_Ptr);
procedure Prepare_Working_Directory (Sys : in out System_Process;
Proc : in out Process'Class);
procedure Redirect_Output (Path : in Wchar_Ptr;
Append : in Boolean;
Output : out HANDLE);
procedure Redirect_Input (Path : in Wchar_Ptr;
Input : out HANDLE);
-- ------------------------------
-- Wait for the process to exit.
-- ------------------------------
overriding
procedure Wait (Sys : in out System_Process;
Proc : in out Process'Class;
Timeout : in Duration) is
use type Util.Streams.Output_Stream_Access;
Result : DWORD;
T : DWORD;
Code : aliased DWORD;
Status : BOOL;
begin
-- Close the input stream pipe if there is one.
if Proc.Input /= null then
Util.Streams.Raw.Raw_Stream'Class (Proc.Input.all).Close;
end if;
if Timeout < 0.0 then
T := DWORD'Last;
else
T := DWORD (Timeout * 1000.0);
Log.Debug ("Waiting {0} ms", DWORD'Image (T));
end if;
Result := Wait_For_Single_Object (H => Sys.Process_Info.hProcess,
Time => T);
Log.Debug ("Status {0}", DWORD'Image (Result));
Status := Get_Exit_Code_Process (Proc => Sys.Process_Info.hProcess,
Code => Code'Unchecked_Access);
if Status = 0 then
Log.Error ("Process is still running. Error {0}", Integer'Image (Get_Last_Error));
end if;
Proc.Exit_Value := Integer (Code);
Log.Debug ("Process exit is: {0}", Integer'Image (Proc.Exit_Value));
end Wait;
-- ------------------------------
-- Terminate the process by sending a signal on Unix and exiting the process on Windows.
-- This operation is not portable and has a different behavior between Unix and Windows.
-- Its intent is to stop the process.
-- ------------------------------
overriding
procedure Stop (Sys : in out System_Process;
Proc : in out Process'Class;
Signal : in Positive := 15) is
pragma Unreferenced (Proc);
Result : Integer;
pragma Unreferenced (Result);
begin
Result := Terminate_Process (Sys.Process_Info.hProcess, DWORD (Signal));
end Stop;
procedure Prepare_Working_Directory (Sys : in out System_Process;
Proc : in out Process'Class) is
Dir : constant String := Ada.Strings.Unbounded.To_String (Proc.Dir);
begin
Free (Sys.Dir);
if Dir'Length > 0 then
if not Ada.Directories.Exists (Dir)
or else Ada.Directories.Kind (Dir) /= Ada.Directories.Directory
then
raise Ada.Directories.Name_Error with "Invalid directory: " & Dir;
end if;
Sys.Dir := To_WSTR (Dir);
end if;
end Prepare_Working_Directory;
procedure Redirect_Output (Path : in Wchar_Ptr;
Append : in Boolean;
Output : out HANDLE) is
Sec : aliased Security_Attributes;
begin
Sec.Length := Security_Attributes'Size / 8;
Sec.Security_Descriptor := System.Null_Address;
Sec.Inherit := 1;
Output := Create_File (Path.all'Address,
(if Append then FILE_APPEND_DATA else GENERIC_WRITE),
FILE_SHARE_WRITE + FILE_SHARE_READ,
Sec'Unchecked_Access,
(if Append then OPEN_ALWAYS else CREATE_ALWAYS),
FILE_ATTRIBUTE_NORMAL,
NO_FILE);
if Output = INVALID_HANDLE_VALUE then
Log.Error ("Cannot create process output file: {0}", Integer'Image (Get_Last_Error));
raise Process_Error with "Cannot create process output file";
end if;
end Redirect_Output;
procedure Redirect_Input (Path : in Wchar_Ptr;
Input : out HANDLE) is
Sec : aliased Security_Attributes;
begin
Sec.Length := Security_Attributes'Size / 8;
Sec.Security_Descriptor := System.Null_Address;
Sec.Inherit := 1;
Input := Create_File (Path.all'Address,
GENERIC_READ,
FILE_SHARE_READ,
Sec'Unchecked_Access,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NO_FILE);
if Input = INVALID_HANDLE_VALUE then
Log.Error ("Cannot open process input file: {0}", Integer'Image (Get_Last_Error));
raise Process_Error with "Cannot open process input file";
end if;
end Redirect_Input;
-- ------------------------------
-- Spawn a new process.
-- ------------------------------
overriding
procedure Spawn (Sys : in out System_Process;
Proc : in out Process'Class;
Mode : in Pipe_Mode := NONE) is
use Interfaces.C;
Result : Integer;
Startup : aliased Startup_Info;
R : BOOL with Unreferenced;
begin
Sys.Prepare_Working_Directory (Proc);
-- Since checks are disabled, verify by hand that the argv table is correct.
if Sys.Command = null or else Sys.Command'Length < 1 then
raise Program_Error with "Invalid process argument list";
end if;
Startup.cb := Startup'Size / 8;
Startup.hStdInput := Get_Std_Handle (STD_INPUT_HANDLE);
Startup.hStdOutput := Get_Std_Handle (STD_OUTPUT_HANDLE);
Startup.hStdError := Get_Std_Handle (STD_ERROR_HANDLE);
if Sys.Out_File /= null then
Redirect_Output (Sys.Out_File, Sys.Out_Append, Startup.hStdOutput);
Startup.dwFlags := 16#100#;
end if;
if Sys.Err_File /= null then
Redirect_Output (Sys.Err_File, Sys.Err_Append, Startup.hStdError);
Startup.dwFlags := 16#100#;
end if;
if Sys.In_File /= null then
Redirect_Input (Sys.In_File, Startup.hStdInput);
Startup.dwFlags := 16#100#;
end if;
if Mode = WRITE or Mode = READ_WRITE or Mode = READ_WRITE_ALL then
Build_Input_Pipe (Sys, Proc, Startup);
end if;
if Mode = READ or Mode = READ_WRITE or Mode = READ_ALL or Mode = READ_WRITE_ALL then
Build_Output_Pipe (Sys, Proc, Startup, Mode);
end if;
-- Start the child process.
if Sys.Dir /= null then
Result := Create_Process (System.Null_Address,
Sys.Command.all'Address,
null,
null,
1,
16#0#,
System.Null_Address,
Sys.Dir.all'Address,
Startup'Unchecked_Access,
Sys.Process_Info'Unchecked_Access);
else
Result := Create_Process (System.Null_Address,
Sys.Command.all'Address,
null,
null,
1,
16#0#,
System.Null_Address,
System.Null_Address,
Startup'Unchecked_Access,
Sys.Process_Info'Unchecked_Access);
end if;
-- Close the handles which are not necessary.
if Startup.hStdInput /= Get_Std_Handle (STD_INPUT_HANDLE) then
R := Close_Handle (Startup.hStdInput);
end if;
if Startup.hStdOutput /= Get_Std_Handle (STD_OUTPUT_HANDLE) then
R := Close_Handle (Startup.hStdOutput);
end if;
if Startup.hStdError /= Get_Std_Handle (STD_ERROR_HANDLE) then
R := Close_Handle (Startup.hStdError);
end if;
if Result /= 1 then
Result := Get_Last_Error;
Log.Error ("Process creation failed: {0}", Integer'Image (Result));
raise Process_Error with "Cannot create process " & Integer'Image (Result);
end if;
Proc.Pid := Process_Identifier (Sys.Process_Info.dwProcessId);
end Spawn;
-- ------------------------------
-- Create the output stream to read/write on the process input/output.
-- Setup the file to be closed on exec.
-- ------------------------------
function Create_Stream (File : in Util.Streams.Raw.File_Type)
return Util.Streams.Raw.Raw_Stream_Access is
Stream : constant Util.Streams.Raw.Raw_Stream_Access := new Util.Streams.Raw.Raw_Stream;
begin
Stream.Initialize (File);
return Stream;
end Create_Stream;
-- ------------------------------
-- Build the output pipe redirection to read the process output.
-- ------------------------------
procedure Build_Output_Pipe (Sys : in out System_Process;
Proc : in out Process'Class;
Into : in out Startup_Info;
Mode : in Pipe_Mode) is
Sec : aliased Security_Attributes;
Read_Handle : aliased HANDLE;
Write_Handle : aliased HANDLE;
Read_Pipe_Handle : aliased HANDLE;
Error_Handle : aliased HANDLE;
Result : BOOL;
R : BOOL with Unreferenced;
Current_Proc : constant HANDLE := Get_Current_Process;
Redirect_Error : constant Boolean := Mode = READ_ALL or Mode = READ_WRITE_ALL;
begin
Sec.Length := Sec'Size / 8;
Sec.Inherit := 1;
Sec.Security_Descriptor := System.Null_Address;
Result := Create_Pipe (Read_Handle => Read_Handle'Unchecked_Access,
Write_Handle => Write_Handle'Unchecked_Access,
Attributes => Sec'Unchecked_Access,
Buf_Size => 0);
if Result = 0 then
Log.Error ("Cannot create pipe: {0}", Integer'Image (Get_Last_Error));
raise Program_Error with "Cannot create pipe";
end if;
Result := Duplicate_Handle (SourceProcessHandle => Current_Proc,
SourceHandle => Read_Handle,
TargetProcessHandle => Current_Proc,
TargetHandle => Read_Pipe_Handle'Unchecked_Access,
DesiredAccess => 0,
InheritHandle => 0,
Options => 2);
if Result = 0 then
Log.Error ("Cannot create pipe: {0}", Integer'Image (Get_Last_Error));
raise Program_Error with "Cannot create pipe";
end if;
R := Close_Handle (Read_Handle);
if Redirect_Error and Sys.Out_File = null and Sys.Err_File = null then
Result := Duplicate_Handle (SourceProcessHandle => Current_Proc,
SourceHandle => Write_Handle,
TargetProcessHandle => Current_Proc,
TargetHandle => Error_Handle'Unchecked_Access,
DesiredAccess => 0,
InheritHandle => 1,
Options => 2);
if Result = 0 then
Log.Error ("Cannot create pipe: {0}", Integer'Image (Get_Last_Error));
raise Program_Error with "Cannot create pipe";
end if;
elsif Sys.Out_File /= null then
Error_Handle := Write_Handle;
end if;
Into.dwFlags := 16#100#;
if Sys.Out_File = null then
Into.hStdOutput := Write_Handle;
end if;
if Redirect_Error and Sys.Err_File = null then
Into.hStdError := Error_Handle;
end if;
Proc.Output := Create_Stream (Read_Pipe_Handle).all'Access;
end Build_Output_Pipe;
-- ------------------------------
-- Build the input pipe redirection to write the process standard input.
-- ------------------------------
procedure Build_Input_Pipe (Sys : in out System_Process;
Proc : in out Process'Class;
Into : in out Startup_Info) is
pragma Unreferenced (Sys);
Sec : aliased Security_Attributes;
Read_Handle : aliased HANDLE;
Write_Handle : aliased HANDLE;
Write_Pipe_Handle : aliased HANDLE;
Result : BOOL;
R : BOOL with Unreferenced;
Current_Proc : constant HANDLE := Get_Current_Process;
begin
Sec.Length := Sec'Size / 8;
Sec.Inherit := 1;
Sec.Security_Descriptor := System.Null_Address;
Result := Create_Pipe (Read_Handle => Read_Handle'Unchecked_Access,
Write_Handle => Write_Handle'Unchecked_Access,
Attributes => Sec'Unchecked_Access,
Buf_Size => 0);
if Result = 0 then
Log.Error ("Cannot create pipe: {0}", Integer'Image (Get_Last_Error));
raise Program_Error with "Cannot create pipe";
end if;
Result := Duplicate_Handle (SourceProcessHandle => Current_Proc,
SourceHandle => Write_Handle,
TargetProcessHandle => Current_Proc,
TargetHandle => Write_Pipe_Handle'Unchecked_Access,
DesiredAccess => 0,
InheritHandle => 0,
Options => 2);
if Result = 0 then
Log.Error ("Cannot create pipe: {0}", Integer'Image (Get_Last_Error));
raise Program_Error with "Cannot create pipe";
end if;
R := Close_Handle (Write_Handle);
Into.dwFlags := 16#100#;
Into.hStdInput := Read_Handle;
Proc.Input := Create_Stream (Write_Pipe_Handle).all'Access;
end Build_Input_Pipe;
-- ------------------------------
-- Append the argument to the process argument list.
-- ------------------------------
overriding
procedure Append_Argument (Sys : in out System_Process;
Arg : in String) is
Len : Interfaces.C.size_t := Arg'Length;
begin
if Sys.Command /= null then
Len := Len + Sys.Command'Length + 2;
declare
S : constant Wchar_Ptr := new Interfaces.C.wchar_array (0 .. Len);
begin
S (Sys.Command'Range) := Sys.Command.all;
Free (Sys.Command);
Sys.Command := S;
end;
Sys.Command (Sys.Pos) := Interfaces.C.To_C (' ');
Sys.Pos := Sys.Pos + 1;
else
Sys.Command := new Interfaces.C.wchar_array (0 .. Len + 1);
Sys.Pos := 0;
end if;
for I in Arg'Range loop
Sys.Command (Sys.Pos)
:= Interfaces.C.To_C (Ada.Characters.Conversions.To_Wide_Character (Arg (I)));
Sys.Pos := Sys.Pos + 1;
end loop;
Sys.Command (Sys.Pos) := Interfaces.C.wide_nul;
end Append_Argument;
-- ------------------------------
-- Set the process input, output and error streams to redirect and use specified files.
-- ------------------------------
overriding
procedure Set_Streams (Sys : in out System_Process;
Input : in String;
Output : in String;
Error : in String;
Append_Output : in Boolean;
Append_Error : in Boolean;
To_Close : in File_Type_Array_Access) is
begin
if Input'Length > 0 then
Log.Info ("Redirect input {0}", Input);
Sys.In_File := To_WSTR (Input);
end if;
if Output'Length > 0 then
Log.Info ("Redirect output {0}", Output);
Sys.Out_File := To_WSTR (Output);
Sys.Out_Append := Append_Output;
end if;
if Error'Length > 0 then
Sys.Err_File := To_WSTR (Error);
Sys.Err_Append := Append_Error;
end if;
Sys.To_Close := To_Close;
end Set_Streams;
-- ------------------------------
-- Deletes the storage held by the system process.
-- ------------------------------
overriding
procedure Finalize (Sys : in out System_Process) is
Result : BOOL;
pragma Unreferenced (Result);
begin
if Sys.Process_Info.hProcess /= NO_FILE then
Result := Close_Handle (Sys.Process_Info.hProcess);
Sys.Process_Info.hProcess := NO_FILE;
end if;
if Sys.Process_Info.hThread /= NO_FILE then
Result := Close_Handle (Sys.Process_Info.hThread);
Sys.Process_Info.hThread := NO_FILE;
end if;
Free (Sys.In_File);
Free (Sys.Out_File);
Free (Sys.Err_File);
Free (Sys.Dir);
Free (Sys.Command);
end Finalize;
end Util.Processes.Os;
| true | -----------------------------------------------------------------------
-- util-processes-os -- System specific and low level operations
-- Copyright (C) 2011, 2012, 2018, 2019 PI:NAME:<NAME>END_PI
-- Written by PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with System;
with Ada.Unchecked_Deallocation;
with Ada.Characters.Conversions;
with Ada.Directories;
with Util.Log.Loggers;
package body Util.Processes.Os is
use type Interfaces.C.size_t;
use type Util.Systems.Os.HANDLE;
use type Ada.Directories.File_Kind;
use type System.Address;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Processes.Os");
procedure Free is
new Ada.Unchecked_Deallocation (Object => Interfaces.C.wchar_array,
Name => Wchar_Ptr);
procedure Prepare_Working_Directory (Sys : in out System_Process;
Proc : in out Process'Class);
procedure Redirect_Output (Path : in Wchar_Ptr;
Append : in Boolean;
Output : out HANDLE);
procedure Redirect_Input (Path : in Wchar_Ptr;
Input : out HANDLE);
-- ------------------------------
-- Wait for the process to exit.
-- ------------------------------
overriding
procedure Wait (Sys : in out System_Process;
Proc : in out Process'Class;
Timeout : in Duration) is
use type Util.Streams.Output_Stream_Access;
Result : DWORD;
T : DWORD;
Code : aliased DWORD;
Status : BOOL;
begin
-- Close the input stream pipe if there is one.
if Proc.Input /= null then
Util.Streams.Raw.Raw_Stream'Class (Proc.Input.all).Close;
end if;
if Timeout < 0.0 then
T := DWORD'Last;
else
T := DWORD (Timeout * 1000.0);
Log.Debug ("Waiting {0} ms", DWORD'Image (T));
end if;
Result := Wait_For_Single_Object (H => Sys.Process_Info.hProcess,
Time => T);
Log.Debug ("Status {0}", DWORD'Image (Result));
Status := Get_Exit_Code_Process (Proc => Sys.Process_Info.hProcess,
Code => Code'Unchecked_Access);
if Status = 0 then
Log.Error ("Process is still running. Error {0}", Integer'Image (Get_Last_Error));
end if;
Proc.Exit_Value := Integer (Code);
Log.Debug ("Process exit is: {0}", Integer'Image (Proc.Exit_Value));
end Wait;
-- ------------------------------
-- Terminate the process by sending a signal on Unix and exiting the process on Windows.
-- This operation is not portable and has a different behavior between Unix and Windows.
-- Its intent is to stop the process.
-- ------------------------------
overriding
procedure Stop (Sys : in out System_Process;
Proc : in out Process'Class;
Signal : in Positive := 15) is
pragma Unreferenced (Proc);
Result : Integer;
pragma Unreferenced (Result);
begin
Result := Terminate_Process (Sys.Process_Info.hProcess, DWORD (Signal));
end Stop;
procedure Prepare_Working_Directory (Sys : in out System_Process;
Proc : in out Process'Class) is
Dir : constant String := Ada.Strings.Unbounded.To_String (Proc.Dir);
begin
Free (Sys.Dir);
if Dir'Length > 0 then
if not Ada.Directories.Exists (Dir)
or else Ada.Directories.Kind (Dir) /= Ada.Directories.Directory
then
raise Ada.Directories.Name_Error with "Invalid directory: " & Dir;
end if;
Sys.Dir := To_WSTR (Dir);
end if;
end Prepare_Working_Directory;
procedure Redirect_Output (Path : in Wchar_Ptr;
Append : in Boolean;
Output : out HANDLE) is
Sec : aliased Security_Attributes;
begin
Sec.Length := Security_Attributes'Size / 8;
Sec.Security_Descriptor := System.Null_Address;
Sec.Inherit := 1;
Output := Create_File (Path.all'Address,
(if Append then FILE_APPEND_DATA else GENERIC_WRITE),
FILE_SHARE_WRITE + FILE_SHARE_READ,
Sec'Unchecked_Access,
(if Append then OPEN_ALWAYS else CREATE_ALWAYS),
FILE_ATTRIBUTE_NORMAL,
NO_FILE);
if Output = INVALID_HANDLE_VALUE then
Log.Error ("Cannot create process output file: {0}", Integer'Image (Get_Last_Error));
raise Process_Error with "Cannot create process output file";
end if;
end Redirect_Output;
procedure Redirect_Input (Path : in Wchar_Ptr;
Input : out HANDLE) is
Sec : aliased Security_Attributes;
begin
Sec.Length := Security_Attributes'Size / 8;
Sec.Security_Descriptor := System.Null_Address;
Sec.Inherit := 1;
Input := Create_File (Path.all'Address,
GENERIC_READ,
FILE_SHARE_READ,
Sec'Unchecked_Access,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NO_FILE);
if Input = INVALID_HANDLE_VALUE then
Log.Error ("Cannot open process input file: {0}", Integer'Image (Get_Last_Error));
raise Process_Error with "Cannot open process input file";
end if;
end Redirect_Input;
-- ------------------------------
-- Spawn a new process.
-- ------------------------------
overriding
procedure Spawn (Sys : in out System_Process;
Proc : in out Process'Class;
Mode : in Pipe_Mode := NONE) is
use Interfaces.C;
Result : Integer;
Startup : aliased Startup_Info;
R : BOOL with Unreferenced;
begin
Sys.Prepare_Working_Directory (Proc);
-- Since checks are disabled, verify by hand that the argv table is correct.
if Sys.Command = null or else Sys.Command'Length < 1 then
raise Program_Error with "Invalid process argument list";
end if;
Startup.cb := Startup'Size / 8;
Startup.hStdInput := Get_Std_Handle (STD_INPUT_HANDLE);
Startup.hStdOutput := Get_Std_Handle (STD_OUTPUT_HANDLE);
Startup.hStdError := Get_Std_Handle (STD_ERROR_HANDLE);
if Sys.Out_File /= null then
Redirect_Output (Sys.Out_File, Sys.Out_Append, Startup.hStdOutput);
Startup.dwFlags := 16#100#;
end if;
if Sys.Err_File /= null then
Redirect_Output (Sys.Err_File, Sys.Err_Append, Startup.hStdError);
Startup.dwFlags := 16#100#;
end if;
if Sys.In_File /= null then
Redirect_Input (Sys.In_File, Startup.hStdInput);
Startup.dwFlags := 16#100#;
end if;
if Mode = WRITE or Mode = READ_WRITE or Mode = READ_WRITE_ALL then
Build_Input_Pipe (Sys, Proc, Startup);
end if;
if Mode = READ or Mode = READ_WRITE or Mode = READ_ALL or Mode = READ_WRITE_ALL then
Build_Output_Pipe (Sys, Proc, Startup, Mode);
end if;
-- Start the child process.
if Sys.Dir /= null then
Result := Create_Process (System.Null_Address,
Sys.Command.all'Address,
null,
null,
1,
16#0#,
System.Null_Address,
Sys.Dir.all'Address,
Startup'Unchecked_Access,
Sys.Process_Info'Unchecked_Access);
else
Result := Create_Process (System.Null_Address,
Sys.Command.all'Address,
null,
null,
1,
16#0#,
System.Null_Address,
System.Null_Address,
Startup'Unchecked_Access,
Sys.Process_Info'Unchecked_Access);
end if;
-- Close the handles which are not necessary.
if Startup.hStdInput /= Get_Std_Handle (STD_INPUT_HANDLE) then
R := Close_Handle (Startup.hStdInput);
end if;
if Startup.hStdOutput /= Get_Std_Handle (STD_OUTPUT_HANDLE) then
R := Close_Handle (Startup.hStdOutput);
end if;
if Startup.hStdError /= Get_Std_Handle (STD_ERROR_HANDLE) then
R := Close_Handle (Startup.hStdError);
end if;
if Result /= 1 then
Result := Get_Last_Error;
Log.Error ("Process creation failed: {0}", Integer'Image (Result));
raise Process_Error with "Cannot create process " & Integer'Image (Result);
end if;
Proc.Pid := Process_Identifier (Sys.Process_Info.dwProcessId);
end Spawn;
-- ------------------------------
-- Create the output stream to read/write on the process input/output.
-- Setup the file to be closed on exec.
-- ------------------------------
function Create_Stream (File : in Util.Streams.Raw.File_Type)
return Util.Streams.Raw.Raw_Stream_Access is
Stream : constant Util.Streams.Raw.Raw_Stream_Access := new Util.Streams.Raw.Raw_Stream;
begin
Stream.Initialize (File);
return Stream;
end Create_Stream;
-- ------------------------------
-- Build the output pipe redirection to read the process output.
-- ------------------------------
procedure Build_Output_Pipe (Sys : in out System_Process;
Proc : in out Process'Class;
Into : in out Startup_Info;
Mode : in Pipe_Mode) is
Sec : aliased Security_Attributes;
Read_Handle : aliased HANDLE;
Write_Handle : aliased HANDLE;
Read_Pipe_Handle : aliased HANDLE;
Error_Handle : aliased HANDLE;
Result : BOOL;
R : BOOL with Unreferenced;
Current_Proc : constant HANDLE := Get_Current_Process;
Redirect_Error : constant Boolean := Mode = READ_ALL or Mode = READ_WRITE_ALL;
begin
Sec.Length := Sec'Size / 8;
Sec.Inherit := 1;
Sec.Security_Descriptor := System.Null_Address;
Result := Create_Pipe (Read_Handle => Read_Handle'Unchecked_Access,
Write_Handle => Write_Handle'Unchecked_Access,
Attributes => Sec'Unchecked_Access,
Buf_Size => 0);
if Result = 0 then
Log.Error ("Cannot create pipe: {0}", Integer'Image (Get_Last_Error));
raise Program_Error with "Cannot create pipe";
end if;
Result := Duplicate_Handle (SourceProcessHandle => Current_Proc,
SourceHandle => Read_Handle,
TargetProcessHandle => Current_Proc,
TargetHandle => Read_Pipe_Handle'Unchecked_Access,
DesiredAccess => 0,
InheritHandle => 0,
Options => 2);
if Result = 0 then
Log.Error ("Cannot create pipe: {0}", Integer'Image (Get_Last_Error));
raise Program_Error with "Cannot create pipe";
end if;
R := Close_Handle (Read_Handle);
if Redirect_Error and Sys.Out_File = null and Sys.Err_File = null then
Result := Duplicate_Handle (SourceProcessHandle => Current_Proc,
SourceHandle => Write_Handle,
TargetProcessHandle => Current_Proc,
TargetHandle => Error_Handle'Unchecked_Access,
DesiredAccess => 0,
InheritHandle => 1,
Options => 2);
if Result = 0 then
Log.Error ("Cannot create pipe: {0}", Integer'Image (Get_Last_Error));
raise Program_Error with "Cannot create pipe";
end if;
elsif Sys.Out_File /= null then
Error_Handle := Write_Handle;
end if;
Into.dwFlags := 16#100#;
if Sys.Out_File = null then
Into.hStdOutput := Write_Handle;
end if;
if Redirect_Error and Sys.Err_File = null then
Into.hStdError := Error_Handle;
end if;
Proc.Output := Create_Stream (Read_Pipe_Handle).all'Access;
end Build_Output_Pipe;
-- ------------------------------
-- Build the input pipe redirection to write the process standard input.
-- ------------------------------
procedure Build_Input_Pipe (Sys : in out System_Process;
Proc : in out Process'Class;
Into : in out Startup_Info) is
pragma Unreferenced (Sys);
Sec : aliased Security_Attributes;
Read_Handle : aliased HANDLE;
Write_Handle : aliased HANDLE;
Write_Pipe_Handle : aliased HANDLE;
Result : BOOL;
R : BOOL with Unreferenced;
Current_Proc : constant HANDLE := Get_Current_Process;
begin
Sec.Length := Sec'Size / 8;
Sec.Inherit := 1;
Sec.Security_Descriptor := System.Null_Address;
Result := Create_Pipe (Read_Handle => Read_Handle'Unchecked_Access,
Write_Handle => Write_Handle'Unchecked_Access,
Attributes => Sec'Unchecked_Access,
Buf_Size => 0);
if Result = 0 then
Log.Error ("Cannot create pipe: {0}", Integer'Image (Get_Last_Error));
raise Program_Error with "Cannot create pipe";
end if;
Result := Duplicate_Handle (SourceProcessHandle => Current_Proc,
SourceHandle => Write_Handle,
TargetProcessHandle => Current_Proc,
TargetHandle => Write_Pipe_Handle'Unchecked_Access,
DesiredAccess => 0,
InheritHandle => 0,
Options => 2);
if Result = 0 then
Log.Error ("Cannot create pipe: {0}", Integer'Image (Get_Last_Error));
raise Program_Error with "Cannot create pipe";
end if;
R := Close_Handle (Write_Handle);
Into.dwFlags := 16#100#;
Into.hStdInput := Read_Handle;
Proc.Input := Create_Stream (Write_Pipe_Handle).all'Access;
end Build_Input_Pipe;
-- ------------------------------
-- Append the argument to the process argument list.
-- ------------------------------
overriding
procedure Append_Argument (Sys : in out System_Process;
Arg : in String) is
Len : Interfaces.C.size_t := Arg'Length;
begin
if Sys.Command /= null then
Len := Len + Sys.Command'Length + 2;
declare
S : constant Wchar_Ptr := new Interfaces.C.wchar_array (0 .. Len);
begin
S (Sys.Command'Range) := Sys.Command.all;
Free (Sys.Command);
Sys.Command := S;
end;
Sys.Command (Sys.Pos) := Interfaces.C.To_C (' ');
Sys.Pos := Sys.Pos + 1;
else
Sys.Command := new Interfaces.C.wchar_array (0 .. Len + 1);
Sys.Pos := 0;
end if;
for I in Arg'Range loop
Sys.Command (Sys.Pos)
:= Interfaces.C.To_C (Ada.Characters.Conversions.To_Wide_Character (Arg (I)));
Sys.Pos := Sys.Pos + 1;
end loop;
Sys.Command (Sys.Pos) := Interfaces.C.wide_nul;
end Append_Argument;
-- ------------------------------
-- Set the process input, output and error streams to redirect and use specified files.
-- ------------------------------
overriding
procedure Set_Streams (Sys : in out System_Process;
Input : in String;
Output : in String;
Error : in String;
Append_Output : in Boolean;
Append_Error : in Boolean;
To_Close : in File_Type_Array_Access) is
begin
if Input'Length > 0 then
Log.Info ("Redirect input {0}", Input);
Sys.In_File := To_WSTR (Input);
end if;
if Output'Length > 0 then
Log.Info ("Redirect output {0}", Output);
Sys.Out_File := To_WSTR (Output);
Sys.Out_Append := Append_Output;
end if;
if Error'Length > 0 then
Sys.Err_File := To_WSTR (Error);
Sys.Err_Append := Append_Error;
end if;
Sys.To_Close := To_Close;
end Set_Streams;
-- ------------------------------
-- Deletes the storage held by the system process.
-- ------------------------------
overriding
procedure Finalize (Sys : in out System_Process) is
Result : BOOL;
pragma Unreferenced (Result);
begin
if Sys.Process_Info.hProcess /= NO_FILE then
Result := Close_Handle (Sys.Process_Info.hProcess);
Sys.Process_Info.hProcess := NO_FILE;
end if;
if Sys.Process_Info.hThread /= NO_FILE then
Result := Close_Handle (Sys.Process_Info.hThread);
Sys.Process_Info.hThread := NO_FILE;
end if;
Free (Sys.In_File);
Free (Sys.Out_File);
Free (Sys.Err_File);
Free (Sys.Dir);
Free (Sys.Command);
end Finalize;
end Util.Processes.Os;
|
[
{
"context": "files-sets -- Sets of files\n-- Copyright (C) 2014 Stephane.Carrez\n-- Written by Stephane.Carrez (Stephane.Carrez@g",
"end": 148,
"score": 0.9998847842216492,
"start": 133,
"tag": "NAME",
"value": "Stephane.Carrez"
},
{
"context": " Copyright (C) 2014 Stephane.Carrez\n-- Written by Stephane.Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under",
"end": 179,
"score": 0.9998858571052551,
"start": 164,
"tag": "NAME",
"value": "Stephane.Carrez"
},
{
"context": "4 Stephane.Carrez\n-- Written by Stephane.Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under the Apache License, Versio",
"end": 206,
"score": 0.9999285936355591,
"start": 181,
"tag": "EMAIL",
"value": "Stephane.Carrez@gmail.com"
}
] | src/babel-files-sets.adb | stcarrez/babel | 1 | -----------------------------------------------------------------------
-- babel-files-sets -- Sets of files
-- Copyright (C) 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 Ada.Containers.Ordered_Sets;
with Util.Strings;
package body Babel.Files.Sets is
-- Insert the file in the file set.
procedure Insert (Into : in out File_Set;
File : in File_Type) is
begin
File_Sets.Insert (Into, File);
end Insert;
end Babel.Files.Sets;
| 2166 | -----------------------------------------------------------------------
-- babel-files-sets -- Sets of files
-- Copyright (C) 2014 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Containers.Ordered_Sets;
with Util.Strings;
package body Babel.Files.Sets is
-- Insert the file in the file set.
procedure Insert (Into : in out File_Set;
File : in File_Type) is
begin
File_Sets.Insert (Into, File);
end Insert;
end Babel.Files.Sets;
| true | -----------------------------------------------------------------------
-- babel-files-sets -- Sets of files
-- Copyright (C) 2014 PI:NAME:<NAME>END_PI
-- Written by PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Containers.Ordered_Sets;
with Util.Strings;
package body Babel.Files.Sets is
-- Insert the file in the file set.
procedure Insert (Into : in out File_Set;
File : in File_Type) is
begin
File_Sets.Insert (Into, File);
end Insert;
end Babel.Files.Sets;
|
[
{
"context": "t causes SIGBUS and should it be caught?\n -- Peter Burwood\n\n case signo is\n when SIGFPE =>\n ",
"end": 6420,
"score": 0.9998299479484558,
"start": 6407,
"tag": "NAME",
"value": "Peter Burwood"
},
{
"context": "task\n -- for the application.\n My_Id := taskIdSelf;\n if taskIsSuspended (My_Id) /= 0 then\n ",
"end": 8251,
"score": 0.9739312529563904,
"start": 8241,
"tag": "USERNAME",
"value": "taskIdSelf"
},
{
"context": " the SA_NODEFER option is\n -- not needed. - Dan Eischen\n\n Result := sigemptyset (mask'Access);\n ",
"end": 10789,
"score": 0.9997787475585938,
"start": 10778,
"tag": "NAME",
"value": "Dan Eischen"
}
] | tools-src/gnu/gcc/gcc/ada/5zintman.adb | enfoTek/tomato.linksys.e2000.nvram-mod | 80 | ------------------------------------------------------------------------------
-- --
-- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . I N T E R R U P T _ M A N A G E M E N T --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1991-2001 Florida State University --
-- --
-- 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. It is --
-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
-- State University (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
-- This is the VxWorks version of this package.
-- It is likely to need tailoring to fit each operating system
-- and machine architecture.
-- PLEASE DO NOT add any dependences on other packages.
-- This package is designed to work with or without tasking support.
-- See the other warnings in the package specification before making
-- any modifications to this file.
-- Make a careful study of all signals available under the OS,
-- to see which need to be reserved, kept always unmasked,
-- or kept always unmasked.
-- Be on the lookout for special signals that
-- may be used by the thread library.
with Interfaces.C;
-- used for int and other types
with System.Error_Reporting;
pragma Warnings (Off, System.Error_Reporting);
-- used for Shutdown
with System.OS_Interface;
-- used for various Constants, Signal and types
with Unchecked_Conversion;
package body System.Interrupt_Management is
use Interfaces.C;
use System.Error_Reporting;
use System.OS_Interface;
function To_Isr is new Unchecked_Conversion (Long_Integer, isr_address);
type Interrupt_List is array (Interrupt_ID range <>) of Interrupt_ID;
Exception_Interrupts : constant Interrupt_List :=
(SIGFPE, SIGILL, SIGSEGV, SIGBUS);
-- Keep these variables global so that they are initialized only once.
Exception_Action : aliased struct_sigaction;
Default_Action : aliased struct_sigaction;
-- ????? Use these horrible imports here to solve elaboration order
-- problems.
type Task_Id is access all Integer;
Interrupt_ID_Map : array (Interrupt_ID) of Task_Id;
pragma Import (Ada, Interrupt_ID_Map,
"system__task_primitives__interrupt_operations__interrupt_id_map");
----------------------
-- Notify_Exception --
----------------------
procedure Notify_Exception (signo : Signal);
-- Identify the Ada exception to be raised using
-- the information when the system received a synchronous signal.
procedure Notify_Exception (signo : Signal) is
Mask : aliased sigset_t;
Result : Interfaces.C.int;
My_Id : pthread_t;
begin
-- VxWorks will always mask out the signal during the signal
-- handler and will reenable it on a longjmp. GNAT does
-- not generate a longjmp to return from a signal handler
-- so the signal will still be masked unless we unmask it.
Result := pthread_sigmask (SIG_SETMASK, null, Mask'Unchecked_Access);
Result := sigdelset (Mask'Access, signo);
Result := pthread_sigmask (SIG_SETMASK, Mask'Unchecked_Access, null);
-- VxWorks will suspend the task when it gets a hardware
-- exception. We take the liberty of resuming the task
-- for the application.
My_Id := taskIdSelf;
if taskIsSuspended (My_Id) /= 0 then
Result := taskResume (My_Id);
end if;
-- As long as we are using a longjmp to return control to the
-- exception handler on the runtime stack, we are safe. The original
-- signal mask (the one we had before coming into this signal catching
-- function) will be restored by the longjmp. Therefore, raising
-- an exception in this handler should be a safe operation.
-- Check that treatment of exception propagation here
-- is consistent with treatment of the abort signal in
-- System.Task_Primitives.Operations.
-- How can SIGSEGV be split into constraint and storage errors?
-- What should SIGILL really raise ? Some implementations have
-- codes for different types of SIGILL and some raise Storage_Error.
-- What causes SIGBUS and should it be caught?
-- Peter Burwood
case signo is
when SIGFPE =>
raise Constraint_Error;
when SIGILL =>
raise Constraint_Error;
when SIGSEGV =>
raise Program_Error;
when SIGBUS =>
raise Program_Error;
when others =>
pragma Assert (Shutdown ("Unexpected signal"));
null;
end case;
end Notify_Exception;
-------------------
-- Notify_Signal --
-------------------
-- VxWorks needs a special casing here. Each VxWorks task has a completely
-- separate signal handling, so the usual signal masking can't work.
-- This idea is to handle all the signals in all the tasks, and when
-- such a signal occurs, redirect it to the dedicated task (if any) or
-- reraise it.
procedure Notify_Signal (signo : Signal);
procedure Notify_Signal (signo : Signal) is
Mask : aliased sigset_t;
Result : Interfaces.C.int;
My_Id : pthread_t;
old_isr : isr_address;
function Get_Thread_Id (T : Task_Id) return pthread_t;
pragma Import (Ada, Get_Thread_Id,
"system__task_primitives__operations__get_thread_id");
begin
-- VxWorks will always mask out the signal during the signal
-- handler and will reenable it on a longjmp. GNAT does
-- not generate a longjmp to return from a signal handler
-- so the signal will still be masked unless we unmask it.
Result := pthread_sigmask (SIG_SETMASK, null, Mask'Unchecked_Access);
Result := sigdelset (Mask'Access, signo);
Result := pthread_sigmask (SIG_SETMASK, Mask'Unchecked_Access, null);
-- VxWorks will suspend the task when it gets a hardware
-- exception. We take the liberty of resuming the task
-- for the application.
My_Id := taskIdSelf;
if taskIsSuspended (My_Id) /= 0 then
Result := taskResume (My_Id);
end if;
-- ??? Need a lock around this, in case the handler is detached
-- between the two following statements.
if Interrupt_ID_Map (Interrupt_ID (signo)) /= null then
Result :=
kill (Get_Thread_Id (Interrupt_ID_Map (Interrupt_ID (signo))),
Signal (signo));
else
old_isr := c_signal (signo, To_Isr (SIG_DFL));
Result := kill (My_Id, Signal (signo));
end if;
end Notify_Signal;
---------------------------
-- Initialize_Interrupts --
---------------------------
-- Since there is no signal inheritance between VxWorks tasks, we need
-- to initialize signal handling in each task.
procedure Initialize_Interrupts is
old_act : aliased struct_sigaction;
Result : Interfaces.C.int;
begin
for J in Interrupt_ID'First + 1 .. Interrupt_ID'Last loop
if J /= Abort_Task_Interrupt then
Result := sigaction (Signal (J), Default_Action'Access,
old_act'Unchecked_Access);
pragma Assert (Result = 0);
end if;
end loop;
for J in Exception_Interrupts'Range loop
Keep_Unmasked (Exception_Interrupts (J)) := True;
Result :=
sigaction
(Signal (Exception_Interrupts (J)), Exception_Action'Access,
old_act'Unchecked_Access);
pragma Assert (Result = 0);
end loop;
end Initialize_Interrupts;
begin
declare
mask : aliased sigset_t;
default_mask : aliased sigset_t;
Result : Interfaces.C.int;
begin
-- The VxWorks POSIX threads library currently needs initialization.
-- We wish it could be in System.OS_Interface, but that would
-- cause an elaboration problem.
pthread_init;
Abort_Task_Interrupt := SIGABRT;
-- Change this if you want to use another signal for task abort.
-- SIGTERM might be a good one.
Exception_Action.sa_handler := Notify_Exception'Address;
Default_Action.sa_handler := Notify_Signal'Address;
Exception_Action.sa_flags := SA_SIGINFO + SA_ONSTACK;
Default_Action.sa_flags := SA_SIGINFO + SA_ONSTACK;
-- Send us extra signal information (SA_SIGINFO) on the
-- stack (SA_ONSTACK).
-- There is no SA_NODEFER in VxWorks. The signal mask is
-- restored after a longjmp so the SA_NODEFER option is
-- not needed. - Dan Eischen
Result := sigemptyset (mask'Access);
pragma Assert (Result = 0);
Result := sigemptyset (default_mask'Access);
pragma Assert (Result = 0);
for J in Interrupt_ID'First + 1 .. Interrupt_ID'Last loop
Result := sigaddset (default_mask'Access, Signal (J));
pragma Assert (Result = 0);
end loop;
for J in Exception_Interrupts'Range loop
Result := sigaddset (mask'Access, Signal (Exception_Interrupts (J)));
pragma Assert (Result = 0);
Result :=
sigdelset (default_mask'Access, Signal (Exception_Interrupts (J)));
pragma Assert (Result = 0);
end loop;
Exception_Action.sa_mask := mask;
Default_Action.sa_mask := default_mask;
-- Initialize_Interrupts is called for each task in Enter_Task
Keep_Unmasked (Abort_Task_Interrupt) := True;
Reserve := Reserve or Keep_Unmasked or Keep_Masked;
Reserve (0) := True;
-- We do not have Signal 0 in reality. We just use this value
-- to identify non-existent signals (see s-intnam.ads). Therefore,
-- Signal 0 should not be used in all signal related operations hence
-- mark it as reserved.
end;
end System.Interrupt_Management;
| 7781 | ------------------------------------------------------------------------------
-- --
-- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . I N T E R R U P T _ M A N A G E M E N T --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1991-2001 Florida State University --
-- --
-- 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. It is --
-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
-- State University (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
-- This is the VxWorks version of this package.
-- It is likely to need tailoring to fit each operating system
-- and machine architecture.
-- PLEASE DO NOT add any dependences on other packages.
-- This package is designed to work with or without tasking support.
-- See the other warnings in the package specification before making
-- any modifications to this file.
-- Make a careful study of all signals available under the OS,
-- to see which need to be reserved, kept always unmasked,
-- or kept always unmasked.
-- Be on the lookout for special signals that
-- may be used by the thread library.
with Interfaces.C;
-- used for int and other types
with System.Error_Reporting;
pragma Warnings (Off, System.Error_Reporting);
-- used for Shutdown
with System.OS_Interface;
-- used for various Constants, Signal and types
with Unchecked_Conversion;
package body System.Interrupt_Management is
use Interfaces.C;
use System.Error_Reporting;
use System.OS_Interface;
function To_Isr is new Unchecked_Conversion (Long_Integer, isr_address);
type Interrupt_List is array (Interrupt_ID range <>) of Interrupt_ID;
Exception_Interrupts : constant Interrupt_List :=
(SIGFPE, SIGILL, SIGSEGV, SIGBUS);
-- Keep these variables global so that they are initialized only once.
Exception_Action : aliased struct_sigaction;
Default_Action : aliased struct_sigaction;
-- ????? Use these horrible imports here to solve elaboration order
-- problems.
type Task_Id is access all Integer;
Interrupt_ID_Map : array (Interrupt_ID) of Task_Id;
pragma Import (Ada, Interrupt_ID_Map,
"system__task_primitives__interrupt_operations__interrupt_id_map");
----------------------
-- Notify_Exception --
----------------------
procedure Notify_Exception (signo : Signal);
-- Identify the Ada exception to be raised using
-- the information when the system received a synchronous signal.
procedure Notify_Exception (signo : Signal) is
Mask : aliased sigset_t;
Result : Interfaces.C.int;
My_Id : pthread_t;
begin
-- VxWorks will always mask out the signal during the signal
-- handler and will reenable it on a longjmp. GNAT does
-- not generate a longjmp to return from a signal handler
-- so the signal will still be masked unless we unmask it.
Result := pthread_sigmask (SIG_SETMASK, null, Mask'Unchecked_Access);
Result := sigdelset (Mask'Access, signo);
Result := pthread_sigmask (SIG_SETMASK, Mask'Unchecked_Access, null);
-- VxWorks will suspend the task when it gets a hardware
-- exception. We take the liberty of resuming the task
-- for the application.
My_Id := taskIdSelf;
if taskIsSuspended (My_Id) /= 0 then
Result := taskResume (My_Id);
end if;
-- As long as we are using a longjmp to return control to the
-- exception handler on the runtime stack, we are safe. The original
-- signal mask (the one we had before coming into this signal catching
-- function) will be restored by the longjmp. Therefore, raising
-- an exception in this handler should be a safe operation.
-- Check that treatment of exception propagation here
-- is consistent with treatment of the abort signal in
-- System.Task_Primitives.Operations.
-- How can SIGSEGV be split into constraint and storage errors?
-- What should SIGILL really raise ? Some implementations have
-- codes for different types of SIGILL and some raise Storage_Error.
-- What causes SIGBUS and should it be caught?
-- <NAME>
case signo is
when SIGFPE =>
raise Constraint_Error;
when SIGILL =>
raise Constraint_Error;
when SIGSEGV =>
raise Program_Error;
when SIGBUS =>
raise Program_Error;
when others =>
pragma Assert (Shutdown ("Unexpected signal"));
null;
end case;
end Notify_Exception;
-------------------
-- Notify_Signal --
-------------------
-- VxWorks needs a special casing here. Each VxWorks task has a completely
-- separate signal handling, so the usual signal masking can't work.
-- This idea is to handle all the signals in all the tasks, and when
-- such a signal occurs, redirect it to the dedicated task (if any) or
-- reraise it.
procedure Notify_Signal (signo : Signal);
procedure Notify_Signal (signo : Signal) is
Mask : aliased sigset_t;
Result : Interfaces.C.int;
My_Id : pthread_t;
old_isr : isr_address;
function Get_Thread_Id (T : Task_Id) return pthread_t;
pragma Import (Ada, Get_Thread_Id,
"system__task_primitives__operations__get_thread_id");
begin
-- VxWorks will always mask out the signal during the signal
-- handler and will reenable it on a longjmp. GNAT does
-- not generate a longjmp to return from a signal handler
-- so the signal will still be masked unless we unmask it.
Result := pthread_sigmask (SIG_SETMASK, null, Mask'Unchecked_Access);
Result := sigdelset (Mask'Access, signo);
Result := pthread_sigmask (SIG_SETMASK, Mask'Unchecked_Access, null);
-- VxWorks will suspend the task when it gets a hardware
-- exception. We take the liberty of resuming the task
-- for the application.
My_Id := taskIdSelf;
if taskIsSuspended (My_Id) /= 0 then
Result := taskResume (My_Id);
end if;
-- ??? Need a lock around this, in case the handler is detached
-- between the two following statements.
if Interrupt_ID_Map (Interrupt_ID (signo)) /= null then
Result :=
kill (Get_Thread_Id (Interrupt_ID_Map (Interrupt_ID (signo))),
Signal (signo));
else
old_isr := c_signal (signo, To_Isr (SIG_DFL));
Result := kill (My_Id, Signal (signo));
end if;
end Notify_Signal;
---------------------------
-- Initialize_Interrupts --
---------------------------
-- Since there is no signal inheritance between VxWorks tasks, we need
-- to initialize signal handling in each task.
procedure Initialize_Interrupts is
old_act : aliased struct_sigaction;
Result : Interfaces.C.int;
begin
for J in Interrupt_ID'First + 1 .. Interrupt_ID'Last loop
if J /= Abort_Task_Interrupt then
Result := sigaction (Signal (J), Default_Action'Access,
old_act'Unchecked_Access);
pragma Assert (Result = 0);
end if;
end loop;
for J in Exception_Interrupts'Range loop
Keep_Unmasked (Exception_Interrupts (J)) := True;
Result :=
sigaction
(Signal (Exception_Interrupts (J)), Exception_Action'Access,
old_act'Unchecked_Access);
pragma Assert (Result = 0);
end loop;
end Initialize_Interrupts;
begin
declare
mask : aliased sigset_t;
default_mask : aliased sigset_t;
Result : Interfaces.C.int;
begin
-- The VxWorks POSIX threads library currently needs initialization.
-- We wish it could be in System.OS_Interface, but that would
-- cause an elaboration problem.
pthread_init;
Abort_Task_Interrupt := SIGABRT;
-- Change this if you want to use another signal for task abort.
-- SIGTERM might be a good one.
Exception_Action.sa_handler := Notify_Exception'Address;
Default_Action.sa_handler := Notify_Signal'Address;
Exception_Action.sa_flags := SA_SIGINFO + SA_ONSTACK;
Default_Action.sa_flags := SA_SIGINFO + SA_ONSTACK;
-- Send us extra signal information (SA_SIGINFO) on the
-- stack (SA_ONSTACK).
-- There is no SA_NODEFER in VxWorks. The signal mask is
-- restored after a longjmp so the SA_NODEFER option is
-- not needed. - <NAME>
Result := sigemptyset (mask'Access);
pragma Assert (Result = 0);
Result := sigemptyset (default_mask'Access);
pragma Assert (Result = 0);
for J in Interrupt_ID'First + 1 .. Interrupt_ID'Last loop
Result := sigaddset (default_mask'Access, Signal (J));
pragma Assert (Result = 0);
end loop;
for J in Exception_Interrupts'Range loop
Result := sigaddset (mask'Access, Signal (Exception_Interrupts (J)));
pragma Assert (Result = 0);
Result :=
sigdelset (default_mask'Access, Signal (Exception_Interrupts (J)));
pragma Assert (Result = 0);
end loop;
Exception_Action.sa_mask := mask;
Default_Action.sa_mask := default_mask;
-- Initialize_Interrupts is called for each task in Enter_Task
Keep_Unmasked (Abort_Task_Interrupt) := True;
Reserve := Reserve or Keep_Unmasked or Keep_Masked;
Reserve (0) := True;
-- We do not have Signal 0 in reality. We just use this value
-- to identify non-existent signals (see s-intnam.ads). Therefore,
-- Signal 0 should not be used in all signal related operations hence
-- mark it as reserved.
end;
end System.Interrupt_Management;
| true | ------------------------------------------------------------------------------
-- --
-- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . I N T E R R U P T _ M A N A G E M E N T --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1991-2001 Florida State University --
-- --
-- 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. It is --
-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
-- State University (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
-- This is the VxWorks version of this package.
-- It is likely to need tailoring to fit each operating system
-- and machine architecture.
-- PLEASE DO NOT add any dependences on other packages.
-- This package is designed to work with or without tasking support.
-- See the other warnings in the package specification before making
-- any modifications to this file.
-- Make a careful study of all signals available under the OS,
-- to see which need to be reserved, kept always unmasked,
-- or kept always unmasked.
-- Be on the lookout for special signals that
-- may be used by the thread library.
with Interfaces.C;
-- used for int and other types
with System.Error_Reporting;
pragma Warnings (Off, System.Error_Reporting);
-- used for Shutdown
with System.OS_Interface;
-- used for various Constants, Signal and types
with Unchecked_Conversion;
package body System.Interrupt_Management is
use Interfaces.C;
use System.Error_Reporting;
use System.OS_Interface;
function To_Isr is new Unchecked_Conversion (Long_Integer, isr_address);
type Interrupt_List is array (Interrupt_ID range <>) of Interrupt_ID;
Exception_Interrupts : constant Interrupt_List :=
(SIGFPE, SIGILL, SIGSEGV, SIGBUS);
-- Keep these variables global so that they are initialized only once.
Exception_Action : aliased struct_sigaction;
Default_Action : aliased struct_sigaction;
-- ????? Use these horrible imports here to solve elaboration order
-- problems.
type Task_Id is access all Integer;
Interrupt_ID_Map : array (Interrupt_ID) of Task_Id;
pragma Import (Ada, Interrupt_ID_Map,
"system__task_primitives__interrupt_operations__interrupt_id_map");
----------------------
-- Notify_Exception --
----------------------
procedure Notify_Exception (signo : Signal);
-- Identify the Ada exception to be raised using
-- the information when the system received a synchronous signal.
procedure Notify_Exception (signo : Signal) is
Mask : aliased sigset_t;
Result : Interfaces.C.int;
My_Id : pthread_t;
begin
-- VxWorks will always mask out the signal during the signal
-- handler and will reenable it on a longjmp. GNAT does
-- not generate a longjmp to return from a signal handler
-- so the signal will still be masked unless we unmask it.
Result := pthread_sigmask (SIG_SETMASK, null, Mask'Unchecked_Access);
Result := sigdelset (Mask'Access, signo);
Result := pthread_sigmask (SIG_SETMASK, Mask'Unchecked_Access, null);
-- VxWorks will suspend the task when it gets a hardware
-- exception. We take the liberty of resuming the task
-- for the application.
My_Id := taskIdSelf;
if taskIsSuspended (My_Id) /= 0 then
Result := taskResume (My_Id);
end if;
-- As long as we are using a longjmp to return control to the
-- exception handler on the runtime stack, we are safe. The original
-- signal mask (the one we had before coming into this signal catching
-- function) will be restored by the longjmp. Therefore, raising
-- an exception in this handler should be a safe operation.
-- Check that treatment of exception propagation here
-- is consistent with treatment of the abort signal in
-- System.Task_Primitives.Operations.
-- How can SIGSEGV be split into constraint and storage errors?
-- What should SIGILL really raise ? Some implementations have
-- codes for different types of SIGILL and some raise Storage_Error.
-- What causes SIGBUS and should it be caught?
-- PI:NAME:<NAME>END_PI
case signo is
when SIGFPE =>
raise Constraint_Error;
when SIGILL =>
raise Constraint_Error;
when SIGSEGV =>
raise Program_Error;
when SIGBUS =>
raise Program_Error;
when others =>
pragma Assert (Shutdown ("Unexpected signal"));
null;
end case;
end Notify_Exception;
-------------------
-- Notify_Signal --
-------------------
-- VxWorks needs a special casing here. Each VxWorks task has a completely
-- separate signal handling, so the usual signal masking can't work.
-- This idea is to handle all the signals in all the tasks, and when
-- such a signal occurs, redirect it to the dedicated task (if any) or
-- reraise it.
procedure Notify_Signal (signo : Signal);
procedure Notify_Signal (signo : Signal) is
Mask : aliased sigset_t;
Result : Interfaces.C.int;
My_Id : pthread_t;
old_isr : isr_address;
function Get_Thread_Id (T : Task_Id) return pthread_t;
pragma Import (Ada, Get_Thread_Id,
"system__task_primitives__operations__get_thread_id");
begin
-- VxWorks will always mask out the signal during the signal
-- handler and will reenable it on a longjmp. GNAT does
-- not generate a longjmp to return from a signal handler
-- so the signal will still be masked unless we unmask it.
Result := pthread_sigmask (SIG_SETMASK, null, Mask'Unchecked_Access);
Result := sigdelset (Mask'Access, signo);
Result := pthread_sigmask (SIG_SETMASK, Mask'Unchecked_Access, null);
-- VxWorks will suspend the task when it gets a hardware
-- exception. We take the liberty of resuming the task
-- for the application.
My_Id := taskIdSelf;
if taskIsSuspended (My_Id) /= 0 then
Result := taskResume (My_Id);
end if;
-- ??? Need a lock around this, in case the handler is detached
-- between the two following statements.
if Interrupt_ID_Map (Interrupt_ID (signo)) /= null then
Result :=
kill (Get_Thread_Id (Interrupt_ID_Map (Interrupt_ID (signo))),
Signal (signo));
else
old_isr := c_signal (signo, To_Isr (SIG_DFL));
Result := kill (My_Id, Signal (signo));
end if;
end Notify_Signal;
---------------------------
-- Initialize_Interrupts --
---------------------------
-- Since there is no signal inheritance between VxWorks tasks, we need
-- to initialize signal handling in each task.
procedure Initialize_Interrupts is
old_act : aliased struct_sigaction;
Result : Interfaces.C.int;
begin
for J in Interrupt_ID'First + 1 .. Interrupt_ID'Last loop
if J /= Abort_Task_Interrupt then
Result := sigaction (Signal (J), Default_Action'Access,
old_act'Unchecked_Access);
pragma Assert (Result = 0);
end if;
end loop;
for J in Exception_Interrupts'Range loop
Keep_Unmasked (Exception_Interrupts (J)) := True;
Result :=
sigaction
(Signal (Exception_Interrupts (J)), Exception_Action'Access,
old_act'Unchecked_Access);
pragma Assert (Result = 0);
end loop;
end Initialize_Interrupts;
begin
declare
mask : aliased sigset_t;
default_mask : aliased sigset_t;
Result : Interfaces.C.int;
begin
-- The VxWorks POSIX threads library currently needs initialization.
-- We wish it could be in System.OS_Interface, but that would
-- cause an elaboration problem.
pthread_init;
Abort_Task_Interrupt := SIGABRT;
-- Change this if you want to use another signal for task abort.
-- SIGTERM might be a good one.
Exception_Action.sa_handler := Notify_Exception'Address;
Default_Action.sa_handler := Notify_Signal'Address;
Exception_Action.sa_flags := SA_SIGINFO + SA_ONSTACK;
Default_Action.sa_flags := SA_SIGINFO + SA_ONSTACK;
-- Send us extra signal information (SA_SIGINFO) on the
-- stack (SA_ONSTACK).
-- There is no SA_NODEFER in VxWorks. The signal mask is
-- restored after a longjmp so the SA_NODEFER option is
-- not needed. - PI:NAME:<NAME>END_PI
Result := sigemptyset (mask'Access);
pragma Assert (Result = 0);
Result := sigemptyset (default_mask'Access);
pragma Assert (Result = 0);
for J in Interrupt_ID'First + 1 .. Interrupt_ID'Last loop
Result := sigaddset (default_mask'Access, Signal (J));
pragma Assert (Result = 0);
end loop;
for J in Exception_Interrupts'Range loop
Result := sigaddset (mask'Access, Signal (Exception_Interrupts (J)));
pragma Assert (Result = 0);
Result :=
sigdelset (default_mask'Access, Signal (Exception_Interrupts (J)));
pragma Assert (Result = 0);
end loop;
Exception_Action.sa_mask := mask;
Default_Action.sa_mask := default_mask;
-- Initialize_Interrupts is called for each task in Enter_Task
Keep_Unmasked (Abort_Task_Interrupt) := True;
Reserve := Reserve or Keep_Unmasked or Keep_Masked;
Reserve (0) := True;
-- We do not have Signal 0 in reality. We just use this value
-- to identify non-existent signals (see s-intnam.ads). Therefore,
-- Signal 0 should not be used in all signal related operations hence
-- mark it as reserved.
end;
end System.Interrupt_Management;
|
[
{
"context": "---------------------------\n-- Copyright (c) 2014, Natacha Porté --\n-- ",
"end": 115,
"score": 0.9998553991317749,
"start": 102,
"tag": "NAME",
"value": "Natacha Porté"
}
] | tests/natools-s_expressions-templates-tests-integers.adb | faelys/natools | 0 | ------------------------------------------------------------------------------
-- 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. --
------------------------------------------------------------------------------
with Natools.S_Expressions.Parsers;
with Natools.S_Expressions.Test_Tools;
with Natools.S_Expressions.Templates.Integers;
with Natools.Static_Maps.S_Expressions.Templates.Integers.T;
package body Natools.S_Expressions.Templates.Tests.Integers is
procedure Test_Render
(Test : in out NT.Test;
Defaults : in Templates.Integers.Format;
Template : in String;
Value : in Integer;
Expected : in String);
procedure Test_Render
(Test : in out NT.Test;
Template : in String;
Value : in Integer;
Expected : in String);
-- Run Template with Value and compare the result with Expected
------------------------------
-- Local Helper Subprograms --
------------------------------
procedure Test_Render
(Test : in out NT.Test;
Template : in String;
Value : in Integer;
Expected : in String)
is
Input : aliased Test_Tools.Memory_Stream;
Output : Test_Tools.Memory_Stream;
Parser : Parsers.Stream_Parser (Input'Access);
begin
Input.Set_Data (To_Atom (Template));
Parser.Next;
Output.Set_Expected (To_Atom (Expected));
Templates.Integers.Render (Output, Parser, Value);
Output.Check_Stream (Test);
end Test_Render;
procedure Test_Render
(Test : in out NT.Test;
Defaults : in Templates.Integers.Format;
Template : in String;
Value : in Integer;
Expected : in String)
is
Input : aliased Test_Tools.Memory_Stream;
Output : Test_Tools.Memory_Stream;
Parser : Parsers.Stream_Parser (Input'Access);
begin
Input.Set_Data (To_Atom (Template));
Parser.Next;
Output.Set_Expected (To_Atom (Expected));
Templates.Integers.Render (Output, Defaults, Parser, Value);
Output.Check_Stream (Test);
end Test_Render;
-------------------------
-- Complete Test Suite --
-------------------------
procedure All_Tests (Report : in out NT.Reporter'Class) is
begin
Alignment (Report);
Default_Format (Report);
Explicit_Images (Report);
Explicit_Sign (Report);
Hexadecimal (Report);
Overflow (Report);
Parse_Errors (Report);
Static_Hash_Map (Report);
Explicit_Default_Format (Report);
Prefix_And_Suffix (Report);
end All_Tests;
-----------------------
-- Inidividual Tests --
-----------------------
procedure Alignment (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Debug instantiation");
begin
Test_Render (Test, "(width 5)", 0, " 0");
Test_Render (Test, "(width 5)(padding _)(align center)", 10, "_10__");
Test_Render (Test, "(width 5 10)(left-align)", 7, "7 ");
Test_Render (Test, "(min-width 5)(right-align)", 2, " 2");
Test_Render (Test, "(width 5)(padding > <)(centered)", 4, ">>4<<");
Test_Render
(Test,
"(width 5)(left-padding ""["")(right-padding ""]"")(centered)",
126,
"[126]");
Test_Render (Test, "(width 3)(centered)", 16, "16 ");
Test_Render (Test, "(width 3)(centered)", 456, "456");
Test_Render (Test, "(width 3)(align left)", 567, "567");
Test_Render (Test, "(width 3)(align right)", 678, "678");
exception
when Error : others => Test.Report_Exception (Error);
end Alignment;
procedure Default_Format (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Debug instantiation");
begin
Test_Render (Test, "", 42, "42");
exception
when Error : others => Test.Report_Exception (Error);
end Default_Format;
procedure Explicit_Default_Format (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Client-provided default format");
begin
declare
Default : Templates.Integers.Format;
begin
Default.Set_Minimum_Width (2);
Default.Set_Left_Padding (To_Atom ("0"));
Test_Render (Test, Default, "", 5, "05");
Test_Render (Test, Default, "", 12, "12");
Test_Render (Test, Default, "(padding 1: )", 7, " 7");
end;
exception
when Error : others => Test.Report_Exception (Error);
end Explicit_Default_Format;
procedure Explicit_Images (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Explicit images in template");
begin
Test_Render (Test, "(image (-2 two) (666 evil))", 10, "10");
Test_Render (Test, "(image (-2 two) (666 evil))", -2, "two");
Test_Render (Test, "(image (-2 two) (666 evil))", 666, "evil");
Test_Render (Test, "(image (-2 two) (666 evil) (-2))", -2, "-2");
Test_Render (Test, "(image (1 one))3:Two4:four", 1, "one");
Test_Render (Test, "(image (1 one))3:Two4:four", 2, "Two");
Test_Render (Test, "(image (1 one))3:Two4:four", 3, "four");
Test_Render (Test, "(image (1 one))3:Two4:four", 4, "4");
Test_Render (Test, "(image (invalid -))5:first", Integer'First, "first");
Test_Render (Test, "(image-range (""?"" (10 19)))", 9, "9");
Test_Render (Test, "(image-range (""?"" (10 19)))", 10, "?");
Test_Render (Test, "(image-range (""?"" (10 19)))", 15, "?");
Test_Render (Test, "(image-range (""?"" (10 19)))", 19, "?");
Test_Render (Test, "(image-range (""?"" (10 19)))", 20, "20");
exception
when Error : others => Test.Report_Exception (Error);
end Explicit_Images;
procedure Explicit_Sign (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Explicit sign specification");
begin
Test_Render (Test, "(sign +)", 42, "+42");
Test_Render (Test, "(sign + _)", 42, "+42");
Test_Render (Test, "(sign + _)", -42, "_42");
exception
when Error : others => Test.Report_Exception (Error);
end Explicit_Sign;
procedure Hexadecimal (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Hexadecimal representation");
Hex_Spec : constant String
:= "(base 0 1 2 3 4 5 6 7 8 9 A B C D E F)";
begin
Test_Render (Test, Hex_Spec, 8, "8");
Test_Render (Test, Hex_Spec, 16#BEE#, "BEE");
exception
when Error : others => Test.Report_Exception (Error);
end Hexadecimal;
procedure Overflow (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Width overflow");
begin
Test_Render (Test, "(width 3)", 10_000, "");
Test_Render (Test, "(max-width 4)", 10_000, "");
Test_Render (Test, "(max-width 3 ""[...]"")", 10_000, "[...]");
Test_Render (Test, "(width 2 3 ...)", 10_000, "...");
exception
when Error : others => Test.Report_Exception (Error);
end Overflow;
procedure Parse_Errors (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Parse errors in template");
begin
Test_Render (Test, "(invalid-command)", 1, "1");
Test_Render (Test, "(align)", 2, "2");
Test_Render (Test, "(align invalid)", 3, "3");
Test_Render (Test, "(padding)", 4, "4");
Test_Render (Test, "(left-padding)", 5, "5");
Test_Render (Test, "(right-padding)", 6, "6");
Test_Render (Test, "(signs)", 7, "7");
Test_Render (Test, "(width)", 8, "8");
Test_Render (Test, "(max-width)", 9, "9");
Test_Render (Test, "(min-width)", 10, "10");
exception
when Error : others => Test.Report_Exception (Error);
end Parse_Errors;
procedure Prefix_And_Suffix (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Parse errors in template");
Ordinal : constant String
:= "(suffix 1:? (th (0 31)) (st 1 21 31) (nd 2 22) (rd 3 23) (0: 0))";
begin
declare
Format : Templates.Integers.Format;
begin
Format.Set_Prefix ((0, 9), To_Atom ("a"));
Format.Set_Prefix ((-99, -10), To_Atom ("b"));
Format.Set_Prefix ((50, 99), To_Atom ("c"));
Format.Set_Prefix (0, To_Atom ("d"));
Format.Set_Prefix (-10, To_Atom ("e"));
Format.Set_Prefix (5, To_Atom ("f"));
Format.Set_Prefix ((7, 52), To_Atom ("g"));
Format.Set_Prefix ((-52, -49), To_Atom ("h"));
Format.Set_Prefix ((-100, -90), To_Atom ("i"));
Format.Remove_Prefix (8);
Test_Render (Test, Format, "", -196, "-196");
Test_Render (Test, Format, "", -101, "-101");
Test_Render (Test, Format, "", -100, "i-100");
Test_Render (Test, Format, "", -90, "i-90");
Test_Render (Test, Format, "", -89, "b-89");
Test_Render (Test, Format, "", -53, "b-53");
Test_Render (Test, Format, "", -52, "h-52");
Test_Render (Test, Format, "", -49, "h-49");
Test_Render (Test, Format, "", -48, "b-48");
Test_Render (Test, Format, "", -11, "b-11");
Test_Render (Test, Format, "", -10, "e-10");
Test_Render (Test, Format, "", -9, "-9");
Test_Render (Test, Format, "", -1, "-1");
Test_Render (Test, Format, "", 0, "d0");
Test_Render (Test, Format, "", 1, "a1");
Test_Render (Test, Format, "", 4, "a4");
Test_Render (Test, Format, "", 5, "f5");
Test_Render (Test, Format, "", 6, "a6");
Test_Render (Test, Format, "", 7, "g7");
Test_Render (Test, Format, "", 8, "8");
Test_Render (Test, Format, "", 9, "g9");
Test_Render (Test, Format, "", 52, "g52");
Test_Render (Test, Format, "", 53, "c53");
Test_Render (Test, Format, "", 99, "c99");
Test_Render (Test, Format, "", 100, "100");
Test_Render (Test, Format, "", 192, "192");
end;
declare
Format : Templates.Integers.Format;
begin
Format.Set_Suffix ((0, 10), To_Atom ("th"));
Format.Set_Suffix (1, To_Atom ("st"));
Format.Remove_Suffix (0);
Test_Render (Test, Format, "", -1, "-1");
Test_Render (Test, Format, "", 0, "0");
Test_Render (Test, Format, "", 1, "1st");
Test_Render (Test, Format, "", 4, "4th");
Test_Render (Test, Format, "", 10, "10th");
end;
Test_Render (Test, Ordinal, -1, "-1?");
Test_Render (Test, Ordinal, 0, "0");
Test_Render (Test, Ordinal, 1, "1st");
Test_Render (Test, Ordinal, 2, "2nd");
Test_Render (Test, Ordinal, 3, "3rd");
Test_Render (Test, Ordinal, 4, "4th");
Test_Render (Test, "(prefix (a) (b invalid (9 5)))", 0, "0");
Test_Render (Test, "(prefix (c (invalid 5) (-1 invalid)))", 0, "0");
Test_Render (Test, "(prefix (d ((invalid) 5) (-1)) ())", 0, "0");
declare
Format : Templates.Integers.Format;
begin
Format.Set_Minimum_Width (10);
Format.Set_Suffix (1, To_Atom ("<sup>er</sup>"), 2);
Format.Set_Prefix (10, To_Atom ("dix : "));
Test_Render (Test, Format, "", 5, " 5");
Test_Render (Test, Format, "", 1, " 1<sup>er</sup>");
Test_Render (Test, Format, "(centered)", 10, " dix : 10 ");
Test_Render (Test, Format, "(suffix ((th 0) 7))", 7, " 7th");
end;
exception
when Error : others => Test.Report_Exception (Error);
end Prefix_And_Suffix;
procedure Static_Hash_Map (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Parse errors in template");
begin
if not Natools.Static_Maps.S_Expressions.Templates.Integers.T then
Test.Fail;
end if;
exception
when Error : others => Test.Report_Exception (Error);
end Static_Hash_Map;
end Natools.S_Expressions.Templates.Tests.Integers;
| 20659 | ------------------------------------------------------------------------------
-- Copyright (c) 2014, <NAME> --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Natools.S_Expressions.Parsers;
with Natools.S_Expressions.Test_Tools;
with Natools.S_Expressions.Templates.Integers;
with Natools.Static_Maps.S_Expressions.Templates.Integers.T;
package body Natools.S_Expressions.Templates.Tests.Integers is
procedure Test_Render
(Test : in out NT.Test;
Defaults : in Templates.Integers.Format;
Template : in String;
Value : in Integer;
Expected : in String);
procedure Test_Render
(Test : in out NT.Test;
Template : in String;
Value : in Integer;
Expected : in String);
-- Run Template with Value and compare the result with Expected
------------------------------
-- Local Helper Subprograms --
------------------------------
procedure Test_Render
(Test : in out NT.Test;
Template : in String;
Value : in Integer;
Expected : in String)
is
Input : aliased Test_Tools.Memory_Stream;
Output : Test_Tools.Memory_Stream;
Parser : Parsers.Stream_Parser (Input'Access);
begin
Input.Set_Data (To_Atom (Template));
Parser.Next;
Output.Set_Expected (To_Atom (Expected));
Templates.Integers.Render (Output, Parser, Value);
Output.Check_Stream (Test);
end Test_Render;
procedure Test_Render
(Test : in out NT.Test;
Defaults : in Templates.Integers.Format;
Template : in String;
Value : in Integer;
Expected : in String)
is
Input : aliased Test_Tools.Memory_Stream;
Output : Test_Tools.Memory_Stream;
Parser : Parsers.Stream_Parser (Input'Access);
begin
Input.Set_Data (To_Atom (Template));
Parser.Next;
Output.Set_Expected (To_Atom (Expected));
Templates.Integers.Render (Output, Defaults, Parser, Value);
Output.Check_Stream (Test);
end Test_Render;
-------------------------
-- Complete Test Suite --
-------------------------
procedure All_Tests (Report : in out NT.Reporter'Class) is
begin
Alignment (Report);
Default_Format (Report);
Explicit_Images (Report);
Explicit_Sign (Report);
Hexadecimal (Report);
Overflow (Report);
Parse_Errors (Report);
Static_Hash_Map (Report);
Explicit_Default_Format (Report);
Prefix_And_Suffix (Report);
end All_Tests;
-----------------------
-- Inidividual Tests --
-----------------------
procedure Alignment (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Debug instantiation");
begin
Test_Render (Test, "(width 5)", 0, " 0");
Test_Render (Test, "(width 5)(padding _)(align center)", 10, "_10__");
Test_Render (Test, "(width 5 10)(left-align)", 7, "7 ");
Test_Render (Test, "(min-width 5)(right-align)", 2, " 2");
Test_Render (Test, "(width 5)(padding > <)(centered)", 4, ">>4<<");
Test_Render
(Test,
"(width 5)(left-padding ""["")(right-padding ""]"")(centered)",
126,
"[126]");
Test_Render (Test, "(width 3)(centered)", 16, "16 ");
Test_Render (Test, "(width 3)(centered)", 456, "456");
Test_Render (Test, "(width 3)(align left)", 567, "567");
Test_Render (Test, "(width 3)(align right)", 678, "678");
exception
when Error : others => Test.Report_Exception (Error);
end Alignment;
procedure Default_Format (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Debug instantiation");
begin
Test_Render (Test, "", 42, "42");
exception
when Error : others => Test.Report_Exception (Error);
end Default_Format;
procedure Explicit_Default_Format (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Client-provided default format");
begin
declare
Default : Templates.Integers.Format;
begin
Default.Set_Minimum_Width (2);
Default.Set_Left_Padding (To_Atom ("0"));
Test_Render (Test, Default, "", 5, "05");
Test_Render (Test, Default, "", 12, "12");
Test_Render (Test, Default, "(padding 1: )", 7, " 7");
end;
exception
when Error : others => Test.Report_Exception (Error);
end Explicit_Default_Format;
procedure Explicit_Images (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Explicit images in template");
begin
Test_Render (Test, "(image (-2 two) (666 evil))", 10, "10");
Test_Render (Test, "(image (-2 two) (666 evil))", -2, "two");
Test_Render (Test, "(image (-2 two) (666 evil))", 666, "evil");
Test_Render (Test, "(image (-2 two) (666 evil) (-2))", -2, "-2");
Test_Render (Test, "(image (1 one))3:Two4:four", 1, "one");
Test_Render (Test, "(image (1 one))3:Two4:four", 2, "Two");
Test_Render (Test, "(image (1 one))3:Two4:four", 3, "four");
Test_Render (Test, "(image (1 one))3:Two4:four", 4, "4");
Test_Render (Test, "(image (invalid -))5:first", Integer'First, "first");
Test_Render (Test, "(image-range (""?"" (10 19)))", 9, "9");
Test_Render (Test, "(image-range (""?"" (10 19)))", 10, "?");
Test_Render (Test, "(image-range (""?"" (10 19)))", 15, "?");
Test_Render (Test, "(image-range (""?"" (10 19)))", 19, "?");
Test_Render (Test, "(image-range (""?"" (10 19)))", 20, "20");
exception
when Error : others => Test.Report_Exception (Error);
end Explicit_Images;
procedure Explicit_Sign (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Explicit sign specification");
begin
Test_Render (Test, "(sign +)", 42, "+42");
Test_Render (Test, "(sign + _)", 42, "+42");
Test_Render (Test, "(sign + _)", -42, "_42");
exception
when Error : others => Test.Report_Exception (Error);
end Explicit_Sign;
procedure Hexadecimal (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Hexadecimal representation");
Hex_Spec : constant String
:= "(base 0 1 2 3 4 5 6 7 8 9 A B C D E F)";
begin
Test_Render (Test, Hex_Spec, 8, "8");
Test_Render (Test, Hex_Spec, 16#BEE#, "BEE");
exception
when Error : others => Test.Report_Exception (Error);
end Hexadecimal;
procedure Overflow (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Width overflow");
begin
Test_Render (Test, "(width 3)", 10_000, "");
Test_Render (Test, "(max-width 4)", 10_000, "");
Test_Render (Test, "(max-width 3 ""[...]"")", 10_000, "[...]");
Test_Render (Test, "(width 2 3 ...)", 10_000, "...");
exception
when Error : others => Test.Report_Exception (Error);
end Overflow;
procedure Parse_Errors (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Parse errors in template");
begin
Test_Render (Test, "(invalid-command)", 1, "1");
Test_Render (Test, "(align)", 2, "2");
Test_Render (Test, "(align invalid)", 3, "3");
Test_Render (Test, "(padding)", 4, "4");
Test_Render (Test, "(left-padding)", 5, "5");
Test_Render (Test, "(right-padding)", 6, "6");
Test_Render (Test, "(signs)", 7, "7");
Test_Render (Test, "(width)", 8, "8");
Test_Render (Test, "(max-width)", 9, "9");
Test_Render (Test, "(min-width)", 10, "10");
exception
when Error : others => Test.Report_Exception (Error);
end Parse_Errors;
procedure Prefix_And_Suffix (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Parse errors in template");
Ordinal : constant String
:= "(suffix 1:? (th (0 31)) (st 1 21 31) (nd 2 22) (rd 3 23) (0: 0))";
begin
declare
Format : Templates.Integers.Format;
begin
Format.Set_Prefix ((0, 9), To_Atom ("a"));
Format.Set_Prefix ((-99, -10), To_Atom ("b"));
Format.Set_Prefix ((50, 99), To_Atom ("c"));
Format.Set_Prefix (0, To_Atom ("d"));
Format.Set_Prefix (-10, To_Atom ("e"));
Format.Set_Prefix (5, To_Atom ("f"));
Format.Set_Prefix ((7, 52), To_Atom ("g"));
Format.Set_Prefix ((-52, -49), To_Atom ("h"));
Format.Set_Prefix ((-100, -90), To_Atom ("i"));
Format.Remove_Prefix (8);
Test_Render (Test, Format, "", -196, "-196");
Test_Render (Test, Format, "", -101, "-101");
Test_Render (Test, Format, "", -100, "i-100");
Test_Render (Test, Format, "", -90, "i-90");
Test_Render (Test, Format, "", -89, "b-89");
Test_Render (Test, Format, "", -53, "b-53");
Test_Render (Test, Format, "", -52, "h-52");
Test_Render (Test, Format, "", -49, "h-49");
Test_Render (Test, Format, "", -48, "b-48");
Test_Render (Test, Format, "", -11, "b-11");
Test_Render (Test, Format, "", -10, "e-10");
Test_Render (Test, Format, "", -9, "-9");
Test_Render (Test, Format, "", -1, "-1");
Test_Render (Test, Format, "", 0, "d0");
Test_Render (Test, Format, "", 1, "a1");
Test_Render (Test, Format, "", 4, "a4");
Test_Render (Test, Format, "", 5, "f5");
Test_Render (Test, Format, "", 6, "a6");
Test_Render (Test, Format, "", 7, "g7");
Test_Render (Test, Format, "", 8, "8");
Test_Render (Test, Format, "", 9, "g9");
Test_Render (Test, Format, "", 52, "g52");
Test_Render (Test, Format, "", 53, "c53");
Test_Render (Test, Format, "", 99, "c99");
Test_Render (Test, Format, "", 100, "100");
Test_Render (Test, Format, "", 192, "192");
end;
declare
Format : Templates.Integers.Format;
begin
Format.Set_Suffix ((0, 10), To_Atom ("th"));
Format.Set_Suffix (1, To_Atom ("st"));
Format.Remove_Suffix (0);
Test_Render (Test, Format, "", -1, "-1");
Test_Render (Test, Format, "", 0, "0");
Test_Render (Test, Format, "", 1, "1st");
Test_Render (Test, Format, "", 4, "4th");
Test_Render (Test, Format, "", 10, "10th");
end;
Test_Render (Test, Ordinal, -1, "-1?");
Test_Render (Test, Ordinal, 0, "0");
Test_Render (Test, Ordinal, 1, "1st");
Test_Render (Test, Ordinal, 2, "2nd");
Test_Render (Test, Ordinal, 3, "3rd");
Test_Render (Test, Ordinal, 4, "4th");
Test_Render (Test, "(prefix (a) (b invalid (9 5)))", 0, "0");
Test_Render (Test, "(prefix (c (invalid 5) (-1 invalid)))", 0, "0");
Test_Render (Test, "(prefix (d ((invalid) 5) (-1)) ())", 0, "0");
declare
Format : Templates.Integers.Format;
begin
Format.Set_Minimum_Width (10);
Format.Set_Suffix (1, To_Atom ("<sup>er</sup>"), 2);
Format.Set_Prefix (10, To_Atom ("dix : "));
Test_Render (Test, Format, "", 5, " 5");
Test_Render (Test, Format, "", 1, " 1<sup>er</sup>");
Test_Render (Test, Format, "(centered)", 10, " dix : 10 ");
Test_Render (Test, Format, "(suffix ((th 0) 7))", 7, " 7th");
end;
exception
when Error : others => Test.Report_Exception (Error);
end Prefix_And_Suffix;
procedure Static_Hash_Map (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Parse errors in template");
begin
if not Natools.Static_Maps.S_Expressions.Templates.Integers.T then
Test.Fail;
end if;
exception
when Error : others => Test.Report_Exception (Error);
end Static_Hash_Map;
end Natools.S_Expressions.Templates.Tests.Integers;
| true | ------------------------------------------------------------------------------
-- Copyright (c) 2014, PI:NAME:<NAME>END_PI --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Natools.S_Expressions.Parsers;
with Natools.S_Expressions.Test_Tools;
with Natools.S_Expressions.Templates.Integers;
with Natools.Static_Maps.S_Expressions.Templates.Integers.T;
package body Natools.S_Expressions.Templates.Tests.Integers is
procedure Test_Render
(Test : in out NT.Test;
Defaults : in Templates.Integers.Format;
Template : in String;
Value : in Integer;
Expected : in String);
procedure Test_Render
(Test : in out NT.Test;
Template : in String;
Value : in Integer;
Expected : in String);
-- Run Template with Value and compare the result with Expected
------------------------------
-- Local Helper Subprograms --
------------------------------
procedure Test_Render
(Test : in out NT.Test;
Template : in String;
Value : in Integer;
Expected : in String)
is
Input : aliased Test_Tools.Memory_Stream;
Output : Test_Tools.Memory_Stream;
Parser : Parsers.Stream_Parser (Input'Access);
begin
Input.Set_Data (To_Atom (Template));
Parser.Next;
Output.Set_Expected (To_Atom (Expected));
Templates.Integers.Render (Output, Parser, Value);
Output.Check_Stream (Test);
end Test_Render;
procedure Test_Render
(Test : in out NT.Test;
Defaults : in Templates.Integers.Format;
Template : in String;
Value : in Integer;
Expected : in String)
is
Input : aliased Test_Tools.Memory_Stream;
Output : Test_Tools.Memory_Stream;
Parser : Parsers.Stream_Parser (Input'Access);
begin
Input.Set_Data (To_Atom (Template));
Parser.Next;
Output.Set_Expected (To_Atom (Expected));
Templates.Integers.Render (Output, Defaults, Parser, Value);
Output.Check_Stream (Test);
end Test_Render;
-------------------------
-- Complete Test Suite --
-------------------------
procedure All_Tests (Report : in out NT.Reporter'Class) is
begin
Alignment (Report);
Default_Format (Report);
Explicit_Images (Report);
Explicit_Sign (Report);
Hexadecimal (Report);
Overflow (Report);
Parse_Errors (Report);
Static_Hash_Map (Report);
Explicit_Default_Format (Report);
Prefix_And_Suffix (Report);
end All_Tests;
-----------------------
-- Inidividual Tests --
-----------------------
procedure Alignment (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Debug instantiation");
begin
Test_Render (Test, "(width 5)", 0, " 0");
Test_Render (Test, "(width 5)(padding _)(align center)", 10, "_10__");
Test_Render (Test, "(width 5 10)(left-align)", 7, "7 ");
Test_Render (Test, "(min-width 5)(right-align)", 2, " 2");
Test_Render (Test, "(width 5)(padding > <)(centered)", 4, ">>4<<");
Test_Render
(Test,
"(width 5)(left-padding ""["")(right-padding ""]"")(centered)",
126,
"[126]");
Test_Render (Test, "(width 3)(centered)", 16, "16 ");
Test_Render (Test, "(width 3)(centered)", 456, "456");
Test_Render (Test, "(width 3)(align left)", 567, "567");
Test_Render (Test, "(width 3)(align right)", 678, "678");
exception
when Error : others => Test.Report_Exception (Error);
end Alignment;
procedure Default_Format (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Debug instantiation");
begin
Test_Render (Test, "", 42, "42");
exception
when Error : others => Test.Report_Exception (Error);
end Default_Format;
procedure Explicit_Default_Format (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Client-provided default format");
begin
declare
Default : Templates.Integers.Format;
begin
Default.Set_Minimum_Width (2);
Default.Set_Left_Padding (To_Atom ("0"));
Test_Render (Test, Default, "", 5, "05");
Test_Render (Test, Default, "", 12, "12");
Test_Render (Test, Default, "(padding 1: )", 7, " 7");
end;
exception
when Error : others => Test.Report_Exception (Error);
end Explicit_Default_Format;
procedure Explicit_Images (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Explicit images in template");
begin
Test_Render (Test, "(image (-2 two) (666 evil))", 10, "10");
Test_Render (Test, "(image (-2 two) (666 evil))", -2, "two");
Test_Render (Test, "(image (-2 two) (666 evil))", 666, "evil");
Test_Render (Test, "(image (-2 two) (666 evil) (-2))", -2, "-2");
Test_Render (Test, "(image (1 one))3:Two4:four", 1, "one");
Test_Render (Test, "(image (1 one))3:Two4:four", 2, "Two");
Test_Render (Test, "(image (1 one))3:Two4:four", 3, "four");
Test_Render (Test, "(image (1 one))3:Two4:four", 4, "4");
Test_Render (Test, "(image (invalid -))5:first", Integer'First, "first");
Test_Render (Test, "(image-range (""?"" (10 19)))", 9, "9");
Test_Render (Test, "(image-range (""?"" (10 19)))", 10, "?");
Test_Render (Test, "(image-range (""?"" (10 19)))", 15, "?");
Test_Render (Test, "(image-range (""?"" (10 19)))", 19, "?");
Test_Render (Test, "(image-range (""?"" (10 19)))", 20, "20");
exception
when Error : others => Test.Report_Exception (Error);
end Explicit_Images;
procedure Explicit_Sign (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Explicit sign specification");
begin
Test_Render (Test, "(sign +)", 42, "+42");
Test_Render (Test, "(sign + _)", 42, "+42");
Test_Render (Test, "(sign + _)", -42, "_42");
exception
when Error : others => Test.Report_Exception (Error);
end Explicit_Sign;
procedure Hexadecimal (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Hexadecimal representation");
Hex_Spec : constant String
:= "(base 0 1 2 3 4 5 6 7 8 9 A B C D E F)";
begin
Test_Render (Test, Hex_Spec, 8, "8");
Test_Render (Test, Hex_Spec, 16#BEE#, "BEE");
exception
when Error : others => Test.Report_Exception (Error);
end Hexadecimal;
procedure Overflow (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Width overflow");
begin
Test_Render (Test, "(width 3)", 10_000, "");
Test_Render (Test, "(max-width 4)", 10_000, "");
Test_Render (Test, "(max-width 3 ""[...]"")", 10_000, "[...]");
Test_Render (Test, "(width 2 3 ...)", 10_000, "...");
exception
when Error : others => Test.Report_Exception (Error);
end Overflow;
procedure Parse_Errors (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Parse errors in template");
begin
Test_Render (Test, "(invalid-command)", 1, "1");
Test_Render (Test, "(align)", 2, "2");
Test_Render (Test, "(align invalid)", 3, "3");
Test_Render (Test, "(padding)", 4, "4");
Test_Render (Test, "(left-padding)", 5, "5");
Test_Render (Test, "(right-padding)", 6, "6");
Test_Render (Test, "(signs)", 7, "7");
Test_Render (Test, "(width)", 8, "8");
Test_Render (Test, "(max-width)", 9, "9");
Test_Render (Test, "(min-width)", 10, "10");
exception
when Error : others => Test.Report_Exception (Error);
end Parse_Errors;
procedure Prefix_And_Suffix (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Parse errors in template");
Ordinal : constant String
:= "(suffix 1:? (th (0 31)) (st 1 21 31) (nd 2 22) (rd 3 23) (0: 0))";
begin
declare
Format : Templates.Integers.Format;
begin
Format.Set_Prefix ((0, 9), To_Atom ("a"));
Format.Set_Prefix ((-99, -10), To_Atom ("b"));
Format.Set_Prefix ((50, 99), To_Atom ("c"));
Format.Set_Prefix (0, To_Atom ("d"));
Format.Set_Prefix (-10, To_Atom ("e"));
Format.Set_Prefix (5, To_Atom ("f"));
Format.Set_Prefix ((7, 52), To_Atom ("g"));
Format.Set_Prefix ((-52, -49), To_Atom ("h"));
Format.Set_Prefix ((-100, -90), To_Atom ("i"));
Format.Remove_Prefix (8);
Test_Render (Test, Format, "", -196, "-196");
Test_Render (Test, Format, "", -101, "-101");
Test_Render (Test, Format, "", -100, "i-100");
Test_Render (Test, Format, "", -90, "i-90");
Test_Render (Test, Format, "", -89, "b-89");
Test_Render (Test, Format, "", -53, "b-53");
Test_Render (Test, Format, "", -52, "h-52");
Test_Render (Test, Format, "", -49, "h-49");
Test_Render (Test, Format, "", -48, "b-48");
Test_Render (Test, Format, "", -11, "b-11");
Test_Render (Test, Format, "", -10, "e-10");
Test_Render (Test, Format, "", -9, "-9");
Test_Render (Test, Format, "", -1, "-1");
Test_Render (Test, Format, "", 0, "d0");
Test_Render (Test, Format, "", 1, "a1");
Test_Render (Test, Format, "", 4, "a4");
Test_Render (Test, Format, "", 5, "f5");
Test_Render (Test, Format, "", 6, "a6");
Test_Render (Test, Format, "", 7, "g7");
Test_Render (Test, Format, "", 8, "8");
Test_Render (Test, Format, "", 9, "g9");
Test_Render (Test, Format, "", 52, "g52");
Test_Render (Test, Format, "", 53, "c53");
Test_Render (Test, Format, "", 99, "c99");
Test_Render (Test, Format, "", 100, "100");
Test_Render (Test, Format, "", 192, "192");
end;
declare
Format : Templates.Integers.Format;
begin
Format.Set_Suffix ((0, 10), To_Atom ("th"));
Format.Set_Suffix (1, To_Atom ("st"));
Format.Remove_Suffix (0);
Test_Render (Test, Format, "", -1, "-1");
Test_Render (Test, Format, "", 0, "0");
Test_Render (Test, Format, "", 1, "1st");
Test_Render (Test, Format, "", 4, "4th");
Test_Render (Test, Format, "", 10, "10th");
end;
Test_Render (Test, Ordinal, -1, "-1?");
Test_Render (Test, Ordinal, 0, "0");
Test_Render (Test, Ordinal, 1, "1st");
Test_Render (Test, Ordinal, 2, "2nd");
Test_Render (Test, Ordinal, 3, "3rd");
Test_Render (Test, Ordinal, 4, "4th");
Test_Render (Test, "(prefix (a) (b invalid (9 5)))", 0, "0");
Test_Render (Test, "(prefix (c (invalid 5) (-1 invalid)))", 0, "0");
Test_Render (Test, "(prefix (d ((invalid) 5) (-1)) ())", 0, "0");
declare
Format : Templates.Integers.Format;
begin
Format.Set_Minimum_Width (10);
Format.Set_Suffix (1, To_Atom ("<sup>er</sup>"), 2);
Format.Set_Prefix (10, To_Atom ("dix : "));
Test_Render (Test, Format, "", 5, " 5");
Test_Render (Test, Format, "", 1, " 1<sup>er</sup>");
Test_Render (Test, Format, "(centered)", 10, " dix : 10 ");
Test_Render (Test, Format, "(suffix ((th 0) 7))", 7, " 7th");
end;
exception
when Error : others => Test.Report_Exception (Error);
end Prefix_And_Suffix;
procedure Static_Hash_Map (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Parse errors in template");
begin
if not Natools.Static_Maps.S_Expressions.Templates.Integers.T then
Test.Fail;
end if;
exception
when Error : others => Test.Report_Exception (Error);
end Static_Hash_Map;
end Natools.S_Expressions.Templates.Tests.Integers;
|
[
{
"context": "---------------------\n-- Copyright (c) 2006-2013, Maxim Reznik\n-- All rights reserved.\n--\n-- Redistribution an",
"end": 1812,
"score": 0.9997780919075012,
"start": 1800,
"tag": "NAME",
"value": "Maxim Reznik"
},
{
"context": "the distribution.\n-- * Neither the name of the Maxim Reznik, IE nor the names of its\n-- contributors ma",
"end": 2413,
"score": 0.9998720288276672,
"start": 2401,
"tag": "NAME",
"value": "Maxim Reznik"
}
] | source/libgela/gela-containers-vectors.ads | faelys/gela-asis | 4 | ------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
-- Purpose:
generic
type Item_Type is private;
type Index_Type is range <>;
package Gela.Containers.Vectors is
pragma Preelaborate;
type Vector is private;
procedure Add
(Object : in out Vector;
Item : in Item_Type);
procedure Clear (Object : in out Vector);
procedure Free (Object : in out Vector);
function Length (Object : Vector) return Index_Type'Base;
function Get (Object : Vector; Index : Index_Type) return Item_Type;
procedure Set
(Object : in out Vector;
Index : in Index_Type;
Item : in Item_Type);
procedure Copy
(Target : in out Vector;
Source : in Vector);
private
type Vector_Node;
type Vector is access all Vector_Node;
Default_Size : constant Index_Type := 8 * 4096 / Item_Type'Size;
type Table is array (Index_Type range <>) of Item_Type;
type Vector_Node (Size : Index_Type) is record
Data : Table (1 .. Size);
Last : Index_Type'Base := 0;
Next : Vector;
end record;
end Gela.Containers.Vectors;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, Maxim Reznik
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the Maxim Reznik, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
| 2979 | ------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
-- Purpose:
generic
type Item_Type is private;
type Index_Type is range <>;
package Gela.Containers.Vectors is
pragma Preelaborate;
type Vector is private;
procedure Add
(Object : in out Vector;
Item : in Item_Type);
procedure Clear (Object : in out Vector);
procedure Free (Object : in out Vector);
function Length (Object : Vector) return Index_Type'Base;
function Get (Object : Vector; Index : Index_Type) return Item_Type;
procedure Set
(Object : in out Vector;
Index : in Index_Type;
Item : in Item_Type);
procedure Copy
(Target : in out Vector;
Source : in Vector);
private
type Vector_Node;
type Vector is access all Vector_Node;
Default_Size : constant Index_Type := 8 * 4096 / Item_Type'Size;
type Table is array (Index_Type range <>) of Item_Type;
type Vector_Node (Size : Index_Type) is record
Data : Table (1 .. Size);
Last : Index_Type'Base := 0;
Next : Vector;
end record;
end Gela.Containers.Vectors;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, <NAME>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the <NAME>, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
| true | ------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
-- Purpose:
generic
type Item_Type is private;
type Index_Type is range <>;
package Gela.Containers.Vectors is
pragma Preelaborate;
type Vector is private;
procedure Add
(Object : in out Vector;
Item : in Item_Type);
procedure Clear (Object : in out Vector);
procedure Free (Object : in out Vector);
function Length (Object : Vector) return Index_Type'Base;
function Get (Object : Vector; Index : Index_Type) return Item_Type;
procedure Set
(Object : in out Vector;
Index : in Index_Type;
Item : in Item_Type);
procedure Copy
(Target : in out Vector;
Source : in Vector);
private
type Vector_Node;
type Vector is access all Vector_Node;
Default_Size : constant Index_Type := 8 * 4096 / Item_Type'Size;
type Table is array (Index_Type range <>) of Item_Type;
type Vector_Node (Size : Index_Type) is record
Data : Table (1 .. Size);
Last : Index_Type'Base := 0;
Next : Vector;
end record;
end Gela.Containers.Vectors;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, PI:NAME:<NAME>END_PI
-- 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 PI:NAME:<NAME>END_PI, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
|
[
{
"context": "rfaces -- Network interface\n-- Copyright (C) 2016 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@g",
"end": 150,
"score": 0.999873161315918,
"start": 135,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": " Copyright (C) 2016 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under",
"end": 181,
"score": 0.9998840093612671,
"start": 166,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "6 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under the Apache License, Versio",
"end": 208,
"score": 0.9999223947525024,
"start": 183,
"tag": "EMAIL",
"value": "Stephane.Carrez@gmail.com"
}
] | src/net-interfaces.adb | stcarrez/ada-enet | 16 | -----------------------------------------------------------------------
-- net-interfaces -- Network interface
-- Copyright (C) 2016 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.
-----------------------------------------------------------------------
package body Net.Interfaces is
-- ------------------------------
-- Check if the IP address is in the same subnet as the interface IP address.
-- ------------------------------
function Is_Local_Network (Ifnet : in Ifnet_Type;
Ip : in Ip_Addr) return Boolean is
begin
for I in Ip'Range loop
if (Ifnet.Netmask (I) and Ip (I)) /= (Ifnet.Netmask (I) and Ifnet.Ip (I)) then
return False;
end if;
end loop;
return True;
end Is_Local_Network;
end Net.Interfaces;
| 12064 | -----------------------------------------------------------------------
-- net-interfaces -- Network interface
-- Copyright (C) 2016 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Net.Interfaces is
-- ------------------------------
-- Check if the IP address is in the same subnet as the interface IP address.
-- ------------------------------
function Is_Local_Network (Ifnet : in Ifnet_Type;
Ip : in Ip_Addr) return Boolean is
begin
for I in Ip'Range loop
if (Ifnet.Netmask (I) and Ip (I)) /= (Ifnet.Netmask (I) and Ifnet.Ip (I)) then
return False;
end if;
end loop;
return True;
end Is_Local_Network;
end Net.Interfaces;
| true | -----------------------------------------------------------------------
-- net-interfaces -- Network interface
-- Copyright (C) 2016 PI:NAME:<NAME>END_PI
-- Written by PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Net.Interfaces is
-- ------------------------------
-- Check if the IP address is in the same subnet as the interface IP address.
-- ------------------------------
function Is_Local_Network (Ifnet : in Ifnet_Type;
Ip : in Ip_Addr) return Boolean is
begin
for I in Ip'Range loop
if (Ifnet.Netmask (I) and Ip (I)) /= (Ifnet.Netmask (I) and Ifnet.Ip (I)) then
return False;
end if;
end loop;
return True;
end Is_Local_Network;
end Net.Interfaces;
|
[
{
"context": "e original SPITBOL MINIMAL sources,\n-- created by Robert Dewar. The translation is not exact, but the\n-- algori",
"end": 2663,
"score": 0.9998564124107361,
"start": 2651,
"tag": "NAME",
"value": "Robert Dewar"
}
] | Validation/pyFrame3DD-master/gcc-master/gcc/ada/libgnat/g-spitbo.ads | djamal2727/Main-Bearing-Analytical-Model | 0 | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- G N A T . S P I T B O L --
-- --
-- S p e c --
-- --
-- Copyright (C) 1997-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. --
-- --
------------------------------------------------------------------------------
-- SPITBOL-like interface facilities
-- This package provides a set of interfaces to semantic operations copied
-- from SPITBOL, including a complete implementation of SPITBOL pattern
-- matching. The code is derived from the original SPITBOL MINIMAL sources,
-- created by Robert Dewar. The translation is not exact, but the
-- algorithmic approaches are similar.
with Ada.Finalization; use Ada.Finalization;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Interfaces; use Interfaces;
package GNAT.Spitbol is
pragma Preelaborate;
-- The Spitbol package relies heavily on the Unbounded_String package,
-- using the synonym VString for variable length string. The following
-- declarations define this type and other useful abbreviations.
subtype VString is Ada.Strings.Unbounded.Unbounded_String;
function V (Source : String) return VString
renames Ada.Strings.Unbounded.To_Unbounded_String;
function S (Source : VString) return String
renames Ada.Strings.Unbounded.To_String;
Nul : VString renames Ada.Strings.Unbounded.Null_Unbounded_String;
-------------------------
-- Facilities Provided --
-------------------------
-- The SPITBOL support in GNAT consists of this package together with
-- several child packages. In this package, we have first a set of
-- useful string functions, copied exactly from the corresponding
-- SPITBOL functions, except that we had to rename REVERSE because
-- reverse is a reserved word (it is now Reverse_String).
-- The second element of the parent package is a generic implementation
-- of a table facility. In SPITBOL, the TABLE function allows general
-- mappings from any datatype to any other datatype, and of course, as
-- always, we can freely mix multiple types in the same table.
-- The Ada version of tables is strongly typed, so the indexing type and
-- the range type are always of a consistent type. In this implementation
-- we only provide VString as an indexing type, since this is by far the
-- most common case. The generic instantiation specifies the range type
-- to be used.
-- Three child packages provide standard instantiations of this table
-- package for three common datatypes:
-- GNAT.Spitbol.Table_Boolean (file g-sptabo.ads)
-- The range type is Boolean. The default value is False. This
-- means that this table is essentially a representation of a set.
-- GNAT.Spitbol.Table_Integer (file g-sptain.ads)
-- The range type is Integer. The default value is Integer'First.
-- This provides a general mapping from strings to integers.
-- GNAT.Spitbol.Table_VString (file g-sptavs.ads)
-- The range type is VString. The default value is the null string.
-- This provides a general mapping from strings to strings.
-- Finally there is another child package:
-- GNAT.Spitbol.Patterns (file g-spipat.ads)
-- This child package provides a complete implementation of SPITBOL
-- pattern matching. The spec contains a complete tutorial on the
-- use of pattern matching.
---------------------------------
-- Standard String Subprograms --
---------------------------------
-- This section contains some operations on unbounded strings that are
-- closely related to those in the package Unbounded.Strings, but they
-- correspond to the SPITBOL semantics for these operations.
function Char (Num : Natural) return Character;
pragma Inline (Char);
-- Equivalent to Character'Val (Num)
function Lpad
(Str : VString;
Len : Natural;
Pad : Character := ' ') return VString;
function Lpad
(Str : String;
Len : Natural;
Pad : Character := ' ') return VString;
-- If the length of Str is greater than or equal to Len, then Str is
-- returned unchanged. Otherwise, the value returned is obtained by
-- concatenating Length (Str) - Len instances of the Pad character to
-- the left hand side.
procedure Lpad
(Str : in out VString;
Len : Natural;
Pad : Character := ' ');
-- The procedure form is identical to the function form, except that
-- the result overwrites the input argument Str.
function Reverse_String (Str : VString) return VString;
function Reverse_String (Str : String) return VString;
-- Returns result of reversing the string Str, i.e. the result returned
-- is a mirror image (end-for-end reversal) of the input string.
procedure Reverse_String (Str : in out VString);
-- The procedure form is identical to the function form, except that the
-- result overwrites the input argument Str.
function Rpad
(Str : VString;
Len : Natural;
Pad : Character := ' ') return VString;
function Rpad
(Str : String;
Len : Natural;
Pad : Character := ' ') return VString;
-- If the length of Str is greater than or equal to Len, then Str is
-- returned unchanged. Otherwise, the value returned is obtained by
-- concatenating Length (Str) - Len instances of the Pad character to
-- the right hand side.
procedure Rpad
(Str : in out VString;
Len : Natural;
Pad : Character := ' ');
-- The procedure form is identical to the function form, except that the
-- result overwrites the input argument Str.
function Size (Source : VString) return Natural
renames Ada.Strings.Unbounded.Length;
function Substr
(Str : VString;
Start : Positive;
Len : Natural) return VString;
function Substr
(Str : String;
Start : Positive;
Len : Natural) return VString;
-- Returns the substring starting at the given character position (which
-- is always counted from the start of the string, regardless of bounds,
-- e.g. 2 means starting with the second character of the string), and
-- with the length (Len) given. Index_Error is raised if the starting
-- position is out of range, and Length_Error is raised if Len is too long.
function Trim (Str : VString) return VString;
function Trim (Str : String) return VString;
-- Returns the string obtained by removing all spaces from the right
-- hand side of the string Str.
procedure Trim (Str : in out VString);
-- The procedure form is identical to the function form, except that the
-- result overwrites the input argument Str.
-----------------------
-- Utility Functions --
-----------------------
-- In SPITBOL, integer values can be freely treated as strings. The
-- following definitions help provide some of this capability in
-- some common cases.
function "&" (Num : Integer; Str : String) return String;
function "&" (Str : String; Num : Integer) return String;
function "&" (Num : Integer; Str : VString) return VString;
function "&" (Str : VString; Num : Integer) return VString;
-- In all these concatenation operations, the integer is converted to
-- its corresponding decimal string form, with no leading blank.
function S (Num : Integer) return String;
function V (Num : Integer) return VString;
-- These operators return the given integer converted to its decimal
-- string form with no leading blank.
function N (Str : VString) return Integer;
-- Converts string to number (same as Integer'Value (S (Str)))
-------------------
-- Table Support --
-------------------
-- So far, we only provide support for tables whose indexing data values
-- are strings (or unbounded strings). The values stored may be of any
-- type, as supplied by the generic formal parameter.
generic
type Value_Type is private;
-- Any non-limited type can be used as the value type in the table
Null_Value : Value_Type;
-- Value used to represent a value that is not present in the table
with function Img (A : Value_Type) return String;
-- Used to provide image of value in Dump procedure
with function "=" (A, B : Value_Type) return Boolean is <>;
-- This allows a user-defined equality function to override the
-- predefined equality function.
package Table is
------------------------
-- Table Declarations --
------------------------
type Table (N : Unsigned_32) is private;
-- This is the table type itself. A table is a mapping from string
-- values to values of Value_Type. The discriminant is an estimate of
-- the number of values in the table. If the estimate is much too
-- high, some space is wasted, if the estimate is too low, access to
-- table elements is slowed down. The type Table has copy semantics,
-- not reference semantics. This means that if a table is copied
-- using simple assignment, then the two copies refer to entirely
-- separate tables.
-----------------------------
-- Table Access Operations --
-----------------------------
function Get (T : Table; Name : VString) return Value_Type;
function Get (T : Table; Name : Character) return Value_Type;
pragma Inline (Get);
function Get (T : Table; Name : String) return Value_Type;
-- If an entry with the given name exists in the table, then the
-- corresponding Value_Type value is returned. Otherwise Null_Value
-- is returned.
function Present (T : Table; Name : VString) return Boolean;
function Present (T : Table; Name : Character) return Boolean;
pragma Inline (Present);
function Present (T : Table; Name : String) return Boolean;
-- Determines if an entry with the given name is present in the table.
-- A returned value of True means that it is in the table, otherwise
-- False indicates that it is not in the table.
procedure Delete (T : in out Table; Name : VString);
procedure Delete (T : in out Table; Name : Character);
pragma Inline (Delete);
procedure Delete (T : in out Table; Name : String);
-- Deletes the table element with the given name from the table. If
-- no element in the table has this name, then the call has no effect.
procedure Set (T : in out Table; Name : VString; Value : Value_Type);
procedure Set (T : in out Table; Name : Character; Value : Value_Type);
pragma Inline (Set);
procedure Set (T : in out Table; Name : String; Value : Value_Type);
-- Sets the value of the element with the given name to the given
-- value. If Value is equal to Null_Value, the effect is to remove
-- the entry from the table. If no element with the given name is
-- currently in the table, then a new element with the given value
-- is created.
----------------------------
-- Allocation and Copying --
----------------------------
-- Table is a controlled type, so that all storage associated with
-- tables is properly reclaimed when a Table value is abandoned.
-- Tables have value semantics rather than reference semantics as
-- in Spitbol, i.e. when you assign a copy you end up with two
-- distinct copies of the table, as though COPY had been used in
-- Spitbol. It seems clearly more appropriate in Ada to require
-- the use of explicit pointers for reference semantics.
procedure Clear (T : in out Table);
-- Clears all the elements of the given table, freeing associated
-- storage. On return T is an empty table with no elements.
procedure Copy (From : Table; To : in out Table);
-- First all the elements of table To are cleared (as described for
-- the Clear procedure above), then all the elements of table From
-- are copied into To. In the case where the tables From and To have
-- the same declared size (i.e. the same discriminant), the call to
-- Copy has the same effect as the assignment of From to To. The
-- difference is that, unlike the assignment statement, which will
-- cause a Constraint_Error if the source and target are of different
-- sizes, Copy works fine with different sized tables.
----------------
-- Conversion --
----------------
type Table_Entry is record
Name : VString;
Value : Value_Type;
end record;
type Table_Array is array (Positive range <>) of Table_Entry;
function Convert_To_Array (T : Table) return Table_Array;
-- Returns a Table_Array value with a low bound of 1, and a length
-- corresponding to the number of elements in the table. The elements
-- of the array give the elements of the table in unsorted order.
---------------
-- Debugging --
---------------
procedure Dump (T : Table; Str : String := "Table");
-- Dump contents of given table to the standard output file. The
-- string value Str is used as the name of the table in the dump.
procedure Dump (T : Table_Array; Str : String := "Table_Array");
-- Dump contents of given table array to the current output file. The
-- string value Str is used as the name of the table array in the dump.
private
------------------
-- Private Part --
------------------
-- A Table is a pointer to a hash table which contains the indicated
-- number of hash elements (the number is forced to the next odd value
-- if it is even to improve hashing performance). If more than one
-- of the entries in a table hashes to the same slot, the Next field
-- is used to chain entries from the header. The chains are not kept
-- ordered. A chain is terminated by a null pointer in Next. An unused
-- chain is marked by an element whose Name is null and whose value
-- is Null_Value.
type Hash_Element;
type Hash_Element_Ptr is access all Hash_Element;
type Hash_Element is record
Name : String_Access := null;
Value : Value_Type := Null_Value;
Next : Hash_Element_Ptr := null;
end record;
type Hash_Table is
array (Unsigned_32 range <>) of aliased Hash_Element;
type Table (N : Unsigned_32) is new Controlled with record
Elmts : Hash_Table (1 .. N);
end record;
pragma Finalize_Storage_Only (Table);
overriding procedure Adjust (Object : in out Table);
-- The Adjust procedure does a deep copy of the table structure
-- so that the effect of assignment is, like other assignments
-- in Ada, value-oriented.
overriding procedure Finalize (Object : in out Table);
-- This is the finalization routine that ensures that all storage
-- associated with a table is properly released when a table object
-- is abandoned and finalized.
end Table;
end GNAT.Spitbol;
| 7431 | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- G N A T . S P I T B O L --
-- --
-- S p e c --
-- --
-- Copyright (C) 1997-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. --
-- --
------------------------------------------------------------------------------
-- SPITBOL-like interface facilities
-- This package provides a set of interfaces to semantic operations copied
-- from SPITBOL, including a complete implementation of SPITBOL pattern
-- matching. The code is derived from the original SPITBOL MINIMAL sources,
-- created by <NAME>. The translation is not exact, but the
-- algorithmic approaches are similar.
with Ada.Finalization; use Ada.Finalization;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Interfaces; use Interfaces;
package GNAT.Spitbol is
pragma Preelaborate;
-- The Spitbol package relies heavily on the Unbounded_String package,
-- using the synonym VString for variable length string. The following
-- declarations define this type and other useful abbreviations.
subtype VString is Ada.Strings.Unbounded.Unbounded_String;
function V (Source : String) return VString
renames Ada.Strings.Unbounded.To_Unbounded_String;
function S (Source : VString) return String
renames Ada.Strings.Unbounded.To_String;
Nul : VString renames Ada.Strings.Unbounded.Null_Unbounded_String;
-------------------------
-- Facilities Provided --
-------------------------
-- The SPITBOL support in GNAT consists of this package together with
-- several child packages. In this package, we have first a set of
-- useful string functions, copied exactly from the corresponding
-- SPITBOL functions, except that we had to rename REVERSE because
-- reverse is a reserved word (it is now Reverse_String).
-- The second element of the parent package is a generic implementation
-- of a table facility. In SPITBOL, the TABLE function allows general
-- mappings from any datatype to any other datatype, and of course, as
-- always, we can freely mix multiple types in the same table.
-- The Ada version of tables is strongly typed, so the indexing type and
-- the range type are always of a consistent type. In this implementation
-- we only provide VString as an indexing type, since this is by far the
-- most common case. The generic instantiation specifies the range type
-- to be used.
-- Three child packages provide standard instantiations of this table
-- package for three common datatypes:
-- GNAT.Spitbol.Table_Boolean (file g-sptabo.ads)
-- The range type is Boolean. The default value is False. This
-- means that this table is essentially a representation of a set.
-- GNAT.Spitbol.Table_Integer (file g-sptain.ads)
-- The range type is Integer. The default value is Integer'First.
-- This provides a general mapping from strings to integers.
-- GNAT.Spitbol.Table_VString (file g-sptavs.ads)
-- The range type is VString. The default value is the null string.
-- This provides a general mapping from strings to strings.
-- Finally there is another child package:
-- GNAT.Spitbol.Patterns (file g-spipat.ads)
-- This child package provides a complete implementation of SPITBOL
-- pattern matching. The spec contains a complete tutorial on the
-- use of pattern matching.
---------------------------------
-- Standard String Subprograms --
---------------------------------
-- This section contains some operations on unbounded strings that are
-- closely related to those in the package Unbounded.Strings, but they
-- correspond to the SPITBOL semantics for these operations.
function Char (Num : Natural) return Character;
pragma Inline (Char);
-- Equivalent to Character'Val (Num)
function Lpad
(Str : VString;
Len : Natural;
Pad : Character := ' ') return VString;
function Lpad
(Str : String;
Len : Natural;
Pad : Character := ' ') return VString;
-- If the length of Str is greater than or equal to Len, then Str is
-- returned unchanged. Otherwise, the value returned is obtained by
-- concatenating Length (Str) - Len instances of the Pad character to
-- the left hand side.
procedure Lpad
(Str : in out VString;
Len : Natural;
Pad : Character := ' ');
-- The procedure form is identical to the function form, except that
-- the result overwrites the input argument Str.
function Reverse_String (Str : VString) return VString;
function Reverse_String (Str : String) return VString;
-- Returns result of reversing the string Str, i.e. the result returned
-- is a mirror image (end-for-end reversal) of the input string.
procedure Reverse_String (Str : in out VString);
-- The procedure form is identical to the function form, except that the
-- result overwrites the input argument Str.
function Rpad
(Str : VString;
Len : Natural;
Pad : Character := ' ') return VString;
function Rpad
(Str : String;
Len : Natural;
Pad : Character := ' ') return VString;
-- If the length of Str is greater than or equal to Len, then Str is
-- returned unchanged. Otherwise, the value returned is obtained by
-- concatenating Length (Str) - Len instances of the Pad character to
-- the right hand side.
procedure Rpad
(Str : in out VString;
Len : Natural;
Pad : Character := ' ');
-- The procedure form is identical to the function form, except that the
-- result overwrites the input argument Str.
function Size (Source : VString) return Natural
renames Ada.Strings.Unbounded.Length;
function Substr
(Str : VString;
Start : Positive;
Len : Natural) return VString;
function Substr
(Str : String;
Start : Positive;
Len : Natural) return VString;
-- Returns the substring starting at the given character position (which
-- is always counted from the start of the string, regardless of bounds,
-- e.g. 2 means starting with the second character of the string), and
-- with the length (Len) given. Index_Error is raised if the starting
-- position is out of range, and Length_Error is raised if Len is too long.
function Trim (Str : VString) return VString;
function Trim (Str : String) return VString;
-- Returns the string obtained by removing all spaces from the right
-- hand side of the string Str.
procedure Trim (Str : in out VString);
-- The procedure form is identical to the function form, except that the
-- result overwrites the input argument Str.
-----------------------
-- Utility Functions --
-----------------------
-- In SPITBOL, integer values can be freely treated as strings. The
-- following definitions help provide some of this capability in
-- some common cases.
function "&" (Num : Integer; Str : String) return String;
function "&" (Str : String; Num : Integer) return String;
function "&" (Num : Integer; Str : VString) return VString;
function "&" (Str : VString; Num : Integer) return VString;
-- In all these concatenation operations, the integer is converted to
-- its corresponding decimal string form, with no leading blank.
function S (Num : Integer) return String;
function V (Num : Integer) return VString;
-- These operators return the given integer converted to its decimal
-- string form with no leading blank.
function N (Str : VString) return Integer;
-- Converts string to number (same as Integer'Value (S (Str)))
-------------------
-- Table Support --
-------------------
-- So far, we only provide support for tables whose indexing data values
-- are strings (or unbounded strings). The values stored may be of any
-- type, as supplied by the generic formal parameter.
generic
type Value_Type is private;
-- Any non-limited type can be used as the value type in the table
Null_Value : Value_Type;
-- Value used to represent a value that is not present in the table
with function Img (A : Value_Type) return String;
-- Used to provide image of value in Dump procedure
with function "=" (A, B : Value_Type) return Boolean is <>;
-- This allows a user-defined equality function to override the
-- predefined equality function.
package Table is
------------------------
-- Table Declarations --
------------------------
type Table (N : Unsigned_32) is private;
-- This is the table type itself. A table is a mapping from string
-- values to values of Value_Type. The discriminant is an estimate of
-- the number of values in the table. If the estimate is much too
-- high, some space is wasted, if the estimate is too low, access to
-- table elements is slowed down. The type Table has copy semantics,
-- not reference semantics. This means that if a table is copied
-- using simple assignment, then the two copies refer to entirely
-- separate tables.
-----------------------------
-- Table Access Operations --
-----------------------------
function Get (T : Table; Name : VString) return Value_Type;
function Get (T : Table; Name : Character) return Value_Type;
pragma Inline (Get);
function Get (T : Table; Name : String) return Value_Type;
-- If an entry with the given name exists in the table, then the
-- corresponding Value_Type value is returned. Otherwise Null_Value
-- is returned.
function Present (T : Table; Name : VString) return Boolean;
function Present (T : Table; Name : Character) return Boolean;
pragma Inline (Present);
function Present (T : Table; Name : String) return Boolean;
-- Determines if an entry with the given name is present in the table.
-- A returned value of True means that it is in the table, otherwise
-- False indicates that it is not in the table.
procedure Delete (T : in out Table; Name : VString);
procedure Delete (T : in out Table; Name : Character);
pragma Inline (Delete);
procedure Delete (T : in out Table; Name : String);
-- Deletes the table element with the given name from the table. If
-- no element in the table has this name, then the call has no effect.
procedure Set (T : in out Table; Name : VString; Value : Value_Type);
procedure Set (T : in out Table; Name : Character; Value : Value_Type);
pragma Inline (Set);
procedure Set (T : in out Table; Name : String; Value : Value_Type);
-- Sets the value of the element with the given name to the given
-- value. If Value is equal to Null_Value, the effect is to remove
-- the entry from the table. If no element with the given name is
-- currently in the table, then a new element with the given value
-- is created.
----------------------------
-- Allocation and Copying --
----------------------------
-- Table is a controlled type, so that all storage associated with
-- tables is properly reclaimed when a Table value is abandoned.
-- Tables have value semantics rather than reference semantics as
-- in Spitbol, i.e. when you assign a copy you end up with two
-- distinct copies of the table, as though COPY had been used in
-- Spitbol. It seems clearly more appropriate in Ada to require
-- the use of explicit pointers for reference semantics.
procedure Clear (T : in out Table);
-- Clears all the elements of the given table, freeing associated
-- storage. On return T is an empty table with no elements.
procedure Copy (From : Table; To : in out Table);
-- First all the elements of table To are cleared (as described for
-- the Clear procedure above), then all the elements of table From
-- are copied into To. In the case where the tables From and To have
-- the same declared size (i.e. the same discriminant), the call to
-- Copy has the same effect as the assignment of From to To. The
-- difference is that, unlike the assignment statement, which will
-- cause a Constraint_Error if the source and target are of different
-- sizes, Copy works fine with different sized tables.
----------------
-- Conversion --
----------------
type Table_Entry is record
Name : VString;
Value : Value_Type;
end record;
type Table_Array is array (Positive range <>) of Table_Entry;
function Convert_To_Array (T : Table) return Table_Array;
-- Returns a Table_Array value with a low bound of 1, and a length
-- corresponding to the number of elements in the table. The elements
-- of the array give the elements of the table in unsorted order.
---------------
-- Debugging --
---------------
procedure Dump (T : Table; Str : String := "Table");
-- Dump contents of given table to the standard output file. The
-- string value Str is used as the name of the table in the dump.
procedure Dump (T : Table_Array; Str : String := "Table_Array");
-- Dump contents of given table array to the current output file. The
-- string value Str is used as the name of the table array in the dump.
private
------------------
-- Private Part --
------------------
-- A Table is a pointer to a hash table which contains the indicated
-- number of hash elements (the number is forced to the next odd value
-- if it is even to improve hashing performance). If more than one
-- of the entries in a table hashes to the same slot, the Next field
-- is used to chain entries from the header. The chains are not kept
-- ordered. A chain is terminated by a null pointer in Next. An unused
-- chain is marked by an element whose Name is null and whose value
-- is Null_Value.
type Hash_Element;
type Hash_Element_Ptr is access all Hash_Element;
type Hash_Element is record
Name : String_Access := null;
Value : Value_Type := Null_Value;
Next : Hash_Element_Ptr := null;
end record;
type Hash_Table is
array (Unsigned_32 range <>) of aliased Hash_Element;
type Table (N : Unsigned_32) is new Controlled with record
Elmts : Hash_Table (1 .. N);
end record;
pragma Finalize_Storage_Only (Table);
overriding procedure Adjust (Object : in out Table);
-- The Adjust procedure does a deep copy of the table structure
-- so that the effect of assignment is, like other assignments
-- in Ada, value-oriented.
overriding procedure Finalize (Object : in out Table);
-- This is the finalization routine that ensures that all storage
-- associated with a table is properly released when a table object
-- is abandoned and finalized.
end Table;
end GNAT.Spitbol;
| true | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- G N A T . S P I T B O L --
-- --
-- S p e c --
-- --
-- Copyright (C) 1997-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. --
-- --
------------------------------------------------------------------------------
-- SPITBOL-like interface facilities
-- This package provides a set of interfaces to semantic operations copied
-- from SPITBOL, including a complete implementation of SPITBOL pattern
-- matching. The code is derived from the original SPITBOL MINIMAL sources,
-- created by PI:NAME:<NAME>END_PI. The translation is not exact, but the
-- algorithmic approaches are similar.
with Ada.Finalization; use Ada.Finalization;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Interfaces; use Interfaces;
package GNAT.Spitbol is
pragma Preelaborate;
-- The Spitbol package relies heavily on the Unbounded_String package,
-- using the synonym VString for variable length string. The following
-- declarations define this type and other useful abbreviations.
subtype VString is Ada.Strings.Unbounded.Unbounded_String;
function V (Source : String) return VString
renames Ada.Strings.Unbounded.To_Unbounded_String;
function S (Source : VString) return String
renames Ada.Strings.Unbounded.To_String;
Nul : VString renames Ada.Strings.Unbounded.Null_Unbounded_String;
-------------------------
-- Facilities Provided --
-------------------------
-- The SPITBOL support in GNAT consists of this package together with
-- several child packages. In this package, we have first a set of
-- useful string functions, copied exactly from the corresponding
-- SPITBOL functions, except that we had to rename REVERSE because
-- reverse is a reserved word (it is now Reverse_String).
-- The second element of the parent package is a generic implementation
-- of a table facility. In SPITBOL, the TABLE function allows general
-- mappings from any datatype to any other datatype, and of course, as
-- always, we can freely mix multiple types in the same table.
-- The Ada version of tables is strongly typed, so the indexing type and
-- the range type are always of a consistent type. In this implementation
-- we only provide VString as an indexing type, since this is by far the
-- most common case. The generic instantiation specifies the range type
-- to be used.
-- Three child packages provide standard instantiations of this table
-- package for three common datatypes:
-- GNAT.Spitbol.Table_Boolean (file g-sptabo.ads)
-- The range type is Boolean. The default value is False. This
-- means that this table is essentially a representation of a set.
-- GNAT.Spitbol.Table_Integer (file g-sptain.ads)
-- The range type is Integer. The default value is Integer'First.
-- This provides a general mapping from strings to integers.
-- GNAT.Spitbol.Table_VString (file g-sptavs.ads)
-- The range type is VString. The default value is the null string.
-- This provides a general mapping from strings to strings.
-- Finally there is another child package:
-- GNAT.Spitbol.Patterns (file g-spipat.ads)
-- This child package provides a complete implementation of SPITBOL
-- pattern matching. The spec contains a complete tutorial on the
-- use of pattern matching.
---------------------------------
-- Standard String Subprograms --
---------------------------------
-- This section contains some operations on unbounded strings that are
-- closely related to those in the package Unbounded.Strings, but they
-- correspond to the SPITBOL semantics for these operations.
function Char (Num : Natural) return Character;
pragma Inline (Char);
-- Equivalent to Character'Val (Num)
function Lpad
(Str : VString;
Len : Natural;
Pad : Character := ' ') return VString;
function Lpad
(Str : String;
Len : Natural;
Pad : Character := ' ') return VString;
-- If the length of Str is greater than or equal to Len, then Str is
-- returned unchanged. Otherwise, the value returned is obtained by
-- concatenating Length (Str) - Len instances of the Pad character to
-- the left hand side.
procedure Lpad
(Str : in out VString;
Len : Natural;
Pad : Character := ' ');
-- The procedure form is identical to the function form, except that
-- the result overwrites the input argument Str.
function Reverse_String (Str : VString) return VString;
function Reverse_String (Str : String) return VString;
-- Returns result of reversing the string Str, i.e. the result returned
-- is a mirror image (end-for-end reversal) of the input string.
procedure Reverse_String (Str : in out VString);
-- The procedure form is identical to the function form, except that the
-- result overwrites the input argument Str.
function Rpad
(Str : VString;
Len : Natural;
Pad : Character := ' ') return VString;
function Rpad
(Str : String;
Len : Natural;
Pad : Character := ' ') return VString;
-- If the length of Str is greater than or equal to Len, then Str is
-- returned unchanged. Otherwise, the value returned is obtained by
-- concatenating Length (Str) - Len instances of the Pad character to
-- the right hand side.
procedure Rpad
(Str : in out VString;
Len : Natural;
Pad : Character := ' ');
-- The procedure form is identical to the function form, except that the
-- result overwrites the input argument Str.
function Size (Source : VString) return Natural
renames Ada.Strings.Unbounded.Length;
function Substr
(Str : VString;
Start : Positive;
Len : Natural) return VString;
function Substr
(Str : String;
Start : Positive;
Len : Natural) return VString;
-- Returns the substring starting at the given character position (which
-- is always counted from the start of the string, regardless of bounds,
-- e.g. 2 means starting with the second character of the string), and
-- with the length (Len) given. Index_Error is raised if the starting
-- position is out of range, and Length_Error is raised if Len is too long.
function Trim (Str : VString) return VString;
function Trim (Str : String) return VString;
-- Returns the string obtained by removing all spaces from the right
-- hand side of the string Str.
procedure Trim (Str : in out VString);
-- The procedure form is identical to the function form, except that the
-- result overwrites the input argument Str.
-----------------------
-- Utility Functions --
-----------------------
-- In SPITBOL, integer values can be freely treated as strings. The
-- following definitions help provide some of this capability in
-- some common cases.
function "&" (Num : Integer; Str : String) return String;
function "&" (Str : String; Num : Integer) return String;
function "&" (Num : Integer; Str : VString) return VString;
function "&" (Str : VString; Num : Integer) return VString;
-- In all these concatenation operations, the integer is converted to
-- its corresponding decimal string form, with no leading blank.
function S (Num : Integer) return String;
function V (Num : Integer) return VString;
-- These operators return the given integer converted to its decimal
-- string form with no leading blank.
function N (Str : VString) return Integer;
-- Converts string to number (same as Integer'Value (S (Str)))
-------------------
-- Table Support --
-------------------
-- So far, we only provide support for tables whose indexing data values
-- are strings (or unbounded strings). The values stored may be of any
-- type, as supplied by the generic formal parameter.
generic
type Value_Type is private;
-- Any non-limited type can be used as the value type in the table
Null_Value : Value_Type;
-- Value used to represent a value that is not present in the table
with function Img (A : Value_Type) return String;
-- Used to provide image of value in Dump procedure
with function "=" (A, B : Value_Type) return Boolean is <>;
-- This allows a user-defined equality function to override the
-- predefined equality function.
package Table is
------------------------
-- Table Declarations --
------------------------
type Table (N : Unsigned_32) is private;
-- This is the table type itself. A table is a mapping from string
-- values to values of Value_Type. The discriminant is an estimate of
-- the number of values in the table. If the estimate is much too
-- high, some space is wasted, if the estimate is too low, access to
-- table elements is slowed down. The type Table has copy semantics,
-- not reference semantics. This means that if a table is copied
-- using simple assignment, then the two copies refer to entirely
-- separate tables.
-----------------------------
-- Table Access Operations --
-----------------------------
function Get (T : Table; Name : VString) return Value_Type;
function Get (T : Table; Name : Character) return Value_Type;
pragma Inline (Get);
function Get (T : Table; Name : String) return Value_Type;
-- If an entry with the given name exists in the table, then the
-- corresponding Value_Type value is returned. Otherwise Null_Value
-- is returned.
function Present (T : Table; Name : VString) return Boolean;
function Present (T : Table; Name : Character) return Boolean;
pragma Inline (Present);
function Present (T : Table; Name : String) return Boolean;
-- Determines if an entry with the given name is present in the table.
-- A returned value of True means that it is in the table, otherwise
-- False indicates that it is not in the table.
procedure Delete (T : in out Table; Name : VString);
procedure Delete (T : in out Table; Name : Character);
pragma Inline (Delete);
procedure Delete (T : in out Table; Name : String);
-- Deletes the table element with the given name from the table. If
-- no element in the table has this name, then the call has no effect.
procedure Set (T : in out Table; Name : VString; Value : Value_Type);
procedure Set (T : in out Table; Name : Character; Value : Value_Type);
pragma Inline (Set);
procedure Set (T : in out Table; Name : String; Value : Value_Type);
-- Sets the value of the element with the given name to the given
-- value. If Value is equal to Null_Value, the effect is to remove
-- the entry from the table. If no element with the given name is
-- currently in the table, then a new element with the given value
-- is created.
----------------------------
-- Allocation and Copying --
----------------------------
-- Table is a controlled type, so that all storage associated with
-- tables is properly reclaimed when a Table value is abandoned.
-- Tables have value semantics rather than reference semantics as
-- in Spitbol, i.e. when you assign a copy you end up with two
-- distinct copies of the table, as though COPY had been used in
-- Spitbol. It seems clearly more appropriate in Ada to require
-- the use of explicit pointers for reference semantics.
procedure Clear (T : in out Table);
-- Clears all the elements of the given table, freeing associated
-- storage. On return T is an empty table with no elements.
procedure Copy (From : Table; To : in out Table);
-- First all the elements of table To are cleared (as described for
-- the Clear procedure above), then all the elements of table From
-- are copied into To. In the case where the tables From and To have
-- the same declared size (i.e. the same discriminant), the call to
-- Copy has the same effect as the assignment of From to To. The
-- difference is that, unlike the assignment statement, which will
-- cause a Constraint_Error if the source and target are of different
-- sizes, Copy works fine with different sized tables.
----------------
-- Conversion --
----------------
type Table_Entry is record
Name : VString;
Value : Value_Type;
end record;
type Table_Array is array (Positive range <>) of Table_Entry;
function Convert_To_Array (T : Table) return Table_Array;
-- Returns a Table_Array value with a low bound of 1, and a length
-- corresponding to the number of elements in the table. The elements
-- of the array give the elements of the table in unsorted order.
---------------
-- Debugging --
---------------
procedure Dump (T : Table; Str : String := "Table");
-- Dump contents of given table to the standard output file. The
-- string value Str is used as the name of the table in the dump.
procedure Dump (T : Table_Array; Str : String := "Table_Array");
-- Dump contents of given table array to the current output file. The
-- string value Str is used as the name of the table array in the dump.
private
------------------
-- Private Part --
------------------
-- A Table is a pointer to a hash table which contains the indicated
-- number of hash elements (the number is forced to the next odd value
-- if it is even to improve hashing performance). If more than one
-- of the entries in a table hashes to the same slot, the Next field
-- is used to chain entries from the header. The chains are not kept
-- ordered. A chain is terminated by a null pointer in Next. An unused
-- chain is marked by an element whose Name is null and whose value
-- is Null_Value.
type Hash_Element;
type Hash_Element_Ptr is access all Hash_Element;
type Hash_Element is record
Name : String_Access := null;
Value : Value_Type := Null_Value;
Next : Hash_Element_Ptr := null;
end record;
type Hash_Table is
array (Unsigned_32 range <>) of aliased Hash_Element;
type Table (N : Unsigned_32) is new Controlled with record
Elmts : Hash_Table (1 .. N);
end record;
pragma Finalize_Storage_Only (Table);
overriding procedure Adjust (Object : in out Table);
-- The Adjust procedure does a deep copy of the table structure
-- so that the effect of assignment is, like other assignments
-- in Ada, value-oriented.
overriding procedure Finalize (Object : in out Table);
-- This is the finalization routine that ensures that all storage
-- associated with a table is properly released when a table object
-- is abandoned and finalized.
end Table;
end GNAT.Spitbol;
|
[
{
"context": "rs for use with smart_ptrs\n\n-- Copyright (c) 2016, James Humphry\n--\n-- Permission to use, copy, modify, and/or dis",
"end": 115,
"score": 0.9998579025268555,
"start": 102,
"tag": "NAME",
"value": "James Humphry"
}
] | src/counters/basic_counters.ads | jhumphry/auto_counters | 5 | -- basic_counters.ads
-- Basic non-task safe counters for use with smart_ptrs
-- Copyright (c) 2016, James Humphry
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
pragma Profile (No_Implementation_Extensions);
with Counters_Spec;
package Basic_Counters is
type Counter is record
SP_Count : Natural;
WP_Count : Natural;
end record;
type Counter_Ptr is access Counter;
function Make_New_Counter return Counter_Ptr;
procedure Deallocate_If_Unused (C : in out Counter_Ptr) with Inline;
function Use_Count (C : in Counter) return Natural is
(C.SP_Count) with Inline;
procedure Check_Increment_Use_Count (C : in out Counter) with Inline;
procedure Decrement_Use_Count (C : in out Counter) with Inline;
function Weak_Ptr_Count (C : in Counter) return Natural is
(C.WP_Count) with Inline;
procedure Increment_Weak_Ptr_Count (C : in out Counter) with Inline;
procedure Decrement_Weak_Ptr_Count (C : in out Counter) with Inline;
package Basic_Counters_Spec is new Counters_Spec(Counter => Counter,
Counter_Ptr => Counter_Ptr);
end Basic_Counters;
| 20699 | -- basic_counters.ads
-- Basic non-task safe counters for use with smart_ptrs
-- Copyright (c) 2016, <NAME>
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
pragma Profile (No_Implementation_Extensions);
with Counters_Spec;
package Basic_Counters is
type Counter is record
SP_Count : Natural;
WP_Count : Natural;
end record;
type Counter_Ptr is access Counter;
function Make_New_Counter return Counter_Ptr;
procedure Deallocate_If_Unused (C : in out Counter_Ptr) with Inline;
function Use_Count (C : in Counter) return Natural is
(C.SP_Count) with Inline;
procedure Check_Increment_Use_Count (C : in out Counter) with Inline;
procedure Decrement_Use_Count (C : in out Counter) with Inline;
function Weak_Ptr_Count (C : in Counter) return Natural is
(C.WP_Count) with Inline;
procedure Increment_Weak_Ptr_Count (C : in out Counter) with Inline;
procedure Decrement_Weak_Ptr_Count (C : in out Counter) with Inline;
package Basic_Counters_Spec is new Counters_Spec(Counter => Counter,
Counter_Ptr => Counter_Ptr);
end Basic_Counters;
| true | -- basic_counters.ads
-- Basic non-task safe counters for use with smart_ptrs
-- Copyright (c) 2016, PI:NAME:<NAME>END_PI
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
pragma Profile (No_Implementation_Extensions);
with Counters_Spec;
package Basic_Counters is
type Counter is record
SP_Count : Natural;
WP_Count : Natural;
end record;
type Counter_Ptr is access Counter;
function Make_New_Counter return Counter_Ptr;
procedure Deallocate_If_Unused (C : in out Counter_Ptr) with Inline;
function Use_Count (C : in Counter) return Natural is
(C.SP_Count) with Inline;
procedure Check_Increment_Use_Count (C : in out Counter) with Inline;
procedure Decrement_Use_Count (C : in out Counter) with Inline;
function Weak_Ptr_Count (C : in Counter) return Natural is
(C.WP_Count) with Inline;
procedure Increment_Weak_Ptr_Count (C : in out Counter) with Inline;
procedure Decrement_Weak_Ptr_Count (C : in out Counter) with Inline;
package Basic_Counters_Spec is new Counters_Spec(Counter => Counter,
Counter_Ptr => Counter_Ptr);
end Basic_Counters;
|
[
{
"context": " --\n-- Copyright © 2013-2014, Vadim Godunko <vgodunko@gmail.com> --\n-- All rig",
"end": 829,
"score": 0.9998858571052551,
"start": 816,
"tag": "NAME",
"value": "Vadim Godunko"
},
{
"context": " --\n-- Copyright © 2013-2014, Vadim Godunko <vgodunko@gmail.com> --\n-- All rights reserved. ",
"end": 849,
"score": 0.9999324083328247,
"start": 831,
"tag": "EMAIL",
"value": "vgodunko@gmail.com"
}
] | source/xml/dom/matreshka-dom_builders.adb | svn2github/matreshka | 24 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013-2014, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.DOM_Nodes;
with XML.DOM.Attributes;
with XML.DOM.Elements;
with XML.DOM.Texts;
package body Matreshka.DOM_Builders is
procedure Push (Self : in out DOM_Builder'Class);
procedure Pop (Self : in out DOM_Builder'Class);
----------------
-- Characters --
----------------
overriding procedure Characters
(Self : in out DOM_Builder;
Text : League.Strings.Universal_String;
Success : in out Boolean)
is
Aux : XML.DOM.Texts.DOM_Text_Access
:= Self.Document.Create_Text_Node (Text);
begin
Self.Current.Append_Child (XML.DOM.Nodes.DOM_Node_Access (Aux));
-- XML.DOM.Nodes.Dereference (XML.DOM.Nodes.DOM_Node_Access (Aux));
end Characters;
-----------------
-- End_Element --
-----------------
overriding procedure End_Element
(Self : in out DOM_Builder;
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.Pop;
end End_Element;
------------------
-- Error_String --
------------------
overriding function Error_String
(Self : DOM_Builder) return League.Strings.Universal_String is
begin
return League.Strings.Empty_Universal_String;
end Error_String;
------------------
-- Get_Document --
------------------
function Get_Document
(Self : DOM_Builder'Class) return XML.DOM.Documents.DOM_Document_Access is
begin
return Self.Document;
end Get_Document;
---------
-- Pop --
---------
procedure Pop (Self : in out DOM_Builder'Class) is
begin
Self.Current := Self.Parent;
if not Self.Stack.Is_Empty then
Self.Parent := Self.Stack.Last_Element;
Self.Stack.Delete_Last;
else
Self.Parent := null;
end if;
end Pop;
----------
-- Push --
----------
procedure Push (Self : in out DOM_Builder'Class) is
begin
Self.Stack.Append (Self.Parent);
Self.Parent := Self.Current;
Self.Current := null;
end Push;
------------------
-- Set_Document --
------------------
procedure Set_Document
(Self : in out DOM_Builder'Class;
Document : not null XML.DOM.Documents.DOM_Document_Access) is
begin
Self.Document := Document;
end Set_Document;
--------------------
-- Start_Document --
--------------------
overriding procedure Start_Document
(Self : in out DOM_Builder;
Success : in out Boolean)
is
use type XML.DOM.Documents.DOM_Document_Access;
Document : Matreshka.DOM_Nodes.Document_Access;
begin
if Self.Document = null then
-- Create new document when it was not specified by application.
Document := new Matreshka.DOM_Documents.Document_Node;
Matreshka.DOM_Documents.Constructors.Initialize (Document);
Self.Document := XML.DOM.Documents.DOM_Document_Access (Document);
end if;
Self.Current := XML.DOM.Nodes.DOM_Node_Access (Self.Document);
end Start_Document;
-------------------
-- Start_Element --
-------------------
overriding procedure Start_Element
(Self : in out DOM_Builder;
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
Element : XML.DOM.Elements.DOM_Element_Access;
Attribute : XML.DOM.Attributes.DOM_Attribute_Access;
begin
Self.Push;
if Local_Name.Is_Empty then
raise Program_Error;
else
Element :=
Self.Document.Create_Element_NS (Namespace_URI, Qualified_Name);
Self.Current := XML.DOM.Nodes.DOM_Node_Access (Element);
Self.Parent.Append_Child (Self.Current);
-- XML.DOM.Nodes.Dereference (XML.DOM.Nodes.DOM_Node_Access (Element));
end if;
-- Process attributes.
for J in 1 .. Attributes.Length loop
if Attributes.Local_Name (J).Is_Empty then
raise Program_Error;
else
Attribute :=
Self.Document.Create_Attribute_NS
(Attributes.Namespace_URI (J), Attributes.Qualified_Name (J));
XML.DOM.Elements.DOM_Element_Access
(Self.Current).Set_Attribute_Node_NS (Attribute);
Attribute.Set_Value (Attributes.Value (J));
-- XML.DOM.Nodes.Dereference
-- (XML.DOM.Nodes.DOM_Node_Access (Attribute));
end if;
end loop;
end Start_Element;
end Matreshka.DOM_Builders;
| 24578 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013-2014, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.DOM_Nodes;
with XML.DOM.Attributes;
with XML.DOM.Elements;
with XML.DOM.Texts;
package body Matreshka.DOM_Builders is
procedure Push (Self : in out DOM_Builder'Class);
procedure Pop (Self : in out DOM_Builder'Class);
----------------
-- Characters --
----------------
overriding procedure Characters
(Self : in out DOM_Builder;
Text : League.Strings.Universal_String;
Success : in out Boolean)
is
Aux : XML.DOM.Texts.DOM_Text_Access
:= Self.Document.Create_Text_Node (Text);
begin
Self.Current.Append_Child (XML.DOM.Nodes.DOM_Node_Access (Aux));
-- XML.DOM.Nodes.Dereference (XML.DOM.Nodes.DOM_Node_Access (Aux));
end Characters;
-----------------
-- End_Element --
-----------------
overriding procedure End_Element
(Self : in out DOM_Builder;
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.Pop;
end End_Element;
------------------
-- Error_String --
------------------
overriding function Error_String
(Self : DOM_Builder) return League.Strings.Universal_String is
begin
return League.Strings.Empty_Universal_String;
end Error_String;
------------------
-- Get_Document --
------------------
function Get_Document
(Self : DOM_Builder'Class) return XML.DOM.Documents.DOM_Document_Access is
begin
return Self.Document;
end Get_Document;
---------
-- Pop --
---------
procedure Pop (Self : in out DOM_Builder'Class) is
begin
Self.Current := Self.Parent;
if not Self.Stack.Is_Empty then
Self.Parent := Self.Stack.Last_Element;
Self.Stack.Delete_Last;
else
Self.Parent := null;
end if;
end Pop;
----------
-- Push --
----------
procedure Push (Self : in out DOM_Builder'Class) is
begin
Self.Stack.Append (Self.Parent);
Self.Parent := Self.Current;
Self.Current := null;
end Push;
------------------
-- Set_Document --
------------------
procedure Set_Document
(Self : in out DOM_Builder'Class;
Document : not null XML.DOM.Documents.DOM_Document_Access) is
begin
Self.Document := Document;
end Set_Document;
--------------------
-- Start_Document --
--------------------
overriding procedure Start_Document
(Self : in out DOM_Builder;
Success : in out Boolean)
is
use type XML.DOM.Documents.DOM_Document_Access;
Document : Matreshka.DOM_Nodes.Document_Access;
begin
if Self.Document = null then
-- Create new document when it was not specified by application.
Document := new Matreshka.DOM_Documents.Document_Node;
Matreshka.DOM_Documents.Constructors.Initialize (Document);
Self.Document := XML.DOM.Documents.DOM_Document_Access (Document);
end if;
Self.Current := XML.DOM.Nodes.DOM_Node_Access (Self.Document);
end Start_Document;
-------------------
-- Start_Element --
-------------------
overriding procedure Start_Element
(Self : in out DOM_Builder;
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
Element : XML.DOM.Elements.DOM_Element_Access;
Attribute : XML.DOM.Attributes.DOM_Attribute_Access;
begin
Self.Push;
if Local_Name.Is_Empty then
raise Program_Error;
else
Element :=
Self.Document.Create_Element_NS (Namespace_URI, Qualified_Name);
Self.Current := XML.DOM.Nodes.DOM_Node_Access (Element);
Self.Parent.Append_Child (Self.Current);
-- XML.DOM.Nodes.Dereference (XML.DOM.Nodes.DOM_Node_Access (Element));
end if;
-- Process attributes.
for J in 1 .. Attributes.Length loop
if Attributes.Local_Name (J).Is_Empty then
raise Program_Error;
else
Attribute :=
Self.Document.Create_Attribute_NS
(Attributes.Namespace_URI (J), Attributes.Qualified_Name (J));
XML.DOM.Elements.DOM_Element_Access
(Self.Current).Set_Attribute_Node_NS (Attribute);
Attribute.Set_Value (Attributes.Value (J));
-- XML.DOM.Nodes.Dereference
-- (XML.DOM.Nodes.DOM_Node_Access (Attribute));
end if;
end loop;
end Start_Element;
end Matreshka.DOM_Builders;
| true | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013-2014, PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.DOM_Nodes;
with XML.DOM.Attributes;
with XML.DOM.Elements;
with XML.DOM.Texts;
package body Matreshka.DOM_Builders is
procedure Push (Self : in out DOM_Builder'Class);
procedure Pop (Self : in out DOM_Builder'Class);
----------------
-- Characters --
----------------
overriding procedure Characters
(Self : in out DOM_Builder;
Text : League.Strings.Universal_String;
Success : in out Boolean)
is
Aux : XML.DOM.Texts.DOM_Text_Access
:= Self.Document.Create_Text_Node (Text);
begin
Self.Current.Append_Child (XML.DOM.Nodes.DOM_Node_Access (Aux));
-- XML.DOM.Nodes.Dereference (XML.DOM.Nodes.DOM_Node_Access (Aux));
end Characters;
-----------------
-- End_Element --
-----------------
overriding procedure End_Element
(Self : in out DOM_Builder;
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.Pop;
end End_Element;
------------------
-- Error_String --
------------------
overriding function Error_String
(Self : DOM_Builder) return League.Strings.Universal_String is
begin
return League.Strings.Empty_Universal_String;
end Error_String;
------------------
-- Get_Document --
------------------
function Get_Document
(Self : DOM_Builder'Class) return XML.DOM.Documents.DOM_Document_Access is
begin
return Self.Document;
end Get_Document;
---------
-- Pop --
---------
procedure Pop (Self : in out DOM_Builder'Class) is
begin
Self.Current := Self.Parent;
if not Self.Stack.Is_Empty then
Self.Parent := Self.Stack.Last_Element;
Self.Stack.Delete_Last;
else
Self.Parent := null;
end if;
end Pop;
----------
-- Push --
----------
procedure Push (Self : in out DOM_Builder'Class) is
begin
Self.Stack.Append (Self.Parent);
Self.Parent := Self.Current;
Self.Current := null;
end Push;
------------------
-- Set_Document --
------------------
procedure Set_Document
(Self : in out DOM_Builder'Class;
Document : not null XML.DOM.Documents.DOM_Document_Access) is
begin
Self.Document := Document;
end Set_Document;
--------------------
-- Start_Document --
--------------------
overriding procedure Start_Document
(Self : in out DOM_Builder;
Success : in out Boolean)
is
use type XML.DOM.Documents.DOM_Document_Access;
Document : Matreshka.DOM_Nodes.Document_Access;
begin
if Self.Document = null then
-- Create new document when it was not specified by application.
Document := new Matreshka.DOM_Documents.Document_Node;
Matreshka.DOM_Documents.Constructors.Initialize (Document);
Self.Document := XML.DOM.Documents.DOM_Document_Access (Document);
end if;
Self.Current := XML.DOM.Nodes.DOM_Node_Access (Self.Document);
end Start_Document;
-------------------
-- Start_Element --
-------------------
overriding procedure Start_Element
(Self : in out DOM_Builder;
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
Element : XML.DOM.Elements.DOM_Element_Access;
Attribute : XML.DOM.Attributes.DOM_Attribute_Access;
begin
Self.Push;
if Local_Name.Is_Empty then
raise Program_Error;
else
Element :=
Self.Document.Create_Element_NS (Namespace_URI, Qualified_Name);
Self.Current := XML.DOM.Nodes.DOM_Node_Access (Element);
Self.Parent.Append_Child (Self.Current);
-- XML.DOM.Nodes.Dereference (XML.DOM.Nodes.DOM_Node_Access (Element));
end if;
-- Process attributes.
for J in 1 .. Attributes.Length loop
if Attributes.Local_Name (J).Is_Empty then
raise Program_Error;
else
Attribute :=
Self.Document.Create_Attribute_NS
(Attributes.Namespace_URI (J), Attributes.Qualified_Name (J));
XML.DOM.Elements.DOM_Element_Access
(Self.Current).Set_Attribute_Node_NS (Attribute);
Attribute.Set_Value (Attributes.Value (J));
-- XML.DOM.Nodes.Dereference
-- (XML.DOM.Nodes.DOM_Node_Access (Attribute));
end if;
end loop;
end Start_Element;
end Matreshka.DOM_Builders;
|
[
{
"context": "ient\n-- Copyright (c) 2019 House Harris Software - Zen Harris\n\nwith Ada.Containers.Vectors;\nwith Ada.Containers",
"end": 115,
"score": 0.9998659491539001,
"start": 105,
"tag": "NAME",
"value": "Zen Harris"
}
] | src/pong_bot.adb | zenharris/ada-bbs | 2 |
-- This was an example bot now converted to an IRC Client
-- Copyright (c) 2019 House Harris Software - Zen Harris
with Ada.Containers.Vectors;
with Ada.Containers; use Ada.Containers;
With Irc.Commands; use Irc.Commands;
with Irc.Message; use Irc.Message;
with Irc.Bot; use Irc.Bot;
with GNAT.Regpat; use GNAT.Regpat;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Strings.Maps.Constants;
with Ada.Strings.Fixed;
package body Pong_Bot is
package SU renames Ada.Strings.Unbounded;
procedure Irc_Client is
-- Bot : Irc.Bot.Connection; moved to pong_bot.ads
c :Key_Code;
Ch : Character;
Edline : Unbounded_String;
Channel : Unbounded_String := To_Unbounded_String("#worldchat");
Lines : Line_Position;
Columns : Column_Position;
Quit : Boolean := False;
task Read_Loop is
entry Start;
end Read_Loop;
task body Read_Loop is
Col : Column_Position;
Lin : Line_Position;
-- Line : Ada.Strings.Unbounded.Unbounded_String;
-- Msg : Irc.Message.Message;
begin
accept Start;
loop
declare
Line : Ada.Strings.Unbounded.Unbounded_String;
Msg : Irc.Message.Message;
begin
Bot.Read_Line (Line);
Msg := Irc.Message.Parse_Line (Line);
Bot.Do_Message (Msg);
-- Print out the message so we can get some feedback
Get_Cursor_Position(Line => Lin,Column => Col);
Msg.Print;
Move_Cursor(Line => Lin,Column => Col);
Refresh;
exception
when Irc.Message.Parse_Error => -- exit;
Irc.Message.Print_Line(To_Unbounded_String("Message Parse Error"));
end;
end loop;
end Read_Loop;
procedure Clear_Response;
package FieldsVector is new Ada.Containers.Vectors (Natural,
Unbounded_String);
use FieldsVector;
Fields : FieldsVector.Vector;
procedure Split (InVector : in out FieldsVector.Vector; InString : in Unbounded_String) is
Cursor : Integer;
scratch : Unbounded_String := InString;
AppendStr : Unbounded_String;
begin
Cursor := Index(scratch," ");
if Cursor /= 0 then
while Cursor /= 0 loop
AppendStr := To_Unbounded_String(Slice (Source => scratch,Low => 1,High => Cursor-1));
if Length(AppendStr) > 0 then
InVector.Append(AppendStr);
end if;
Delete(scratch,1,Cursor);
Cursor := Index(scratch," ");
if Cursor = 0 and then Length(scratch) > 0 then
InVector.Append(scratch);
end if;
end loop;
else
if Length(scratch) > 0 then
InVector.Append(scratch);
end if;
end if;
end Split;
function FieldsMerge (MergeStart : integer; MergeEnd : Integer ) return Unbounded_String is
OutString : Unbounded_String := To_Unbounded_String("");
begin
for i in MergeStart..MergeEnd loop
Append(OutString,Fields.Element(i) & " ");
end loop;
return OutString;
end FieldsMerge;
Suppress_Response : Boolean := True;
Local_Response : Boolean := True;
procedure Process_Command (CommandLine : Unbounded_String; Quit : in out Boolean ) is
begin
Clear(Fields);
Split (Fields,CommandLine);
if Fields.Length > 1 then
if Fields.Element(0) = "/whois" then
Bot.Command(Cmd => "WHOIS",Args => To_String(Fields.Element(1)));
elsif Fields.Element(0) = "/nick" then
Bot.Command(Cmd => "NICK",Args => To_String(Fields.Element(1)));
elsif Fields.Element(0) = "/me" then
Bot.Privmsg (To_String(Channel), Character'val(1)&"ACTION "&
To_String(Unbounded_Slice(CommandLine,index(CommandLine," ")+1,Length(CommandLine)) )
&Character'val(1));
elsif Fields.Element(0) = "/version" then
Bot.Privmsg (To_String(Fields.Element(1)),
Character'val(1)&"VERSION"&Character'val(1));
elsif Fields.Element(0) = "/time" then
Bot.Privmsg (To_String(Fields.Element(1)), Character'val(1)&"TIME"&Character'val(1));
elsif Fields.Element(0) = "/clientinfo" then
Bot.Privmsg (To_String(Fields.Element(1)), Character'val(1)&"CLIENTINFO"&Character'val(1));
elsif Fields.Element(0) = "/source" then
Bot.Privmsg (To_String(Fields.Element(1)), Character'val(1)&"SOURCE"&Character'val(1));
elsif Fields.Element(0) = "/response" then
if Fields.Element(1) = "on" then
--Bot.On_Regexp(OnRegexp => ".*",Func => Response_Processor'Unrestricted_Access);
Suppress_Response := False;
Local_Response := False;
Irc.Message.Print_Line(To_Unbounded_String("Response Processor On"));
elsif Fields.Element(1) = "off" then
Suppress_Response := True;
Irc.Message.Print_Line(To_Unbounded_String("Response Processor Off"));
elsif Fields.Element(1) = "local" then
Suppress_Response := False;
Local_Response := True;
Irc.Message.Print_Line(To_Unbounded_String("Response Processor On Local"));
elsif Fields.Element(1) = "clear" then
Clear_Response;
Irc.Message.Print_Line(To_Unbounded_String("Response Processor Cleared"));
end if;
elsif Fields.Element(0) = "/msg" then
if Fields.Length > 2 then
Bot.Privmsg (To_String(Fields.Element(1)),
--To_String(Unbounded_Slice(CommandLine,index(CommandLine," ")+1,Length(CommandLine)) )
To_String(FieldsMerge(2,Integer(Fields.Length)-1))
);
end if;
end if;
else
if Fields.Length = 1 then
if Fields.Element(0) = "/help" then
Irc.Message.Print_Line(To_Unbounded_String("/whois <nickname> /nick <nickname> "));
Irc.Message.Print_Line(To_Unbounded_String("/me <action description> /version <nickname> "));
Irc.Message.Print_Line(To_Unbounded_String("/time <nickname> /clientinfo <nickname> "));
Irc.Message.Print_Line(To_Unbounded_String("/source <nickname> /msg <nickname> "));
Irc.Message.Print_Line(To_Unbounded_String("/response <on|off|local|clear> /quit "));
elsif Fields.Element(0) = "/quit" then
Quit := True;
end if;
end if;
end if;
end Process_Command;
type String_Access is access String;
type Response_Array is Array (0 .. 2) of String_Access;
type Response_Record is record
MatchRegex : String_Access;
Response : Response_Array;
Counter : Integer;
end record;
type Response_Type is array (Positive range <>) of Response_Record;
ResponseTable : Response_Type :=
((new String'(".*\bsun\b.*"),
(new String'("The Sun's coming up, like a big bald head"),new String'("Sun and Moon"),new String'("That'a alot of sun")),0),
(new String'(".*\b[Hh]ypnotoad\b.*|.*\b[Ff]uturama\b.*|.*\bpraise\b.*"),
(new String'("All Praise to The Hypnotoad GRGGRGRRBRBBRBRRGRGGRGRRBRBBRBRR"),
new String'("GRGGRGRRBRBBRBRRGR"),
new String'("All Praise, All Praise")),0),
(new String'(".*\bconjob\b.*|.*\bconm[ea]n\b.*|.*\bbusted\b.*|.*\billegal\b.*"),
(new String'("Conjob Right on"),new String'("You;ve been ripped off man"),new String'("You're saying conjob alot")),0),
(new String'(".*\bwine\b.*|.*\bdrink\b.*"),
(new String'("Try the wine!"),new String'("I see you enjoya fine wine, Have another Glass!"),new String'("And the water turned wine")),0),
(new String'(".*\bcat\b.*"),
(new String'("Hep Cats"),new String'("Cool for Cats"),new String'("Stop Saying the word cat")),0),
(new String'(".*\bstrange\b.*|.*/bweird/b.*"),
(new String'("STSSTSTTRARRARAANGNNGNGGEGEE"),new String'("That IS strange"),new String'("Never a stranger")),0),
(new String'(".*\bfish\b.*"),
(new String'("Neither fish nor flesh"),new String'("and to eat no fish"),new String'("But enough of fish")),0),
(new String'(".*\bcoffee\b.*"),
(new String'("I feel disoriented if I can't go to the cafe in the morning"),
new String'("Coffee rich Coffee strong"),
new String'("Beans of madness")),0),
(new String'(".*\bweather\b.*"),
(new String'("The weather's on the change"),
new String'("Lines form in feint dischord"),new String'("And the stormwatch brews a concert of kings")),0));
procedure Clear_Response is
begin
for i in ResponseTable'Range loop
ResponseTable(i).Counter := 0;
end loop;
end Clear_Response;
procedure Response_Processor (Conn : in out Irc.Commands.Connection;
Msg : IrcMessage) is
Regex : GNAT.Regpat.Pattern_Matcher (1024);
Matches : GNAT.Regpat.Match_Array (0 .. 1);
Now : Time;
Next : Time;
D : Duration := 0.05;
L : Integer;
scratch : Unbounded_String;
begin
if Suppress_Response = False then
for i in ResponseTable'Range loop
GNAT.Regpat.Compile (Regex, ResponseTable(i).MatchRegex.all);
scratch := SU.Unbounded_Slice(Msg.Args,SU.Index(Msg.Args,":")+1,SU.Length( Msg.Args));
scratch := To_Unbounded_String(Ada.Strings.Fixed.Translate(To_String(scratch),
Ada.Strings.Maps.Constants.Lower_Case_Map));
GNAT.Regpat.Match (Regex, To_String(scratch) , Matches);
if Matches (0) /= GNAT.Regpat.No_Match then
-- Pair.Func (This, Msg);
if ResponseTable(i).Counter <= ResponseTable(i).Response'Last then
Now := Clock;
L := ResponseTable(i).Response(ResponseTable(i).Counter).all'Length;
Next := Now + (D*L) ;
delay until Next;
if Local_Response then
Irc.Message.Print_Line(To_Unbounded_String(
ResponseTable(i).Response(ResponseTable(i).Counter).all));
else
Bot.Privmsg (To_String(Channel),
ResponseTable(i).Response(ResponseTable(i).Counter).all);
end if;
ResponseTable(i).Counter := ResponseTable(i).Counter + 1;
end if;
end if;
end loop;
end if;
end Response_Processor;
begin
Get_Size(Number_Of_Lines => Lines,Number_Of_Columns => Columns);
Add (Column => ((Columns-30)/2)-14,Line => Lines/2 ,Str => "Enter Nick : ");
Clear_To_End_Of_Line;
Edline := To_Unbounded_String("");
Texaco.Line_Editor(Standard_Window,
StartLine => Lines/2,
StartColumn => (Columns-30)/2,
Editlength => 21,
Edline => Edline,
MaxLength => 20,
SuppressSpaces => True);
c := Texaco.c;
if Character'Val (c) /= ESC then
Clear;
Refresh;
-- Specify the server, port, and nick of our bot
Bot := Irc.Bot.Create ("irc.us.ircnet.net", 6667, Nick => To_String(Edline));
-- Normally, you would use Irc.Commands.Install (Bot) to add
-- the standard command set.
Bot.On_Message ("PING", Irc.Commands.Ping_Server'Access);
-- Bot.On_Regexp(OnRegexp => ".*",Func => Response_Processor'Unrestricted_Access);
Bot.On_Regexp(OnRegexp => "^PRIVMSG",Func => Response_Processor'Unrestricted_Access);
-- Connect the socket and identify the bot (send NICK and USER)
Bot.Connect;
Bot.Identify;
Bot.Join (To_String(Channel));
-- Loop until program is killed or an error occurs
Read_Loop.Start;
loop
Get_Size(Number_Of_Lines => Lines,Number_Of_Columns => Columns);
Add (Standard_Window,
Line => Lines-1,
Column => 0,
Str => "/help for commands Esc exit");
Refresh;
Edline := To_Unbounded_String("");
Texaco.Line_Editor(Standard_Window,
StartLine => Lines-2,
StartColumn => 0,
EditLength => Columns,
Edline => Edline,
MaxLength => 400);
c := Texaco.c;
if c in Special_Key_Code'Range then
case c is
when Key_F1 => null;
when others => null;
end case;
elsif c in Real_Key_Code'Range then
Ch := Character'Val (c);
case Ch is
when CR | LF =>
if Index(Source => Edline,Pattern => "/") = 1 then
Process_Command(Edline,Quit);
if Quit then
Bot.Command("QUIT",":Exiting Normally");
exit;
end if;
else
Bot.Privmsg (To_String(Channel), To_String(Edline));
end if;
Edline := To_Unbounded_String("");
Texaco.Current_Char := 1;
when ESC =>
begin
Bot.Command("QUIT",":Exiting Normally");
exit;
end;
when others => null;
end case;
end if;
end loop;
-- Close the socket
Bot.Disconnect;
end if;
Abort Read_Loop;
end Irc_Client;
end Pong_Bot;
| 22646 |
-- This was an example bot now converted to an IRC Client
-- Copyright (c) 2019 House Harris Software - <NAME>
with Ada.Containers.Vectors;
with Ada.Containers; use Ada.Containers;
With Irc.Commands; use Irc.Commands;
with Irc.Message; use Irc.Message;
with Irc.Bot; use Irc.Bot;
with GNAT.Regpat; use GNAT.Regpat;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Strings.Maps.Constants;
with Ada.Strings.Fixed;
package body Pong_Bot is
package SU renames Ada.Strings.Unbounded;
procedure Irc_Client is
-- Bot : Irc.Bot.Connection; moved to pong_bot.ads
c :Key_Code;
Ch : Character;
Edline : Unbounded_String;
Channel : Unbounded_String := To_Unbounded_String("#worldchat");
Lines : Line_Position;
Columns : Column_Position;
Quit : Boolean := False;
task Read_Loop is
entry Start;
end Read_Loop;
task body Read_Loop is
Col : Column_Position;
Lin : Line_Position;
-- Line : Ada.Strings.Unbounded.Unbounded_String;
-- Msg : Irc.Message.Message;
begin
accept Start;
loop
declare
Line : Ada.Strings.Unbounded.Unbounded_String;
Msg : Irc.Message.Message;
begin
Bot.Read_Line (Line);
Msg := Irc.Message.Parse_Line (Line);
Bot.Do_Message (Msg);
-- Print out the message so we can get some feedback
Get_Cursor_Position(Line => Lin,Column => Col);
Msg.Print;
Move_Cursor(Line => Lin,Column => Col);
Refresh;
exception
when Irc.Message.Parse_Error => -- exit;
Irc.Message.Print_Line(To_Unbounded_String("Message Parse Error"));
end;
end loop;
end Read_Loop;
procedure Clear_Response;
package FieldsVector is new Ada.Containers.Vectors (Natural,
Unbounded_String);
use FieldsVector;
Fields : FieldsVector.Vector;
procedure Split (InVector : in out FieldsVector.Vector; InString : in Unbounded_String) is
Cursor : Integer;
scratch : Unbounded_String := InString;
AppendStr : Unbounded_String;
begin
Cursor := Index(scratch," ");
if Cursor /= 0 then
while Cursor /= 0 loop
AppendStr := To_Unbounded_String(Slice (Source => scratch,Low => 1,High => Cursor-1));
if Length(AppendStr) > 0 then
InVector.Append(AppendStr);
end if;
Delete(scratch,1,Cursor);
Cursor := Index(scratch," ");
if Cursor = 0 and then Length(scratch) > 0 then
InVector.Append(scratch);
end if;
end loop;
else
if Length(scratch) > 0 then
InVector.Append(scratch);
end if;
end if;
end Split;
function FieldsMerge (MergeStart : integer; MergeEnd : Integer ) return Unbounded_String is
OutString : Unbounded_String := To_Unbounded_String("");
begin
for i in MergeStart..MergeEnd loop
Append(OutString,Fields.Element(i) & " ");
end loop;
return OutString;
end FieldsMerge;
Suppress_Response : Boolean := True;
Local_Response : Boolean := True;
procedure Process_Command (CommandLine : Unbounded_String; Quit : in out Boolean ) is
begin
Clear(Fields);
Split (Fields,CommandLine);
if Fields.Length > 1 then
if Fields.Element(0) = "/whois" then
Bot.Command(Cmd => "WHOIS",Args => To_String(Fields.Element(1)));
elsif Fields.Element(0) = "/nick" then
Bot.Command(Cmd => "NICK",Args => To_String(Fields.Element(1)));
elsif Fields.Element(0) = "/me" then
Bot.Privmsg (To_String(Channel), Character'val(1)&"ACTION "&
To_String(Unbounded_Slice(CommandLine,index(CommandLine," ")+1,Length(CommandLine)) )
&Character'val(1));
elsif Fields.Element(0) = "/version" then
Bot.Privmsg (To_String(Fields.Element(1)),
Character'val(1)&"VERSION"&Character'val(1));
elsif Fields.Element(0) = "/time" then
Bot.Privmsg (To_String(Fields.Element(1)), Character'val(1)&"TIME"&Character'val(1));
elsif Fields.Element(0) = "/clientinfo" then
Bot.Privmsg (To_String(Fields.Element(1)), Character'val(1)&"CLIENTINFO"&Character'val(1));
elsif Fields.Element(0) = "/source" then
Bot.Privmsg (To_String(Fields.Element(1)), Character'val(1)&"SOURCE"&Character'val(1));
elsif Fields.Element(0) = "/response" then
if Fields.Element(1) = "on" then
--Bot.On_Regexp(OnRegexp => ".*",Func => Response_Processor'Unrestricted_Access);
Suppress_Response := False;
Local_Response := False;
Irc.Message.Print_Line(To_Unbounded_String("Response Processor On"));
elsif Fields.Element(1) = "off" then
Suppress_Response := True;
Irc.Message.Print_Line(To_Unbounded_String("Response Processor Off"));
elsif Fields.Element(1) = "local" then
Suppress_Response := False;
Local_Response := True;
Irc.Message.Print_Line(To_Unbounded_String("Response Processor On Local"));
elsif Fields.Element(1) = "clear" then
Clear_Response;
Irc.Message.Print_Line(To_Unbounded_String("Response Processor Cleared"));
end if;
elsif Fields.Element(0) = "/msg" then
if Fields.Length > 2 then
Bot.Privmsg (To_String(Fields.Element(1)),
--To_String(Unbounded_Slice(CommandLine,index(CommandLine," ")+1,Length(CommandLine)) )
To_String(FieldsMerge(2,Integer(Fields.Length)-1))
);
end if;
end if;
else
if Fields.Length = 1 then
if Fields.Element(0) = "/help" then
Irc.Message.Print_Line(To_Unbounded_String("/whois <nickname> /nick <nickname> "));
Irc.Message.Print_Line(To_Unbounded_String("/me <action description> /version <nickname> "));
Irc.Message.Print_Line(To_Unbounded_String("/time <nickname> /clientinfo <nickname> "));
Irc.Message.Print_Line(To_Unbounded_String("/source <nickname> /msg <nickname> "));
Irc.Message.Print_Line(To_Unbounded_String("/response <on|off|local|clear> /quit "));
elsif Fields.Element(0) = "/quit" then
Quit := True;
end if;
end if;
end if;
end Process_Command;
type String_Access is access String;
type Response_Array is Array (0 .. 2) of String_Access;
type Response_Record is record
MatchRegex : String_Access;
Response : Response_Array;
Counter : Integer;
end record;
type Response_Type is array (Positive range <>) of Response_Record;
ResponseTable : Response_Type :=
((new String'(".*\bsun\b.*"),
(new String'("The Sun's coming up, like a big bald head"),new String'("Sun and Moon"),new String'("That'a alot of sun")),0),
(new String'(".*\b[Hh]ypnotoad\b.*|.*\b[Ff]uturama\b.*|.*\bpraise\b.*"),
(new String'("All Praise to The Hypnotoad GRGGRGRRBRBBRBRRGRGGRGRRBRBBRBRR"),
new String'("GRGGRGRRBRBBRBRRGR"),
new String'("All Praise, All Praise")),0),
(new String'(".*\bconjob\b.*|.*\bconm[ea]n\b.*|.*\bbusted\b.*|.*\billegal\b.*"),
(new String'("Conjob Right on"),new String'("You;ve been ripped off man"),new String'("You're saying conjob alot")),0),
(new String'(".*\bwine\b.*|.*\bdrink\b.*"),
(new String'("Try the wine!"),new String'("I see you enjoya fine wine, Have another Glass!"),new String'("And the water turned wine")),0),
(new String'(".*\bcat\b.*"),
(new String'("Hep Cats"),new String'("Cool for Cats"),new String'("Stop Saying the word cat")),0),
(new String'(".*\bstrange\b.*|.*/bweird/b.*"),
(new String'("STSSTSTTRARRARAANGNNGNGGEGEE"),new String'("That IS strange"),new String'("Never a stranger")),0),
(new String'(".*\bfish\b.*"),
(new String'("Neither fish nor flesh"),new String'("and to eat no fish"),new String'("But enough of fish")),0),
(new String'(".*\bcoffee\b.*"),
(new String'("I feel disoriented if I can't go to the cafe in the morning"),
new String'("Coffee rich Coffee strong"),
new String'("Beans of madness")),0),
(new String'(".*\bweather\b.*"),
(new String'("The weather's on the change"),
new String'("Lines form in feint dischord"),new String'("And the stormwatch brews a concert of kings")),0));
procedure Clear_Response is
begin
for i in ResponseTable'Range loop
ResponseTable(i).Counter := 0;
end loop;
end Clear_Response;
procedure Response_Processor (Conn : in out Irc.Commands.Connection;
Msg : IrcMessage) is
Regex : GNAT.Regpat.Pattern_Matcher (1024);
Matches : GNAT.Regpat.Match_Array (0 .. 1);
Now : Time;
Next : Time;
D : Duration := 0.05;
L : Integer;
scratch : Unbounded_String;
begin
if Suppress_Response = False then
for i in ResponseTable'Range loop
GNAT.Regpat.Compile (Regex, ResponseTable(i).MatchRegex.all);
scratch := SU.Unbounded_Slice(Msg.Args,SU.Index(Msg.Args,":")+1,SU.Length( Msg.Args));
scratch := To_Unbounded_String(Ada.Strings.Fixed.Translate(To_String(scratch),
Ada.Strings.Maps.Constants.Lower_Case_Map));
GNAT.Regpat.Match (Regex, To_String(scratch) , Matches);
if Matches (0) /= GNAT.Regpat.No_Match then
-- Pair.Func (This, Msg);
if ResponseTable(i).Counter <= ResponseTable(i).Response'Last then
Now := Clock;
L := ResponseTable(i).Response(ResponseTable(i).Counter).all'Length;
Next := Now + (D*L) ;
delay until Next;
if Local_Response then
Irc.Message.Print_Line(To_Unbounded_String(
ResponseTable(i).Response(ResponseTable(i).Counter).all));
else
Bot.Privmsg (To_String(Channel),
ResponseTable(i).Response(ResponseTable(i).Counter).all);
end if;
ResponseTable(i).Counter := ResponseTable(i).Counter + 1;
end if;
end if;
end loop;
end if;
end Response_Processor;
begin
Get_Size(Number_Of_Lines => Lines,Number_Of_Columns => Columns);
Add (Column => ((Columns-30)/2)-14,Line => Lines/2 ,Str => "Enter Nick : ");
Clear_To_End_Of_Line;
Edline := To_Unbounded_String("");
Texaco.Line_Editor(Standard_Window,
StartLine => Lines/2,
StartColumn => (Columns-30)/2,
Editlength => 21,
Edline => Edline,
MaxLength => 20,
SuppressSpaces => True);
c := Texaco.c;
if Character'Val (c) /= ESC then
Clear;
Refresh;
-- Specify the server, port, and nick of our bot
Bot := Irc.Bot.Create ("irc.us.ircnet.net", 6667, Nick => To_String(Edline));
-- Normally, you would use Irc.Commands.Install (Bot) to add
-- the standard command set.
Bot.On_Message ("PING", Irc.Commands.Ping_Server'Access);
-- Bot.On_Regexp(OnRegexp => ".*",Func => Response_Processor'Unrestricted_Access);
Bot.On_Regexp(OnRegexp => "^PRIVMSG",Func => Response_Processor'Unrestricted_Access);
-- Connect the socket and identify the bot (send NICK and USER)
Bot.Connect;
Bot.Identify;
Bot.Join (To_String(Channel));
-- Loop until program is killed or an error occurs
Read_Loop.Start;
loop
Get_Size(Number_Of_Lines => Lines,Number_Of_Columns => Columns);
Add (Standard_Window,
Line => Lines-1,
Column => 0,
Str => "/help for commands Esc exit");
Refresh;
Edline := To_Unbounded_String("");
Texaco.Line_Editor(Standard_Window,
StartLine => Lines-2,
StartColumn => 0,
EditLength => Columns,
Edline => Edline,
MaxLength => 400);
c := Texaco.c;
if c in Special_Key_Code'Range then
case c is
when Key_F1 => null;
when others => null;
end case;
elsif c in Real_Key_Code'Range then
Ch := Character'Val (c);
case Ch is
when CR | LF =>
if Index(Source => Edline,Pattern => "/") = 1 then
Process_Command(Edline,Quit);
if Quit then
Bot.Command("QUIT",":Exiting Normally");
exit;
end if;
else
Bot.Privmsg (To_String(Channel), To_String(Edline));
end if;
Edline := To_Unbounded_String("");
Texaco.Current_Char := 1;
when ESC =>
begin
Bot.Command("QUIT",":Exiting Normally");
exit;
end;
when others => null;
end case;
end if;
end loop;
-- Close the socket
Bot.Disconnect;
end if;
Abort Read_Loop;
end Irc_Client;
end Pong_Bot;
| true |
-- This was an example bot now converted to an IRC Client
-- Copyright (c) 2019 House Harris Software - PI:NAME:<NAME>END_PI
with Ada.Containers.Vectors;
with Ada.Containers; use Ada.Containers;
With Irc.Commands; use Irc.Commands;
with Irc.Message; use Irc.Message;
with Irc.Bot; use Irc.Bot;
with GNAT.Regpat; use GNAT.Regpat;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Strings.Maps.Constants;
with Ada.Strings.Fixed;
package body Pong_Bot is
package SU renames Ada.Strings.Unbounded;
procedure Irc_Client is
-- Bot : Irc.Bot.Connection; moved to pong_bot.ads
c :Key_Code;
Ch : Character;
Edline : Unbounded_String;
Channel : Unbounded_String := To_Unbounded_String("#worldchat");
Lines : Line_Position;
Columns : Column_Position;
Quit : Boolean := False;
task Read_Loop is
entry Start;
end Read_Loop;
task body Read_Loop is
Col : Column_Position;
Lin : Line_Position;
-- Line : Ada.Strings.Unbounded.Unbounded_String;
-- Msg : Irc.Message.Message;
begin
accept Start;
loop
declare
Line : Ada.Strings.Unbounded.Unbounded_String;
Msg : Irc.Message.Message;
begin
Bot.Read_Line (Line);
Msg := Irc.Message.Parse_Line (Line);
Bot.Do_Message (Msg);
-- Print out the message so we can get some feedback
Get_Cursor_Position(Line => Lin,Column => Col);
Msg.Print;
Move_Cursor(Line => Lin,Column => Col);
Refresh;
exception
when Irc.Message.Parse_Error => -- exit;
Irc.Message.Print_Line(To_Unbounded_String("Message Parse Error"));
end;
end loop;
end Read_Loop;
procedure Clear_Response;
package FieldsVector is new Ada.Containers.Vectors (Natural,
Unbounded_String);
use FieldsVector;
Fields : FieldsVector.Vector;
procedure Split (InVector : in out FieldsVector.Vector; InString : in Unbounded_String) is
Cursor : Integer;
scratch : Unbounded_String := InString;
AppendStr : Unbounded_String;
begin
Cursor := Index(scratch," ");
if Cursor /= 0 then
while Cursor /= 0 loop
AppendStr := To_Unbounded_String(Slice (Source => scratch,Low => 1,High => Cursor-1));
if Length(AppendStr) > 0 then
InVector.Append(AppendStr);
end if;
Delete(scratch,1,Cursor);
Cursor := Index(scratch," ");
if Cursor = 0 and then Length(scratch) > 0 then
InVector.Append(scratch);
end if;
end loop;
else
if Length(scratch) > 0 then
InVector.Append(scratch);
end if;
end if;
end Split;
function FieldsMerge (MergeStart : integer; MergeEnd : Integer ) return Unbounded_String is
OutString : Unbounded_String := To_Unbounded_String("");
begin
for i in MergeStart..MergeEnd loop
Append(OutString,Fields.Element(i) & " ");
end loop;
return OutString;
end FieldsMerge;
Suppress_Response : Boolean := True;
Local_Response : Boolean := True;
procedure Process_Command (CommandLine : Unbounded_String; Quit : in out Boolean ) is
begin
Clear(Fields);
Split (Fields,CommandLine);
if Fields.Length > 1 then
if Fields.Element(0) = "/whois" then
Bot.Command(Cmd => "WHOIS",Args => To_String(Fields.Element(1)));
elsif Fields.Element(0) = "/nick" then
Bot.Command(Cmd => "NICK",Args => To_String(Fields.Element(1)));
elsif Fields.Element(0) = "/me" then
Bot.Privmsg (To_String(Channel), Character'val(1)&"ACTION "&
To_String(Unbounded_Slice(CommandLine,index(CommandLine," ")+1,Length(CommandLine)) )
&Character'val(1));
elsif Fields.Element(0) = "/version" then
Bot.Privmsg (To_String(Fields.Element(1)),
Character'val(1)&"VERSION"&Character'val(1));
elsif Fields.Element(0) = "/time" then
Bot.Privmsg (To_String(Fields.Element(1)), Character'val(1)&"TIME"&Character'val(1));
elsif Fields.Element(0) = "/clientinfo" then
Bot.Privmsg (To_String(Fields.Element(1)), Character'val(1)&"CLIENTINFO"&Character'val(1));
elsif Fields.Element(0) = "/source" then
Bot.Privmsg (To_String(Fields.Element(1)), Character'val(1)&"SOURCE"&Character'val(1));
elsif Fields.Element(0) = "/response" then
if Fields.Element(1) = "on" then
--Bot.On_Regexp(OnRegexp => ".*",Func => Response_Processor'Unrestricted_Access);
Suppress_Response := False;
Local_Response := False;
Irc.Message.Print_Line(To_Unbounded_String("Response Processor On"));
elsif Fields.Element(1) = "off" then
Suppress_Response := True;
Irc.Message.Print_Line(To_Unbounded_String("Response Processor Off"));
elsif Fields.Element(1) = "local" then
Suppress_Response := False;
Local_Response := True;
Irc.Message.Print_Line(To_Unbounded_String("Response Processor On Local"));
elsif Fields.Element(1) = "clear" then
Clear_Response;
Irc.Message.Print_Line(To_Unbounded_String("Response Processor Cleared"));
end if;
elsif Fields.Element(0) = "/msg" then
if Fields.Length > 2 then
Bot.Privmsg (To_String(Fields.Element(1)),
--To_String(Unbounded_Slice(CommandLine,index(CommandLine," ")+1,Length(CommandLine)) )
To_String(FieldsMerge(2,Integer(Fields.Length)-1))
);
end if;
end if;
else
if Fields.Length = 1 then
if Fields.Element(0) = "/help" then
Irc.Message.Print_Line(To_Unbounded_String("/whois <nickname> /nick <nickname> "));
Irc.Message.Print_Line(To_Unbounded_String("/me <action description> /version <nickname> "));
Irc.Message.Print_Line(To_Unbounded_String("/time <nickname> /clientinfo <nickname> "));
Irc.Message.Print_Line(To_Unbounded_String("/source <nickname> /msg <nickname> "));
Irc.Message.Print_Line(To_Unbounded_String("/response <on|off|local|clear> /quit "));
elsif Fields.Element(0) = "/quit" then
Quit := True;
end if;
end if;
end if;
end Process_Command;
type String_Access is access String;
type Response_Array is Array (0 .. 2) of String_Access;
type Response_Record is record
MatchRegex : String_Access;
Response : Response_Array;
Counter : Integer;
end record;
type Response_Type is array (Positive range <>) of Response_Record;
ResponseTable : Response_Type :=
((new String'(".*\bsun\b.*"),
(new String'("The Sun's coming up, like a big bald head"),new String'("Sun and Moon"),new String'("That'a alot of sun")),0),
(new String'(".*\b[Hh]ypnotoad\b.*|.*\b[Ff]uturama\b.*|.*\bpraise\b.*"),
(new String'("All Praise to The Hypnotoad GRGGRGRRBRBBRBRRGRGGRGRRBRBBRBRR"),
new String'("GRGGRGRRBRBBRBRRGR"),
new String'("All Praise, All Praise")),0),
(new String'(".*\bconjob\b.*|.*\bconm[ea]n\b.*|.*\bbusted\b.*|.*\billegal\b.*"),
(new String'("Conjob Right on"),new String'("You;ve been ripped off man"),new String'("You're saying conjob alot")),0),
(new String'(".*\bwine\b.*|.*\bdrink\b.*"),
(new String'("Try the wine!"),new String'("I see you enjoya fine wine, Have another Glass!"),new String'("And the water turned wine")),0),
(new String'(".*\bcat\b.*"),
(new String'("Hep Cats"),new String'("Cool for Cats"),new String'("Stop Saying the word cat")),0),
(new String'(".*\bstrange\b.*|.*/bweird/b.*"),
(new String'("STSSTSTTRARRARAANGNNGNGGEGEE"),new String'("That IS strange"),new String'("Never a stranger")),0),
(new String'(".*\bfish\b.*"),
(new String'("Neither fish nor flesh"),new String'("and to eat no fish"),new String'("But enough of fish")),0),
(new String'(".*\bcoffee\b.*"),
(new String'("I feel disoriented if I can't go to the cafe in the morning"),
new String'("Coffee rich Coffee strong"),
new String'("Beans of madness")),0),
(new String'(".*\bweather\b.*"),
(new String'("The weather's on the change"),
new String'("Lines form in feint dischord"),new String'("And the stormwatch brews a concert of kings")),0));
procedure Clear_Response is
begin
for i in ResponseTable'Range loop
ResponseTable(i).Counter := 0;
end loop;
end Clear_Response;
procedure Response_Processor (Conn : in out Irc.Commands.Connection;
Msg : IrcMessage) is
Regex : GNAT.Regpat.Pattern_Matcher (1024);
Matches : GNAT.Regpat.Match_Array (0 .. 1);
Now : Time;
Next : Time;
D : Duration := 0.05;
L : Integer;
scratch : Unbounded_String;
begin
if Suppress_Response = False then
for i in ResponseTable'Range loop
GNAT.Regpat.Compile (Regex, ResponseTable(i).MatchRegex.all);
scratch := SU.Unbounded_Slice(Msg.Args,SU.Index(Msg.Args,":")+1,SU.Length( Msg.Args));
scratch := To_Unbounded_String(Ada.Strings.Fixed.Translate(To_String(scratch),
Ada.Strings.Maps.Constants.Lower_Case_Map));
GNAT.Regpat.Match (Regex, To_String(scratch) , Matches);
if Matches (0) /= GNAT.Regpat.No_Match then
-- Pair.Func (This, Msg);
if ResponseTable(i).Counter <= ResponseTable(i).Response'Last then
Now := Clock;
L := ResponseTable(i).Response(ResponseTable(i).Counter).all'Length;
Next := Now + (D*L) ;
delay until Next;
if Local_Response then
Irc.Message.Print_Line(To_Unbounded_String(
ResponseTable(i).Response(ResponseTable(i).Counter).all));
else
Bot.Privmsg (To_String(Channel),
ResponseTable(i).Response(ResponseTable(i).Counter).all);
end if;
ResponseTable(i).Counter := ResponseTable(i).Counter + 1;
end if;
end if;
end loop;
end if;
end Response_Processor;
begin
Get_Size(Number_Of_Lines => Lines,Number_Of_Columns => Columns);
Add (Column => ((Columns-30)/2)-14,Line => Lines/2 ,Str => "Enter Nick : ");
Clear_To_End_Of_Line;
Edline := To_Unbounded_String("");
Texaco.Line_Editor(Standard_Window,
StartLine => Lines/2,
StartColumn => (Columns-30)/2,
Editlength => 21,
Edline => Edline,
MaxLength => 20,
SuppressSpaces => True);
c := Texaco.c;
if Character'Val (c) /= ESC then
Clear;
Refresh;
-- Specify the server, port, and nick of our bot
Bot := Irc.Bot.Create ("irc.us.ircnet.net", 6667, Nick => To_String(Edline));
-- Normally, you would use Irc.Commands.Install (Bot) to add
-- the standard command set.
Bot.On_Message ("PING", Irc.Commands.Ping_Server'Access);
-- Bot.On_Regexp(OnRegexp => ".*",Func => Response_Processor'Unrestricted_Access);
Bot.On_Regexp(OnRegexp => "^PRIVMSG",Func => Response_Processor'Unrestricted_Access);
-- Connect the socket and identify the bot (send NICK and USER)
Bot.Connect;
Bot.Identify;
Bot.Join (To_String(Channel));
-- Loop until program is killed or an error occurs
Read_Loop.Start;
loop
Get_Size(Number_Of_Lines => Lines,Number_Of_Columns => Columns);
Add (Standard_Window,
Line => Lines-1,
Column => 0,
Str => "/help for commands Esc exit");
Refresh;
Edline := To_Unbounded_String("");
Texaco.Line_Editor(Standard_Window,
StartLine => Lines-2,
StartColumn => 0,
EditLength => Columns,
Edline => Edline,
MaxLength => 400);
c := Texaco.c;
if c in Special_Key_Code'Range then
case c is
when Key_F1 => null;
when others => null;
end case;
elsif c in Real_Key_Code'Range then
Ch := Character'Val (c);
case Ch is
when CR | LF =>
if Index(Source => Edline,Pattern => "/") = 1 then
Process_Command(Edline,Quit);
if Quit then
Bot.Command("QUIT",":Exiting Normally");
exit;
end if;
else
Bot.Privmsg (To_String(Channel), To_String(Edline));
end if;
Edline := To_Unbounded_String("");
Texaco.Current_Char := 1;
when ESC =>
begin
Bot.Command("QUIT",":Exiting Normally");
exit;
end;
when others => null;
end case;
end if;
end loop;
-- Close the socket
Bot.Disconnect;
end if;
Abort Read_Loop;
end Irc_Client;
end Pong_Bot;
|
[
{
"context": ":41 grosch rel $\n\n-- $Log: Strings.md,v $\n\n-- Ich, Doktor Josef Grosch, Informatiker, Sept. 1994\n\nwith Unchecked_Dealloc",
"end": 111,
"score": 0.9993573427200317,
"start": 92,
"tag": "NAME",
"value": "Doktor Josef Grosch"
}
] | reuse/ada/strings.adb | cocolab8/cocktail | 0 | -- $Id: Strings.md,v 1.3 1992/08/07 14:45:41 grosch rel $
-- $Log: Strings.md,v $
-- Ich, Doktor Josef Grosch, Informatiker, Sept. 1994
with Unchecked_Deallocation;
package body strings is
procedure Free is new Unchecked_Deallocation (String, tString);
function "=" (Left, Right: tString) return Boolean is
begin return Left.all = Right.all; end "=";
function "<" (Left, Right: tString) return Boolean is
begin return Left.all < Right.all; end "<";
function "<=" (Left, Right: tString) return Boolean is
begin return Left.all <= Right.all; end "<=";
function ">" (Left, Right: tString) return Boolean is
begin return Left.all > Right.all; end ">";
function ">=" (Left, Right: tString) return Boolean is
begin return Left.all >= Right.all; end ">=";
function "&" (Left, Right: tString) return tString is
L_Length : constant Integer := Left.all'Length;
R_Length : constant Integer := Right.all'Length;
Length : constant Integer := L_Length + R_Length;
Result : tString := new String (1 .. Length);
begin
Result.all (1 .. L_Length) := Left.all;
Result.all (L_Length + 1 .. Length) := Right.all;
return Result;
end "&";
function "&" (Left: tString; Right: String) return tString is
L_Length : constant Integer := Left.all'Length;
Length : constant Integer := L_Length + Right'Length;
Result : tString := new String (1 .. Length);
begin
Result.all (1 .. L_Length) := Left.all;
Result.all (L_Length + 1 .. Length) := Right;
return Result;
end "&";
function "&" (Left: String; Right: tString) return tString is
R_Length : constant Integer := Right.all'Length;
Length : constant Integer := Left'Length + R_Length;
Result : tString := new String (1 .. Length);
begin
Result.all (1 .. Left'Length) := Left;
Result.all (Left'Length + 1 .. Length) := Right.all;
return Result;
end "&";
function "&" (Left: tString; Right: Character) return tString is
Length : constant Integer := Left.all'Length + 1;
Result : tString := new String (1 .. Length);
begin
Result.all (1 .. Length - 1) := Left.all;
Result.all (Length) := Right;
return Result;
end "&";
function "&" (Left: Character; Right: tString) return tString is
Length : constant Integer := Right.all'Length + 1;
Result : tString := new String (1 .. Length);
begin
Result.all (1) := Left;
Result.all (2 .. Length) := Right.all;
return Result;
end "&";
procedure Create (Target: in out tString; Length: Natural) is
begin
Free (Target);
Target := new String (1 .. Length);
end Create;
function Length (Source: tString) return Natural is
begin
return Source.all'Length;
end Length;
function Element (Source: tString; Index: Positive) return Character is
begin
if Index <= Source.all'Last then
return Source.all (Index);
else
null; -- raise String.Index_Error;
return '?';
end if;
end Element;
procedure Replace_Element (Source: in out tString; Index: Positive; By: Character) is
begin
if Index <= Source.all'Last then
Source.all (Index) := By;
else
null; -- raise Strings.Index_Error;
end if;
end Replace_Element;
function Replace_Slice (Source: in tString; Low: Positive; High: Natural; By: String) return tString is
begin
return Source; -- To_tString (Fixed.Replace_Slice (Source.all, Low, High, By));
end Replace_Slice;
function Slice (Source: tString; Low: Positive; High: Natural) return String is
Result : String (1 .. High - Low + 1);
begin
Result := Source.all (Low .. High);
return Result;
end Slice;
function To_String (Source: tString) return String is
begin
return Source.all;
end To_String;
procedure To_tString (Source: String; Target: in out tString) is
begin
Free (Target);
Target := new String (1 .. Source'Length);
Target.all := Source;
end To_tString;
procedure ReadS (File: File_Type; Target: in out tString) is
s : String (1 .. 1024);
n : Integer;
begin
Get_Line (File, s, n);
To_tString (s (1 .. n), Target);
end ReadS;
procedure WriteS (File: File_Type; Source: tString) is
begin
Put (File, Source.all);
end WriteS;
end strings;
| 26194 | -- $Id: Strings.md,v 1.3 1992/08/07 14:45:41 grosch rel $
-- $Log: Strings.md,v $
-- Ich, <NAME>, Informatiker, Sept. 1994
with Unchecked_Deallocation;
package body strings is
procedure Free is new Unchecked_Deallocation (String, tString);
function "=" (Left, Right: tString) return Boolean is
begin return Left.all = Right.all; end "=";
function "<" (Left, Right: tString) return Boolean is
begin return Left.all < Right.all; end "<";
function "<=" (Left, Right: tString) return Boolean is
begin return Left.all <= Right.all; end "<=";
function ">" (Left, Right: tString) return Boolean is
begin return Left.all > Right.all; end ">";
function ">=" (Left, Right: tString) return Boolean is
begin return Left.all >= Right.all; end ">=";
function "&" (Left, Right: tString) return tString is
L_Length : constant Integer := Left.all'Length;
R_Length : constant Integer := Right.all'Length;
Length : constant Integer := L_Length + R_Length;
Result : tString := new String (1 .. Length);
begin
Result.all (1 .. L_Length) := Left.all;
Result.all (L_Length + 1 .. Length) := Right.all;
return Result;
end "&";
function "&" (Left: tString; Right: String) return tString is
L_Length : constant Integer := Left.all'Length;
Length : constant Integer := L_Length + Right'Length;
Result : tString := new String (1 .. Length);
begin
Result.all (1 .. L_Length) := Left.all;
Result.all (L_Length + 1 .. Length) := Right;
return Result;
end "&";
function "&" (Left: String; Right: tString) return tString is
R_Length : constant Integer := Right.all'Length;
Length : constant Integer := Left'Length + R_Length;
Result : tString := new String (1 .. Length);
begin
Result.all (1 .. Left'Length) := Left;
Result.all (Left'Length + 1 .. Length) := Right.all;
return Result;
end "&";
function "&" (Left: tString; Right: Character) return tString is
Length : constant Integer := Left.all'Length + 1;
Result : tString := new String (1 .. Length);
begin
Result.all (1 .. Length - 1) := Left.all;
Result.all (Length) := Right;
return Result;
end "&";
function "&" (Left: Character; Right: tString) return tString is
Length : constant Integer := Right.all'Length + 1;
Result : tString := new String (1 .. Length);
begin
Result.all (1) := Left;
Result.all (2 .. Length) := Right.all;
return Result;
end "&";
procedure Create (Target: in out tString; Length: Natural) is
begin
Free (Target);
Target := new String (1 .. Length);
end Create;
function Length (Source: tString) return Natural is
begin
return Source.all'Length;
end Length;
function Element (Source: tString; Index: Positive) return Character is
begin
if Index <= Source.all'Last then
return Source.all (Index);
else
null; -- raise String.Index_Error;
return '?';
end if;
end Element;
procedure Replace_Element (Source: in out tString; Index: Positive; By: Character) is
begin
if Index <= Source.all'Last then
Source.all (Index) := By;
else
null; -- raise Strings.Index_Error;
end if;
end Replace_Element;
function Replace_Slice (Source: in tString; Low: Positive; High: Natural; By: String) return tString is
begin
return Source; -- To_tString (Fixed.Replace_Slice (Source.all, Low, High, By));
end Replace_Slice;
function Slice (Source: tString; Low: Positive; High: Natural) return String is
Result : String (1 .. High - Low + 1);
begin
Result := Source.all (Low .. High);
return Result;
end Slice;
function To_String (Source: tString) return String is
begin
return Source.all;
end To_String;
procedure To_tString (Source: String; Target: in out tString) is
begin
Free (Target);
Target := new String (1 .. Source'Length);
Target.all := Source;
end To_tString;
procedure ReadS (File: File_Type; Target: in out tString) is
s : String (1 .. 1024);
n : Integer;
begin
Get_Line (File, s, n);
To_tString (s (1 .. n), Target);
end ReadS;
procedure WriteS (File: File_Type; Source: tString) is
begin
Put (File, Source.all);
end WriteS;
end strings;
| true | -- $Id: Strings.md,v 1.3 1992/08/07 14:45:41 grosch rel $
-- $Log: Strings.md,v $
-- Ich, PI:NAME:<NAME>END_PI, Informatiker, Sept. 1994
with Unchecked_Deallocation;
package body strings is
procedure Free is new Unchecked_Deallocation (String, tString);
function "=" (Left, Right: tString) return Boolean is
begin return Left.all = Right.all; end "=";
function "<" (Left, Right: tString) return Boolean is
begin return Left.all < Right.all; end "<";
function "<=" (Left, Right: tString) return Boolean is
begin return Left.all <= Right.all; end "<=";
function ">" (Left, Right: tString) return Boolean is
begin return Left.all > Right.all; end ">";
function ">=" (Left, Right: tString) return Boolean is
begin return Left.all >= Right.all; end ">=";
function "&" (Left, Right: tString) return tString is
L_Length : constant Integer := Left.all'Length;
R_Length : constant Integer := Right.all'Length;
Length : constant Integer := L_Length + R_Length;
Result : tString := new String (1 .. Length);
begin
Result.all (1 .. L_Length) := Left.all;
Result.all (L_Length + 1 .. Length) := Right.all;
return Result;
end "&";
function "&" (Left: tString; Right: String) return tString is
L_Length : constant Integer := Left.all'Length;
Length : constant Integer := L_Length + Right'Length;
Result : tString := new String (1 .. Length);
begin
Result.all (1 .. L_Length) := Left.all;
Result.all (L_Length + 1 .. Length) := Right;
return Result;
end "&";
function "&" (Left: String; Right: tString) return tString is
R_Length : constant Integer := Right.all'Length;
Length : constant Integer := Left'Length + R_Length;
Result : tString := new String (1 .. Length);
begin
Result.all (1 .. Left'Length) := Left;
Result.all (Left'Length + 1 .. Length) := Right.all;
return Result;
end "&";
function "&" (Left: tString; Right: Character) return tString is
Length : constant Integer := Left.all'Length + 1;
Result : tString := new String (1 .. Length);
begin
Result.all (1 .. Length - 1) := Left.all;
Result.all (Length) := Right;
return Result;
end "&";
function "&" (Left: Character; Right: tString) return tString is
Length : constant Integer := Right.all'Length + 1;
Result : tString := new String (1 .. Length);
begin
Result.all (1) := Left;
Result.all (2 .. Length) := Right.all;
return Result;
end "&";
procedure Create (Target: in out tString; Length: Natural) is
begin
Free (Target);
Target := new String (1 .. Length);
end Create;
function Length (Source: tString) return Natural is
begin
return Source.all'Length;
end Length;
function Element (Source: tString; Index: Positive) return Character is
begin
if Index <= Source.all'Last then
return Source.all (Index);
else
null; -- raise String.Index_Error;
return '?';
end if;
end Element;
procedure Replace_Element (Source: in out tString; Index: Positive; By: Character) is
begin
if Index <= Source.all'Last then
Source.all (Index) := By;
else
null; -- raise Strings.Index_Error;
end if;
end Replace_Element;
function Replace_Slice (Source: in tString; Low: Positive; High: Natural; By: String) return tString is
begin
return Source; -- To_tString (Fixed.Replace_Slice (Source.all, Low, High, By));
end Replace_Slice;
function Slice (Source: tString; Low: Positive; High: Natural) return String is
Result : String (1 .. High - Low + 1);
begin
Result := Source.all (Low .. High);
return Result;
end Slice;
function To_String (Source: tString) return String is
begin
return Source.all;
end To_String;
procedure To_tString (Source: String; Target: in out tString) is
begin
Free (Target);
Target := new String (1 .. Source'Length);
Target.all := Source;
end To_tString;
procedure ReadS (File: File_Type; Target: in out tString) is
s : String (1 .. 1024);
n : Integer;
begin
Get_Line (File, s, n);
To_tString (s (1 .. n), Target);
end ReadS;
procedure WriteS (File: File_Type; Source: tString) is
begin
Put (File, Source.all);
end WriteS;
end strings;
|
[
{
"context": "---------------------------\n-- Copyright (c) 2016, Natacha Porté --\n-- ",
"end": 115,
"score": 0.999861478805542,
"start": 102,
"tag": "NAME",
"value": "Natacha Porté"
}
] | src/natools-parallelism.ads | faelys/natools | 0 | ------------------------------------------------------------------------------
-- Copyright (c) 2016, 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.Parallelism provides generic procedures to help with simple --
-- parallelisation needs. --
------------------------------------------------------------------------------
package Natools.Parallelism is
pragma Pure;
generic
type Global_State (<>) is limited private;
-- State common to all jobs, only accessed from protected subprograms
type Job_State is limited private;
-- State of a single job, each worker task having its own
with procedure Initialize_Job
(Global : in out Global_State;
Job : out Job_State) is <>;
-- Initialize Job and update Global as needed
with procedure Do_Job (Job : in out Job_State) is <>;
-- Perform the job in parallel
with procedure Gather_Result
(Global : in out Global_State;
Job : in Job_State) is <>;
-- Update Global with results stored in Job
with function Is_Finished (Global : in Global_State)
return Boolean is <>;
-- Check whether there is still a job to do
procedure Single_Accumulator_Run
(Global : in out Global_State;
Task_Count : in Positive);
generic
type Global_State (<>) is limited private;
-- State common to all jobs, only accessed from protected subprograms
type Task_Result is limited private;
-- Accumulated result in a single task
type Job_Description is limited private;
-- Parameters for a given job
with procedure Initialize (Result : in out Task_Result) is <>;
-- Initialize Result for the current task
with procedure Get_Next_Job
(Global : in out Global_State;
Job : out Job_Description;
Terminated : out Boolean) is <>;
-- If there is a next job available from Global, set Terminated
-- to False and initialize Job, otherwise set Terminated to True.
with procedure Do_Job
(Result : in out Task_Result;
Job : in Job_Description) is <>;
-- Perform the job in parallel
with procedure Gather_Result
(Global : in out Global_State;
Partial : in Task_Result) is <>;
-- Update Global with results stored in Partial
procedure Per_Task_Accumulator_Run
(Global : in out Global_State;
Task_Count : in Positive);
end Natools.Parallelism;
| 28093 | ------------------------------------------------------------------------------
-- Copyright (c) 2016, <NAME> --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.Parallelism provides generic procedures to help with simple --
-- parallelisation needs. --
------------------------------------------------------------------------------
package Natools.Parallelism is
pragma Pure;
generic
type Global_State (<>) is limited private;
-- State common to all jobs, only accessed from protected subprograms
type Job_State is limited private;
-- State of a single job, each worker task having its own
with procedure Initialize_Job
(Global : in out Global_State;
Job : out Job_State) is <>;
-- Initialize Job and update Global as needed
with procedure Do_Job (Job : in out Job_State) is <>;
-- Perform the job in parallel
with procedure Gather_Result
(Global : in out Global_State;
Job : in Job_State) is <>;
-- Update Global with results stored in Job
with function Is_Finished (Global : in Global_State)
return Boolean is <>;
-- Check whether there is still a job to do
procedure Single_Accumulator_Run
(Global : in out Global_State;
Task_Count : in Positive);
generic
type Global_State (<>) is limited private;
-- State common to all jobs, only accessed from protected subprograms
type Task_Result is limited private;
-- Accumulated result in a single task
type Job_Description is limited private;
-- Parameters for a given job
with procedure Initialize (Result : in out Task_Result) is <>;
-- Initialize Result for the current task
with procedure Get_Next_Job
(Global : in out Global_State;
Job : out Job_Description;
Terminated : out Boolean) is <>;
-- If there is a next job available from Global, set Terminated
-- to False and initialize Job, otherwise set Terminated to True.
with procedure Do_Job
(Result : in out Task_Result;
Job : in Job_Description) is <>;
-- Perform the job in parallel
with procedure Gather_Result
(Global : in out Global_State;
Partial : in Task_Result) is <>;
-- Update Global with results stored in Partial
procedure Per_Task_Accumulator_Run
(Global : in out Global_State;
Task_Count : in Positive);
end Natools.Parallelism;
| true | ------------------------------------------------------------------------------
-- Copyright (c) 2016, PI:NAME:<NAME>END_PI --
-- --
-- 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.Parallelism provides generic procedures to help with simple --
-- parallelisation needs. --
------------------------------------------------------------------------------
package Natools.Parallelism is
pragma Pure;
generic
type Global_State (<>) is limited private;
-- State common to all jobs, only accessed from protected subprograms
type Job_State is limited private;
-- State of a single job, each worker task having its own
with procedure Initialize_Job
(Global : in out Global_State;
Job : out Job_State) is <>;
-- Initialize Job and update Global as needed
with procedure Do_Job (Job : in out Job_State) is <>;
-- Perform the job in parallel
with procedure Gather_Result
(Global : in out Global_State;
Job : in Job_State) is <>;
-- Update Global with results stored in Job
with function Is_Finished (Global : in Global_State)
return Boolean is <>;
-- Check whether there is still a job to do
procedure Single_Accumulator_Run
(Global : in out Global_State;
Task_Count : in Positive);
generic
type Global_State (<>) is limited private;
-- State common to all jobs, only accessed from protected subprograms
type Task_Result is limited private;
-- Accumulated result in a single task
type Job_Description is limited private;
-- Parameters for a given job
with procedure Initialize (Result : in out Task_Result) is <>;
-- Initialize Result for the current task
with procedure Get_Next_Job
(Global : in out Global_State;
Job : out Job_Description;
Terminated : out Boolean) is <>;
-- If there is a next job available from Global, set Terminated
-- to False and initialize Job, otherwise set Terminated to True.
with procedure Do_Job
(Result : in out Task_Result;
Job : in Job_Description) is <>;
-- Perform the job in parallel
with procedure Gather_Result
(Global : in out Global_State;
Partial : in Task_Result) is <>;
-- Update Global with results stored in Partial
procedure Per_Task_Accumulator_Run
(Global : in out Global_State;
Task_Count : in Positive);
end Natools.Parallelism;
|
[
{
"context": "ey verification\n-- Copyright (C) 2011, 2012, 2013 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@g",
"end": 204,
"score": 0.9998725652694702,
"start": 189,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "C) 2011, 2012, 2013 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under",
"end": 235,
"score": 0.9998773336410522,
"start": 220,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "3 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under the Apache License, Versio",
"end": 262,
"score": 0.9999268651008606,
"start": 237,
"tag": "EMAIL",
"value": "Stephane.Carrez@gmail.com"
}
] | awa/src/awa-users-filters.adb | Letractively/ada-awa | 0 | -----------------------------------------------------------------------
-- awa-users-filters -- Specific filters for authentication and key verification
-- Copyright (C) 2011, 2012, 2013 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 Util.Log.Loggers;
with ASF.Cookies;
with AWA.Users.Services;
with AWA.Users.Modules;
package body AWA.Users.Filters is
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Users.Filters");
-- ------------------------------
-- Set the user principal on the session associated with the ASF request.
-- ------------------------------
procedure Set_Session_Principal (Request : in out ASF.Requests.Request'Class;
Principal : in Principals.Principal_Access) is
Session : ASF.Sessions.Session := Request.Get_Session (Create => True);
begin
Session.Set_Principal (Principal.all'Access);
end Set_Session_Principal;
-- ------------------------------
-- Initialize the filter and configure the redirection URIs.
-- ------------------------------
procedure Initialize (Filter : in out Auth_Filter;
Context : in ASF.Servlets.Servlet_Registry'Class) is
URI : constant String := Context.Get_Init_Parameter (AUTH_FILTER_REDIRECT_PARAM);
begin
Log.Info ("Using login URI: {0}", URI);
if URI = "" then
Log.Error ("The login URI is empty. Redirection to the login page will not work.");
end if;
Filter.Login_URI := To_Unbounded_String (URI);
ASF.Security.Filters.Auth_Filter (Filter).Initialize (Context);
end Initialize;
procedure Authenticate (F : in Auth_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class;
Session : in ASF.Sessions.Session;
Auth_Id : in String;
Principal : out ASF.Principals.Principal_Access) is
pragma Unreferenced (F, Session);
use AWA.Users.Modules;
use AWA.Users.Services;
Manager : constant User_Service_Access := AWA.Users.Modules.Get_User_Manager;
P : AWA.Users.Principals.Principal_Access;
begin
Manager.Authenticate (Cookie => Auth_Id,
Ip_Addr => "",
Principal => P);
Principal := P.all'Access;
-- Setup a new AID cookie with the new connection session.
declare
Cookie : constant String := Manager.Get_Authenticate_Cookie (P.Get_Session_Identifier);
C : ASF.Cookies.Cookie := ASF.Cookies.Create (ASF.Security.Filters.AID_COOKIE,
Cookie);
begin
ASF.Cookies.Set_Path (C, Request.Get_Context_Path);
ASF.Cookies.Set_Max_Age (C, 15 * 86400);
Response.Add_Cookie (Cookie => C);
end;
exception
when Not_Found =>
Principal := null;
end Authenticate;
-- ------------------------------
-- Display or redirects the user to the login page. This procedure is called when
-- the user is not authenticated.
-- ------------------------------
overriding
procedure Do_Login (Filter : in Auth_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class) is
URI : constant String := To_String (Filter.Login_URI);
begin
Log.Info ("User is not logged, redirecting to {0}", URI);
if Request.Get_Header ("X-Requested-With") = "" then
Response.Send_Redirect (Location => URI);
else
Response.Send_Error (ASF.Responses.SC_UNAUTHORIZED);
end if;
end Do_Login;
-- ------------------------------
-- Initialize the filter and configure the redirection URIs.
-- ------------------------------
overriding
procedure Initialize (Filter : in out Verify_Filter;
Context : in ASF.Servlets.Servlet_Registry'Class) is
URI : constant String := Context.Get_Init_Parameter (VERIFY_FILTER_REDIRECT_PARAM);
begin
Filter.Invalid_Key_URI := To_Unbounded_String (URI);
end Initialize;
-- ------------------------------
-- Filter a request which contains an access key and verify that the
-- key is valid and identifies a user. Once the user is known, create
-- a session and setup the user principal.
--
-- If the access key is missing or invalid, redirect to the
-- <b>Invalid_Key_URI</b> associated with the filter.
-- ------------------------------
overriding
procedure Do_Filter (Filter : in Verify_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class;
Chain : in out ASF.Servlets.Filter_Chain) is
Key : constant String := Request.Get_Parameter (PARAM_ACCESS_KEY);
Manager : constant Users.Services.User_Service_Access := Users.Modules.Get_User_Manager;
Principal : AWA.Users.Principals.Principal_Access;
begin
Log.Info ("Verify access key {0}", Key);
Manager.Verify_User (Key => Key,
IpAddr => "",
Principal => Principal);
Set_Session_Principal (Request, Principal);
-- Request is authorized, proceed to the next filter.
ASF.Servlets.Do_Filter (Chain => Chain,
Request => Request,
Response => Response);
exception
when AWA.Users.Services.Not_Found =>
declare
URI : constant String := To_String (Filter.Invalid_Key_URI);
begin
Log.Info ("Invalid access key {0}, redirecting to {1}", Key, URI);
Response.Send_Redirect (Location => URI);
end;
end Do_Filter;
end AWA.Users.Filters;
| 5 | -----------------------------------------------------------------------
-- awa-users-filters -- Specific filters for authentication and key verification
-- Copyright (C) 2011, 2012, 2013 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Log.Loggers;
with ASF.Cookies;
with AWA.Users.Services;
with AWA.Users.Modules;
package body AWA.Users.Filters is
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Users.Filters");
-- ------------------------------
-- Set the user principal on the session associated with the ASF request.
-- ------------------------------
procedure Set_Session_Principal (Request : in out ASF.Requests.Request'Class;
Principal : in Principals.Principal_Access) is
Session : ASF.Sessions.Session := Request.Get_Session (Create => True);
begin
Session.Set_Principal (Principal.all'Access);
end Set_Session_Principal;
-- ------------------------------
-- Initialize the filter and configure the redirection URIs.
-- ------------------------------
procedure Initialize (Filter : in out Auth_Filter;
Context : in ASF.Servlets.Servlet_Registry'Class) is
URI : constant String := Context.Get_Init_Parameter (AUTH_FILTER_REDIRECT_PARAM);
begin
Log.Info ("Using login URI: {0}", URI);
if URI = "" then
Log.Error ("The login URI is empty. Redirection to the login page will not work.");
end if;
Filter.Login_URI := To_Unbounded_String (URI);
ASF.Security.Filters.Auth_Filter (Filter).Initialize (Context);
end Initialize;
procedure Authenticate (F : in Auth_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class;
Session : in ASF.Sessions.Session;
Auth_Id : in String;
Principal : out ASF.Principals.Principal_Access) is
pragma Unreferenced (F, Session);
use AWA.Users.Modules;
use AWA.Users.Services;
Manager : constant User_Service_Access := AWA.Users.Modules.Get_User_Manager;
P : AWA.Users.Principals.Principal_Access;
begin
Manager.Authenticate (Cookie => Auth_Id,
Ip_Addr => "",
Principal => P);
Principal := P.all'Access;
-- Setup a new AID cookie with the new connection session.
declare
Cookie : constant String := Manager.Get_Authenticate_Cookie (P.Get_Session_Identifier);
C : ASF.Cookies.Cookie := ASF.Cookies.Create (ASF.Security.Filters.AID_COOKIE,
Cookie);
begin
ASF.Cookies.Set_Path (C, Request.Get_Context_Path);
ASF.Cookies.Set_Max_Age (C, 15 * 86400);
Response.Add_Cookie (Cookie => C);
end;
exception
when Not_Found =>
Principal := null;
end Authenticate;
-- ------------------------------
-- Display or redirects the user to the login page. This procedure is called when
-- the user is not authenticated.
-- ------------------------------
overriding
procedure Do_Login (Filter : in Auth_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class) is
URI : constant String := To_String (Filter.Login_URI);
begin
Log.Info ("User is not logged, redirecting to {0}", URI);
if Request.Get_Header ("X-Requested-With") = "" then
Response.Send_Redirect (Location => URI);
else
Response.Send_Error (ASF.Responses.SC_UNAUTHORIZED);
end if;
end Do_Login;
-- ------------------------------
-- Initialize the filter and configure the redirection URIs.
-- ------------------------------
overriding
procedure Initialize (Filter : in out Verify_Filter;
Context : in ASF.Servlets.Servlet_Registry'Class) is
URI : constant String := Context.Get_Init_Parameter (VERIFY_FILTER_REDIRECT_PARAM);
begin
Filter.Invalid_Key_URI := To_Unbounded_String (URI);
end Initialize;
-- ------------------------------
-- Filter a request which contains an access key and verify that the
-- key is valid and identifies a user. Once the user is known, create
-- a session and setup the user principal.
--
-- If the access key is missing or invalid, redirect to the
-- <b>Invalid_Key_URI</b> associated with the filter.
-- ------------------------------
overriding
procedure Do_Filter (Filter : in Verify_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class;
Chain : in out ASF.Servlets.Filter_Chain) is
Key : constant String := Request.Get_Parameter (PARAM_ACCESS_KEY);
Manager : constant Users.Services.User_Service_Access := Users.Modules.Get_User_Manager;
Principal : AWA.Users.Principals.Principal_Access;
begin
Log.Info ("Verify access key {0}", Key);
Manager.Verify_User (Key => Key,
IpAddr => "",
Principal => Principal);
Set_Session_Principal (Request, Principal);
-- Request is authorized, proceed to the next filter.
ASF.Servlets.Do_Filter (Chain => Chain,
Request => Request,
Response => Response);
exception
when AWA.Users.Services.Not_Found =>
declare
URI : constant String := To_String (Filter.Invalid_Key_URI);
begin
Log.Info ("Invalid access key {0}, redirecting to {1}", Key, URI);
Response.Send_Redirect (Location => URI);
end;
end Do_Filter;
end AWA.Users.Filters;
| true | -----------------------------------------------------------------------
-- awa-users-filters -- Specific filters for authentication and key verification
-- Copyright (C) 2011, 2012, 2013 PI:NAME:<NAME>END_PI
-- Written by PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Log.Loggers;
with ASF.Cookies;
with AWA.Users.Services;
with AWA.Users.Modules;
package body AWA.Users.Filters is
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Users.Filters");
-- ------------------------------
-- Set the user principal on the session associated with the ASF request.
-- ------------------------------
procedure Set_Session_Principal (Request : in out ASF.Requests.Request'Class;
Principal : in Principals.Principal_Access) is
Session : ASF.Sessions.Session := Request.Get_Session (Create => True);
begin
Session.Set_Principal (Principal.all'Access);
end Set_Session_Principal;
-- ------------------------------
-- Initialize the filter and configure the redirection URIs.
-- ------------------------------
procedure Initialize (Filter : in out Auth_Filter;
Context : in ASF.Servlets.Servlet_Registry'Class) is
URI : constant String := Context.Get_Init_Parameter (AUTH_FILTER_REDIRECT_PARAM);
begin
Log.Info ("Using login URI: {0}", URI);
if URI = "" then
Log.Error ("The login URI is empty. Redirection to the login page will not work.");
end if;
Filter.Login_URI := To_Unbounded_String (URI);
ASF.Security.Filters.Auth_Filter (Filter).Initialize (Context);
end Initialize;
procedure Authenticate (F : in Auth_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class;
Session : in ASF.Sessions.Session;
Auth_Id : in String;
Principal : out ASF.Principals.Principal_Access) is
pragma Unreferenced (F, Session);
use AWA.Users.Modules;
use AWA.Users.Services;
Manager : constant User_Service_Access := AWA.Users.Modules.Get_User_Manager;
P : AWA.Users.Principals.Principal_Access;
begin
Manager.Authenticate (Cookie => Auth_Id,
Ip_Addr => "",
Principal => P);
Principal := P.all'Access;
-- Setup a new AID cookie with the new connection session.
declare
Cookie : constant String := Manager.Get_Authenticate_Cookie (P.Get_Session_Identifier);
C : ASF.Cookies.Cookie := ASF.Cookies.Create (ASF.Security.Filters.AID_COOKIE,
Cookie);
begin
ASF.Cookies.Set_Path (C, Request.Get_Context_Path);
ASF.Cookies.Set_Max_Age (C, 15 * 86400);
Response.Add_Cookie (Cookie => C);
end;
exception
when Not_Found =>
Principal := null;
end Authenticate;
-- ------------------------------
-- Display or redirects the user to the login page. This procedure is called when
-- the user is not authenticated.
-- ------------------------------
overriding
procedure Do_Login (Filter : in Auth_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class) is
URI : constant String := To_String (Filter.Login_URI);
begin
Log.Info ("User is not logged, redirecting to {0}", URI);
if Request.Get_Header ("X-Requested-With") = "" then
Response.Send_Redirect (Location => URI);
else
Response.Send_Error (ASF.Responses.SC_UNAUTHORIZED);
end if;
end Do_Login;
-- ------------------------------
-- Initialize the filter and configure the redirection URIs.
-- ------------------------------
overriding
procedure Initialize (Filter : in out Verify_Filter;
Context : in ASF.Servlets.Servlet_Registry'Class) is
URI : constant String := Context.Get_Init_Parameter (VERIFY_FILTER_REDIRECT_PARAM);
begin
Filter.Invalid_Key_URI := To_Unbounded_String (URI);
end Initialize;
-- ------------------------------
-- Filter a request which contains an access key and verify that the
-- key is valid and identifies a user. Once the user is known, create
-- a session and setup the user principal.
--
-- If the access key is missing or invalid, redirect to the
-- <b>Invalid_Key_URI</b> associated with the filter.
-- ------------------------------
overriding
procedure Do_Filter (Filter : in Verify_Filter;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class;
Chain : in out ASF.Servlets.Filter_Chain) is
Key : constant String := Request.Get_Parameter (PARAM_ACCESS_KEY);
Manager : constant Users.Services.User_Service_Access := Users.Modules.Get_User_Manager;
Principal : AWA.Users.Principals.Principal_Access;
begin
Log.Info ("Verify access key {0}", Key);
Manager.Verify_User (Key => Key,
IpAddr => "",
Principal => Principal);
Set_Session_Principal (Request, Principal);
-- Request is authorized, proceed to the next filter.
ASF.Servlets.Do_Filter (Chain => Chain,
Request => Request,
Response => Response);
exception
when AWA.Users.Services.Not_Found =>
declare
URI : constant String := To_String (Filter.Invalid_Key_URI);
begin
Log.Info ("Invalid access key {0}, redirecting to {1}", Key, URI);
Response.Send_Redirect (Location => URI);
end;
end Do_Filter;
end AWA.Users.Filters;
|
[
{
"context": " mappings\n-- Copyright (C) 2010, 2011, 2012, 2014 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@g",
"end": 177,
"score": 0.9998806715011597,
"start": 162,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "0, 2011, 2012, 2014 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under",
"end": 208,
"score": 0.9998828768730164,
"start": 193,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "4 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under the Apache License, Versio",
"end": 235,
"score": 0.9999300241470337,
"start": 210,
"tag": "EMAIL",
"value": "Stephane.Carrez@gmail.com"
}
] | samples/mapping.ads | Letractively/ada-util | 60 | -----------------------------------------------------------------------
-- mapping -- Example of serialization mappings
-- Copyright (C) 2010, 2011, 2012, 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 Ada.Strings.Unbounded;
with Util.Beans.Objects;
with Util.Serialize.Mappers.Record_Mapper;
with Util.Serialize.Mappers;
with Ada.Containers.Vectors;
package Mapping is
use Ada.Strings.Unbounded;
type Property is record
Name : Unbounded_String;
Value : Unbounded_String;
end record;
type Address is record
City : Unbounded_String;
Street : Unbounded_String;
Country : Unbounded_String;
Zip : Natural := 0;
Info : Property;
end record;
type Person is record
Name : Unbounded_String;
First_Name : Unbounded_String;
Last_Name : Unbounded_String;
Username : Unbounded_String;
Gender : Unbounded_String;
Link : Unbounded_String;
Age : Natural := 0;
Addr : Address;
Id : Long_Long_Integer := 0;
end record;
type Person_Access is access all Person;
type Person_Fields is (FIELD_FIRST_NAME, FIELD_LAST_NAME, FIELD_AGE,
FIELD_NAME, FIELD_USER_NAME, FIELD_GENDER,
FIELD_LINK, FIELD_ID);
-- Set the name/value pair on the current object.
procedure Set_Member (P : in out Person;
Field : in Person_Fields;
Value : in Util.Beans.Objects.Object);
function Get_Person_Member (From : in Person;
Field : in Person_Fields) return Util.Beans.Objects.Object;
package Person_Mapper is
new Util.Serialize.Mappers.Record_Mapper (Element_Type => Person,
Element_Type_Access => Person_Access,
Fields => Person_Fields,
Set_Member => Set_Member);
subtype Person_Context is Person_Mapper.Element_Data;
package Person_Vector is
new Ada.Containers.Vectors (Element_Type => Person,
Index_Type => Natural);
-- Get the address mapper which describes how to load an Address.
function Get_Address_Mapper return Util.Serialize.Mappers.Mapper_Access;
-- Get the person mapper which describes how to load a Person.
function Get_Person_Mapper return Person_Mapper.Mapper_Access;
end Mapping;
| 1831 | -----------------------------------------------------------------------
-- mapping -- Example of serialization mappings
-- Copyright (C) 2010, 2011, 2012, 2014 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Util.Beans.Objects;
with Util.Serialize.Mappers.Record_Mapper;
with Util.Serialize.Mappers;
with Ada.Containers.Vectors;
package Mapping is
use Ada.Strings.Unbounded;
type Property is record
Name : Unbounded_String;
Value : Unbounded_String;
end record;
type Address is record
City : Unbounded_String;
Street : Unbounded_String;
Country : Unbounded_String;
Zip : Natural := 0;
Info : Property;
end record;
type Person is record
Name : Unbounded_String;
First_Name : Unbounded_String;
Last_Name : Unbounded_String;
Username : Unbounded_String;
Gender : Unbounded_String;
Link : Unbounded_String;
Age : Natural := 0;
Addr : Address;
Id : Long_Long_Integer := 0;
end record;
type Person_Access is access all Person;
type Person_Fields is (FIELD_FIRST_NAME, FIELD_LAST_NAME, FIELD_AGE,
FIELD_NAME, FIELD_USER_NAME, FIELD_GENDER,
FIELD_LINK, FIELD_ID);
-- Set the name/value pair on the current object.
procedure Set_Member (P : in out Person;
Field : in Person_Fields;
Value : in Util.Beans.Objects.Object);
function Get_Person_Member (From : in Person;
Field : in Person_Fields) return Util.Beans.Objects.Object;
package Person_Mapper is
new Util.Serialize.Mappers.Record_Mapper (Element_Type => Person,
Element_Type_Access => Person_Access,
Fields => Person_Fields,
Set_Member => Set_Member);
subtype Person_Context is Person_Mapper.Element_Data;
package Person_Vector is
new Ada.Containers.Vectors (Element_Type => Person,
Index_Type => Natural);
-- Get the address mapper which describes how to load an Address.
function Get_Address_Mapper return Util.Serialize.Mappers.Mapper_Access;
-- Get the person mapper which describes how to load a Person.
function Get_Person_Mapper return Person_Mapper.Mapper_Access;
end Mapping;
| true | -----------------------------------------------------------------------
-- mapping -- Example of serialization mappings
-- Copyright (C) 2010, 2011, 2012, 2014 PI:NAME:<NAME>END_PI
-- Written by PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Util.Beans.Objects;
with Util.Serialize.Mappers.Record_Mapper;
with Util.Serialize.Mappers;
with Ada.Containers.Vectors;
package Mapping is
use Ada.Strings.Unbounded;
type Property is record
Name : Unbounded_String;
Value : Unbounded_String;
end record;
type Address is record
City : Unbounded_String;
Street : Unbounded_String;
Country : Unbounded_String;
Zip : Natural := 0;
Info : Property;
end record;
type Person is record
Name : Unbounded_String;
First_Name : Unbounded_String;
Last_Name : Unbounded_String;
Username : Unbounded_String;
Gender : Unbounded_String;
Link : Unbounded_String;
Age : Natural := 0;
Addr : Address;
Id : Long_Long_Integer := 0;
end record;
type Person_Access is access all Person;
type Person_Fields is (FIELD_FIRST_NAME, FIELD_LAST_NAME, FIELD_AGE,
FIELD_NAME, FIELD_USER_NAME, FIELD_GENDER,
FIELD_LINK, FIELD_ID);
-- Set the name/value pair on the current object.
procedure Set_Member (P : in out Person;
Field : in Person_Fields;
Value : in Util.Beans.Objects.Object);
function Get_Person_Member (From : in Person;
Field : in Person_Fields) return Util.Beans.Objects.Object;
package Person_Mapper is
new Util.Serialize.Mappers.Record_Mapper (Element_Type => Person,
Element_Type_Access => Person_Access,
Fields => Person_Fields,
Set_Member => Set_Member);
subtype Person_Context is Person_Mapper.Element_Data;
package Person_Vector is
new Ada.Containers.Vectors (Element_Type => Person,
Index_Type => Natural);
-- Get the address mapper which describes how to load an Address.
function Get_Address_Mapper return Util.Serialize.Mappers.Mapper_Access;
-- Get the person mapper which describes how to load a Person.
function Get_Person_Mapper return Person_Mapper.Mapper_Access;
end Mapping;
|
[
{
"context": "e-Identifier: Apache-2.0\n--\n-- Copyright (c) 2020 onox <denkpadje@gmail.com>\n--\n-- Licensed under the A",
"end": 70,
"score": 0.9993318319320679,
"start": 66,
"tag": "USERNAME",
"value": "onox"
},
{
"context": "ifier: Apache-2.0\n--\n-- Copyright (c) 2020 onox <denkpadje@gmail.com>\n--\n-- Licensed under the Apache License, Versio",
"end": 91,
"score": 0.9999244809150696,
"start": 72,
"tag": "EMAIL",
"value": "denkpadje@gmail.com"
}
] | orka/src/orka/implementation/orka-algorithms-fft.adb | onox/orka | 52 | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 onox <denkpadje@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 GL.Barriers;
with GL.Compute;
with GL.Types.Compute;
with Orka.Rendering.Programs.Modules;
package body Orka.Algorithms.FFT is
function Create_FFT
(Location : Resources.Locations.Location_Ptr) return FFT
is
use Rendering.Programs;
begin
return Result : FFT :=
(Program_FFT => Create_Program (Modules.Create_Module
(Location, CS => "algorithms/fft.comp")),
others => <>)
do
Result.Uniform_Size := Result.Program_FFT.Uniform ("size");
Result.Uniform_Transpose := Result.Program_FFT.Uniform ("transposeData");
Result.Uniform_Inverse := Result.Program_FFT.Uniform ("inverseFFT");
declare
Work_Group_Size : constant GL.Types.Compute.Dimension_Size_Array
:= Result.Program_FFT.Compute_Work_Group_Size;
begin
Result.Local_Size := Positive (Work_Group_Size (X));
end;
end return;
end Create_FFT;
procedure Compute_FFT
(Object : in out FFT;
Buffer : Rendering.Buffers.Buffer;
Width, Height : Positive;
Transpose, Inverse : Boolean)
is
use GL.Types;
use all type Rendering.Buffers.Indexed_Buffer_Target;
Columns : constant Positive := (if Transpose then Height else Width);
Rows : constant Positive := (if Transpose then Width else Height);
pragma Assert (Columns <= Object.Local_Size);
Rows_In_Shared : constant Size := Size (Object.Local_Size / Columns);
begin
Object.Uniform_Size.Set_Vector (GL.Types.UInt_Array'(UInt (Width), UInt (Height)));
Object.Uniform_Transpose.Set_Boolean (Transpose);
Object.Uniform_Inverse.Set_Boolean (Inverse);
Object.Program_FFT.Use_Program;
Buffer.Bind (Shader_Storage, 0);
GL.Barriers.Memory_Barrier ((Shader_Storage => True, others => False));
GL.Compute.Dispatch_Compute
(X => UInt (Single'Ceiling (Single (Rows) / Single (Rows_In_Shared))));
end Compute_FFT;
end Orka.Algorithms.FFT;
| 22996 | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 onox <<EMAIL>>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with GL.Barriers;
with GL.Compute;
with GL.Types.Compute;
with Orka.Rendering.Programs.Modules;
package body Orka.Algorithms.FFT is
function Create_FFT
(Location : Resources.Locations.Location_Ptr) return FFT
is
use Rendering.Programs;
begin
return Result : FFT :=
(Program_FFT => Create_Program (Modules.Create_Module
(Location, CS => "algorithms/fft.comp")),
others => <>)
do
Result.Uniform_Size := Result.Program_FFT.Uniform ("size");
Result.Uniform_Transpose := Result.Program_FFT.Uniform ("transposeData");
Result.Uniform_Inverse := Result.Program_FFT.Uniform ("inverseFFT");
declare
Work_Group_Size : constant GL.Types.Compute.Dimension_Size_Array
:= Result.Program_FFT.Compute_Work_Group_Size;
begin
Result.Local_Size := Positive (Work_Group_Size (X));
end;
end return;
end Create_FFT;
procedure Compute_FFT
(Object : in out FFT;
Buffer : Rendering.Buffers.Buffer;
Width, Height : Positive;
Transpose, Inverse : Boolean)
is
use GL.Types;
use all type Rendering.Buffers.Indexed_Buffer_Target;
Columns : constant Positive := (if Transpose then Height else Width);
Rows : constant Positive := (if Transpose then Width else Height);
pragma Assert (Columns <= Object.Local_Size);
Rows_In_Shared : constant Size := Size (Object.Local_Size / Columns);
begin
Object.Uniform_Size.Set_Vector (GL.Types.UInt_Array'(UInt (Width), UInt (Height)));
Object.Uniform_Transpose.Set_Boolean (Transpose);
Object.Uniform_Inverse.Set_Boolean (Inverse);
Object.Program_FFT.Use_Program;
Buffer.Bind (Shader_Storage, 0);
GL.Barriers.Memory_Barrier ((Shader_Storage => True, others => False));
GL.Compute.Dispatch_Compute
(X => UInt (Single'Ceiling (Single (Rows) / Single (Rows_In_Shared))));
end Compute_FFT;
end Orka.Algorithms.FFT;
| true | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 onox <PI:EMAIL:<EMAIL>END_PI>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with GL.Barriers;
with GL.Compute;
with GL.Types.Compute;
with Orka.Rendering.Programs.Modules;
package body Orka.Algorithms.FFT is
function Create_FFT
(Location : Resources.Locations.Location_Ptr) return FFT
is
use Rendering.Programs;
begin
return Result : FFT :=
(Program_FFT => Create_Program (Modules.Create_Module
(Location, CS => "algorithms/fft.comp")),
others => <>)
do
Result.Uniform_Size := Result.Program_FFT.Uniform ("size");
Result.Uniform_Transpose := Result.Program_FFT.Uniform ("transposeData");
Result.Uniform_Inverse := Result.Program_FFT.Uniform ("inverseFFT");
declare
Work_Group_Size : constant GL.Types.Compute.Dimension_Size_Array
:= Result.Program_FFT.Compute_Work_Group_Size;
begin
Result.Local_Size := Positive (Work_Group_Size (X));
end;
end return;
end Create_FFT;
procedure Compute_FFT
(Object : in out FFT;
Buffer : Rendering.Buffers.Buffer;
Width, Height : Positive;
Transpose, Inverse : Boolean)
is
use GL.Types;
use all type Rendering.Buffers.Indexed_Buffer_Target;
Columns : constant Positive := (if Transpose then Height else Width);
Rows : constant Positive := (if Transpose then Width else Height);
pragma Assert (Columns <= Object.Local_Size);
Rows_In_Shared : constant Size := Size (Object.Local_Size / Columns);
begin
Object.Uniform_Size.Set_Vector (GL.Types.UInt_Array'(UInt (Width), UInt (Height)));
Object.Uniform_Transpose.Set_Boolean (Transpose);
Object.Uniform_Inverse.Set_Boolean (Inverse);
Object.Program_FFT.Use_Program;
Buffer.Bind (Shader_Storage, 0);
GL.Barriers.Memory_Barrier ((Shader_Storage => True, others => False));
GL.Compute.Dispatch_Compute
(X => UInt (Single'Ceiling (Single (Rows) / Single (Rows_In_Shared))));
end Compute_FFT;
end Orka.Algorithms.FFT;
|
[
{
"context": "); }\n -- GStreamer\n -- * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>\n -- * 200",
"end": 1801,
"score": 0.9998741745948792,
"start": 1786,
"tag": "NAME",
"value": "Erik Walthinsen"
},
{
"context": "r\n -- * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>\n -- * 2000 Wim Taymans <wtay",
"end": 1820,
"score": 0.9999279379844666,
"start": 1803,
"tag": "EMAIL",
"value": "omega@cse.ogi.edu"
},
{
"context": "<omega@cse.ogi.edu>\n -- * 2000 Wim Taymans <wtay@chello.be>\n -- *\n -- * gsttrace.h: Header",
"end": 1864,
"score": 0.9998762011528015,
"start": 1853,
"tag": "NAME",
"value": "Wim Taymans"
},
{
"context": ".edu>\n -- * 2000 Wim Taymans <wtay@chello.be>\n -- *\n -- * gsttrace.h: Header for tracing fun",
"end": 1880,
"score": 0.9999326467514038,
"start": 1866,
"tag": "EMAIL",
"value": "wtay@chello.be"
}
] | src/gen/gstreamer-gst_low_level-gstreamer_0_10_gst_gsttrace_h.ads | persan/A-gst | 1 | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
with glib.Values;
with System;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_gslist_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_glist_h;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttrace_h is
-- arg-macro: function gst_trace_get_size (trace)
-- return (trace).bufsize;
-- arg-macro: function gst_trace_get_offset (trace)
-- return (trace).bufoffset;
-- arg-macro: function gst_trace_get_remaining (trace)
-- return (trace).bufsize - (trace).bufoffset;
-- arg-macro: procedure gst_alloc_trace_register (name)
-- _gst_alloc_trace_register (name);
-- arg-macro: procedure gst_alloc_trace_new (trace, mem)
-- G_STMT_START { if (G_UNLIKELY ((trace).flags)) { g_static_mutex_lock (and_gst_trace_mutex); if ((trace).flags and GST_ALLOC_TRACE_LIVE) (trace).live++; if ((trace).flags and GST_ALLOC_TRACE_MEM_LIVE) (trace).mem_live := g_slist_prepend ((trace).mem_live, mem); g_static_mutex_unlock (and_gst_trace_mutex); } } G_STMT_END
-- arg-macro: procedure gst_alloc_trace_free (trace, mem)
-- G_STMT_START { if (G_UNLIKELY ((trace).flags)) { g_static_mutex_lock (and_gst_trace_mutex); if ((trace).flags and GST_ALLOC_TRACE_LIVE) (trace).live--; if ((trace).flags and GST_ALLOC_TRACE_MEM_LIVE) (trace).mem_live := g_slist_remove ((trace).mem_live, mem); g_static_mutex_unlock (and_gst_trace_mutex); } } G_STMT_END
-- arg-macro: procedure gst_trace_add_entry (trace, seq, data, msg)
-- if (_gst_trace_on) { _gst_trace_add_entry(trace,(guint32)seq,(guint32)data,msg); }
-- GStreamer
-- * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
-- * 2000 Wim Taymans <wtay@chello.be>
-- *
-- * gsttrace.h: Header for tracing functions (deprecated)
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
--*
-- * GstAllocTraceFlags:
-- * @GST_ALLOC_TRACE_NONE: No tracing specified or desired. Since 0.10.36.
-- * @GST_ALLOC_TRACE_LIVE: Trace number of non-freed memory.
-- * @GST_ALLOC_TRACE_MEM_LIVE: Trace pointers of unfreed memory.
-- *
-- * Flags indicating which tracing feature to enable.
--
type GstAllocTraceFlags is
(GST_ALLOC_TRACE_NONE,
GST_ALLOC_TRACE_LIVE,
GST_ALLOC_TRACE_MEM_LIVE);
pragma Convention (C, GstAllocTraceFlags); -- gst/gsttrace.h:43
type GstAllocTrace;
--subtype GstAllocTrace is u_GstAllocTrace; -- gst/gsttrace.h:45
--*
-- * GstAllocTrace:
-- * @name: The name of the tracing object
-- * @flags: Flags for this object
-- * @live: counter for live memory
-- * @mem_live: list with pointers to unfreed memory
-- *
-- * The main tracing object
--
type GstAllocTrace is record
name : access GLIB.gchar; -- gst/gsttrace.h:57
flags : aliased GLIB.gint; -- gst/gsttrace.h:58
live : aliased GLIB.gint; -- gst/gsttrace.h:60
mem_live : access GStreamer.GST_Low_Level.glib_2_0_glib_gslist_h.GSList; -- gst/gsttrace.h:61
end record;
pragma Convention (C_Pass_By_Copy, GstAllocTrace); -- gst/gsttrace.h:56
type GstTrace;
--subtype GstTrace is u_GstTrace; -- gst/gsttrace.h:66
type GstTraceEntry;
type u_GstTraceEntry_message_array is array (0 .. 111) of aliased GLIB.gchar;
--subtype GstTraceEntry is u_GstTraceEntry; -- gst/gsttrace.h:67
--*
-- * GstTrace:
-- *
-- * Opaque #GstTrace structure.
--
--< private >
-- where this trace is going
type GstTrace is record
filename : access GLIB.gchar; -- gst/gsttrace.h:77
fd : aliased int; -- gst/gsttrace.h:78
buf : access GstTraceEntry; -- gst/gsttrace.h:81
bufsize : aliased GLIB.gint; -- gst/gsttrace.h:82
bufoffset : aliased GLIB.gint; -- gst/gsttrace.h:83
end record;
pragma Convention (C_Pass_By_Copy, GstTrace); -- gst/gsttrace.h:74
-- current buffer, size, head offset
type GstTraceEntry is record
timestamp : aliased GLIB.gint64; -- gst/gsttrace.h:87
sequence : aliased GLIB.guint32; -- gst/gsttrace.h:88
data : aliased GLIB.guint32; -- gst/gsttrace.h:89
message : aliased u_GstTraceEntry_message_array; -- gst/gsttrace.h:90
end record;
pragma Convention (C_Pass_By_Copy, GstTraceEntry); -- gst/gsttrace.h:86
function gst_trace_new (filename : access GLIB.gchar; size : GLIB.gint) return access GstTrace; -- gst/gsttrace.h:93
pragma Import (C, gst_trace_new, "gst_trace_new");
procedure gst_trace_destroy (trace : access GstTrace); -- gst/gsttrace.h:95
pragma Import (C, gst_trace_destroy, "gst_trace_destroy");
procedure gst_trace_flush (trace : access GstTrace); -- gst/gsttrace.h:96
pragma Import (C, gst_trace_flush, "gst_trace_flush");
procedure gst_trace_text_flush (trace : access GstTrace); -- gst/gsttrace.h:97
pragma Import (C, gst_trace_text_flush, "gst_trace_text_flush");
--*
-- * gst_trace_get_size:
-- * @trace: a #GstTrace
-- *
-- * Retrieve the buffer size of @trace.
--
--*
-- * gst_trace_get_offset:
-- * @trace: a #GstTrace
-- *
-- * Retrieve the current buffer offset of @trace.
--
--*
-- * gst_trace_get_remaining:
-- * @trace: a #GstTrace
-- *
-- * Retrieve the remaining size in the @trace buffer.
--
procedure gst_trace_set_default (trace : access GstTrace); -- gst/gsttrace.h:119
pragma Import (C, gst_trace_set_default, "gst_trace_set_default");
-- skipped func _gst_trace_add_entry
procedure gst_trace_read_tsc (dst : access GLIB.gint64); -- gst/gsttrace.h:124
pragma Import (C, gst_trace_read_tsc, "gst_trace_read_tsc");
function gst_alloc_trace_available return GLIB.gboolean; -- gst/gsttrace.h:129
pragma Import (C, gst_alloc_trace_available, "gst_alloc_trace_available");
function gst_alloc_trace_list return access constant GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gsttrace.h:130
pragma Import (C, gst_alloc_trace_list, "gst_alloc_trace_list");
-- skipped func _gst_alloc_trace_register
function gst_alloc_trace_live_all return int; -- gst/gsttrace.h:133
pragma Import (C, gst_alloc_trace_live_all, "gst_alloc_trace_live_all");
procedure gst_alloc_trace_print_all; -- gst/gsttrace.h:134
pragma Import (C, gst_alloc_trace_print_all, "gst_alloc_trace_print_all");
procedure gst_alloc_trace_print_live; -- gst/gsttrace.h:135
pragma Import (C, gst_alloc_trace_print_live, "gst_alloc_trace_print_live");
procedure gst_alloc_trace_set_flags_all (flags : GstAllocTraceFlags); -- gst/gsttrace.h:136
pragma Import (C, gst_alloc_trace_set_flags_all, "gst_alloc_trace_set_flags_all");
function gst_alloc_trace_get (name : access GLIB.gchar) return access GstAllocTrace; -- gst/gsttrace.h:138
pragma Import (C, gst_alloc_trace_get, "gst_alloc_trace_get");
procedure gst_alloc_trace_print (trace : access constant GstAllocTrace); -- gst/gsttrace.h:139
pragma Import (C, gst_alloc_trace_print, "gst_alloc_trace_print");
procedure gst_alloc_trace_set_flags (trace : access GstAllocTrace; flags : GstAllocTraceFlags); -- gst/gsttrace.h:140
pragma Import (C, gst_alloc_trace_set_flags, "gst_alloc_trace_set_flags");
--*
-- * gst_alloc_trace_register:
-- * @name: The name of the tracer object
-- *
-- * Register a new alloc tracer with the given name
--
--*
-- * gst_alloc_trace_new:
-- * @trace: The tracer to use
-- * @mem: The memory allocated
-- *
-- * Use the tracer to trace a new memory allocation
--
--*
-- * gst_alloc_trace_free:
-- * @trace: The tracer to use
-- * @mem: The memory that is freed
-- *
-- * Trace a memory free operation
--
--*
-- * gst_trace_add_entry:
-- * @trace: a #GstTrace
-- * @seq: a sequence number
-- * @data: the data to trace
-- * @msg: the trace message
-- *
-- * Add an entry to @trace with sequence number @seq, @data and @msg.
-- * If @trace is NULL, the entry will be added to the default #GstTrace.
--
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttrace_h;
| 15081 | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
with glib.Values;
with System;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_gslist_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_glist_h;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttrace_h is
-- arg-macro: function gst_trace_get_size (trace)
-- return (trace).bufsize;
-- arg-macro: function gst_trace_get_offset (trace)
-- return (trace).bufoffset;
-- arg-macro: function gst_trace_get_remaining (trace)
-- return (trace).bufsize - (trace).bufoffset;
-- arg-macro: procedure gst_alloc_trace_register (name)
-- _gst_alloc_trace_register (name);
-- arg-macro: procedure gst_alloc_trace_new (trace, mem)
-- G_STMT_START { if (G_UNLIKELY ((trace).flags)) { g_static_mutex_lock (and_gst_trace_mutex); if ((trace).flags and GST_ALLOC_TRACE_LIVE) (trace).live++; if ((trace).flags and GST_ALLOC_TRACE_MEM_LIVE) (trace).mem_live := g_slist_prepend ((trace).mem_live, mem); g_static_mutex_unlock (and_gst_trace_mutex); } } G_STMT_END
-- arg-macro: procedure gst_alloc_trace_free (trace, mem)
-- G_STMT_START { if (G_UNLIKELY ((trace).flags)) { g_static_mutex_lock (and_gst_trace_mutex); if ((trace).flags and GST_ALLOC_TRACE_LIVE) (trace).live--; if ((trace).flags and GST_ALLOC_TRACE_MEM_LIVE) (trace).mem_live := g_slist_remove ((trace).mem_live, mem); g_static_mutex_unlock (and_gst_trace_mutex); } } G_STMT_END
-- arg-macro: procedure gst_trace_add_entry (trace, seq, data, msg)
-- if (_gst_trace_on) { _gst_trace_add_entry(trace,(guint32)seq,(guint32)data,msg); }
-- GStreamer
-- * Copyright (C) 1999,2000 <NAME> <<EMAIL>>
-- * 2000 <NAME> <<EMAIL>>
-- *
-- * gsttrace.h: Header for tracing functions (deprecated)
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
--*
-- * GstAllocTraceFlags:
-- * @GST_ALLOC_TRACE_NONE: No tracing specified or desired. Since 0.10.36.
-- * @GST_ALLOC_TRACE_LIVE: Trace number of non-freed memory.
-- * @GST_ALLOC_TRACE_MEM_LIVE: Trace pointers of unfreed memory.
-- *
-- * Flags indicating which tracing feature to enable.
--
type GstAllocTraceFlags is
(GST_ALLOC_TRACE_NONE,
GST_ALLOC_TRACE_LIVE,
GST_ALLOC_TRACE_MEM_LIVE);
pragma Convention (C, GstAllocTraceFlags); -- gst/gsttrace.h:43
type GstAllocTrace;
--subtype GstAllocTrace is u_GstAllocTrace; -- gst/gsttrace.h:45
--*
-- * GstAllocTrace:
-- * @name: The name of the tracing object
-- * @flags: Flags for this object
-- * @live: counter for live memory
-- * @mem_live: list with pointers to unfreed memory
-- *
-- * The main tracing object
--
type GstAllocTrace is record
name : access GLIB.gchar; -- gst/gsttrace.h:57
flags : aliased GLIB.gint; -- gst/gsttrace.h:58
live : aliased GLIB.gint; -- gst/gsttrace.h:60
mem_live : access GStreamer.GST_Low_Level.glib_2_0_glib_gslist_h.GSList; -- gst/gsttrace.h:61
end record;
pragma Convention (C_Pass_By_Copy, GstAllocTrace); -- gst/gsttrace.h:56
type GstTrace;
--subtype GstTrace is u_GstTrace; -- gst/gsttrace.h:66
type GstTraceEntry;
type u_GstTraceEntry_message_array is array (0 .. 111) of aliased GLIB.gchar;
--subtype GstTraceEntry is u_GstTraceEntry; -- gst/gsttrace.h:67
--*
-- * GstTrace:
-- *
-- * Opaque #GstTrace structure.
--
--< private >
-- where this trace is going
type GstTrace is record
filename : access GLIB.gchar; -- gst/gsttrace.h:77
fd : aliased int; -- gst/gsttrace.h:78
buf : access GstTraceEntry; -- gst/gsttrace.h:81
bufsize : aliased GLIB.gint; -- gst/gsttrace.h:82
bufoffset : aliased GLIB.gint; -- gst/gsttrace.h:83
end record;
pragma Convention (C_Pass_By_Copy, GstTrace); -- gst/gsttrace.h:74
-- current buffer, size, head offset
type GstTraceEntry is record
timestamp : aliased GLIB.gint64; -- gst/gsttrace.h:87
sequence : aliased GLIB.guint32; -- gst/gsttrace.h:88
data : aliased GLIB.guint32; -- gst/gsttrace.h:89
message : aliased u_GstTraceEntry_message_array; -- gst/gsttrace.h:90
end record;
pragma Convention (C_Pass_By_Copy, GstTraceEntry); -- gst/gsttrace.h:86
function gst_trace_new (filename : access GLIB.gchar; size : GLIB.gint) return access GstTrace; -- gst/gsttrace.h:93
pragma Import (C, gst_trace_new, "gst_trace_new");
procedure gst_trace_destroy (trace : access GstTrace); -- gst/gsttrace.h:95
pragma Import (C, gst_trace_destroy, "gst_trace_destroy");
procedure gst_trace_flush (trace : access GstTrace); -- gst/gsttrace.h:96
pragma Import (C, gst_trace_flush, "gst_trace_flush");
procedure gst_trace_text_flush (trace : access GstTrace); -- gst/gsttrace.h:97
pragma Import (C, gst_trace_text_flush, "gst_trace_text_flush");
--*
-- * gst_trace_get_size:
-- * @trace: a #GstTrace
-- *
-- * Retrieve the buffer size of @trace.
--
--*
-- * gst_trace_get_offset:
-- * @trace: a #GstTrace
-- *
-- * Retrieve the current buffer offset of @trace.
--
--*
-- * gst_trace_get_remaining:
-- * @trace: a #GstTrace
-- *
-- * Retrieve the remaining size in the @trace buffer.
--
procedure gst_trace_set_default (trace : access GstTrace); -- gst/gsttrace.h:119
pragma Import (C, gst_trace_set_default, "gst_trace_set_default");
-- skipped func _gst_trace_add_entry
procedure gst_trace_read_tsc (dst : access GLIB.gint64); -- gst/gsttrace.h:124
pragma Import (C, gst_trace_read_tsc, "gst_trace_read_tsc");
function gst_alloc_trace_available return GLIB.gboolean; -- gst/gsttrace.h:129
pragma Import (C, gst_alloc_trace_available, "gst_alloc_trace_available");
function gst_alloc_trace_list return access constant GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gsttrace.h:130
pragma Import (C, gst_alloc_trace_list, "gst_alloc_trace_list");
-- skipped func _gst_alloc_trace_register
function gst_alloc_trace_live_all return int; -- gst/gsttrace.h:133
pragma Import (C, gst_alloc_trace_live_all, "gst_alloc_trace_live_all");
procedure gst_alloc_trace_print_all; -- gst/gsttrace.h:134
pragma Import (C, gst_alloc_trace_print_all, "gst_alloc_trace_print_all");
procedure gst_alloc_trace_print_live; -- gst/gsttrace.h:135
pragma Import (C, gst_alloc_trace_print_live, "gst_alloc_trace_print_live");
procedure gst_alloc_trace_set_flags_all (flags : GstAllocTraceFlags); -- gst/gsttrace.h:136
pragma Import (C, gst_alloc_trace_set_flags_all, "gst_alloc_trace_set_flags_all");
function gst_alloc_trace_get (name : access GLIB.gchar) return access GstAllocTrace; -- gst/gsttrace.h:138
pragma Import (C, gst_alloc_trace_get, "gst_alloc_trace_get");
procedure gst_alloc_trace_print (trace : access constant GstAllocTrace); -- gst/gsttrace.h:139
pragma Import (C, gst_alloc_trace_print, "gst_alloc_trace_print");
procedure gst_alloc_trace_set_flags (trace : access GstAllocTrace; flags : GstAllocTraceFlags); -- gst/gsttrace.h:140
pragma Import (C, gst_alloc_trace_set_flags, "gst_alloc_trace_set_flags");
--*
-- * gst_alloc_trace_register:
-- * @name: The name of the tracer object
-- *
-- * Register a new alloc tracer with the given name
--
--*
-- * gst_alloc_trace_new:
-- * @trace: The tracer to use
-- * @mem: The memory allocated
-- *
-- * Use the tracer to trace a new memory allocation
--
--*
-- * gst_alloc_trace_free:
-- * @trace: The tracer to use
-- * @mem: The memory that is freed
-- *
-- * Trace a memory free operation
--
--*
-- * gst_trace_add_entry:
-- * @trace: a #GstTrace
-- * @seq: a sequence number
-- * @data: the data to trace
-- * @msg: the trace message
-- *
-- * Add an entry to @trace with sequence number @seq, @data and @msg.
-- * If @trace is NULL, the entry will be added to the default #GstTrace.
--
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttrace_h;
| true | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
with glib.Values;
with System;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_gslist_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_glist_h;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttrace_h is
-- arg-macro: function gst_trace_get_size (trace)
-- return (trace).bufsize;
-- arg-macro: function gst_trace_get_offset (trace)
-- return (trace).bufoffset;
-- arg-macro: function gst_trace_get_remaining (trace)
-- return (trace).bufsize - (trace).bufoffset;
-- arg-macro: procedure gst_alloc_trace_register (name)
-- _gst_alloc_trace_register (name);
-- arg-macro: procedure gst_alloc_trace_new (trace, mem)
-- G_STMT_START { if (G_UNLIKELY ((trace).flags)) { g_static_mutex_lock (and_gst_trace_mutex); if ((trace).flags and GST_ALLOC_TRACE_LIVE) (trace).live++; if ((trace).flags and GST_ALLOC_TRACE_MEM_LIVE) (trace).mem_live := g_slist_prepend ((trace).mem_live, mem); g_static_mutex_unlock (and_gst_trace_mutex); } } G_STMT_END
-- arg-macro: procedure gst_alloc_trace_free (trace, mem)
-- G_STMT_START { if (G_UNLIKELY ((trace).flags)) { g_static_mutex_lock (and_gst_trace_mutex); if ((trace).flags and GST_ALLOC_TRACE_LIVE) (trace).live--; if ((trace).flags and GST_ALLOC_TRACE_MEM_LIVE) (trace).mem_live := g_slist_remove ((trace).mem_live, mem); g_static_mutex_unlock (and_gst_trace_mutex); } } G_STMT_END
-- arg-macro: procedure gst_trace_add_entry (trace, seq, data, msg)
-- if (_gst_trace_on) { _gst_trace_add_entry(trace,(guint32)seq,(guint32)data,msg); }
-- GStreamer
-- * Copyright (C) 1999,2000 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
-- * 2000 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
-- *
-- * gsttrace.h: Header for tracing functions (deprecated)
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
--*
-- * GstAllocTraceFlags:
-- * @GST_ALLOC_TRACE_NONE: No tracing specified or desired. Since 0.10.36.
-- * @GST_ALLOC_TRACE_LIVE: Trace number of non-freed memory.
-- * @GST_ALLOC_TRACE_MEM_LIVE: Trace pointers of unfreed memory.
-- *
-- * Flags indicating which tracing feature to enable.
--
type GstAllocTraceFlags is
(GST_ALLOC_TRACE_NONE,
GST_ALLOC_TRACE_LIVE,
GST_ALLOC_TRACE_MEM_LIVE);
pragma Convention (C, GstAllocTraceFlags); -- gst/gsttrace.h:43
type GstAllocTrace;
--subtype GstAllocTrace is u_GstAllocTrace; -- gst/gsttrace.h:45
--*
-- * GstAllocTrace:
-- * @name: The name of the tracing object
-- * @flags: Flags for this object
-- * @live: counter for live memory
-- * @mem_live: list with pointers to unfreed memory
-- *
-- * The main tracing object
--
type GstAllocTrace is record
name : access GLIB.gchar; -- gst/gsttrace.h:57
flags : aliased GLIB.gint; -- gst/gsttrace.h:58
live : aliased GLIB.gint; -- gst/gsttrace.h:60
mem_live : access GStreamer.GST_Low_Level.glib_2_0_glib_gslist_h.GSList; -- gst/gsttrace.h:61
end record;
pragma Convention (C_Pass_By_Copy, GstAllocTrace); -- gst/gsttrace.h:56
type GstTrace;
--subtype GstTrace is u_GstTrace; -- gst/gsttrace.h:66
type GstTraceEntry;
type u_GstTraceEntry_message_array is array (0 .. 111) of aliased GLIB.gchar;
--subtype GstTraceEntry is u_GstTraceEntry; -- gst/gsttrace.h:67
--*
-- * GstTrace:
-- *
-- * Opaque #GstTrace structure.
--
--< private >
-- where this trace is going
type GstTrace is record
filename : access GLIB.gchar; -- gst/gsttrace.h:77
fd : aliased int; -- gst/gsttrace.h:78
buf : access GstTraceEntry; -- gst/gsttrace.h:81
bufsize : aliased GLIB.gint; -- gst/gsttrace.h:82
bufoffset : aliased GLIB.gint; -- gst/gsttrace.h:83
end record;
pragma Convention (C_Pass_By_Copy, GstTrace); -- gst/gsttrace.h:74
-- current buffer, size, head offset
type GstTraceEntry is record
timestamp : aliased GLIB.gint64; -- gst/gsttrace.h:87
sequence : aliased GLIB.guint32; -- gst/gsttrace.h:88
data : aliased GLIB.guint32; -- gst/gsttrace.h:89
message : aliased u_GstTraceEntry_message_array; -- gst/gsttrace.h:90
end record;
pragma Convention (C_Pass_By_Copy, GstTraceEntry); -- gst/gsttrace.h:86
function gst_trace_new (filename : access GLIB.gchar; size : GLIB.gint) return access GstTrace; -- gst/gsttrace.h:93
pragma Import (C, gst_trace_new, "gst_trace_new");
procedure gst_trace_destroy (trace : access GstTrace); -- gst/gsttrace.h:95
pragma Import (C, gst_trace_destroy, "gst_trace_destroy");
procedure gst_trace_flush (trace : access GstTrace); -- gst/gsttrace.h:96
pragma Import (C, gst_trace_flush, "gst_trace_flush");
procedure gst_trace_text_flush (trace : access GstTrace); -- gst/gsttrace.h:97
pragma Import (C, gst_trace_text_flush, "gst_trace_text_flush");
--*
-- * gst_trace_get_size:
-- * @trace: a #GstTrace
-- *
-- * Retrieve the buffer size of @trace.
--
--*
-- * gst_trace_get_offset:
-- * @trace: a #GstTrace
-- *
-- * Retrieve the current buffer offset of @trace.
--
--*
-- * gst_trace_get_remaining:
-- * @trace: a #GstTrace
-- *
-- * Retrieve the remaining size in the @trace buffer.
--
procedure gst_trace_set_default (trace : access GstTrace); -- gst/gsttrace.h:119
pragma Import (C, gst_trace_set_default, "gst_trace_set_default");
-- skipped func _gst_trace_add_entry
procedure gst_trace_read_tsc (dst : access GLIB.gint64); -- gst/gsttrace.h:124
pragma Import (C, gst_trace_read_tsc, "gst_trace_read_tsc");
function gst_alloc_trace_available return GLIB.gboolean; -- gst/gsttrace.h:129
pragma Import (C, gst_alloc_trace_available, "gst_alloc_trace_available");
function gst_alloc_trace_list return access constant GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gsttrace.h:130
pragma Import (C, gst_alloc_trace_list, "gst_alloc_trace_list");
-- skipped func _gst_alloc_trace_register
function gst_alloc_trace_live_all return int; -- gst/gsttrace.h:133
pragma Import (C, gst_alloc_trace_live_all, "gst_alloc_trace_live_all");
procedure gst_alloc_trace_print_all; -- gst/gsttrace.h:134
pragma Import (C, gst_alloc_trace_print_all, "gst_alloc_trace_print_all");
procedure gst_alloc_trace_print_live; -- gst/gsttrace.h:135
pragma Import (C, gst_alloc_trace_print_live, "gst_alloc_trace_print_live");
procedure gst_alloc_trace_set_flags_all (flags : GstAllocTraceFlags); -- gst/gsttrace.h:136
pragma Import (C, gst_alloc_trace_set_flags_all, "gst_alloc_trace_set_flags_all");
function gst_alloc_trace_get (name : access GLIB.gchar) return access GstAllocTrace; -- gst/gsttrace.h:138
pragma Import (C, gst_alloc_trace_get, "gst_alloc_trace_get");
procedure gst_alloc_trace_print (trace : access constant GstAllocTrace); -- gst/gsttrace.h:139
pragma Import (C, gst_alloc_trace_print, "gst_alloc_trace_print");
procedure gst_alloc_trace_set_flags (trace : access GstAllocTrace; flags : GstAllocTraceFlags); -- gst/gsttrace.h:140
pragma Import (C, gst_alloc_trace_set_flags, "gst_alloc_trace_set_flags");
--*
-- * gst_alloc_trace_register:
-- * @name: The name of the tracer object
-- *
-- * Register a new alloc tracer with the given name
--
--*
-- * gst_alloc_trace_new:
-- * @trace: The tracer to use
-- * @mem: The memory allocated
-- *
-- * Use the tracer to trace a new memory allocation
--
--*
-- * gst_alloc_trace_free:
-- * @trace: The tracer to use
-- * @mem: The memory that is freed
-- *
-- * Trace a memory free operation
--
--*
-- * gst_trace_add_entry:
-- * @trace: a #GstTrace
-- * @seq: a sequence number
-- * @data: the data to trace
-- * @msg: the trace message
-- *
-- * Add an entry to @trace with sequence number @seq, @data and @msg.
-- * If @trace is NULL, the entry will be added to the default #GstTrace.
--
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttrace_h;
|
[
{
"context": "-- package GNAT.Sockets.Server Copyright (c) Dmitry A. Kazakov --\r\n-- Implementation ",
"end": 142,
"score": 0.9998340606689453,
"start": 125,
"tag": "NAME",
"value": "Dmitry A. Kazakov"
}
] | gnat-sockets-server.adb | jrcarter/Ada_GUI | 19 | -- --
-- package GNAT.Sockets.Server Copyright (c) Dmitry A. Kazakov --
-- Implementation Luebeck --
-- Winter, 2012 --
-- --
-- Last revision : 14:53 29 Feb 2020 --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public License as --
-- published by the Free Software Foundation; either version 2 of --
-- the License, or (at your option) any later version. This library --
-- is distributed in the hope that it will be useful, but WITHOUT --
-- ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have --
-- received a copy of the GNU General Public License along with --
-- this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
--____________________________________________________________________--
with Ada.Calendar; use Ada.Calendar;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.IO_Exceptions; use Ada.IO_Exceptions;
with Strings_Edit; use Strings_Edit;
with Strings_Edit.Integers; use Strings_Edit.Integers;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
package body GNAT.Sockets.Server is
Receive_Masks : constant array (IO_Tracing_Mode) of Factory_Flags :=
( Trace_None => 0,
Trace_Encoded => Trace_Encoded_Received,
Trace_Decoded => Trace_Decoded_Received,
Trace_Any => Trace_Encoded_Received
or Trace_Decoded_Received
);
Sent_Masks : constant array (IO_Tracing_Mode) of Factory_Flags :=
( Trace_None => 0,
Trace_Encoded => Trace_Encoded_Sent,
Trace_Decoded => Trace_Decoded_Sent,
Trace_Any => Trace_Encoded_Sent
or Trace_Decoded_Sent
);
procedure Free is
new Ada.Unchecked_Deallocation (Encoder'Class, Encoder_Ptr);
procedure Activated (Client : in out Connection) is
begin
null;
end Activated;
procedure Append
( List : in out Connection_Ptr;
Item : Connection_Ptr;
Count : in out Integer
) is
begin
if Item.Successor = null then
if List = null then
List := Item;
Item.Successor := Item;
Item.Predecessor := Item;
else
Item.Successor := List;
Item.Predecessor := List.Predecessor;
List.Predecessor := Item;
Item.Predecessor.Successor := Item;
end if;
Count := Count + 1;
end if;
end Append;
function Available_To_Process (Client : Connection)
return Stream_Element_Count is
begin
return Used (Client.Read);
end Available_To_Process;
function Available_To_Send (Client : Connection)
return Stream_Element_Count is
begin
return Free (Client.Written);
end Available_To_Send;
procedure Clear (Client : in out Connection'Class) is
begin
Client.Failed := False; -- Clean I/O state
Client.External_Action := False;
Client.Data_Sent := False;
Client.Dont_Block := False;
Client.Read.Expected := 0;
Client.Read.First_Read := 0;
Client.Read.Free_To_Read := 0;
Client.Written.First_Written := 0;
Client.Written.Free_To_Write := 0;
Client.Written.Send_Blocked := False;
Free (Client.Transport);
end Clear;
procedure Close (Socket : in out Socket_Type) is
begin
if Socket /= No_Socket then
begin
Shutdown_Socket (Socket);
exception
when others =>
null;
end;
begin
Close_Socket (Socket);
exception
when others =>
null;
end;
Socket := No_Socket;
end if;
end Close;
procedure Connect
( Listener : in out Connections_Server;
Client : Connection_Ptr;
Host : String;
Port : Port_Type;
Max_Connect_No : Positive := Positive'Last;
Overlapped : Stream_Element_Count :=
Stream_Element_Count'Last
) is
Address : Sock_Addr_Type renames Client.Client_Address;
Option : Request_Type := (Non_Blocking_IO, True);
begin
if Client.Socket /= No_Socket then
Raise_Exception
( Use_Error'Identity,
"Connection " & Image (Address) & " is already in use"
);
end if;
Address.Addr := To_Addr (Host);
Address.Port := Port;
Create_Socket (Client.Socket);
Set_Socket_Option
( Client.Socket,
Socket_Level,
(Reuse_Address, True)
);
Control_Socket (Client.Socket, Option);
Connect_Parameters_Set
( Client.all,
Host,
Address,
Max_Connect_No
);
Client.Session := Session_Disconnected;
Client.Client := True;
Client.Connect_No := 0;
Client.Max_Connect_No := Max_Connect_No;
Client.Socket_Listener := Listener'Unchecked_Access;
Client.Overlapped_Read := Stream_Element_Count'Min
( Overlapped,
Client.Output_Size
);
Increment_Count (Client.all);
Listener.Request.Connect (Client);
end Connect;
procedure Connect_Error
( Client : in out Connection;
Error : Error_Type
) is
begin
null;
end Connect_Error;
procedure Connect_Parameters_Set
( Client : in out Connection;
Host : String;
Address : Sock_Addr_Type;
Max_Connect_No : Positive
) is
begin
null;
end Connect_Parameters_Set;
procedure Connected (Client : in out Connection) is
begin
null;
end Connected;
procedure Connected
( Listener : in out Connections_Server;
Client : in out Connection'Class
) is
begin
Client.Session := Session_Active;
end Connected;
function Create
( Factory : access Connections_Factory;
Listener : access Connections_Server'Class;
From : Sock_Addr_Type
) return Connection_Ptr is
begin
return null;
end Create;
procedure Create_Socket
( Listener : in out Connections_Server;
Socket : in out Socket_Type;
Address : Sock_Addr_Type
) is
begin
Create_Socket (Socket);
Set_Socket_Option (Socket, Socket_Level, (Reuse_Address, True));
Bind_Socket (Socket, Address);
Listen_Socket (Socket);
end Create_Socket;
function Create_Transport
( Factory : access Connections_Factory;
Listener : access Connections_Server'Class;
Client : access Connection'Class
) return Encoder_Ptr is
begin
return null;
end Create_Transport;
procedure Create_Transport (Client : in out Connection) is
begin
if Client.Transport /= null then
Raise_Exception
( Status_Error'Identity,
"Connection already has a transport layer"
);
end if;
Client.Transport :=
Create_Transport
( Client.Socket_Listener.Factory,
Client.Socket_Listener,
Client'Unchecked_Access
);
if Client.Transport = null then
Raise_Exception
( Status_Error'Identity,
"Connection transport layer is not supported"
);
end if;
Client.Session := Session_Handshaking;
if Client.Client then
Append
( Client.Socket_Listener.Postponed,
Client'Unchecked_Access,
Client.Socket_Listener.Postponed_Count
);
end if;
end Create_Transport;
procedure Data_Sent
( Listener : in out Connections_Server;
Client : Connection_Ptr
) is
begin
Client.Data_Sent := False;
Sent (Client.all);
end Data_Sent;
procedure Disconnected (Client : in out Connection) is
begin
null;
end Disconnected;
procedure Disconnected
( Listener : in out Connections_Server;
Client : in out Connection'Class
) is
begin
Client.Session := Session_Disconnected;
Remove (Listener.Postponed, Client, Listener.Postponed_Count);
end Disconnected;
procedure Downed
( Listener : in out Connections_Server;
Client : in out Connection'Class
) is
begin
Client.Session := Session_Down;
end Downed;
procedure Downed (Client : in out Connection) is
begin
null;
end Downed;
procedure Do_Connect
( Listener : in out Connections_Server'Class;
Client : in out Connection_Ptr
) is
Status : Selector_Status;
begin
Client.Connect_No := Client.Connect_No + 1;
Client.Session := Session_Connecting;
if Client.Connect_No > Client.Max_Connect_No then
Client.Try_To_Reconnect := False; -- Ensure connection killed
Save_Occurrence (Client.Last_Error, Null_Occurrence);
Stop (Listener, Client);
else
Clear (Client.all);
Connect_Socket
( Socket => Client.Socket,
Server => Client.Client_Address,
Timeout => 0.0,
Selector => Listener.Selector'Unchecked_Access,
Status => Status
);
if Status = Completed then
Set (Listener.Read_Sockets, Client.Socket);
On_Connected (Listener, Client.all);
end if;
end if;
exception
when Connection_Error =>
Client.Try_To_Reconnect := False; -- Ensure connection killed
Save_Occurrence (Client.Last_Error, Null_Occurrence);
Stop (Listener, Client);
when Error : Socket_Error =>
if Resolve_Exception (Error) = Operation_Now_In_Progress then
Trace_Sending
( Listener.Factory.all,
Client.all,
False,
", connecting to ..."
);
else
Trace_Error
( Listener.Factory.all,
"Connect socket",
Error
);
Client.Try_To_Reconnect := False; -- Ensure object killed
Save_Occurrence (Client.Last_Error, Error);
Stop (Listener, Client);
end if;
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Connect socket",
Error
);
Client.Try_To_Reconnect := False; -- Ensure connection killed
Save_Occurrence (Client.Last_Error, Error);
Stop (Listener, Client);
end Do_Connect;
procedure Elevated (Client : in out Connection) is
begin
null;
end Elevated;
procedure Fill_From_Stream
( Buffer : in out Output_Buffer;
Stream : in out Root_Stream_Type'Class;
Count : Stream_Element_Count;
Reserve : Stream_Element_Count;
Last : out Stream_Element_Offset;
Next : out Stream_Element_Offset;
Done : out Boolean
) is
begin
if Reserve >= Buffer.Written'Length then
Raise_Exception
( Data_Error'Identity,
( "Output buffer is too small for prefix and suffix ("
& Image (Reserve)
& ")"
) );
end if;
if Buffer.First_Written <= Buffer.Free_To_Write then
--
-- [ XXXXXXXXXXXXXXX ]
-- | |
-- First_Written Free_To_Write
--
declare
Tail : constant Stream_Element_Offset :=
Reserve + Buffer.Written'First - Buffer.First_Written;
begin
if Tail > 0 then
if Buffer.Free_To_Write + Tail = Buffer.Written'Last then
Done := False;
else
Next := Buffer.Written'Last - Tail;
if Count < Next - Buffer.Free_To_Write then
Next := Buffer.Free_To_Write + Count - 1;
end if;
Read
( Stream,
Buffer.Written (Buffer.Free_To_Write..Next),
Last
);
Done := Last < Next;
Next := Last + 1;
end if;
else
Next := Buffer.Written'Last;
if Count < Next - Buffer.Free_To_Write then
Next := Buffer.Free_To_Write + Count - 1;
end if;
Read
( Stream,
Buffer.Written (Buffer.Free_To_Write..Next),
Last
);
Done := Last < Next;
if Last < Buffer.Written'Last then
Next := Last + 1;
else
Next := Buffer.Written'First;
end if;
end if;
end;
else
--
-- [XXXXX XXXXXXX]
-- | |
-- Free_To_Write First_Written
--
if Buffer.Free_To_Write + Reserve >= Buffer.First_Written then
Done := False;
else
Next := Buffer.First_Written - Reserve;
if Count < Next - Buffer.Free_To_Write then
Next := Buffer.Free_To_Write + Count - 1;
end if;
Read
( Stream,
Buffer.Written (Buffer.Free_To_Write..Next),
Last
);
Done := Last < Next;
Next := Last + 1;
end if;
end if;
end Fill_From_Stream;
procedure Finalize (Listener : in out Connections_Server) is
procedure Free is
new Ada.Unchecked_Deallocation (Worker, Worker_Ptr);
begin
if Listener.Doer /= null then
Listener.Finalizing := True;
Abort_Selector (Listener.Selector);
while not Listener.Doer'Terminated loop
delay 0.001;
end loop;
Free (Listener.Doer);
end if;
Close_Selector (Listener.Selector);
end Finalize;
procedure Finalize (Client : in out Connection) is
begin
Close (Client.Socket);
Free (Client.Transport);
Object.Finalize (Object.Entity (Client));
end Finalize;
function Free (Buffer : Output_Buffer) return Stream_Element_Count is
begin
return Buffer.Written'Length - Used (Buffer) - 1;
end Free;
function From_String (Data : String) return Stream_Element_Array is
Result : Stream_Element_Array (1..Data'Length);
Pointer : Stream_Element_Offset := Result'First;
begin
for Index in Data'Range loop
Result (Pointer) := Character'Pos (Data (Index));
Pointer := Pointer + 1;
end loop;
return Result;
end From_String;
function Get_Client_Address (Client : Connection)
return Sock_Addr_Type is
begin
return Client.Client_Address;
end Get_Client_Address;
function Get_Clients_Count (Listener : Connections_Server)
return Natural is
begin
return Listener.Clients;
end Get_Clients_Count;
function Get_Client_Name
( Factory : Connections_Factory;
Client : Connection'Class
) return String is
begin
return Image (Client.Client_Address);
end Get_Client_Name;
function Get_Connections_Server (Client : Connection)
return Connections_Server_Ptr is
begin
return Client.Socket_Listener;
end Get_Connections_Server;
function Get_IO_Timeout (Factory : Connections_Factory)
return Duration is
begin
return 0.02;
end Get_IO_Timeout;
procedure Get_Occurrence
( Client : Connection;
Source : out Exception_Occurrence
) is
begin
Save_Occurrence (Source, Client.Last_Error);
end Get_Occurrence;
function Get_Overlapped_Size (Client : Connection)
return Stream_Element_Count is
begin
return Client.Overlapped_Read;
end Get_Overlapped_Size;
function Get_Polling_Timeout (Factory : Connections_Factory)
return Duration is
begin
return 0.5;
end Get_Polling_Timeout;
function Get_Server_Address
( Listener : Connections_Server
) return Sock_Addr_Type is
Address : Sock_Addr_Type;
begin
Address.Addr := Any_Inet_Addr;
Address.Port := Listener.Port;
return Address;
end Get_Server_Address;
function Get_Session_State (Client : Connection)
return Session_State is
Result : constant Session_State := Client.Session;
begin
if Result = Session_Down then
if Client.Socket = No_Socket then
return Session_Down;
else
return Session_Disconnected; -- Almost here
end if;
else
return Result;
end if;
end Get_Session_State;
function Get_Socket (Client : Connection) return Socket_Type is
begin
return Client.Socket;
end Get_Socket;
function Has_Data (Buffer : Input_Buffer) return Boolean is
begin
return
( Buffer.Free_To_Read /= Buffer.First_Read
and then
( Buffer.Expected = 0
or else
Used (Buffer) >= Buffer.Size - 1
) );
end Has_Data;
function Has_Data (Client : Connection) return Boolean is
begin
return Has_Data (Client.Read);
end Has_Data;
function Image (Code : Error_Type) return String is
Result : String := Error_Type'Image (Code);
begin
for Index in Result'First + 1..Result'Last loop
if Result (Index) = '_' then
Result (Index) := ' ';
else
Result (Index) := To_Lower (Result (Index));
end if;
end loop;
return Result;
end Image;
function Image
( Data : Stream_Element_Array;
Hexadecimal : Boolean := False
) return String is
begin
if Hexadecimal then
declare
Result : String (1..Data'Length * 3);
Pointer : Integer := 1;
begin
for Index in Data'Range loop
Put
( Destination => Result,
Pointer => Pointer,
Value => Integer (Data (Index)),
Base => 16,
Field => 2,
Fill => '0',
Justify => Right
);
Put
( Destination => Result,
Pointer => Pointer,
Value => " "
);
end loop;
return Result;
end;
else
declare
Length : Natural := 0;
begin
for Index in Data'Range loop
case Data (Index) is
when 32..36 | 38..126 =>
Length := Length + 1;
when others =>
Length := Length + 3;
end case;
end loop;
declare
Result : String (1..Length);
Pointer : Integer := 1;
begin
for Index in Data'Range loop
case Data (Index) is
when 32..36 | 38..126 =>
Put
( Destination => Result,
Pointer => Pointer,
Value => Character'Val (Data (Index))
);
when others =>
Put
( Destination => Result,
Pointer => Pointer,
Value => '%'
);
Put
( Destination => Result,
Pointer => Pointer,
Value => Integer (Data (Index)),
Base => 16,
Field => 2,
Fill => '0',
Justify => Right
);
end case;
end loop;
return Result;
end;
end;
end if;
end Image;
procedure Initialize (Listener : in out Connections_Server) is
begin
Listener.IO_Timeout := Get_IO_Timeout (Listener.Factory.all);
Listener.Polling_Timeout :=
Get_Polling_Timeout (Listener.Factory.all);
Create_Selector (Listener.Selector);
Listener.Doer := new Worker (Listener'Unchecked_Access);
end Initialize;
function Is_Connected (Client : Connection) return Boolean is
begin
return Client.Session in Session_Active..Session_Busy;
end Is_Connected;
function Is_Down (Client : Connection) return Boolean is
begin
return
( Client.Session = Session_Down
and then
Client.Socket = No_Socket
);
end Is_Down;
function Is_Elevated (Client : Connection) return Boolean is
begin
return Client.Transport /= null;
end Is_Elevated;
function Is_Incoming (Client : Connection) return Boolean is
begin
return not Client.Client;
end Is_Incoming;
function Is_Opportunistic (Client : Connection) return Boolean is
begin
return False;
end Is_Opportunistic;
function Is_TLS_Capable
( Factory : Connections_Factory
) return Boolean is
begin
return False;
end Is_TLS_Capable;
function Is_Trace_Received_On
( Factory : Connections_Factory;
Encoded : IO_Tracing_Mode
) return Boolean is
begin
return 0 /= (Factory.Trace_Flags and Receive_Masks (Encoded));
end Is_Trace_Received_On;
function Is_Trace_Sent_On
( Factory : Connections_Factory;
Encoded : IO_Tracing_Mode
) return Boolean is
begin
return 0 /= (Factory.Trace_Flags and Sent_Masks (Encoded));
end Is_Trace_Sent_On;
function Is_Unblock_Send_Queued
( Listener : Connections_Server
) return Boolean is
begin
return Listener.Unblock_Send;
end Is_Unblock_Send_Queued;
procedure Keep_On_Sending (Client : in out Connection) is
begin
Client.Dont_Block := True;
end Keep_On_Sending;
procedure On_Connected
( Listener : in out Connections_Server'Class;
Client : in out Connection'Class
) is
begin
Trace_Sending
( Listener.Factory.all,
Client,
False,
", connected"
);
Free (Client.Transport);
if not Is_Opportunistic (Client) then
Client.Transport :=
Create_Transport
( Listener.Factory,
Listener'Unchecked_Access,
Client'Unchecked_Access
);
end if;
Set (Listener.Read_Sockets, Client.Socket);
if Client.Transport = null then -- No handshaking
declare
Saved : constant Session_State := Client.Session;
begin
Client.Session := Session_Connected;
Connected (Client);
Connected (Listener, Client);
Client.Session := Session_Active;
Activated (Client);
exception
when others =>
if Client.Session in Session_Connected
.. Session_Active
then
Client.Session := Saved;
end if;
raise;
end;
else
Client.Session := Session_Handshaking;
Append
( Listener.Postponed,
Client'Unchecked_Access,
Listener.Postponed_Count
);
end if;
end On_Connected;
procedure On_Worker_Start (Listener : in out Connections_Server) is
begin
null;
end On_Worker_Start;
procedure Process
( Buffer : in out Input_Buffer;
Receiver : in out Connection'Class;
Data_Left : out Boolean
) is
Last : Stream_Element_Offset;
Pointer : Stream_Element_Offset;
begin
while Has_Data (Buffer) loop
if Buffer.Free_To_Read < Buffer.First_Read then
--
-- [XXXXXXXXXXXXXX XXXXX]
-- Free_To_Read | First_Read |
--
if Buffer.First_Read > Buffer.Read'Last then
--
-- [XXXXXXXXXXXXXX ]
-- Free_To_Read | First_Read |
--
Buffer.First_Read := Buffer.Read'First; -- Wrap
Last := Buffer.Free_To_Read - 1;
else
Last := Buffer.Read'Last;
end if;
else
--
-- [ XXXXXXXXX ]
-- First_Read | | Free_To_Read
--
Last := Buffer.Free_To_Read - 1;
end if;
Pointer := Last + 1;
Received
( Receiver,
Buffer.Read (Buffer.First_Read..Last),
Pointer
);
if Pointer < Buffer.First_Read or else Pointer > Last + 1 then
Raise_Exception
( Layout_Error'Identity,
( "Subscript error, pointer "
& Image (Pointer)
& " out of range "
& Image (Buffer.First_Read)
& ".."
& Image (Last)
& "+"
) );
elsif Pointer > Buffer.Read'Last then
if Buffer.Free_To_Read <= Buffer.Read'Last then
Buffer.First_Read := Buffer.Read'First; -- Wrap
else
Buffer.First_Read := Pointer; -- Not yet
end if;
else
Buffer.First_Read := Pointer;
end if;
if Pointer <= Last then -- Some input left unprocessed
Data_Left := True;
return;
end if;
end loop;
Data_Left := False;
end Process;
procedure Process
( Listener : in out Connections_Server;
Client : Connection_Ptr;
Data_Left : out Boolean
) is
begin
if Client.Transport = null then
Process (Client.Read, Client.all, Data_Left);
else
Process
( Client.Transport.all,
Listener,
Client.all,
Data_Left
);
end if;
end Process;
procedure Process_Packet (Client : in out Connection) is
begin
null;
end Process_Packet;
procedure Pull
( Buffer : in out Input_Buffer;
Data : in out Stream_Element_Array;
Pointer : in out Stream_Element_Offset
) is
Last : Stream_Element_Offset;
Offset : Stream_Element_Offset;
begin
while Pointer <= Data'Last and then Has_Data (Buffer) loop
if Buffer.Free_To_Read < Buffer.First_Read then
--
-- [XXXXXXXXXXXXXX XXXXX]
-- Free_To_Read | First_Read |
--
if Buffer.First_Read > Buffer.Read'Last then
--
-- [XXXXXXXXXXXXXX ]
-- Free_To_Read | First_Read |
--
Buffer.First_Read := Buffer.Read'First; -- Wrap
Last := Buffer.Free_To_Read - 1;
else
Last := Buffer.Read'Last;
end if;
else
--
-- [ XXXXXXXXX ]
-- First_Read | | Free_To_Read
--
Last := Buffer.Free_To_Read - 1;
end if;
Offset := Last - Buffer.First_Read;
if Offset > Data'Last - Pointer then
Offset := Data'Last - Pointer;
Last := Buffer.First_Read + Offset;
end if;
Data (Pointer..Pointer + Offset) :=
Buffer.Read (Buffer.First_Read..Last);
Pointer := Pointer + Offset + 1;
if Last >= Buffer.Read'Last then
if Buffer.Free_To_Read <= Buffer.Read'Last then
Buffer.First_Read := Buffer.Read'First; -- Wrap
else
Buffer.First_Read := Last + 1; -- Not yet
end if;
else
Buffer.First_Read := Last + 1;
end if;
end loop;
end Pull;
procedure Push
( Client : in out Connection;
Data : Stream_Element_Array;
Last : out Stream_Element_Offset
) is
begin
if Client.Transport = null then
Send_Socket (Client.Socket_Listener.all, Client, Data, Last);
else
Encode (Client.Transport.all, Client, Data, Last);
end if;
if Last + 1 /= Data'First then
Client.Data_Sent := True;
if ( 0
/= ( Client.Socket_Listener.Factory.Trace_Flags
and
Trace_Decoded_Sent
) )
then
Trace_Sent
( Factory => Client.Socket_Listener.Factory.all,
Client => Client,
Data => Data,
From => Data'First,
To => Last,
Encoded => False
);
end if;
end if;
end Push;
procedure Queue
( Client : in out Connection;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset
) is
Buffer : Output_Buffer renames Client.Written;
Free : Stream_Element_Offset;
Count : Stream_Element_Offset := Data'Last - Pointer + 1;
begin
if Buffer.First_Written = Buffer.Free_To_Write then
--
-- Moving First_Written as far back as possible to diminish
-- buffer fragmenting. We cannot move it further than the
-- number of elements we put there, because of race condition,
-- when Free_To_Write is not yet set. But when Free_To_Write
-- points into the elements written everything is OK
--
-- [ ............ ]
-- |<--Count-->|
-- | Free_To_Write = First_Written
-- new First_Written
--
Count :=
Stream_Element_Offset'Min
( Buffer.Written'Length - 1,
Count
);
Free := Stream_Element_Offset'Max
( Buffer.Written'First,
Buffer.Free_To_Write - Count
);
Buffer.Written (Free..Free + Count - 1) :=
Data (Pointer..Pointer + Count - 1);
Pointer := Pointer + Count;
Buffer.First_Written := Free;
Buffer.Free_To_Write := Free + Count;
return;
elsif Buffer.First_Written < Buffer.Free_To_Write then
--
-- [ XXXXXXXXXXXXXXX ]
-- | |
-- First_Written Free_To_Write
--
Free :=
( Buffer.Written'Length
- Buffer.Free_To_Write
+ Buffer.First_Written
- 1 -- Last element is never written
);
if Free <= 0 then
return;
end if;
declare
Tail : constant Stream_Element_Offset :=
Stream_Element_Offset'Min
( Buffer.Written'Last - Buffer.Free_To_Write + 1,
Free
);
begin
if Count <= Tail then -- Can queue all Count elements
Buffer.Written
( Buffer.Free_To_Write
.. Buffer.Free_To_Write + Count - 1
) := Data (Pointer..Data'Last);
Pointer := Data'Last + 1;
Free := Buffer.Free_To_Write + Count;
if Free > Buffer.Written'Last then
Buffer.Free_To_Write := Buffer.Written'First;
else
Buffer.Free_To_Write := Free;
end if;
return;
end if; -- Can queue only Tail elements
Buffer.Written
( Buffer.Free_To_Write
.. Buffer.Free_To_Write + Tail - 1
) := Data (Pointer..Pointer + Tail - 1);
Pointer := Pointer + Tail;
Count := Count - Tail;
Free := Free - Tail;
if Buffer.Free_To_Write + Tail > Buffer.Written'Last then
Buffer.Free_To_Write := Buffer.Written'First;
else
Buffer.Free_To_Write := Buffer.Free_To_Write + Tail;
end if;
end;
else
--
-- [XXXXX XXXXXXXX]
-- | |
-- Free_To_Write First_Written
--
Free :=
( Buffer.First_Written
+ Buffer.Free_To_Write
- 1 -- Last element is never written
);
end if;
if Free <= 0 then
return;
end if;
Count := Stream_Element_Offset'Min (Count, Free);
Buffer.Written
( Buffer.Free_To_Write
.. Buffer.Free_To_Write + Count - 1
) := Data (Pointer..Pointer + Count - 1);
Pointer := Pointer + Count;
Buffer.Free_To_Write := Buffer.Free_To_Write + Count;
end Queue;
function Queued_To_Send (Client : Connection)
return Stream_Element_Count is
begin
return Used (Client.Written);
end Queued_To_Send;
procedure Read
( Client : in out Connection;
Factory : in out Connections_Factory'Class
) is
Buffer : Input_Buffer renames Client.Read;
Last : Stream_Element_Offset;
begin
if Client.Overlapped_Read < Queued_To_Send (Client) then
return; -- Not ready to read yet
elsif Buffer.Free_To_Read < Buffer.First_Read then
--
-- [XXXXXXXXXXXXXX XXXXX]
-- Free_To_Read | First_Read |
--
Last := Buffer.First_Read - 2;
if Last <= Buffer.First_Read then -- Read buffer is full
return;
end if;
else
--
-- [ XXXXXXXXX ]
-- First_Read | | Free_To_Read
--
if ( Buffer.Free_To_Read - Buffer.First_Read
>= Buffer.Read'Length
)
then -- Read buffer is full
return;
elsif Buffer.Free_To_Read > Buffer.Read'Last then -- Wrap
Buffer.Free_To_Read := Buffer.Read'First;
Last := Buffer.First_Read - 2;
else
Last := Buffer.Read'Last;
end if;
end if;
Receive_Socket
( Client.Socket_Listener.all,
Client,
Buffer.Read (Buffer.Free_To_Read..Last),
Last
);
Received
( Factory,
Client,
Buffer.Read,
Buffer.Free_To_Read,
Last
);
if Last = Buffer.Free_To_Read - 1 then -- Nothing read
raise Connection_Error;
end if;
Buffer.Expected :=
Stream_Element_Offset'Max
( Buffer.Expected - (Last - Buffer.Free_To_Read + 1),
0
);
Buffer.Free_To_Read := Last + 1;
exception
when Error : Socket_Error | Layout_Error =>
Receive_Error (Client, Error);
raise Connection_Error;
end Read;
procedure Receive_Socket
( Listener : in out Connections_Server;
Client : in out Connection'Class;
Data : in out Stream_Element_Array;
Last : out Stream_Element_Offset
) is
begin
Receive_Socket (Client.Socket, Data, Last);
end Receive_Socket;
procedure Received
( Factory : in out Connections_Factory;
Client : in out Connection'Class;
Data : Stream_Element_Array;
From : Stream_Element_Offset;
To : Stream_Element_Offset
) is
begin
if Client.Transport = null then
if 0 /= (Factory.Trace_Flags and Trace_Decoded_Received) then
Trace_Received
( Factory => Connections_Factory'Class (Factory),
Client => Client,
Data => Data,
From => From,
To => To,
Encoded => False
);
end if;
else
if 0 /= (Factory.Trace_Flags and Trace_Encoded_Received) then
Trace_Received
( Factory => Connections_Factory'Class (Factory),
Client => Client,
Data => Data,
From => From,
To => To,
Encoded => True
);
end if;
end if;
end Received;
procedure Reconnect (Client : in out Connection) is
begin
if Client.Socket = No_Socket then
Raise_Exception
( Use_Error'Identity,
"No connection"
);
elsif not Client.Client then
Raise_Exception
( Mode_Error'Identity,
"Server connection"
);
elsif Client.Session /= Session_Down then
if Client.Socket_Listener /= null then
Request_Disconnect
( Client.Socket_Listener.all,
Client,
True
);
return;
end if;
Client.Session := Session_Down;
end if;
Raise_Exception
( Status_Error'Identity,
"Downed connection"
);
end Reconnect;
procedure Received
( Client : in out Connection;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset
) is
begin
raise Connection_Error;
end Received;
procedure Released (Client : in out Connection) is
begin
null;
end Released;
procedure Remove
( List : in out Connection_Ptr;
Item : in out Connection'Class;
Count : in out Integer
) is
begin
if Item.Successor /= null then
Count := Count - 1;
if List = Item.Successor.Predecessor then -- First in the list
if List = List.Successor then -- The single item of the list
List := null;
Item.Successor := null;
return;
else
List := Item.Successor;
end if;
end if;
Item.Predecessor.Successor := Item.Successor;
Item.Successor.Predecessor := Item.Predecessor;
Item.Successor := null;
end if;
end Remove;
procedure Receive_Error
( Client : in out Connection;
Occurrence : Exception_Occurrence
) is
begin
null;
end Receive_Error;
procedure Request_Disconnect
( Listener : in out Connections_Server;
Client : in out Connection'Class;
Reconnect : Boolean
) is
begin
Client.Failed := True;
if Reconnect then
Client.Try_To_Reconnect := True;
Client.Action_Request := Reconnect_Connection;
else
Client.Try_To_Reconnect := False;
Client.Action_Request := Shutdown_Connection;
end if;
Client.Socket_Listener.Shutdown_Request := True;
if Client.Socket_Listener.Doer /= null then
Abort_Selector (Client.Socket_Listener.Selector);
end if;
end Request_Disconnect;
procedure Save_Occurrence
( Client : in out Connection;
Source : Exception_Occurrence
) is
begin
Save_Occurrence (Client.Last_Error, Source);
end Save_Occurrence;
procedure Send
( Client : in out Connection;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset
) is
Buffer : Output_Buffer renames Client.Written;
begin
if ( Pointer < Data'First
or else
( Pointer > Data'Last
and then
Pointer - 1 > Data'Last
) )
then
Raise_Exception (Layout_Error'Identity, "Subscript error");
end if;
Queue (Client, Data, Pointer);
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Data : String;
Pointer : in out Integer
) is
Buffer : Output_Buffer renames Client.Written;
begin
Pointer := Data'Last + 1;
for Index in Data'Range loop
if Used (Buffer) + 1 >= Buffer.Written'Length then
Pointer := Index;
exit;
end if;
Buffer.Written (Buffer.Free_To_Write) :=
Stream_Element (Character'Pos (Data (Index)));
if Buffer.Free_To_Write = Buffer.Written'Last then
Buffer.Free_To_Write := Buffer.Written'First;
else
Buffer.Free_To_Write := Buffer.Free_To_Write + 1;
end if;
end loop;
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
End_Of_Stream : out Boolean
) is
Buffer : Output_Buffer renames Client.Written;
Last : Stream_Element_Offset;
Next : Stream_Element_Offset;
begin
Fill_From_Stream
( Buffer => Buffer,
Stream => Stream,
Count => Stream_Element_Count'Last,
Reserve => 1,
Last => Last,
Next => Next,
Done => End_Of_Stream
);
Buffer.Free_To_Write := Next;
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
Count : in out Stream_Element_Count;
End_Of_Stream : out Boolean
) is
Buffer : Output_Buffer renames Client.Written;
Last : Stream_Element_Offset;
Next : Stream_Element_Offset;
begin
Fill_From_Stream
( Buffer => Buffer,
Stream => Stream,
Count => Count,
Reserve => 1,
Last => Last,
Next => Next,
Done => End_Of_Stream
);
Count := Count - (Last + 1 - Buffer.Free_To_Write);
Buffer.Free_To_Write := Next;
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
Reserve : Stream_Element_Count;
Get_Prefix : Create_Stream_Element_Array;
Get_Suffix : Create_Stream_Element_Array;
End_Of_Stream : out Boolean
) is
Count : Stream_Element_Count := Stream_Element_Count'Last;
begin
Send
( Client => Client,
Stream => Stream,
Count => Count,
Reserve => Reserve,
Get_Prefix => Get_Prefix,
Get_Suffix => Get_Suffix,
End_Of_Stream => End_Of_Stream
);
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
Count : in out Stream_Element_Count;
Reserve : Stream_Element_Count;
Get_Prefix : Create_Stream_Element_Array;
Get_Suffix : Create_Stream_Element_Array;
End_Of_Stream : out Boolean
) is
Buffer : Output_Buffer renames Client.Written;
Last : Stream_Element_Offset;
Next : Stream_Element_Offset;
begin
if Buffer.Free_To_Write = Buffer.First_Written then
if Buffer.Written'Length <= Reserve then
Raise_Exception
( Data_Error'Identity,
( "Output buffer size"
& Stream_Element_Count'Image (Buffer.Written'Length)
& " is less than required"
& Stream_Element_Count'Image (Reserve + 1)
& " elements"
) );
end if;
Fill_From_Stream
( Buffer => Buffer,
Stream => Stream,
Count => Count,
Reserve => Reserve + 1,
Last => Last,
Next => Next,
Done => End_Of_Stream
);
Count := Count - (Last + 1 - Buffer.Free_To_Write);
declare
Header : constant Stream_Element_Array :=
Get_Prefix.all
( Client'Unchecked_Access,
Buffer.Written (Buffer.Free_To_Write..Last),
End_Of_Stream
);
Tail : constant Stream_Element_Array :=
Get_Suffix.all
( Client'Unchecked_Access,
Buffer.Written (Buffer.Free_To_Write..Last),
End_Of_Stream
);
begin
if Header'Length + Tail'Length > Reserve then
Raise_Exception
( Data_Error'Identity,
( "Prefix returns more than"
& Stream_Element_Count'Image (Reserve)
& " elements"
) );
elsif Header'Length > 0 then
Last := Buffer.First_Written;
for Index in reverse Header'Range loop
if Last = Buffer.Written'First then
Last := Buffer.Written'Last;
else
Last := Last - 1;
end if;
Buffer.Written (Last) := Header (Index);
end loop;
end if;
Buffer.First_Written := Last;
Buffer.Free_To_Write := Next;
if Tail'Length > 0 then
Last := Tail'First;
Queue (Client, Tail, Last);
end if;
end;
else
End_Of_Stream := False;
end if;
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
Count : in out Stream_Element_Count;
Reserve : Natural;
Get_Prefix : Create_String;
Get_Suffix : Create_String;
End_Of_Stream : out Boolean
) is
Buffer : Output_Buffer renames Client.Written;
Last : Stream_Element_Offset;
Next : Stream_Element_Offset;
begin
if Buffer.Free_To_Write = Buffer.First_Written then
if Buffer.Written'Length <= Reserve then
Raise_Exception
( Data_Error'Identity,
( "Output buffer size"
& Stream_Element_Count'Image (Buffer.Written'Length)
& " is less than required"
& Integer'Image (Reserve + 1)
& " elements"
) );
end if;
Fill_From_Stream
( Buffer => Buffer,
Stream => Stream,
Count => Count,
Reserve => Stream_Element_Count (Reserve) + 1,
Last => Last,
Next => Next,
Done => End_Of_Stream
);
Count := Count - (Last + 1 - Buffer.Free_To_Write);
declare
Header : constant String :=
Get_Prefix.all
( Client'Unchecked_Access,
Buffer.Written (Buffer.Free_To_Write..Last),
End_Of_Stream
);
Tail : constant String :=
Get_Suffix.all
( Client'Unchecked_Access,
Buffer.Written (Buffer.Free_To_Write..Last),
End_Of_Stream
);
begin
if Header'Length + Tail'Length > Reserve then
Raise_Exception
( Data_Error'Identity,
( "Prefix returns more than"
& Integer'Image (Reserve)
& " elements"
) );
elsif Header'Length > 0 then
Last := Buffer.First_Written;
for Index in reverse Header'Range loop
if Last = Buffer.Written'First then
Last := Buffer.Written'Last;
else
Last := Last - 1;
end if;
Buffer.Written (Last) :=
Stream_Element (Character'Pos (Header (Index)));
end loop;
end if;
Buffer.First_Written := Last;
Buffer.Free_To_Write := Next;
if Tail'Length > 0 then
declare
Pointer : Integer := Tail'First;
begin
Send (Client, Tail, Pointer);
end;
end if;
end;
else
End_Of_Stream := False;
end if;
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
Reserve : Natural;
Get_Prefix : Create_String;
Get_Suffix : Create_String;
End_Of_Stream : out Boolean
) is
Count : Stream_Element_Count := Stream_Element_Count'Last;
begin
Send
( Client => Client,
Stream => Stream,
Count => Count,
Reserve => Reserve,
Get_Prefix => Get_Prefix,
Get_Suffix => Get_Suffix,
End_Of_Stream => End_Of_Stream
);
end Send;
procedure Send_Error
( Client : in out Connection;
Occurrence : Exception_Occurrence
) is
begin
null;
end Send_Error;
procedure Send_Socket
( Listener : in out Connections_Server;
Client : in out Connection'Class;
Data : Stream_Element_Array;
Last : out Stream_Element_Offset
) is
begin
Send_Socket (Client.Socket, Data, Last);
end Send_Socket;
procedure Sent (Client : in out Connection) is
begin
null;
end Sent;
procedure Set_Client_Data
( Client : in out Connection;
Address : Sock_Addr_Type;
Listener : Connections_Server_Ptr
) is
begin
if Client.Socket_Listener /= null then
Raise_Exception
( Constraint_Error'Identity,
"The client has a connections server set"
);
end if;
Client.Client_Address := Address;
Client.Socket_Listener := Listener;
end Set_Client_Data;
procedure Set_Expected_Count
( Client : in out Connection;
Count : Stream_Element_Count
) is
begin
Client.Read.Expected := Count;
end Set_Expected_Count;
procedure Service_Postponed (Listener : in out Connections_Server) is
Leftover : Connection_Ptr;
Client : Connection_Ptr;
Data_Left : Boolean;
begin
loop
Client := Listener.Postponed;
exit when Client = null;
Remove
( Listener.Postponed,
Client.all,
Listener.Postponed_Count
);
begin
Process
( Connections_Server'Class (Listener),
Client,
Data_Left
);
if Data_Left then
Append (Leftover, Client, Listener.Postponed_Count);
end if;
exception
when Connection_Error =>
Stop (Listener, Client);
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Postponed service",
Error
);
Stop (Listener, Client);
end;
end loop;
Listener.Postponed := Leftover;
end Service_Postponed;
procedure Set_Failed
( Client : in out Connection;
Error : Exception_Occurrence
) is
begin
Save_Occurrence (Client.Last_Error, Error);
Client.Failed := True;
end Set_Failed;
procedure Set_Overlapped_Size
( Client : in out Connection;
Size : Stream_Element_Count
) is
begin
Client.Overlapped_Read := Size;
end Set_Overlapped_Size;
procedure Shutdown (Client : in out Connection) is
begin
if Client.Session /= Session_Down then
if Client.Socket_Listener = null then
Client.Session := Session_Down;
else
Request_Disconnect
( Client.Socket_Listener.all,
Client,
False
);
Shutdown (Client.Socket_Listener.all, Client);
end if;
end if;
end Shutdown;
procedure Shutdown
( Listener : in out Connections_Server;
Client : in out Connection'Class
) is
begin
null;
end Shutdown;
procedure Stop
( Listener : in out Connections_Server'Class;
Client : in out Connection_Ptr
) is
Old_Socket : constant Socket_Type := Client.Socket;
Reconnect : Boolean :=
Client.Action_Request /= Shutdown_Connection;
begin
Trace_Sending
( Listener.Factory.all,
Client.all,
False,
", dropping connection"
);
Client.Action_Request := Keep_Connection;
Clear (Listener.Read_Sockets, Client.Socket);
Clear (Listener.Blocked_Sockets, Client.Socket);
Clear (Listener.Ready_To_Read, Client.Socket);
Clear (Listener.Ready_To_Write, Client.Socket);
Clear (Listener.Write_Sockets, Client.Socket);
Clear (Listener.Ready_To_Write, Client.Socket);
Free (Client.Transport);
if Client.Session in Session_Connected..Session_Busy then
begin
Disconnected (Listener, Client.all);
exception
when Connection_Error =>
Reconnect := False;
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Disconnected (server)",
Error
);
end;
begin -- Disconnected
Client.Session := Session_Disconnected;
Disconnected (Client.all);
exception
when Connection_Error =>
Reconnect := False;
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Disconnected (client)",
Error
);
end;
end if;
if Client.Client then -- Try to reconnect
if ( Reconnect
and then
not Listener.Finalizing
and then
Client.Try_To_Reconnect
and then
Client.Session /= Session_Down
and then
Client.Action_Request /= Shutdown_Connection
)
then
begin
Close (Client.Socket);
declare
Option : Request_Type := (Non_Blocking_IO, True);
begin
Create_Socket (Client.Socket);
Set_Socket_Option
( Client.Socket,
Socket_Level,
(Reuse_Address, True)
);
end;
if Old_Socket /= Client.Socket then -- Move client
Put (Listener.Connections, Client.Socket, Client);
Put (Listener.Connections, Old_Socket, null);
end if;
Set (Listener.Write_Sockets, Client.Socket);
Do_Connect (Listener, Client);
return;
exception
when Error : Socket_Error => -- Kill the object
Trace_Error
( Listener.Factory.all,
"Reconnecting",
Error
);
end;
end if;
Listener.Servers := Listener.Servers - 1;
else
Listener.Clients := Listener.Clients - 1;
end if;
Close (Client.Socket);
Client.Session := Session_Down;
Client.Failed := False;
Client.Action_Request := Keep_Connection;
begin
Downed (Listener, Client.all);
exception
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Downed (server)",
Error
);
end;
begin
Downed (Client.all);
exception
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Downed (client)",
Error
);
end;
begin
Released (Client.all);
exception
when others =>
null;
end;
if Get (Listener.Connections, Old_Socket) = Client then
Put (Listener.Connections, Old_Socket, null);
end if;
Client := null;
exception
when Error : others =>
Trace_Error (Listener.Factory.all, "Stopping", Error);
raise;
end Stop;
function To_Addr (Host : String) return Inet_Addr_Type is
begin
for Index in Host'Range loop
case Host (Index) is
when '.' | '0'..'9' =>
null;
when others =>
return Addresses (Get_Host_By_Name (Host), 1);
end case;
end loop;
return Inet_Addr (Host);
end To_Addr;
function To_String (Data : Stream_Element_Array) return String is
Result : String (1..Data'Length);
Index : Integer := Result'First;
begin
for Item in Data'Range loop
Result (Index) := Character'Val (Data (Item));
Index := Index + 1;
end loop;
return Result;
end To_String;
procedure Trace
( Factory : in out Connections_Factory;
Message : String
) is
use Ada.Text_IO;
begin
if 0 /= (Factory.Trace_Flags and Standard_Output) then
Put_Line (Message);
end if;
if Is_Open (Factory.Trace_File) then
Put_Line (Factory.Trace_File, Message);
end if;
end Trace;
procedure Trace_Error
( Factory : in out Connections_Factory;
Context : String;
Occurrence : Exception_Occurrence
) is
begin
Trace
( Connections_Factory'Class (Factory),
Context & ": " & Exception_Information (Occurrence)
);
end Trace_Error;
procedure Trace_Off (Factory : in out Connections_Factory) is
use Ada.Text_IO;
begin
if Is_Open (Factory.Trace_File) then
Close (Factory.Trace_File);
end if;
Factory.Trace_Flags :=
Factory.Trace_Flags and not Standard_Output;
end Trace_Off;
procedure Trace_On
( Factory : in out Connections_Factory;
Received : IO_Tracing_Mode := Trace_None;
Sent : IO_Tracing_Mode := Trace_None
) is
Flags : Factory_Flags := Standard_Output;
begin
case Received is
when Trace_Any =>
Flags := Flags
or Trace_Decoded_Received
or Trace_Encoded_Received;
when Trace_Decoded =>
Flags := Flags or Trace_Decoded_Received;
when Trace_Encoded =>
Flags := Flags or Trace_Encoded_Received;
when Trace_None =>
null;
end case;
case Sent is
when Trace_Any =>
Flags := Flags or Trace_Decoded_Sent or Trace_Encoded_Sent;
when Trace_Decoded =>
Flags := Flags or Trace_Decoded_Sent;
when Trace_Encoded =>
Flags := Flags or Trace_Encoded_Sent;
when Trace_None =>
null;
end case;
Factory.Trace_Flags := Flags;
end Trace_On;
procedure Trace_On
( Factory : in out Connections_Factory;
Name : String;
Received : IO_Tracing_Mode := Trace_None;
Sent : IO_Tracing_Mode := Trace_None
) is
use Ada.Text_IO;
Flags : Factory_Flags := 0;
begin
if Is_Open (Factory.Trace_File) then
Close (Factory.Trace_File);
end if;
Create (File => Factory.Trace_File, Name => Name);
case Received is
when Trace_Any =>
Flags := Flags
or Trace_Decoded_Received
or Trace_Encoded_Received;
when Trace_Decoded =>
Flags := Flags or Trace_Decoded_Received;
when Trace_Encoded =>
Flags := Flags or Trace_Encoded_Received;
when Trace_None =>
null;
end case;
case Sent is
when Trace_Any =>
Flags := Flags or Trace_Decoded_Sent or Trace_Encoded_Sent;
when Trace_Decoded =>
Flags := Flags or Trace_Decoded_Sent;
when Trace_Encoded =>
Flags := Flags or Trace_Encoded_Sent;
when Trace_None =>
null;
end case;
Factory.Trace_Flags := Flags;
end Trace_On;
procedure Trace_Received
( Factory : in out Connections_Factory;
Client : Connection'Class;
Data : Stream_Element_Array;
From : Stream_Element_Offset;
To : Stream_Element_Offset;
Encoded : Boolean := False
) is
This : Connections_Factory'Class renames
Connections_Factory'Class (Factory);
begin
if Encoded then
Trace
( This,
( Get_Client_Name (This, Client)
& " encoded> |"
& Image (Data (From..To))
& "| "
& Image (From)
& ".."
& Image (To)
) );
else
Trace
( This,
( Get_Client_Name (This, Client)
& " > |"
& Image (Data (From..To))
& "| "
& Image (From)
& ".."
& Image (To)
) );
end if;
end Trace_Received;
procedure Trace_Sending
( Factory : in out Connections_Factory;
Client : Connection'Class;
Enabled : Boolean;
Reason : String
) is
This : Connections_Factory'Class renames
Connections_Factory'Class (Factory);
begin
if Enabled then
Trace
( This,
( Get_Client_Name (This, Client)
& " < +++ Resume polling"
& Reason
) );
else
Trace
( This,
( Get_Client_Name (This, Client)
& " < --- Stop polling"
& Reason
) );
end if;
end Trace_Sending;
procedure Trace_Sent
( Factory : in out Connections_Factory;
Client : Connection'Class;
Data : Stream_Element_Array;
From : Stream_Element_Offset;
To : Stream_Element_Offset;
Encoded : Boolean := False
) is
This : Connections_Factory'Class renames
Connections_Factory'Class (Factory);
begin
if Encoded then
Trace
( This,
( Get_Client_Name (This, Client)
& " <encoded |"
& Image (Data (From..To))
& "| "
& Image (From)
& ".."
& Image (To)
) );
else
Trace
( This,
( Get_Client_Name (This, Client)
& " < |"
& Image (Data (From..To))
& "| "
& Image (From)
& ".."
& Image (To)
) );
end if;
end Trace_Sent;
procedure Trace_Service_Loop
( Factory : in out Connections_Factory;
Stage : Service_Loop_Stage;
Server : in out Connections_Server'Class
) is
begin
null;
end Trace_Service_Loop;
procedure Unblock_Send
( Listener : in out Connections_Server;
Client : in out Connection'Class
) is
Buffer : Output_Buffer renames Client.Written;
begin
if Buffer.Send_Blocked then -- Request socket unblocking
Buffer.Send_Blocked := False;
Listener.Unblock_Send := True;
if Listener.Doer /= null then
Abort_Selector (Listener.Selector);
end if;
end if;
end Unblock_Send;
procedure Unblock_Send (Client : in out Connection) is
begin
Unblock_Send (Client.Socket_Listener.all, Client);
end Unblock_Send;
function Used (Buffer : Input_Buffer) return Stream_Element_Count is
Diff : constant Stream_Element_Offset :=
Buffer.Free_To_Read - Buffer.First_Read;
begin
if Diff < 0 then
return Buffer.Read'Length - Diff;
else
return Diff;
end if;
end Used;
function Used (Buffer : Output_Buffer) return Stream_Element_Count is
begin
if Buffer.Free_To_Write >= Buffer.First_Written then
return Buffer.Free_To_Write - Buffer.First_Written;
else
return Buffer.Written'Length - Buffer.First_Written +
Buffer.Free_To_Write;
end if;
end Used;
procedure Write
( Client : in out Connection;
Factory : in out Connections_Factory'Class;
Blocked : out Boolean
) is
Buffer : Output_Buffer renames Client.Written;
Next : Stream_Element_Count;
begin
Blocked := Buffer.First_Written = Buffer.Free_To_Write;
if Blocked then
if Client.Dont_Block then
Blocked := False;
Client.Data_Sent := True;
Client.Dont_Block := False;
end if;
else
loop
if Buffer.First_Written > Buffer.Free_To_Write then
--
-- [XXXXX XXXXXXX]
-- | |
-- Free_To_Write First_Written
--
if Client.Transport = null then
Send_Socket
( Client.Socket_Listener.all,
Client,
Buffer.Written
( Buffer.First_Written
.. Buffer.Written'Last
),
Next
);
else
Encode
( Client.Transport.all,
Client,
Buffer.Written
( Buffer.First_Written
.. Buffer.Written'Last
),
Next
);
end if;
Next := Next + 1;
if Next = Buffer.First_Written then
exit; -- Cannot send anything right now
elsif Next <= Buffer.Written'Last then
if 0 /= (Factory.Trace_Flags and Trace_Decoded_Sent)
then
Trace_Sent
( Factory => Factory,
Client => Client,
Data => Buffer.Written,
From => Buffer.First_Written,
To => Next - 1,
Encoded => False
);
end if;
Buffer.First_Written := Next;
Client.Data_Sent := True;
exit;
end if;
if 0 /= (Factory.Trace_Flags and Trace_Decoded_Sent) then
Trace_Sent
( Factory => Factory,
Client => Client,
Data => Buffer.Written,
From => Buffer.First_Written,
To => Next - 1,
Encoded => False
);
end if;
Buffer.First_Written := 0;
Client.Data_Sent := True;
else
--
-- [ XXXXXXXXXXXXXXX ]
-- | |
-- First_Written Free_To_Write
--
if Client.Transport = null then
Send_Socket
( Client.Socket_Listener.all,
Client,
Buffer.Written
( Buffer.First_Written
.. Buffer.Free_To_Write - 1
),
Next
);
else
Encode
( Client.Transport.all,
Client,
Buffer.Written
( Buffer.First_Written
.. Buffer.Free_To_Write - 1
),
Next
);
end if;
Next := Next + 1;
if Next = Buffer.First_Written then
exit;
elsif Next <= Buffer.Free_To_Write then
if 0 /= (Factory.Trace_Flags and Trace_Decoded_Sent)
then
Trace_Sent
( Factory => Factory,
Client => Client,
Data => Buffer.Written,
From => Buffer.First_Written,
To => Next - 1,
Encoded => False
);
end if;
Buffer.First_Written := Next;
Client.Data_Sent := True;
exit;
end if;
if 0 /= (Factory.Trace_Flags and Trace_Decoded_Sent) then
Trace_Sent
( Factory => Factory,
Client => Client,
Data => Buffer.Written,
From => Buffer.First_Written,
To => Next - 1,
Encoded => False
);
end if;
Buffer.First_Written := Next;
Client.Data_Sent := True;
end if;
exit when Buffer.First_Written = Buffer.Free_To_Write;
end loop;
end if;
end Write;
task body Worker is
Address : Sock_Addr_Type :=
Get_Server_Address (Listener.all);
Server_Socket : Socket_Type := No_Socket;
Client_Socket : Socket_Type;
That_Time : Time := Clock;
This_Time : Time;
Status : Selector_Status;
function Set_Image (Socket : Socket_Type) return String is
begin
return
( Image (Socket)
& ", listener"
& " read: " & Image (Listener.Read_Sockets)
& ", write: " & Image (Listener.Write_Sockets)
& ", blocked: " & Image (Listener.Blocked_Sockets)
& ", ready"
& " read: " & Image (Listener.Ready_To_Read)
& ", write: " & Image (Listener.Ready_To_Write)
);
end Set_Image;
procedure Check (Sockets : Socket_Set_Type) is
Socket : Socket_Type;
List : Socket_Set_Type := Sockets;
begin
loop
Get (List, Socket);
exit when Socket = No_Socket;
if Socket /= Server_Socket then
declare
Client : Connection_Ptr :=
Get (Listener.Connections, Socket);
begin
if Client = null then
Trace
( Listener.Factory.all,
( "Missing client when checking socket "
& Set_Image (Socket)
) );
Clear (Listener.Read_Sockets, Socket);
Clear (Listener.Write_Sockets, Socket);
Clear (Listener.Blocked_Sockets, Socket);
elsif Client.Failed then
if ( Client.Action_Request = Keep_Connection
and then
( Exception_Identity (Client.Last_Error)
/= Connection_Error'Identity
) )
then
Trace_Error
( Listener.Factory.all,
"Dropping connection on request",
Client.Last_Error
);
end if;
Stop (Listener.all, Client);
end if;
end;
end if;
end loop;
end Check;
procedure Unblock (Requested_Only : Boolean) is
Socket : Socket_Type;
begin
while not Listener.Finalizing loop
Get (Listener.Blocked_Sockets, Socket);
exit when Socket = No_Socket;
if Socket /= Server_Socket then
declare
Client : Connection_Ptr :=
Get (Listener.Connections, Socket);
begin
if Client = null then
Trace
( Listener.Factory.all,
( "Missing client when unblocking socket "
& Set_Image (Socket)
) );
Clear (Listener.Read_Sockets, Socket);
Clear (Listener.Write_Sockets, Socket);
Clear (Listener.Ready_To_Write, Socket);
elsif Client.Failed then
if ( Client.Session /= Session_Down
and then
Client.Action_Request = Keep_Connection
and then
( Exception_Identity (Client.Last_Error)
/= Connection_Error'Identity
) )
then
Trace_Error
( Listener.Factory.all,
"Unblocking socket",
Client.Last_Error
);
end if;
Stop (Listener.all, Client);
elsif ( Requested_Only
and then
Client.Written.Send_Blocked
) then -- Keep it blocked
Set (Listener.Ready_To_Read, Client.Socket);
else -- Unblock
Set (Listener.Write_Sockets, Client.Socket);
Set (Listener.Ready_To_Write, Client.Socket);
Status := Completed; -- Make sure it written later
Client.Written.Send_Blocked := False;
Client.Data_Sent := True;
if ( 0
/= ( Listener.Factory.Trace_Flags
and
(Trace_Encoded_Sent or Trace_Decoded_Sent)
) )
then
if Requested_Only then
Trace_Sending
( Listener.Factory.all,
Client.all,
True,
", some data to send"
);
else
Trace_Sending
( Listener.Factory.all,
Client.all,
True,
", blocking timeout expired"
);
end if;
end if;
end if;
end;
end if;
end loop;
end Unblock;
Exit_Error : exception;
begin
On_Worker_Start (Listener.all);
if Address.Port /= 0 then
Create_Socket (Listener.all, Server_Socket, Address);
if Server_Socket = No_Socket then
raise Exit_Error;
end if;
Set (Listener.Read_Sockets, Server_Socket);
end if;
Listener.Request.Activate;
loop
Trace_Service_Loop
( Listener.Factory.all,
Service_Loop_Begin,
Listener.all
);
if Listener.Shutdown_Request then
Listener.Shutdown_Request := False;
Check (Listener.Read_Sockets);
end if;
if Listener.Connect_Request then
declare
Client : Connection_Ptr;
begin
loop
Listener.Request.Get (Client);
exit when Client = null;
Set (Listener.Write_Sockets, Client.Socket);
Put (Listener.Connections, Client.Socket, Client);
declare
use Object;
Ptr : Entity_Ptr := Client.all'Unchecked_Access;
begin
Release (Ptr);
end;
Listener.Servers := Listener.Servers + 1;
Do_Connect (Listener.all, Client);
end loop;
end;
end if;
Copy (Listener.Read_Sockets, Listener.Ready_To_Read);
Copy (Listener.Write_Sockets, Listener.Ready_To_Write);
Check_Selector
( Selector => Listener.Selector,
R_Socket_Set => Listener.Ready_To_Read,
W_Socket_Set => Listener.Ready_To_Write,
Status => Status,
Timeout => Listener.IO_Timeout
);
exit when Listener.Finalizing;
if Status = Completed then
Trace_Service_Loop
( Listener.Factory.all,
Service_Loop_Reading,
Listener.all
);
loop -- Reading from sockets
Get (Listener.Ready_To_Read, Client_Socket);
exit when Client_Socket = No_Socket;
if Client_Socket = Server_Socket then
Accept_Socket
( Server_Socket,
Client_Socket,
Address
);
declare
Client : Connection_Ptr;
begin
Client :=
Create (Listener.Factory, Listener, Address);
if Client = null then
Close (Client_Socket);
else
declare
This : Connection'Class renames Client.all;
begin
This.Client := False;
This.Connect_No := 0;
This.Client_Address := Address;
This.Socket := Client_Socket;
This.Try_To_Reconnect := False;
Clear (This);
This.Socket_Listener :=
Listener.all'Unchecked_Access;
Set (Listener.Read_Sockets, Client_Socket);
Set (Listener.Write_Sockets, Client_Socket);
Put
( Listener.Connections,
Client_Socket,
Client
);
Listener.Clients := Listener.Clients + 1;
if not Is_Opportunistic (This) then
This.Transport :=
Create_Transport
( Listener.Factory,
Listener,
Client
);
end if;
if This.Transport = null then -- Ready
This.Session := Session_Connected;
Connected (This);
Connected (Listener.all, This);
This.Session := Session_Active;
Activated (This);
else
This.Session := Session_Handshaking;
end if;
end;
end if;
exception
when Connection_Error =>
if Client /= null then
Stop (Listener.all, Client);
end if;
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Accept socket",
Error
);
if Client /= null then
Stop (Listener.all, Client);
end if;
end;
else
declare
Client : Connection_Ptr :=
Get (Listener.Connections, Client_Socket);
begin
if Client = null then
Trace
( Listener.Factory.all,
( "Missing client when reading from socket "
& Set_Image (Client_Socket)
) );
Clear (Listener.Read_Sockets, Client_Socket);
Clear (Listener.Write_Sockets, Client_Socket);
Clear (Listener.Blocked_Sockets, Client_Socket);
Clear (Listener.Ready_To_Write, Client_Socket);
elsif Client.Failed then
if ( Client.Session /= Session_Down
and then
Client.Action_Request = Keep_Connection
and then
( Exception_Identity (Client.Last_Error)
/= Connection_Error'Identity
) )
then
Trace_Error
( Listener.Factory.all,
"Preparing to receive",
Client.Last_Error
);
end if;
Stop (Listener.all, Client);
else
begin
Read (Client.all, Listener.Factory.all);
exception
when Connection_Error =>
Stop (Listener.all, Client);
when Error : Socket_Error =>
Send_Error (Client.all, Error);
Stop (Listener.all, Client);
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Receive socket",
Error
);
Stop (Listener.all, Client);
end;
declare
Data_Left : Boolean;
begin
if Client /= null then
Process (Listener.all, Client, Data_Left);
if Data_Left then
Append
( Listener.Postponed,
Client,
Listener.Postponed_Count
);
end if;
end if;
exception
when Connection_Error =>
Stop (Listener.all, Client);
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Processing received",
Error
);
Stop (Listener.all, Client);
end;
end if;
end;
end if;
end loop;
else
Empty (Listener.Ready_To_Read); -- Clear the set
end if;
Trace_Service_Loop
( Listener.Factory.all,
Service_Loop_Unblocking,
Listener.all
);
This_Time := Clock;
if This_Time - That_Time > Listener.Polling_Timeout then
-- Unblock everything now
That_Time := This_Time;
Unblock (False);
if ( Server_Socket /= No_Socket
and then
not Is_Set (Listener.Read_Sockets, Server_Socket)
)
then
Trace
( Listener.Factory.all,
"Server socket fell out of the read sockets list"
);
Set (Listener.Read_Sockets, Server_Socket);
end if;
else
-- Checking for explicit unblocking requests
while Listener.Unblock_Send loop
Listener.Unblock_Send := False;
Unblock (True); -- Still blocked are now in Ready_To_Read
Copy (Listener.Ready_To_Read, Listener.Blocked_Sockets);
Empty (Listener.Ready_To_Read); -- Clear the set
end loop;
end if;
if Status = Completed then
Trace_Service_Loop
( Listener.Factory.all,
Service_Loop_Writing,
Listener.all
);
loop -- Writing sockets
Get (Listener.Ready_To_Write, Client_Socket);
exit when Client_Socket = No_Socket;
if Client_Socket /= Server_Socket then
declare
Client : Connection_Ptr :=
Get (Listener.Connections, Client_Socket);
begin
if Client = null then
Trace
( Listener.Factory.all,
( "Missing client when writing to socket "
& Set_Image (Client_Socket)
) );
Clear (Listener.Read_Sockets, Client_Socket);
Clear (Listener.Write_Sockets, Client_Socket);
Clear (Listener.Blocked_Sockets, Client_Socket);
elsif Client.Failed then
if ( Client.Session /= Session_Down
and then
Client.Action_Request = Keep_Connection
and then
( Exception_Identity (Client.Last_Error)
/= Connection_Error'Identity
) )
then
Trace_Error
( Listener.Factory.all,
"Preparing to send",
Client.Last_Error
);
end if;
Stop (Listener.all, Client);
elsif Client.Session = Session_Connecting then
declare
This : Connection'Class renames Client.all;
Code : constant Error_Type :=
Get_Socket_Option
( Client.Socket,
Socket_Level,
Error
) .Error;
begin
if Code = Success then -- Connected
On_Connected (Listener.all, This);
Set
( Listener.Read_Sockets,
Client_Socket
);
else -- Connect error
Trace_Sending
( Listener.Factory.all,
This,
False,
( ", failed to connect to "
& Image (This.Client_Address)
& ": " & Image (Code)
) );
Connect_Error (This, Code);
Do_Connect (Listener.all, Client);
end if;
exception
when Connection_Error =>
if Client /= null then
Client.Try_To_Reconnect := False;
Stop (Listener.all, Client);
end if;
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Connect socket",
Error
);
if Client /= null then
Client.Try_To_Reconnect := False;
Stop (Listener.all, Client);
end if;
end;
else -- Have space to write
declare
Block : Boolean;
begin
Write
( Client.all,
Listener.Factory.all,
Block
);
if ( Block
and then
not Client.Written.Send_Blocked
)
then
Client.Written.Send_Blocked := True;
Set
( Client.Socket_Listener.Blocked_Sockets,
Client.Socket
);
Clear
( Client.Socket_Listener.Write_Sockets,
Client.Socket
);
if ( 0
/= ( Listener.Factory.Trace_Flags
and
( Trace_Encoded_Sent
or Trace_Decoded_Sent
) ) )
then
Trace_Sending
( Listener.Factory.all,
Client.all,
False,
", nothing to send"
);
end if;
end if;
exception
when Connection_Error =>
Stop (Listener.all, Client);
when Error : Socket_Error =>
Send_Error (Client.all, Error);
Stop (Listener.all, Client);
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Send socket",
Error
);
Stop (Listener.all, Client);
end;
begin
if Client /= null and then Client.Data_Sent
then
Data_Sent (Listener.all, Client);
end if;
exception
when Connection_Error =>
Stop (Listener.all, Client);
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Processing sent notification",
Error
);
Stop (Listener.all, Client);
end;
end if;
end;
end if;
end loop;
else
Empty (Listener.Ready_To_Write); -- Clear the set
end if;
exit when Listener.Finalizing;
Trace_Service_Loop
( Listener.Factory.all,
Service_Loop_Postponed,
Listener.all
);
Service_Postponed (Listener.all);
end loop;
declare
Client : Connection_Ptr;
begin
loop
Listener.Request.Get (Client);
exit when Client = null;
declare
use Object;
Ptr : Entity_Ptr := Client.all'Unchecked_Access;
begin
Release (Ptr);
end;
end loop;
end;
Close (Server_Socket);
Trace (Listener.Factory.all, "Worker task exiting");
exception
when Exit_Error =>
Trace (Listener.Factory.all, "Worker task exiting");
when Error : others =>
Close (Server_Socket);
Trace_Error (Listener.Factory.all, "Worker task", Error);
end Worker;
protected body Box is
entry Connect (Client : Connection_Ptr)
when Active and then Pending = null is
begin
if Client /= null then
Pending := Client;
Client.Socket_Listener.Connect_Request := True;
Abort_Selector (Listener.Selector);
end if;
end Connect;
procedure Activate is
begin
Active := True;
end Activate;
procedure Get (Client : out Connection_Ptr) is
begin
if Pending = null then
Client := null;
else
Client := Pending;
Pending := null;
Client.Socket_Listener.Connect_Request := False;
end if;
end Get;
end Box;
end GNAT.Sockets.Server;
| 14404 | -- --
-- package GNAT.Sockets.Server Copyright (c) <NAME> --
-- Implementation Luebeck --
-- Winter, 2012 --
-- --
-- Last revision : 14:53 29 Feb 2020 --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public License as --
-- published by the Free Software Foundation; either version 2 of --
-- the License, or (at your option) any later version. This library --
-- is distributed in the hope that it will be useful, but WITHOUT --
-- ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have --
-- received a copy of the GNU General Public License along with --
-- this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
--____________________________________________________________________--
with Ada.Calendar; use Ada.Calendar;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.IO_Exceptions; use Ada.IO_Exceptions;
with Strings_Edit; use Strings_Edit;
with Strings_Edit.Integers; use Strings_Edit.Integers;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
package body GNAT.Sockets.Server is
Receive_Masks : constant array (IO_Tracing_Mode) of Factory_Flags :=
( Trace_None => 0,
Trace_Encoded => Trace_Encoded_Received,
Trace_Decoded => Trace_Decoded_Received,
Trace_Any => Trace_Encoded_Received
or Trace_Decoded_Received
);
Sent_Masks : constant array (IO_Tracing_Mode) of Factory_Flags :=
( Trace_None => 0,
Trace_Encoded => Trace_Encoded_Sent,
Trace_Decoded => Trace_Decoded_Sent,
Trace_Any => Trace_Encoded_Sent
or Trace_Decoded_Sent
);
procedure Free is
new Ada.Unchecked_Deallocation (Encoder'Class, Encoder_Ptr);
procedure Activated (Client : in out Connection) is
begin
null;
end Activated;
procedure Append
( List : in out Connection_Ptr;
Item : Connection_Ptr;
Count : in out Integer
) is
begin
if Item.Successor = null then
if List = null then
List := Item;
Item.Successor := Item;
Item.Predecessor := Item;
else
Item.Successor := List;
Item.Predecessor := List.Predecessor;
List.Predecessor := Item;
Item.Predecessor.Successor := Item;
end if;
Count := Count + 1;
end if;
end Append;
function Available_To_Process (Client : Connection)
return Stream_Element_Count is
begin
return Used (Client.Read);
end Available_To_Process;
function Available_To_Send (Client : Connection)
return Stream_Element_Count is
begin
return Free (Client.Written);
end Available_To_Send;
procedure Clear (Client : in out Connection'Class) is
begin
Client.Failed := False; -- Clean I/O state
Client.External_Action := False;
Client.Data_Sent := False;
Client.Dont_Block := False;
Client.Read.Expected := 0;
Client.Read.First_Read := 0;
Client.Read.Free_To_Read := 0;
Client.Written.First_Written := 0;
Client.Written.Free_To_Write := 0;
Client.Written.Send_Blocked := False;
Free (Client.Transport);
end Clear;
procedure Close (Socket : in out Socket_Type) is
begin
if Socket /= No_Socket then
begin
Shutdown_Socket (Socket);
exception
when others =>
null;
end;
begin
Close_Socket (Socket);
exception
when others =>
null;
end;
Socket := No_Socket;
end if;
end Close;
procedure Connect
( Listener : in out Connections_Server;
Client : Connection_Ptr;
Host : String;
Port : Port_Type;
Max_Connect_No : Positive := Positive'Last;
Overlapped : Stream_Element_Count :=
Stream_Element_Count'Last
) is
Address : Sock_Addr_Type renames Client.Client_Address;
Option : Request_Type := (Non_Blocking_IO, True);
begin
if Client.Socket /= No_Socket then
Raise_Exception
( Use_Error'Identity,
"Connection " & Image (Address) & " is already in use"
);
end if;
Address.Addr := To_Addr (Host);
Address.Port := Port;
Create_Socket (Client.Socket);
Set_Socket_Option
( Client.Socket,
Socket_Level,
(Reuse_Address, True)
);
Control_Socket (Client.Socket, Option);
Connect_Parameters_Set
( Client.all,
Host,
Address,
Max_Connect_No
);
Client.Session := Session_Disconnected;
Client.Client := True;
Client.Connect_No := 0;
Client.Max_Connect_No := Max_Connect_No;
Client.Socket_Listener := Listener'Unchecked_Access;
Client.Overlapped_Read := Stream_Element_Count'Min
( Overlapped,
Client.Output_Size
);
Increment_Count (Client.all);
Listener.Request.Connect (Client);
end Connect;
procedure Connect_Error
( Client : in out Connection;
Error : Error_Type
) is
begin
null;
end Connect_Error;
procedure Connect_Parameters_Set
( Client : in out Connection;
Host : String;
Address : Sock_Addr_Type;
Max_Connect_No : Positive
) is
begin
null;
end Connect_Parameters_Set;
procedure Connected (Client : in out Connection) is
begin
null;
end Connected;
procedure Connected
( Listener : in out Connections_Server;
Client : in out Connection'Class
) is
begin
Client.Session := Session_Active;
end Connected;
function Create
( Factory : access Connections_Factory;
Listener : access Connections_Server'Class;
From : Sock_Addr_Type
) return Connection_Ptr is
begin
return null;
end Create;
procedure Create_Socket
( Listener : in out Connections_Server;
Socket : in out Socket_Type;
Address : Sock_Addr_Type
) is
begin
Create_Socket (Socket);
Set_Socket_Option (Socket, Socket_Level, (Reuse_Address, True));
Bind_Socket (Socket, Address);
Listen_Socket (Socket);
end Create_Socket;
function Create_Transport
( Factory : access Connections_Factory;
Listener : access Connections_Server'Class;
Client : access Connection'Class
) return Encoder_Ptr is
begin
return null;
end Create_Transport;
procedure Create_Transport (Client : in out Connection) is
begin
if Client.Transport /= null then
Raise_Exception
( Status_Error'Identity,
"Connection already has a transport layer"
);
end if;
Client.Transport :=
Create_Transport
( Client.Socket_Listener.Factory,
Client.Socket_Listener,
Client'Unchecked_Access
);
if Client.Transport = null then
Raise_Exception
( Status_Error'Identity,
"Connection transport layer is not supported"
);
end if;
Client.Session := Session_Handshaking;
if Client.Client then
Append
( Client.Socket_Listener.Postponed,
Client'Unchecked_Access,
Client.Socket_Listener.Postponed_Count
);
end if;
end Create_Transport;
procedure Data_Sent
( Listener : in out Connections_Server;
Client : Connection_Ptr
) is
begin
Client.Data_Sent := False;
Sent (Client.all);
end Data_Sent;
procedure Disconnected (Client : in out Connection) is
begin
null;
end Disconnected;
procedure Disconnected
( Listener : in out Connections_Server;
Client : in out Connection'Class
) is
begin
Client.Session := Session_Disconnected;
Remove (Listener.Postponed, Client, Listener.Postponed_Count);
end Disconnected;
procedure Downed
( Listener : in out Connections_Server;
Client : in out Connection'Class
) is
begin
Client.Session := Session_Down;
end Downed;
procedure Downed (Client : in out Connection) is
begin
null;
end Downed;
procedure Do_Connect
( Listener : in out Connections_Server'Class;
Client : in out Connection_Ptr
) is
Status : Selector_Status;
begin
Client.Connect_No := Client.Connect_No + 1;
Client.Session := Session_Connecting;
if Client.Connect_No > Client.Max_Connect_No then
Client.Try_To_Reconnect := False; -- Ensure connection killed
Save_Occurrence (Client.Last_Error, Null_Occurrence);
Stop (Listener, Client);
else
Clear (Client.all);
Connect_Socket
( Socket => Client.Socket,
Server => Client.Client_Address,
Timeout => 0.0,
Selector => Listener.Selector'Unchecked_Access,
Status => Status
);
if Status = Completed then
Set (Listener.Read_Sockets, Client.Socket);
On_Connected (Listener, Client.all);
end if;
end if;
exception
when Connection_Error =>
Client.Try_To_Reconnect := False; -- Ensure connection killed
Save_Occurrence (Client.Last_Error, Null_Occurrence);
Stop (Listener, Client);
when Error : Socket_Error =>
if Resolve_Exception (Error) = Operation_Now_In_Progress then
Trace_Sending
( Listener.Factory.all,
Client.all,
False,
", connecting to ..."
);
else
Trace_Error
( Listener.Factory.all,
"Connect socket",
Error
);
Client.Try_To_Reconnect := False; -- Ensure object killed
Save_Occurrence (Client.Last_Error, Error);
Stop (Listener, Client);
end if;
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Connect socket",
Error
);
Client.Try_To_Reconnect := False; -- Ensure connection killed
Save_Occurrence (Client.Last_Error, Error);
Stop (Listener, Client);
end Do_Connect;
procedure Elevated (Client : in out Connection) is
begin
null;
end Elevated;
procedure Fill_From_Stream
( Buffer : in out Output_Buffer;
Stream : in out Root_Stream_Type'Class;
Count : Stream_Element_Count;
Reserve : Stream_Element_Count;
Last : out Stream_Element_Offset;
Next : out Stream_Element_Offset;
Done : out Boolean
) is
begin
if Reserve >= Buffer.Written'Length then
Raise_Exception
( Data_Error'Identity,
( "Output buffer is too small for prefix and suffix ("
& Image (Reserve)
& ")"
) );
end if;
if Buffer.First_Written <= Buffer.Free_To_Write then
--
-- [ XXXXXXXXXXXXXXX ]
-- | |
-- First_Written Free_To_Write
--
declare
Tail : constant Stream_Element_Offset :=
Reserve + Buffer.Written'First - Buffer.First_Written;
begin
if Tail > 0 then
if Buffer.Free_To_Write + Tail = Buffer.Written'Last then
Done := False;
else
Next := Buffer.Written'Last - Tail;
if Count < Next - Buffer.Free_To_Write then
Next := Buffer.Free_To_Write + Count - 1;
end if;
Read
( Stream,
Buffer.Written (Buffer.Free_To_Write..Next),
Last
);
Done := Last < Next;
Next := Last + 1;
end if;
else
Next := Buffer.Written'Last;
if Count < Next - Buffer.Free_To_Write then
Next := Buffer.Free_To_Write + Count - 1;
end if;
Read
( Stream,
Buffer.Written (Buffer.Free_To_Write..Next),
Last
);
Done := Last < Next;
if Last < Buffer.Written'Last then
Next := Last + 1;
else
Next := Buffer.Written'First;
end if;
end if;
end;
else
--
-- [XXXXX XXXXXXX]
-- | |
-- Free_To_Write First_Written
--
if Buffer.Free_To_Write + Reserve >= Buffer.First_Written then
Done := False;
else
Next := Buffer.First_Written - Reserve;
if Count < Next - Buffer.Free_To_Write then
Next := Buffer.Free_To_Write + Count - 1;
end if;
Read
( Stream,
Buffer.Written (Buffer.Free_To_Write..Next),
Last
);
Done := Last < Next;
Next := Last + 1;
end if;
end if;
end Fill_From_Stream;
procedure Finalize (Listener : in out Connections_Server) is
procedure Free is
new Ada.Unchecked_Deallocation (Worker, Worker_Ptr);
begin
if Listener.Doer /= null then
Listener.Finalizing := True;
Abort_Selector (Listener.Selector);
while not Listener.Doer'Terminated loop
delay 0.001;
end loop;
Free (Listener.Doer);
end if;
Close_Selector (Listener.Selector);
end Finalize;
procedure Finalize (Client : in out Connection) is
begin
Close (Client.Socket);
Free (Client.Transport);
Object.Finalize (Object.Entity (Client));
end Finalize;
function Free (Buffer : Output_Buffer) return Stream_Element_Count is
begin
return Buffer.Written'Length - Used (Buffer) - 1;
end Free;
function From_String (Data : String) return Stream_Element_Array is
Result : Stream_Element_Array (1..Data'Length);
Pointer : Stream_Element_Offset := Result'First;
begin
for Index in Data'Range loop
Result (Pointer) := Character'Pos (Data (Index));
Pointer := Pointer + 1;
end loop;
return Result;
end From_String;
function Get_Client_Address (Client : Connection)
return Sock_Addr_Type is
begin
return Client.Client_Address;
end Get_Client_Address;
function Get_Clients_Count (Listener : Connections_Server)
return Natural is
begin
return Listener.Clients;
end Get_Clients_Count;
function Get_Client_Name
( Factory : Connections_Factory;
Client : Connection'Class
) return String is
begin
return Image (Client.Client_Address);
end Get_Client_Name;
function Get_Connections_Server (Client : Connection)
return Connections_Server_Ptr is
begin
return Client.Socket_Listener;
end Get_Connections_Server;
function Get_IO_Timeout (Factory : Connections_Factory)
return Duration is
begin
return 0.02;
end Get_IO_Timeout;
procedure Get_Occurrence
( Client : Connection;
Source : out Exception_Occurrence
) is
begin
Save_Occurrence (Source, Client.Last_Error);
end Get_Occurrence;
function Get_Overlapped_Size (Client : Connection)
return Stream_Element_Count is
begin
return Client.Overlapped_Read;
end Get_Overlapped_Size;
function Get_Polling_Timeout (Factory : Connections_Factory)
return Duration is
begin
return 0.5;
end Get_Polling_Timeout;
function Get_Server_Address
( Listener : Connections_Server
) return Sock_Addr_Type is
Address : Sock_Addr_Type;
begin
Address.Addr := Any_Inet_Addr;
Address.Port := Listener.Port;
return Address;
end Get_Server_Address;
function Get_Session_State (Client : Connection)
return Session_State is
Result : constant Session_State := Client.Session;
begin
if Result = Session_Down then
if Client.Socket = No_Socket then
return Session_Down;
else
return Session_Disconnected; -- Almost here
end if;
else
return Result;
end if;
end Get_Session_State;
function Get_Socket (Client : Connection) return Socket_Type is
begin
return Client.Socket;
end Get_Socket;
function Has_Data (Buffer : Input_Buffer) return Boolean is
begin
return
( Buffer.Free_To_Read /= Buffer.First_Read
and then
( Buffer.Expected = 0
or else
Used (Buffer) >= Buffer.Size - 1
) );
end Has_Data;
function Has_Data (Client : Connection) return Boolean is
begin
return Has_Data (Client.Read);
end Has_Data;
function Image (Code : Error_Type) return String is
Result : String := Error_Type'Image (Code);
begin
for Index in Result'First + 1..Result'Last loop
if Result (Index) = '_' then
Result (Index) := ' ';
else
Result (Index) := To_Lower (Result (Index));
end if;
end loop;
return Result;
end Image;
function Image
( Data : Stream_Element_Array;
Hexadecimal : Boolean := False
) return String is
begin
if Hexadecimal then
declare
Result : String (1..Data'Length * 3);
Pointer : Integer := 1;
begin
for Index in Data'Range loop
Put
( Destination => Result,
Pointer => Pointer,
Value => Integer (Data (Index)),
Base => 16,
Field => 2,
Fill => '0',
Justify => Right
);
Put
( Destination => Result,
Pointer => Pointer,
Value => " "
);
end loop;
return Result;
end;
else
declare
Length : Natural := 0;
begin
for Index in Data'Range loop
case Data (Index) is
when 32..36 | 38..126 =>
Length := Length + 1;
when others =>
Length := Length + 3;
end case;
end loop;
declare
Result : String (1..Length);
Pointer : Integer := 1;
begin
for Index in Data'Range loop
case Data (Index) is
when 32..36 | 38..126 =>
Put
( Destination => Result,
Pointer => Pointer,
Value => Character'Val (Data (Index))
);
when others =>
Put
( Destination => Result,
Pointer => Pointer,
Value => '%'
);
Put
( Destination => Result,
Pointer => Pointer,
Value => Integer (Data (Index)),
Base => 16,
Field => 2,
Fill => '0',
Justify => Right
);
end case;
end loop;
return Result;
end;
end;
end if;
end Image;
procedure Initialize (Listener : in out Connections_Server) is
begin
Listener.IO_Timeout := Get_IO_Timeout (Listener.Factory.all);
Listener.Polling_Timeout :=
Get_Polling_Timeout (Listener.Factory.all);
Create_Selector (Listener.Selector);
Listener.Doer := new Worker (Listener'Unchecked_Access);
end Initialize;
function Is_Connected (Client : Connection) return Boolean is
begin
return Client.Session in Session_Active..Session_Busy;
end Is_Connected;
function Is_Down (Client : Connection) return Boolean is
begin
return
( Client.Session = Session_Down
and then
Client.Socket = No_Socket
);
end Is_Down;
function Is_Elevated (Client : Connection) return Boolean is
begin
return Client.Transport /= null;
end Is_Elevated;
function Is_Incoming (Client : Connection) return Boolean is
begin
return not Client.Client;
end Is_Incoming;
function Is_Opportunistic (Client : Connection) return Boolean is
begin
return False;
end Is_Opportunistic;
function Is_TLS_Capable
( Factory : Connections_Factory
) return Boolean is
begin
return False;
end Is_TLS_Capable;
function Is_Trace_Received_On
( Factory : Connections_Factory;
Encoded : IO_Tracing_Mode
) return Boolean is
begin
return 0 /= (Factory.Trace_Flags and Receive_Masks (Encoded));
end Is_Trace_Received_On;
function Is_Trace_Sent_On
( Factory : Connections_Factory;
Encoded : IO_Tracing_Mode
) return Boolean is
begin
return 0 /= (Factory.Trace_Flags and Sent_Masks (Encoded));
end Is_Trace_Sent_On;
function Is_Unblock_Send_Queued
( Listener : Connections_Server
) return Boolean is
begin
return Listener.Unblock_Send;
end Is_Unblock_Send_Queued;
procedure Keep_On_Sending (Client : in out Connection) is
begin
Client.Dont_Block := True;
end Keep_On_Sending;
procedure On_Connected
( Listener : in out Connections_Server'Class;
Client : in out Connection'Class
) is
begin
Trace_Sending
( Listener.Factory.all,
Client,
False,
", connected"
);
Free (Client.Transport);
if not Is_Opportunistic (Client) then
Client.Transport :=
Create_Transport
( Listener.Factory,
Listener'Unchecked_Access,
Client'Unchecked_Access
);
end if;
Set (Listener.Read_Sockets, Client.Socket);
if Client.Transport = null then -- No handshaking
declare
Saved : constant Session_State := Client.Session;
begin
Client.Session := Session_Connected;
Connected (Client);
Connected (Listener, Client);
Client.Session := Session_Active;
Activated (Client);
exception
when others =>
if Client.Session in Session_Connected
.. Session_Active
then
Client.Session := Saved;
end if;
raise;
end;
else
Client.Session := Session_Handshaking;
Append
( Listener.Postponed,
Client'Unchecked_Access,
Listener.Postponed_Count
);
end if;
end On_Connected;
procedure On_Worker_Start (Listener : in out Connections_Server) is
begin
null;
end On_Worker_Start;
procedure Process
( Buffer : in out Input_Buffer;
Receiver : in out Connection'Class;
Data_Left : out Boolean
) is
Last : Stream_Element_Offset;
Pointer : Stream_Element_Offset;
begin
while Has_Data (Buffer) loop
if Buffer.Free_To_Read < Buffer.First_Read then
--
-- [XXXXXXXXXXXXXX XXXXX]
-- Free_To_Read | First_Read |
--
if Buffer.First_Read > Buffer.Read'Last then
--
-- [XXXXXXXXXXXXXX ]
-- Free_To_Read | First_Read |
--
Buffer.First_Read := Buffer.Read'First; -- Wrap
Last := Buffer.Free_To_Read - 1;
else
Last := Buffer.Read'Last;
end if;
else
--
-- [ XXXXXXXXX ]
-- First_Read | | Free_To_Read
--
Last := Buffer.Free_To_Read - 1;
end if;
Pointer := Last + 1;
Received
( Receiver,
Buffer.Read (Buffer.First_Read..Last),
Pointer
);
if Pointer < Buffer.First_Read or else Pointer > Last + 1 then
Raise_Exception
( Layout_Error'Identity,
( "Subscript error, pointer "
& Image (Pointer)
& " out of range "
& Image (Buffer.First_Read)
& ".."
& Image (Last)
& "+"
) );
elsif Pointer > Buffer.Read'Last then
if Buffer.Free_To_Read <= Buffer.Read'Last then
Buffer.First_Read := Buffer.Read'First; -- Wrap
else
Buffer.First_Read := Pointer; -- Not yet
end if;
else
Buffer.First_Read := Pointer;
end if;
if Pointer <= Last then -- Some input left unprocessed
Data_Left := True;
return;
end if;
end loop;
Data_Left := False;
end Process;
procedure Process
( Listener : in out Connections_Server;
Client : Connection_Ptr;
Data_Left : out Boolean
) is
begin
if Client.Transport = null then
Process (Client.Read, Client.all, Data_Left);
else
Process
( Client.Transport.all,
Listener,
Client.all,
Data_Left
);
end if;
end Process;
procedure Process_Packet (Client : in out Connection) is
begin
null;
end Process_Packet;
procedure Pull
( Buffer : in out Input_Buffer;
Data : in out Stream_Element_Array;
Pointer : in out Stream_Element_Offset
) is
Last : Stream_Element_Offset;
Offset : Stream_Element_Offset;
begin
while Pointer <= Data'Last and then Has_Data (Buffer) loop
if Buffer.Free_To_Read < Buffer.First_Read then
--
-- [XXXXXXXXXXXXXX XXXXX]
-- Free_To_Read | First_Read |
--
if Buffer.First_Read > Buffer.Read'Last then
--
-- [XXXXXXXXXXXXXX ]
-- Free_To_Read | First_Read |
--
Buffer.First_Read := Buffer.Read'First; -- Wrap
Last := Buffer.Free_To_Read - 1;
else
Last := Buffer.Read'Last;
end if;
else
--
-- [ XXXXXXXXX ]
-- First_Read | | Free_To_Read
--
Last := Buffer.Free_To_Read - 1;
end if;
Offset := Last - Buffer.First_Read;
if Offset > Data'Last - Pointer then
Offset := Data'Last - Pointer;
Last := Buffer.First_Read + Offset;
end if;
Data (Pointer..Pointer + Offset) :=
Buffer.Read (Buffer.First_Read..Last);
Pointer := Pointer + Offset + 1;
if Last >= Buffer.Read'Last then
if Buffer.Free_To_Read <= Buffer.Read'Last then
Buffer.First_Read := Buffer.Read'First; -- Wrap
else
Buffer.First_Read := Last + 1; -- Not yet
end if;
else
Buffer.First_Read := Last + 1;
end if;
end loop;
end Pull;
procedure Push
( Client : in out Connection;
Data : Stream_Element_Array;
Last : out Stream_Element_Offset
) is
begin
if Client.Transport = null then
Send_Socket (Client.Socket_Listener.all, Client, Data, Last);
else
Encode (Client.Transport.all, Client, Data, Last);
end if;
if Last + 1 /= Data'First then
Client.Data_Sent := True;
if ( 0
/= ( Client.Socket_Listener.Factory.Trace_Flags
and
Trace_Decoded_Sent
) )
then
Trace_Sent
( Factory => Client.Socket_Listener.Factory.all,
Client => Client,
Data => Data,
From => Data'First,
To => Last,
Encoded => False
);
end if;
end if;
end Push;
procedure Queue
( Client : in out Connection;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset
) is
Buffer : Output_Buffer renames Client.Written;
Free : Stream_Element_Offset;
Count : Stream_Element_Offset := Data'Last - Pointer + 1;
begin
if Buffer.First_Written = Buffer.Free_To_Write then
--
-- Moving First_Written as far back as possible to diminish
-- buffer fragmenting. We cannot move it further than the
-- number of elements we put there, because of race condition,
-- when Free_To_Write is not yet set. But when Free_To_Write
-- points into the elements written everything is OK
--
-- [ ............ ]
-- |<--Count-->|
-- | Free_To_Write = First_Written
-- new First_Written
--
Count :=
Stream_Element_Offset'Min
( Buffer.Written'Length - 1,
Count
);
Free := Stream_Element_Offset'Max
( Buffer.Written'First,
Buffer.Free_To_Write - Count
);
Buffer.Written (Free..Free + Count - 1) :=
Data (Pointer..Pointer + Count - 1);
Pointer := Pointer + Count;
Buffer.First_Written := Free;
Buffer.Free_To_Write := Free + Count;
return;
elsif Buffer.First_Written < Buffer.Free_To_Write then
--
-- [ XXXXXXXXXXXXXXX ]
-- | |
-- First_Written Free_To_Write
--
Free :=
( Buffer.Written'Length
- Buffer.Free_To_Write
+ Buffer.First_Written
- 1 -- Last element is never written
);
if Free <= 0 then
return;
end if;
declare
Tail : constant Stream_Element_Offset :=
Stream_Element_Offset'Min
( Buffer.Written'Last - Buffer.Free_To_Write + 1,
Free
);
begin
if Count <= Tail then -- Can queue all Count elements
Buffer.Written
( Buffer.Free_To_Write
.. Buffer.Free_To_Write + Count - 1
) := Data (Pointer..Data'Last);
Pointer := Data'Last + 1;
Free := Buffer.Free_To_Write + Count;
if Free > Buffer.Written'Last then
Buffer.Free_To_Write := Buffer.Written'First;
else
Buffer.Free_To_Write := Free;
end if;
return;
end if; -- Can queue only Tail elements
Buffer.Written
( Buffer.Free_To_Write
.. Buffer.Free_To_Write + Tail - 1
) := Data (Pointer..Pointer + Tail - 1);
Pointer := Pointer + Tail;
Count := Count - Tail;
Free := Free - Tail;
if Buffer.Free_To_Write + Tail > Buffer.Written'Last then
Buffer.Free_To_Write := Buffer.Written'First;
else
Buffer.Free_To_Write := Buffer.Free_To_Write + Tail;
end if;
end;
else
--
-- [XXXXX XXXXXXXX]
-- | |
-- Free_To_Write First_Written
--
Free :=
( Buffer.First_Written
+ Buffer.Free_To_Write
- 1 -- Last element is never written
);
end if;
if Free <= 0 then
return;
end if;
Count := Stream_Element_Offset'Min (Count, Free);
Buffer.Written
( Buffer.Free_To_Write
.. Buffer.Free_To_Write + Count - 1
) := Data (Pointer..Pointer + Count - 1);
Pointer := Pointer + Count;
Buffer.Free_To_Write := Buffer.Free_To_Write + Count;
end Queue;
function Queued_To_Send (Client : Connection)
return Stream_Element_Count is
begin
return Used (Client.Written);
end Queued_To_Send;
procedure Read
( Client : in out Connection;
Factory : in out Connections_Factory'Class
) is
Buffer : Input_Buffer renames Client.Read;
Last : Stream_Element_Offset;
begin
if Client.Overlapped_Read < Queued_To_Send (Client) then
return; -- Not ready to read yet
elsif Buffer.Free_To_Read < Buffer.First_Read then
--
-- [XXXXXXXXXXXXXX XXXXX]
-- Free_To_Read | First_Read |
--
Last := Buffer.First_Read - 2;
if Last <= Buffer.First_Read then -- Read buffer is full
return;
end if;
else
--
-- [ XXXXXXXXX ]
-- First_Read | | Free_To_Read
--
if ( Buffer.Free_To_Read - Buffer.First_Read
>= Buffer.Read'Length
)
then -- Read buffer is full
return;
elsif Buffer.Free_To_Read > Buffer.Read'Last then -- Wrap
Buffer.Free_To_Read := Buffer.Read'First;
Last := Buffer.First_Read - 2;
else
Last := Buffer.Read'Last;
end if;
end if;
Receive_Socket
( Client.Socket_Listener.all,
Client,
Buffer.Read (Buffer.Free_To_Read..Last),
Last
);
Received
( Factory,
Client,
Buffer.Read,
Buffer.Free_To_Read,
Last
);
if Last = Buffer.Free_To_Read - 1 then -- Nothing read
raise Connection_Error;
end if;
Buffer.Expected :=
Stream_Element_Offset'Max
( Buffer.Expected - (Last - Buffer.Free_To_Read + 1),
0
);
Buffer.Free_To_Read := Last + 1;
exception
when Error : Socket_Error | Layout_Error =>
Receive_Error (Client, Error);
raise Connection_Error;
end Read;
procedure Receive_Socket
( Listener : in out Connections_Server;
Client : in out Connection'Class;
Data : in out Stream_Element_Array;
Last : out Stream_Element_Offset
) is
begin
Receive_Socket (Client.Socket, Data, Last);
end Receive_Socket;
procedure Received
( Factory : in out Connections_Factory;
Client : in out Connection'Class;
Data : Stream_Element_Array;
From : Stream_Element_Offset;
To : Stream_Element_Offset
) is
begin
if Client.Transport = null then
if 0 /= (Factory.Trace_Flags and Trace_Decoded_Received) then
Trace_Received
( Factory => Connections_Factory'Class (Factory),
Client => Client,
Data => Data,
From => From,
To => To,
Encoded => False
);
end if;
else
if 0 /= (Factory.Trace_Flags and Trace_Encoded_Received) then
Trace_Received
( Factory => Connections_Factory'Class (Factory),
Client => Client,
Data => Data,
From => From,
To => To,
Encoded => True
);
end if;
end if;
end Received;
procedure Reconnect (Client : in out Connection) is
begin
if Client.Socket = No_Socket then
Raise_Exception
( Use_Error'Identity,
"No connection"
);
elsif not Client.Client then
Raise_Exception
( Mode_Error'Identity,
"Server connection"
);
elsif Client.Session /= Session_Down then
if Client.Socket_Listener /= null then
Request_Disconnect
( Client.Socket_Listener.all,
Client,
True
);
return;
end if;
Client.Session := Session_Down;
end if;
Raise_Exception
( Status_Error'Identity,
"Downed connection"
);
end Reconnect;
procedure Received
( Client : in out Connection;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset
) is
begin
raise Connection_Error;
end Received;
procedure Released (Client : in out Connection) is
begin
null;
end Released;
procedure Remove
( List : in out Connection_Ptr;
Item : in out Connection'Class;
Count : in out Integer
) is
begin
if Item.Successor /= null then
Count := Count - 1;
if List = Item.Successor.Predecessor then -- First in the list
if List = List.Successor then -- The single item of the list
List := null;
Item.Successor := null;
return;
else
List := Item.Successor;
end if;
end if;
Item.Predecessor.Successor := Item.Successor;
Item.Successor.Predecessor := Item.Predecessor;
Item.Successor := null;
end if;
end Remove;
procedure Receive_Error
( Client : in out Connection;
Occurrence : Exception_Occurrence
) is
begin
null;
end Receive_Error;
procedure Request_Disconnect
( Listener : in out Connections_Server;
Client : in out Connection'Class;
Reconnect : Boolean
) is
begin
Client.Failed := True;
if Reconnect then
Client.Try_To_Reconnect := True;
Client.Action_Request := Reconnect_Connection;
else
Client.Try_To_Reconnect := False;
Client.Action_Request := Shutdown_Connection;
end if;
Client.Socket_Listener.Shutdown_Request := True;
if Client.Socket_Listener.Doer /= null then
Abort_Selector (Client.Socket_Listener.Selector);
end if;
end Request_Disconnect;
procedure Save_Occurrence
( Client : in out Connection;
Source : Exception_Occurrence
) is
begin
Save_Occurrence (Client.Last_Error, Source);
end Save_Occurrence;
procedure Send
( Client : in out Connection;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset
) is
Buffer : Output_Buffer renames Client.Written;
begin
if ( Pointer < Data'First
or else
( Pointer > Data'Last
and then
Pointer - 1 > Data'Last
) )
then
Raise_Exception (Layout_Error'Identity, "Subscript error");
end if;
Queue (Client, Data, Pointer);
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Data : String;
Pointer : in out Integer
) is
Buffer : Output_Buffer renames Client.Written;
begin
Pointer := Data'Last + 1;
for Index in Data'Range loop
if Used (Buffer) + 1 >= Buffer.Written'Length then
Pointer := Index;
exit;
end if;
Buffer.Written (Buffer.Free_To_Write) :=
Stream_Element (Character'Pos (Data (Index)));
if Buffer.Free_To_Write = Buffer.Written'Last then
Buffer.Free_To_Write := Buffer.Written'First;
else
Buffer.Free_To_Write := Buffer.Free_To_Write + 1;
end if;
end loop;
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
End_Of_Stream : out Boolean
) is
Buffer : Output_Buffer renames Client.Written;
Last : Stream_Element_Offset;
Next : Stream_Element_Offset;
begin
Fill_From_Stream
( Buffer => Buffer,
Stream => Stream,
Count => Stream_Element_Count'Last,
Reserve => 1,
Last => Last,
Next => Next,
Done => End_Of_Stream
);
Buffer.Free_To_Write := Next;
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
Count : in out Stream_Element_Count;
End_Of_Stream : out Boolean
) is
Buffer : Output_Buffer renames Client.Written;
Last : Stream_Element_Offset;
Next : Stream_Element_Offset;
begin
Fill_From_Stream
( Buffer => Buffer,
Stream => Stream,
Count => Count,
Reserve => 1,
Last => Last,
Next => Next,
Done => End_Of_Stream
);
Count := Count - (Last + 1 - Buffer.Free_To_Write);
Buffer.Free_To_Write := Next;
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
Reserve : Stream_Element_Count;
Get_Prefix : Create_Stream_Element_Array;
Get_Suffix : Create_Stream_Element_Array;
End_Of_Stream : out Boolean
) is
Count : Stream_Element_Count := Stream_Element_Count'Last;
begin
Send
( Client => Client,
Stream => Stream,
Count => Count,
Reserve => Reserve,
Get_Prefix => Get_Prefix,
Get_Suffix => Get_Suffix,
End_Of_Stream => End_Of_Stream
);
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
Count : in out Stream_Element_Count;
Reserve : Stream_Element_Count;
Get_Prefix : Create_Stream_Element_Array;
Get_Suffix : Create_Stream_Element_Array;
End_Of_Stream : out Boolean
) is
Buffer : Output_Buffer renames Client.Written;
Last : Stream_Element_Offset;
Next : Stream_Element_Offset;
begin
if Buffer.Free_To_Write = Buffer.First_Written then
if Buffer.Written'Length <= Reserve then
Raise_Exception
( Data_Error'Identity,
( "Output buffer size"
& Stream_Element_Count'Image (Buffer.Written'Length)
& " is less than required"
& Stream_Element_Count'Image (Reserve + 1)
& " elements"
) );
end if;
Fill_From_Stream
( Buffer => Buffer,
Stream => Stream,
Count => Count,
Reserve => Reserve + 1,
Last => Last,
Next => Next,
Done => End_Of_Stream
);
Count := Count - (Last + 1 - Buffer.Free_To_Write);
declare
Header : constant Stream_Element_Array :=
Get_Prefix.all
( Client'Unchecked_Access,
Buffer.Written (Buffer.Free_To_Write..Last),
End_Of_Stream
);
Tail : constant Stream_Element_Array :=
Get_Suffix.all
( Client'Unchecked_Access,
Buffer.Written (Buffer.Free_To_Write..Last),
End_Of_Stream
);
begin
if Header'Length + Tail'Length > Reserve then
Raise_Exception
( Data_Error'Identity,
( "Prefix returns more than"
& Stream_Element_Count'Image (Reserve)
& " elements"
) );
elsif Header'Length > 0 then
Last := Buffer.First_Written;
for Index in reverse Header'Range loop
if Last = Buffer.Written'First then
Last := Buffer.Written'Last;
else
Last := Last - 1;
end if;
Buffer.Written (Last) := Header (Index);
end loop;
end if;
Buffer.First_Written := Last;
Buffer.Free_To_Write := Next;
if Tail'Length > 0 then
Last := Tail'First;
Queue (Client, Tail, Last);
end if;
end;
else
End_Of_Stream := False;
end if;
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
Count : in out Stream_Element_Count;
Reserve : Natural;
Get_Prefix : Create_String;
Get_Suffix : Create_String;
End_Of_Stream : out Boolean
) is
Buffer : Output_Buffer renames Client.Written;
Last : Stream_Element_Offset;
Next : Stream_Element_Offset;
begin
if Buffer.Free_To_Write = Buffer.First_Written then
if Buffer.Written'Length <= Reserve then
Raise_Exception
( Data_Error'Identity,
( "Output buffer size"
& Stream_Element_Count'Image (Buffer.Written'Length)
& " is less than required"
& Integer'Image (Reserve + 1)
& " elements"
) );
end if;
Fill_From_Stream
( Buffer => Buffer,
Stream => Stream,
Count => Count,
Reserve => Stream_Element_Count (Reserve) + 1,
Last => Last,
Next => Next,
Done => End_Of_Stream
);
Count := Count - (Last + 1 - Buffer.Free_To_Write);
declare
Header : constant String :=
Get_Prefix.all
( Client'Unchecked_Access,
Buffer.Written (Buffer.Free_To_Write..Last),
End_Of_Stream
);
Tail : constant String :=
Get_Suffix.all
( Client'Unchecked_Access,
Buffer.Written (Buffer.Free_To_Write..Last),
End_Of_Stream
);
begin
if Header'Length + Tail'Length > Reserve then
Raise_Exception
( Data_Error'Identity,
( "Prefix returns more than"
& Integer'Image (Reserve)
& " elements"
) );
elsif Header'Length > 0 then
Last := Buffer.First_Written;
for Index in reverse Header'Range loop
if Last = Buffer.Written'First then
Last := Buffer.Written'Last;
else
Last := Last - 1;
end if;
Buffer.Written (Last) :=
Stream_Element (Character'Pos (Header (Index)));
end loop;
end if;
Buffer.First_Written := Last;
Buffer.Free_To_Write := Next;
if Tail'Length > 0 then
declare
Pointer : Integer := Tail'First;
begin
Send (Client, Tail, Pointer);
end;
end if;
end;
else
End_Of_Stream := False;
end if;
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
Reserve : Natural;
Get_Prefix : Create_String;
Get_Suffix : Create_String;
End_Of_Stream : out Boolean
) is
Count : Stream_Element_Count := Stream_Element_Count'Last;
begin
Send
( Client => Client,
Stream => Stream,
Count => Count,
Reserve => Reserve,
Get_Prefix => Get_Prefix,
Get_Suffix => Get_Suffix,
End_Of_Stream => End_Of_Stream
);
end Send;
procedure Send_Error
( Client : in out Connection;
Occurrence : Exception_Occurrence
) is
begin
null;
end Send_Error;
procedure Send_Socket
( Listener : in out Connections_Server;
Client : in out Connection'Class;
Data : Stream_Element_Array;
Last : out Stream_Element_Offset
) is
begin
Send_Socket (Client.Socket, Data, Last);
end Send_Socket;
procedure Sent (Client : in out Connection) is
begin
null;
end Sent;
procedure Set_Client_Data
( Client : in out Connection;
Address : Sock_Addr_Type;
Listener : Connections_Server_Ptr
) is
begin
if Client.Socket_Listener /= null then
Raise_Exception
( Constraint_Error'Identity,
"The client has a connections server set"
);
end if;
Client.Client_Address := Address;
Client.Socket_Listener := Listener;
end Set_Client_Data;
procedure Set_Expected_Count
( Client : in out Connection;
Count : Stream_Element_Count
) is
begin
Client.Read.Expected := Count;
end Set_Expected_Count;
procedure Service_Postponed (Listener : in out Connections_Server) is
Leftover : Connection_Ptr;
Client : Connection_Ptr;
Data_Left : Boolean;
begin
loop
Client := Listener.Postponed;
exit when Client = null;
Remove
( Listener.Postponed,
Client.all,
Listener.Postponed_Count
);
begin
Process
( Connections_Server'Class (Listener),
Client,
Data_Left
);
if Data_Left then
Append (Leftover, Client, Listener.Postponed_Count);
end if;
exception
when Connection_Error =>
Stop (Listener, Client);
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Postponed service",
Error
);
Stop (Listener, Client);
end;
end loop;
Listener.Postponed := Leftover;
end Service_Postponed;
procedure Set_Failed
( Client : in out Connection;
Error : Exception_Occurrence
) is
begin
Save_Occurrence (Client.Last_Error, Error);
Client.Failed := True;
end Set_Failed;
procedure Set_Overlapped_Size
( Client : in out Connection;
Size : Stream_Element_Count
) is
begin
Client.Overlapped_Read := Size;
end Set_Overlapped_Size;
procedure Shutdown (Client : in out Connection) is
begin
if Client.Session /= Session_Down then
if Client.Socket_Listener = null then
Client.Session := Session_Down;
else
Request_Disconnect
( Client.Socket_Listener.all,
Client,
False
);
Shutdown (Client.Socket_Listener.all, Client);
end if;
end if;
end Shutdown;
procedure Shutdown
( Listener : in out Connections_Server;
Client : in out Connection'Class
) is
begin
null;
end Shutdown;
procedure Stop
( Listener : in out Connections_Server'Class;
Client : in out Connection_Ptr
) is
Old_Socket : constant Socket_Type := Client.Socket;
Reconnect : Boolean :=
Client.Action_Request /= Shutdown_Connection;
begin
Trace_Sending
( Listener.Factory.all,
Client.all,
False,
", dropping connection"
);
Client.Action_Request := Keep_Connection;
Clear (Listener.Read_Sockets, Client.Socket);
Clear (Listener.Blocked_Sockets, Client.Socket);
Clear (Listener.Ready_To_Read, Client.Socket);
Clear (Listener.Ready_To_Write, Client.Socket);
Clear (Listener.Write_Sockets, Client.Socket);
Clear (Listener.Ready_To_Write, Client.Socket);
Free (Client.Transport);
if Client.Session in Session_Connected..Session_Busy then
begin
Disconnected (Listener, Client.all);
exception
when Connection_Error =>
Reconnect := False;
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Disconnected (server)",
Error
);
end;
begin -- Disconnected
Client.Session := Session_Disconnected;
Disconnected (Client.all);
exception
when Connection_Error =>
Reconnect := False;
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Disconnected (client)",
Error
);
end;
end if;
if Client.Client then -- Try to reconnect
if ( Reconnect
and then
not Listener.Finalizing
and then
Client.Try_To_Reconnect
and then
Client.Session /= Session_Down
and then
Client.Action_Request /= Shutdown_Connection
)
then
begin
Close (Client.Socket);
declare
Option : Request_Type := (Non_Blocking_IO, True);
begin
Create_Socket (Client.Socket);
Set_Socket_Option
( Client.Socket,
Socket_Level,
(Reuse_Address, True)
);
end;
if Old_Socket /= Client.Socket then -- Move client
Put (Listener.Connections, Client.Socket, Client);
Put (Listener.Connections, Old_Socket, null);
end if;
Set (Listener.Write_Sockets, Client.Socket);
Do_Connect (Listener, Client);
return;
exception
when Error : Socket_Error => -- Kill the object
Trace_Error
( Listener.Factory.all,
"Reconnecting",
Error
);
end;
end if;
Listener.Servers := Listener.Servers - 1;
else
Listener.Clients := Listener.Clients - 1;
end if;
Close (Client.Socket);
Client.Session := Session_Down;
Client.Failed := False;
Client.Action_Request := Keep_Connection;
begin
Downed (Listener, Client.all);
exception
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Downed (server)",
Error
);
end;
begin
Downed (Client.all);
exception
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Downed (client)",
Error
);
end;
begin
Released (Client.all);
exception
when others =>
null;
end;
if Get (Listener.Connections, Old_Socket) = Client then
Put (Listener.Connections, Old_Socket, null);
end if;
Client := null;
exception
when Error : others =>
Trace_Error (Listener.Factory.all, "Stopping", Error);
raise;
end Stop;
function To_Addr (Host : String) return Inet_Addr_Type is
begin
for Index in Host'Range loop
case Host (Index) is
when '.' | '0'..'9' =>
null;
when others =>
return Addresses (Get_Host_By_Name (Host), 1);
end case;
end loop;
return Inet_Addr (Host);
end To_Addr;
function To_String (Data : Stream_Element_Array) return String is
Result : String (1..Data'Length);
Index : Integer := Result'First;
begin
for Item in Data'Range loop
Result (Index) := Character'Val (Data (Item));
Index := Index + 1;
end loop;
return Result;
end To_String;
procedure Trace
( Factory : in out Connections_Factory;
Message : String
) is
use Ada.Text_IO;
begin
if 0 /= (Factory.Trace_Flags and Standard_Output) then
Put_Line (Message);
end if;
if Is_Open (Factory.Trace_File) then
Put_Line (Factory.Trace_File, Message);
end if;
end Trace;
procedure Trace_Error
( Factory : in out Connections_Factory;
Context : String;
Occurrence : Exception_Occurrence
) is
begin
Trace
( Connections_Factory'Class (Factory),
Context & ": " & Exception_Information (Occurrence)
);
end Trace_Error;
procedure Trace_Off (Factory : in out Connections_Factory) is
use Ada.Text_IO;
begin
if Is_Open (Factory.Trace_File) then
Close (Factory.Trace_File);
end if;
Factory.Trace_Flags :=
Factory.Trace_Flags and not Standard_Output;
end Trace_Off;
procedure Trace_On
( Factory : in out Connections_Factory;
Received : IO_Tracing_Mode := Trace_None;
Sent : IO_Tracing_Mode := Trace_None
) is
Flags : Factory_Flags := Standard_Output;
begin
case Received is
when Trace_Any =>
Flags := Flags
or Trace_Decoded_Received
or Trace_Encoded_Received;
when Trace_Decoded =>
Flags := Flags or Trace_Decoded_Received;
when Trace_Encoded =>
Flags := Flags or Trace_Encoded_Received;
when Trace_None =>
null;
end case;
case Sent is
when Trace_Any =>
Flags := Flags or Trace_Decoded_Sent or Trace_Encoded_Sent;
when Trace_Decoded =>
Flags := Flags or Trace_Decoded_Sent;
when Trace_Encoded =>
Flags := Flags or Trace_Encoded_Sent;
when Trace_None =>
null;
end case;
Factory.Trace_Flags := Flags;
end Trace_On;
procedure Trace_On
( Factory : in out Connections_Factory;
Name : String;
Received : IO_Tracing_Mode := Trace_None;
Sent : IO_Tracing_Mode := Trace_None
) is
use Ada.Text_IO;
Flags : Factory_Flags := 0;
begin
if Is_Open (Factory.Trace_File) then
Close (Factory.Trace_File);
end if;
Create (File => Factory.Trace_File, Name => Name);
case Received is
when Trace_Any =>
Flags := Flags
or Trace_Decoded_Received
or Trace_Encoded_Received;
when Trace_Decoded =>
Flags := Flags or Trace_Decoded_Received;
when Trace_Encoded =>
Flags := Flags or Trace_Encoded_Received;
when Trace_None =>
null;
end case;
case Sent is
when Trace_Any =>
Flags := Flags or Trace_Decoded_Sent or Trace_Encoded_Sent;
when Trace_Decoded =>
Flags := Flags or Trace_Decoded_Sent;
when Trace_Encoded =>
Flags := Flags or Trace_Encoded_Sent;
when Trace_None =>
null;
end case;
Factory.Trace_Flags := Flags;
end Trace_On;
procedure Trace_Received
( Factory : in out Connections_Factory;
Client : Connection'Class;
Data : Stream_Element_Array;
From : Stream_Element_Offset;
To : Stream_Element_Offset;
Encoded : Boolean := False
) is
This : Connections_Factory'Class renames
Connections_Factory'Class (Factory);
begin
if Encoded then
Trace
( This,
( Get_Client_Name (This, Client)
& " encoded> |"
& Image (Data (From..To))
& "| "
& Image (From)
& ".."
& Image (To)
) );
else
Trace
( This,
( Get_Client_Name (This, Client)
& " > |"
& Image (Data (From..To))
& "| "
& Image (From)
& ".."
& Image (To)
) );
end if;
end Trace_Received;
procedure Trace_Sending
( Factory : in out Connections_Factory;
Client : Connection'Class;
Enabled : Boolean;
Reason : String
) is
This : Connections_Factory'Class renames
Connections_Factory'Class (Factory);
begin
if Enabled then
Trace
( This,
( Get_Client_Name (This, Client)
& " < +++ Resume polling"
& Reason
) );
else
Trace
( This,
( Get_Client_Name (This, Client)
& " < --- Stop polling"
& Reason
) );
end if;
end Trace_Sending;
procedure Trace_Sent
( Factory : in out Connections_Factory;
Client : Connection'Class;
Data : Stream_Element_Array;
From : Stream_Element_Offset;
To : Stream_Element_Offset;
Encoded : Boolean := False
) is
This : Connections_Factory'Class renames
Connections_Factory'Class (Factory);
begin
if Encoded then
Trace
( This,
( Get_Client_Name (This, Client)
& " <encoded |"
& Image (Data (From..To))
& "| "
& Image (From)
& ".."
& Image (To)
) );
else
Trace
( This,
( Get_Client_Name (This, Client)
& " < |"
& Image (Data (From..To))
& "| "
& Image (From)
& ".."
& Image (To)
) );
end if;
end Trace_Sent;
procedure Trace_Service_Loop
( Factory : in out Connections_Factory;
Stage : Service_Loop_Stage;
Server : in out Connections_Server'Class
) is
begin
null;
end Trace_Service_Loop;
procedure Unblock_Send
( Listener : in out Connections_Server;
Client : in out Connection'Class
) is
Buffer : Output_Buffer renames Client.Written;
begin
if Buffer.Send_Blocked then -- Request socket unblocking
Buffer.Send_Blocked := False;
Listener.Unblock_Send := True;
if Listener.Doer /= null then
Abort_Selector (Listener.Selector);
end if;
end if;
end Unblock_Send;
procedure Unblock_Send (Client : in out Connection) is
begin
Unblock_Send (Client.Socket_Listener.all, Client);
end Unblock_Send;
function Used (Buffer : Input_Buffer) return Stream_Element_Count is
Diff : constant Stream_Element_Offset :=
Buffer.Free_To_Read - Buffer.First_Read;
begin
if Diff < 0 then
return Buffer.Read'Length - Diff;
else
return Diff;
end if;
end Used;
function Used (Buffer : Output_Buffer) return Stream_Element_Count is
begin
if Buffer.Free_To_Write >= Buffer.First_Written then
return Buffer.Free_To_Write - Buffer.First_Written;
else
return Buffer.Written'Length - Buffer.First_Written +
Buffer.Free_To_Write;
end if;
end Used;
procedure Write
( Client : in out Connection;
Factory : in out Connections_Factory'Class;
Blocked : out Boolean
) is
Buffer : Output_Buffer renames Client.Written;
Next : Stream_Element_Count;
begin
Blocked := Buffer.First_Written = Buffer.Free_To_Write;
if Blocked then
if Client.Dont_Block then
Blocked := False;
Client.Data_Sent := True;
Client.Dont_Block := False;
end if;
else
loop
if Buffer.First_Written > Buffer.Free_To_Write then
--
-- [XXXXX XXXXXXX]
-- | |
-- Free_To_Write First_Written
--
if Client.Transport = null then
Send_Socket
( Client.Socket_Listener.all,
Client,
Buffer.Written
( Buffer.First_Written
.. Buffer.Written'Last
),
Next
);
else
Encode
( Client.Transport.all,
Client,
Buffer.Written
( Buffer.First_Written
.. Buffer.Written'Last
),
Next
);
end if;
Next := Next + 1;
if Next = Buffer.First_Written then
exit; -- Cannot send anything right now
elsif Next <= Buffer.Written'Last then
if 0 /= (Factory.Trace_Flags and Trace_Decoded_Sent)
then
Trace_Sent
( Factory => Factory,
Client => Client,
Data => Buffer.Written,
From => Buffer.First_Written,
To => Next - 1,
Encoded => False
);
end if;
Buffer.First_Written := Next;
Client.Data_Sent := True;
exit;
end if;
if 0 /= (Factory.Trace_Flags and Trace_Decoded_Sent) then
Trace_Sent
( Factory => Factory,
Client => Client,
Data => Buffer.Written,
From => Buffer.First_Written,
To => Next - 1,
Encoded => False
);
end if;
Buffer.First_Written := 0;
Client.Data_Sent := True;
else
--
-- [ XXXXXXXXXXXXXXX ]
-- | |
-- First_Written Free_To_Write
--
if Client.Transport = null then
Send_Socket
( Client.Socket_Listener.all,
Client,
Buffer.Written
( Buffer.First_Written
.. Buffer.Free_To_Write - 1
),
Next
);
else
Encode
( Client.Transport.all,
Client,
Buffer.Written
( Buffer.First_Written
.. Buffer.Free_To_Write - 1
),
Next
);
end if;
Next := Next + 1;
if Next = Buffer.First_Written then
exit;
elsif Next <= Buffer.Free_To_Write then
if 0 /= (Factory.Trace_Flags and Trace_Decoded_Sent)
then
Trace_Sent
( Factory => Factory,
Client => Client,
Data => Buffer.Written,
From => Buffer.First_Written,
To => Next - 1,
Encoded => False
);
end if;
Buffer.First_Written := Next;
Client.Data_Sent := True;
exit;
end if;
if 0 /= (Factory.Trace_Flags and Trace_Decoded_Sent) then
Trace_Sent
( Factory => Factory,
Client => Client,
Data => Buffer.Written,
From => Buffer.First_Written,
To => Next - 1,
Encoded => False
);
end if;
Buffer.First_Written := Next;
Client.Data_Sent := True;
end if;
exit when Buffer.First_Written = Buffer.Free_To_Write;
end loop;
end if;
end Write;
task body Worker is
Address : Sock_Addr_Type :=
Get_Server_Address (Listener.all);
Server_Socket : Socket_Type := No_Socket;
Client_Socket : Socket_Type;
That_Time : Time := Clock;
This_Time : Time;
Status : Selector_Status;
function Set_Image (Socket : Socket_Type) return String is
begin
return
( Image (Socket)
& ", listener"
& " read: " & Image (Listener.Read_Sockets)
& ", write: " & Image (Listener.Write_Sockets)
& ", blocked: " & Image (Listener.Blocked_Sockets)
& ", ready"
& " read: " & Image (Listener.Ready_To_Read)
& ", write: " & Image (Listener.Ready_To_Write)
);
end Set_Image;
procedure Check (Sockets : Socket_Set_Type) is
Socket : Socket_Type;
List : Socket_Set_Type := Sockets;
begin
loop
Get (List, Socket);
exit when Socket = No_Socket;
if Socket /= Server_Socket then
declare
Client : Connection_Ptr :=
Get (Listener.Connections, Socket);
begin
if Client = null then
Trace
( Listener.Factory.all,
( "Missing client when checking socket "
& Set_Image (Socket)
) );
Clear (Listener.Read_Sockets, Socket);
Clear (Listener.Write_Sockets, Socket);
Clear (Listener.Blocked_Sockets, Socket);
elsif Client.Failed then
if ( Client.Action_Request = Keep_Connection
and then
( Exception_Identity (Client.Last_Error)
/= Connection_Error'Identity
) )
then
Trace_Error
( Listener.Factory.all,
"Dropping connection on request",
Client.Last_Error
);
end if;
Stop (Listener.all, Client);
end if;
end;
end if;
end loop;
end Check;
procedure Unblock (Requested_Only : Boolean) is
Socket : Socket_Type;
begin
while not Listener.Finalizing loop
Get (Listener.Blocked_Sockets, Socket);
exit when Socket = No_Socket;
if Socket /= Server_Socket then
declare
Client : Connection_Ptr :=
Get (Listener.Connections, Socket);
begin
if Client = null then
Trace
( Listener.Factory.all,
( "Missing client when unblocking socket "
& Set_Image (Socket)
) );
Clear (Listener.Read_Sockets, Socket);
Clear (Listener.Write_Sockets, Socket);
Clear (Listener.Ready_To_Write, Socket);
elsif Client.Failed then
if ( Client.Session /= Session_Down
and then
Client.Action_Request = Keep_Connection
and then
( Exception_Identity (Client.Last_Error)
/= Connection_Error'Identity
) )
then
Trace_Error
( Listener.Factory.all,
"Unblocking socket",
Client.Last_Error
);
end if;
Stop (Listener.all, Client);
elsif ( Requested_Only
and then
Client.Written.Send_Blocked
) then -- Keep it blocked
Set (Listener.Ready_To_Read, Client.Socket);
else -- Unblock
Set (Listener.Write_Sockets, Client.Socket);
Set (Listener.Ready_To_Write, Client.Socket);
Status := Completed; -- Make sure it written later
Client.Written.Send_Blocked := False;
Client.Data_Sent := True;
if ( 0
/= ( Listener.Factory.Trace_Flags
and
(Trace_Encoded_Sent or Trace_Decoded_Sent)
) )
then
if Requested_Only then
Trace_Sending
( Listener.Factory.all,
Client.all,
True,
", some data to send"
);
else
Trace_Sending
( Listener.Factory.all,
Client.all,
True,
", blocking timeout expired"
);
end if;
end if;
end if;
end;
end if;
end loop;
end Unblock;
Exit_Error : exception;
begin
On_Worker_Start (Listener.all);
if Address.Port /= 0 then
Create_Socket (Listener.all, Server_Socket, Address);
if Server_Socket = No_Socket then
raise Exit_Error;
end if;
Set (Listener.Read_Sockets, Server_Socket);
end if;
Listener.Request.Activate;
loop
Trace_Service_Loop
( Listener.Factory.all,
Service_Loop_Begin,
Listener.all
);
if Listener.Shutdown_Request then
Listener.Shutdown_Request := False;
Check (Listener.Read_Sockets);
end if;
if Listener.Connect_Request then
declare
Client : Connection_Ptr;
begin
loop
Listener.Request.Get (Client);
exit when Client = null;
Set (Listener.Write_Sockets, Client.Socket);
Put (Listener.Connections, Client.Socket, Client);
declare
use Object;
Ptr : Entity_Ptr := Client.all'Unchecked_Access;
begin
Release (Ptr);
end;
Listener.Servers := Listener.Servers + 1;
Do_Connect (Listener.all, Client);
end loop;
end;
end if;
Copy (Listener.Read_Sockets, Listener.Ready_To_Read);
Copy (Listener.Write_Sockets, Listener.Ready_To_Write);
Check_Selector
( Selector => Listener.Selector,
R_Socket_Set => Listener.Ready_To_Read,
W_Socket_Set => Listener.Ready_To_Write,
Status => Status,
Timeout => Listener.IO_Timeout
);
exit when Listener.Finalizing;
if Status = Completed then
Trace_Service_Loop
( Listener.Factory.all,
Service_Loop_Reading,
Listener.all
);
loop -- Reading from sockets
Get (Listener.Ready_To_Read, Client_Socket);
exit when Client_Socket = No_Socket;
if Client_Socket = Server_Socket then
Accept_Socket
( Server_Socket,
Client_Socket,
Address
);
declare
Client : Connection_Ptr;
begin
Client :=
Create (Listener.Factory, Listener, Address);
if Client = null then
Close (Client_Socket);
else
declare
This : Connection'Class renames Client.all;
begin
This.Client := False;
This.Connect_No := 0;
This.Client_Address := Address;
This.Socket := Client_Socket;
This.Try_To_Reconnect := False;
Clear (This);
This.Socket_Listener :=
Listener.all'Unchecked_Access;
Set (Listener.Read_Sockets, Client_Socket);
Set (Listener.Write_Sockets, Client_Socket);
Put
( Listener.Connections,
Client_Socket,
Client
);
Listener.Clients := Listener.Clients + 1;
if not Is_Opportunistic (This) then
This.Transport :=
Create_Transport
( Listener.Factory,
Listener,
Client
);
end if;
if This.Transport = null then -- Ready
This.Session := Session_Connected;
Connected (This);
Connected (Listener.all, This);
This.Session := Session_Active;
Activated (This);
else
This.Session := Session_Handshaking;
end if;
end;
end if;
exception
when Connection_Error =>
if Client /= null then
Stop (Listener.all, Client);
end if;
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Accept socket",
Error
);
if Client /= null then
Stop (Listener.all, Client);
end if;
end;
else
declare
Client : Connection_Ptr :=
Get (Listener.Connections, Client_Socket);
begin
if Client = null then
Trace
( Listener.Factory.all,
( "Missing client when reading from socket "
& Set_Image (Client_Socket)
) );
Clear (Listener.Read_Sockets, Client_Socket);
Clear (Listener.Write_Sockets, Client_Socket);
Clear (Listener.Blocked_Sockets, Client_Socket);
Clear (Listener.Ready_To_Write, Client_Socket);
elsif Client.Failed then
if ( Client.Session /= Session_Down
and then
Client.Action_Request = Keep_Connection
and then
( Exception_Identity (Client.Last_Error)
/= Connection_Error'Identity
) )
then
Trace_Error
( Listener.Factory.all,
"Preparing to receive",
Client.Last_Error
);
end if;
Stop (Listener.all, Client);
else
begin
Read (Client.all, Listener.Factory.all);
exception
when Connection_Error =>
Stop (Listener.all, Client);
when Error : Socket_Error =>
Send_Error (Client.all, Error);
Stop (Listener.all, Client);
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Receive socket",
Error
);
Stop (Listener.all, Client);
end;
declare
Data_Left : Boolean;
begin
if Client /= null then
Process (Listener.all, Client, Data_Left);
if Data_Left then
Append
( Listener.Postponed,
Client,
Listener.Postponed_Count
);
end if;
end if;
exception
when Connection_Error =>
Stop (Listener.all, Client);
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Processing received",
Error
);
Stop (Listener.all, Client);
end;
end if;
end;
end if;
end loop;
else
Empty (Listener.Ready_To_Read); -- Clear the set
end if;
Trace_Service_Loop
( Listener.Factory.all,
Service_Loop_Unblocking,
Listener.all
);
This_Time := Clock;
if This_Time - That_Time > Listener.Polling_Timeout then
-- Unblock everything now
That_Time := This_Time;
Unblock (False);
if ( Server_Socket /= No_Socket
and then
not Is_Set (Listener.Read_Sockets, Server_Socket)
)
then
Trace
( Listener.Factory.all,
"Server socket fell out of the read sockets list"
);
Set (Listener.Read_Sockets, Server_Socket);
end if;
else
-- Checking for explicit unblocking requests
while Listener.Unblock_Send loop
Listener.Unblock_Send := False;
Unblock (True); -- Still blocked are now in Ready_To_Read
Copy (Listener.Ready_To_Read, Listener.Blocked_Sockets);
Empty (Listener.Ready_To_Read); -- Clear the set
end loop;
end if;
if Status = Completed then
Trace_Service_Loop
( Listener.Factory.all,
Service_Loop_Writing,
Listener.all
);
loop -- Writing sockets
Get (Listener.Ready_To_Write, Client_Socket);
exit when Client_Socket = No_Socket;
if Client_Socket /= Server_Socket then
declare
Client : Connection_Ptr :=
Get (Listener.Connections, Client_Socket);
begin
if Client = null then
Trace
( Listener.Factory.all,
( "Missing client when writing to socket "
& Set_Image (Client_Socket)
) );
Clear (Listener.Read_Sockets, Client_Socket);
Clear (Listener.Write_Sockets, Client_Socket);
Clear (Listener.Blocked_Sockets, Client_Socket);
elsif Client.Failed then
if ( Client.Session /= Session_Down
and then
Client.Action_Request = Keep_Connection
and then
( Exception_Identity (Client.Last_Error)
/= Connection_Error'Identity
) )
then
Trace_Error
( Listener.Factory.all,
"Preparing to send",
Client.Last_Error
);
end if;
Stop (Listener.all, Client);
elsif Client.Session = Session_Connecting then
declare
This : Connection'Class renames Client.all;
Code : constant Error_Type :=
Get_Socket_Option
( Client.Socket,
Socket_Level,
Error
) .Error;
begin
if Code = Success then -- Connected
On_Connected (Listener.all, This);
Set
( Listener.Read_Sockets,
Client_Socket
);
else -- Connect error
Trace_Sending
( Listener.Factory.all,
This,
False,
( ", failed to connect to "
& Image (This.Client_Address)
& ": " & Image (Code)
) );
Connect_Error (This, Code);
Do_Connect (Listener.all, Client);
end if;
exception
when Connection_Error =>
if Client /= null then
Client.Try_To_Reconnect := False;
Stop (Listener.all, Client);
end if;
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Connect socket",
Error
);
if Client /= null then
Client.Try_To_Reconnect := False;
Stop (Listener.all, Client);
end if;
end;
else -- Have space to write
declare
Block : Boolean;
begin
Write
( Client.all,
Listener.Factory.all,
Block
);
if ( Block
and then
not Client.Written.Send_Blocked
)
then
Client.Written.Send_Blocked := True;
Set
( Client.Socket_Listener.Blocked_Sockets,
Client.Socket
);
Clear
( Client.Socket_Listener.Write_Sockets,
Client.Socket
);
if ( 0
/= ( Listener.Factory.Trace_Flags
and
( Trace_Encoded_Sent
or Trace_Decoded_Sent
) ) )
then
Trace_Sending
( Listener.Factory.all,
Client.all,
False,
", nothing to send"
);
end if;
end if;
exception
when Connection_Error =>
Stop (Listener.all, Client);
when Error : Socket_Error =>
Send_Error (Client.all, Error);
Stop (Listener.all, Client);
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Send socket",
Error
);
Stop (Listener.all, Client);
end;
begin
if Client /= null and then Client.Data_Sent
then
Data_Sent (Listener.all, Client);
end if;
exception
when Connection_Error =>
Stop (Listener.all, Client);
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Processing sent notification",
Error
);
Stop (Listener.all, Client);
end;
end if;
end;
end if;
end loop;
else
Empty (Listener.Ready_To_Write); -- Clear the set
end if;
exit when Listener.Finalizing;
Trace_Service_Loop
( Listener.Factory.all,
Service_Loop_Postponed,
Listener.all
);
Service_Postponed (Listener.all);
end loop;
declare
Client : Connection_Ptr;
begin
loop
Listener.Request.Get (Client);
exit when Client = null;
declare
use Object;
Ptr : Entity_Ptr := Client.all'Unchecked_Access;
begin
Release (Ptr);
end;
end loop;
end;
Close (Server_Socket);
Trace (Listener.Factory.all, "Worker task exiting");
exception
when Exit_Error =>
Trace (Listener.Factory.all, "Worker task exiting");
when Error : others =>
Close (Server_Socket);
Trace_Error (Listener.Factory.all, "Worker task", Error);
end Worker;
protected body Box is
entry Connect (Client : Connection_Ptr)
when Active and then Pending = null is
begin
if Client /= null then
Pending := Client;
Client.Socket_Listener.Connect_Request := True;
Abort_Selector (Listener.Selector);
end if;
end Connect;
procedure Activate is
begin
Active := True;
end Activate;
procedure Get (Client : out Connection_Ptr) is
begin
if Pending = null then
Client := null;
else
Client := Pending;
Pending := null;
Client.Socket_Listener.Connect_Request := False;
end if;
end Get;
end Box;
end GNAT.Sockets.Server;
| true | -- --
-- package GNAT.Sockets.Server Copyright (c) PI:NAME:<NAME>END_PI --
-- Implementation Luebeck --
-- Winter, 2012 --
-- --
-- Last revision : 14:53 29 Feb 2020 --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public License as --
-- published by the Free Software Foundation; either version 2 of --
-- the License, or (at your option) any later version. This library --
-- is distributed in the hope that it will be useful, but WITHOUT --
-- ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have --
-- received a copy of the GNU General Public License along with --
-- this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
--____________________________________________________________________--
with Ada.Calendar; use Ada.Calendar;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.IO_Exceptions; use Ada.IO_Exceptions;
with Strings_Edit; use Strings_Edit;
with Strings_Edit.Integers; use Strings_Edit.Integers;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
package body GNAT.Sockets.Server is
Receive_Masks : constant array (IO_Tracing_Mode) of Factory_Flags :=
( Trace_None => 0,
Trace_Encoded => Trace_Encoded_Received,
Trace_Decoded => Trace_Decoded_Received,
Trace_Any => Trace_Encoded_Received
or Trace_Decoded_Received
);
Sent_Masks : constant array (IO_Tracing_Mode) of Factory_Flags :=
( Trace_None => 0,
Trace_Encoded => Trace_Encoded_Sent,
Trace_Decoded => Trace_Decoded_Sent,
Trace_Any => Trace_Encoded_Sent
or Trace_Decoded_Sent
);
procedure Free is
new Ada.Unchecked_Deallocation (Encoder'Class, Encoder_Ptr);
procedure Activated (Client : in out Connection) is
begin
null;
end Activated;
procedure Append
( List : in out Connection_Ptr;
Item : Connection_Ptr;
Count : in out Integer
) is
begin
if Item.Successor = null then
if List = null then
List := Item;
Item.Successor := Item;
Item.Predecessor := Item;
else
Item.Successor := List;
Item.Predecessor := List.Predecessor;
List.Predecessor := Item;
Item.Predecessor.Successor := Item;
end if;
Count := Count + 1;
end if;
end Append;
function Available_To_Process (Client : Connection)
return Stream_Element_Count is
begin
return Used (Client.Read);
end Available_To_Process;
function Available_To_Send (Client : Connection)
return Stream_Element_Count is
begin
return Free (Client.Written);
end Available_To_Send;
procedure Clear (Client : in out Connection'Class) is
begin
Client.Failed := False; -- Clean I/O state
Client.External_Action := False;
Client.Data_Sent := False;
Client.Dont_Block := False;
Client.Read.Expected := 0;
Client.Read.First_Read := 0;
Client.Read.Free_To_Read := 0;
Client.Written.First_Written := 0;
Client.Written.Free_To_Write := 0;
Client.Written.Send_Blocked := False;
Free (Client.Transport);
end Clear;
procedure Close (Socket : in out Socket_Type) is
begin
if Socket /= No_Socket then
begin
Shutdown_Socket (Socket);
exception
when others =>
null;
end;
begin
Close_Socket (Socket);
exception
when others =>
null;
end;
Socket := No_Socket;
end if;
end Close;
procedure Connect
( Listener : in out Connections_Server;
Client : Connection_Ptr;
Host : String;
Port : Port_Type;
Max_Connect_No : Positive := Positive'Last;
Overlapped : Stream_Element_Count :=
Stream_Element_Count'Last
) is
Address : Sock_Addr_Type renames Client.Client_Address;
Option : Request_Type := (Non_Blocking_IO, True);
begin
if Client.Socket /= No_Socket then
Raise_Exception
( Use_Error'Identity,
"Connection " & Image (Address) & " is already in use"
);
end if;
Address.Addr := To_Addr (Host);
Address.Port := Port;
Create_Socket (Client.Socket);
Set_Socket_Option
( Client.Socket,
Socket_Level,
(Reuse_Address, True)
);
Control_Socket (Client.Socket, Option);
Connect_Parameters_Set
( Client.all,
Host,
Address,
Max_Connect_No
);
Client.Session := Session_Disconnected;
Client.Client := True;
Client.Connect_No := 0;
Client.Max_Connect_No := Max_Connect_No;
Client.Socket_Listener := Listener'Unchecked_Access;
Client.Overlapped_Read := Stream_Element_Count'Min
( Overlapped,
Client.Output_Size
);
Increment_Count (Client.all);
Listener.Request.Connect (Client);
end Connect;
procedure Connect_Error
( Client : in out Connection;
Error : Error_Type
) is
begin
null;
end Connect_Error;
procedure Connect_Parameters_Set
( Client : in out Connection;
Host : String;
Address : Sock_Addr_Type;
Max_Connect_No : Positive
) is
begin
null;
end Connect_Parameters_Set;
procedure Connected (Client : in out Connection) is
begin
null;
end Connected;
procedure Connected
( Listener : in out Connections_Server;
Client : in out Connection'Class
) is
begin
Client.Session := Session_Active;
end Connected;
function Create
( Factory : access Connections_Factory;
Listener : access Connections_Server'Class;
From : Sock_Addr_Type
) return Connection_Ptr is
begin
return null;
end Create;
procedure Create_Socket
( Listener : in out Connections_Server;
Socket : in out Socket_Type;
Address : Sock_Addr_Type
) is
begin
Create_Socket (Socket);
Set_Socket_Option (Socket, Socket_Level, (Reuse_Address, True));
Bind_Socket (Socket, Address);
Listen_Socket (Socket);
end Create_Socket;
function Create_Transport
( Factory : access Connections_Factory;
Listener : access Connections_Server'Class;
Client : access Connection'Class
) return Encoder_Ptr is
begin
return null;
end Create_Transport;
procedure Create_Transport (Client : in out Connection) is
begin
if Client.Transport /= null then
Raise_Exception
( Status_Error'Identity,
"Connection already has a transport layer"
);
end if;
Client.Transport :=
Create_Transport
( Client.Socket_Listener.Factory,
Client.Socket_Listener,
Client'Unchecked_Access
);
if Client.Transport = null then
Raise_Exception
( Status_Error'Identity,
"Connection transport layer is not supported"
);
end if;
Client.Session := Session_Handshaking;
if Client.Client then
Append
( Client.Socket_Listener.Postponed,
Client'Unchecked_Access,
Client.Socket_Listener.Postponed_Count
);
end if;
end Create_Transport;
procedure Data_Sent
( Listener : in out Connections_Server;
Client : Connection_Ptr
) is
begin
Client.Data_Sent := False;
Sent (Client.all);
end Data_Sent;
procedure Disconnected (Client : in out Connection) is
begin
null;
end Disconnected;
procedure Disconnected
( Listener : in out Connections_Server;
Client : in out Connection'Class
) is
begin
Client.Session := Session_Disconnected;
Remove (Listener.Postponed, Client, Listener.Postponed_Count);
end Disconnected;
procedure Downed
( Listener : in out Connections_Server;
Client : in out Connection'Class
) is
begin
Client.Session := Session_Down;
end Downed;
procedure Downed (Client : in out Connection) is
begin
null;
end Downed;
procedure Do_Connect
( Listener : in out Connections_Server'Class;
Client : in out Connection_Ptr
) is
Status : Selector_Status;
begin
Client.Connect_No := Client.Connect_No + 1;
Client.Session := Session_Connecting;
if Client.Connect_No > Client.Max_Connect_No then
Client.Try_To_Reconnect := False; -- Ensure connection killed
Save_Occurrence (Client.Last_Error, Null_Occurrence);
Stop (Listener, Client);
else
Clear (Client.all);
Connect_Socket
( Socket => Client.Socket,
Server => Client.Client_Address,
Timeout => 0.0,
Selector => Listener.Selector'Unchecked_Access,
Status => Status
);
if Status = Completed then
Set (Listener.Read_Sockets, Client.Socket);
On_Connected (Listener, Client.all);
end if;
end if;
exception
when Connection_Error =>
Client.Try_To_Reconnect := False; -- Ensure connection killed
Save_Occurrence (Client.Last_Error, Null_Occurrence);
Stop (Listener, Client);
when Error : Socket_Error =>
if Resolve_Exception (Error) = Operation_Now_In_Progress then
Trace_Sending
( Listener.Factory.all,
Client.all,
False,
", connecting to ..."
);
else
Trace_Error
( Listener.Factory.all,
"Connect socket",
Error
);
Client.Try_To_Reconnect := False; -- Ensure object killed
Save_Occurrence (Client.Last_Error, Error);
Stop (Listener, Client);
end if;
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Connect socket",
Error
);
Client.Try_To_Reconnect := False; -- Ensure connection killed
Save_Occurrence (Client.Last_Error, Error);
Stop (Listener, Client);
end Do_Connect;
procedure Elevated (Client : in out Connection) is
begin
null;
end Elevated;
procedure Fill_From_Stream
( Buffer : in out Output_Buffer;
Stream : in out Root_Stream_Type'Class;
Count : Stream_Element_Count;
Reserve : Stream_Element_Count;
Last : out Stream_Element_Offset;
Next : out Stream_Element_Offset;
Done : out Boolean
) is
begin
if Reserve >= Buffer.Written'Length then
Raise_Exception
( Data_Error'Identity,
( "Output buffer is too small for prefix and suffix ("
& Image (Reserve)
& ")"
) );
end if;
if Buffer.First_Written <= Buffer.Free_To_Write then
--
-- [ XXXXXXXXXXXXXXX ]
-- | |
-- First_Written Free_To_Write
--
declare
Tail : constant Stream_Element_Offset :=
Reserve + Buffer.Written'First - Buffer.First_Written;
begin
if Tail > 0 then
if Buffer.Free_To_Write + Tail = Buffer.Written'Last then
Done := False;
else
Next := Buffer.Written'Last - Tail;
if Count < Next - Buffer.Free_To_Write then
Next := Buffer.Free_To_Write + Count - 1;
end if;
Read
( Stream,
Buffer.Written (Buffer.Free_To_Write..Next),
Last
);
Done := Last < Next;
Next := Last + 1;
end if;
else
Next := Buffer.Written'Last;
if Count < Next - Buffer.Free_To_Write then
Next := Buffer.Free_To_Write + Count - 1;
end if;
Read
( Stream,
Buffer.Written (Buffer.Free_To_Write..Next),
Last
);
Done := Last < Next;
if Last < Buffer.Written'Last then
Next := Last + 1;
else
Next := Buffer.Written'First;
end if;
end if;
end;
else
--
-- [XXXXX XXXXXXX]
-- | |
-- Free_To_Write First_Written
--
if Buffer.Free_To_Write + Reserve >= Buffer.First_Written then
Done := False;
else
Next := Buffer.First_Written - Reserve;
if Count < Next - Buffer.Free_To_Write then
Next := Buffer.Free_To_Write + Count - 1;
end if;
Read
( Stream,
Buffer.Written (Buffer.Free_To_Write..Next),
Last
);
Done := Last < Next;
Next := Last + 1;
end if;
end if;
end Fill_From_Stream;
procedure Finalize (Listener : in out Connections_Server) is
procedure Free is
new Ada.Unchecked_Deallocation (Worker, Worker_Ptr);
begin
if Listener.Doer /= null then
Listener.Finalizing := True;
Abort_Selector (Listener.Selector);
while not Listener.Doer'Terminated loop
delay 0.001;
end loop;
Free (Listener.Doer);
end if;
Close_Selector (Listener.Selector);
end Finalize;
procedure Finalize (Client : in out Connection) is
begin
Close (Client.Socket);
Free (Client.Transport);
Object.Finalize (Object.Entity (Client));
end Finalize;
function Free (Buffer : Output_Buffer) return Stream_Element_Count is
begin
return Buffer.Written'Length - Used (Buffer) - 1;
end Free;
function From_String (Data : String) return Stream_Element_Array is
Result : Stream_Element_Array (1..Data'Length);
Pointer : Stream_Element_Offset := Result'First;
begin
for Index in Data'Range loop
Result (Pointer) := Character'Pos (Data (Index));
Pointer := Pointer + 1;
end loop;
return Result;
end From_String;
function Get_Client_Address (Client : Connection)
return Sock_Addr_Type is
begin
return Client.Client_Address;
end Get_Client_Address;
function Get_Clients_Count (Listener : Connections_Server)
return Natural is
begin
return Listener.Clients;
end Get_Clients_Count;
function Get_Client_Name
( Factory : Connections_Factory;
Client : Connection'Class
) return String is
begin
return Image (Client.Client_Address);
end Get_Client_Name;
function Get_Connections_Server (Client : Connection)
return Connections_Server_Ptr is
begin
return Client.Socket_Listener;
end Get_Connections_Server;
function Get_IO_Timeout (Factory : Connections_Factory)
return Duration is
begin
return 0.02;
end Get_IO_Timeout;
procedure Get_Occurrence
( Client : Connection;
Source : out Exception_Occurrence
) is
begin
Save_Occurrence (Source, Client.Last_Error);
end Get_Occurrence;
function Get_Overlapped_Size (Client : Connection)
return Stream_Element_Count is
begin
return Client.Overlapped_Read;
end Get_Overlapped_Size;
function Get_Polling_Timeout (Factory : Connections_Factory)
return Duration is
begin
return 0.5;
end Get_Polling_Timeout;
function Get_Server_Address
( Listener : Connections_Server
) return Sock_Addr_Type is
Address : Sock_Addr_Type;
begin
Address.Addr := Any_Inet_Addr;
Address.Port := Listener.Port;
return Address;
end Get_Server_Address;
function Get_Session_State (Client : Connection)
return Session_State is
Result : constant Session_State := Client.Session;
begin
if Result = Session_Down then
if Client.Socket = No_Socket then
return Session_Down;
else
return Session_Disconnected; -- Almost here
end if;
else
return Result;
end if;
end Get_Session_State;
function Get_Socket (Client : Connection) return Socket_Type is
begin
return Client.Socket;
end Get_Socket;
function Has_Data (Buffer : Input_Buffer) return Boolean is
begin
return
( Buffer.Free_To_Read /= Buffer.First_Read
and then
( Buffer.Expected = 0
or else
Used (Buffer) >= Buffer.Size - 1
) );
end Has_Data;
function Has_Data (Client : Connection) return Boolean is
begin
return Has_Data (Client.Read);
end Has_Data;
function Image (Code : Error_Type) return String is
Result : String := Error_Type'Image (Code);
begin
for Index in Result'First + 1..Result'Last loop
if Result (Index) = '_' then
Result (Index) := ' ';
else
Result (Index) := To_Lower (Result (Index));
end if;
end loop;
return Result;
end Image;
function Image
( Data : Stream_Element_Array;
Hexadecimal : Boolean := False
) return String is
begin
if Hexadecimal then
declare
Result : String (1..Data'Length * 3);
Pointer : Integer := 1;
begin
for Index in Data'Range loop
Put
( Destination => Result,
Pointer => Pointer,
Value => Integer (Data (Index)),
Base => 16,
Field => 2,
Fill => '0',
Justify => Right
);
Put
( Destination => Result,
Pointer => Pointer,
Value => " "
);
end loop;
return Result;
end;
else
declare
Length : Natural := 0;
begin
for Index in Data'Range loop
case Data (Index) is
when 32..36 | 38..126 =>
Length := Length + 1;
when others =>
Length := Length + 3;
end case;
end loop;
declare
Result : String (1..Length);
Pointer : Integer := 1;
begin
for Index in Data'Range loop
case Data (Index) is
when 32..36 | 38..126 =>
Put
( Destination => Result,
Pointer => Pointer,
Value => Character'Val (Data (Index))
);
when others =>
Put
( Destination => Result,
Pointer => Pointer,
Value => '%'
);
Put
( Destination => Result,
Pointer => Pointer,
Value => Integer (Data (Index)),
Base => 16,
Field => 2,
Fill => '0',
Justify => Right
);
end case;
end loop;
return Result;
end;
end;
end if;
end Image;
procedure Initialize (Listener : in out Connections_Server) is
begin
Listener.IO_Timeout := Get_IO_Timeout (Listener.Factory.all);
Listener.Polling_Timeout :=
Get_Polling_Timeout (Listener.Factory.all);
Create_Selector (Listener.Selector);
Listener.Doer := new Worker (Listener'Unchecked_Access);
end Initialize;
function Is_Connected (Client : Connection) return Boolean is
begin
return Client.Session in Session_Active..Session_Busy;
end Is_Connected;
function Is_Down (Client : Connection) return Boolean is
begin
return
( Client.Session = Session_Down
and then
Client.Socket = No_Socket
);
end Is_Down;
function Is_Elevated (Client : Connection) return Boolean is
begin
return Client.Transport /= null;
end Is_Elevated;
function Is_Incoming (Client : Connection) return Boolean is
begin
return not Client.Client;
end Is_Incoming;
function Is_Opportunistic (Client : Connection) return Boolean is
begin
return False;
end Is_Opportunistic;
function Is_TLS_Capable
( Factory : Connections_Factory
) return Boolean is
begin
return False;
end Is_TLS_Capable;
function Is_Trace_Received_On
( Factory : Connections_Factory;
Encoded : IO_Tracing_Mode
) return Boolean is
begin
return 0 /= (Factory.Trace_Flags and Receive_Masks (Encoded));
end Is_Trace_Received_On;
function Is_Trace_Sent_On
( Factory : Connections_Factory;
Encoded : IO_Tracing_Mode
) return Boolean is
begin
return 0 /= (Factory.Trace_Flags and Sent_Masks (Encoded));
end Is_Trace_Sent_On;
function Is_Unblock_Send_Queued
( Listener : Connections_Server
) return Boolean is
begin
return Listener.Unblock_Send;
end Is_Unblock_Send_Queued;
procedure Keep_On_Sending (Client : in out Connection) is
begin
Client.Dont_Block := True;
end Keep_On_Sending;
procedure On_Connected
( Listener : in out Connections_Server'Class;
Client : in out Connection'Class
) is
begin
Trace_Sending
( Listener.Factory.all,
Client,
False,
", connected"
);
Free (Client.Transport);
if not Is_Opportunistic (Client) then
Client.Transport :=
Create_Transport
( Listener.Factory,
Listener'Unchecked_Access,
Client'Unchecked_Access
);
end if;
Set (Listener.Read_Sockets, Client.Socket);
if Client.Transport = null then -- No handshaking
declare
Saved : constant Session_State := Client.Session;
begin
Client.Session := Session_Connected;
Connected (Client);
Connected (Listener, Client);
Client.Session := Session_Active;
Activated (Client);
exception
when others =>
if Client.Session in Session_Connected
.. Session_Active
then
Client.Session := Saved;
end if;
raise;
end;
else
Client.Session := Session_Handshaking;
Append
( Listener.Postponed,
Client'Unchecked_Access,
Listener.Postponed_Count
);
end if;
end On_Connected;
procedure On_Worker_Start (Listener : in out Connections_Server) is
begin
null;
end On_Worker_Start;
procedure Process
( Buffer : in out Input_Buffer;
Receiver : in out Connection'Class;
Data_Left : out Boolean
) is
Last : Stream_Element_Offset;
Pointer : Stream_Element_Offset;
begin
while Has_Data (Buffer) loop
if Buffer.Free_To_Read < Buffer.First_Read then
--
-- [XXXXXXXXXXXXXX XXXXX]
-- Free_To_Read | First_Read |
--
if Buffer.First_Read > Buffer.Read'Last then
--
-- [XXXXXXXXXXXXXX ]
-- Free_To_Read | First_Read |
--
Buffer.First_Read := Buffer.Read'First; -- Wrap
Last := Buffer.Free_To_Read - 1;
else
Last := Buffer.Read'Last;
end if;
else
--
-- [ XXXXXXXXX ]
-- First_Read | | Free_To_Read
--
Last := Buffer.Free_To_Read - 1;
end if;
Pointer := Last + 1;
Received
( Receiver,
Buffer.Read (Buffer.First_Read..Last),
Pointer
);
if Pointer < Buffer.First_Read or else Pointer > Last + 1 then
Raise_Exception
( Layout_Error'Identity,
( "Subscript error, pointer "
& Image (Pointer)
& " out of range "
& Image (Buffer.First_Read)
& ".."
& Image (Last)
& "+"
) );
elsif Pointer > Buffer.Read'Last then
if Buffer.Free_To_Read <= Buffer.Read'Last then
Buffer.First_Read := Buffer.Read'First; -- Wrap
else
Buffer.First_Read := Pointer; -- Not yet
end if;
else
Buffer.First_Read := Pointer;
end if;
if Pointer <= Last then -- Some input left unprocessed
Data_Left := True;
return;
end if;
end loop;
Data_Left := False;
end Process;
procedure Process
( Listener : in out Connections_Server;
Client : Connection_Ptr;
Data_Left : out Boolean
) is
begin
if Client.Transport = null then
Process (Client.Read, Client.all, Data_Left);
else
Process
( Client.Transport.all,
Listener,
Client.all,
Data_Left
);
end if;
end Process;
procedure Process_Packet (Client : in out Connection) is
begin
null;
end Process_Packet;
procedure Pull
( Buffer : in out Input_Buffer;
Data : in out Stream_Element_Array;
Pointer : in out Stream_Element_Offset
) is
Last : Stream_Element_Offset;
Offset : Stream_Element_Offset;
begin
while Pointer <= Data'Last and then Has_Data (Buffer) loop
if Buffer.Free_To_Read < Buffer.First_Read then
--
-- [XXXXXXXXXXXXXX XXXXX]
-- Free_To_Read | First_Read |
--
if Buffer.First_Read > Buffer.Read'Last then
--
-- [XXXXXXXXXXXXXX ]
-- Free_To_Read | First_Read |
--
Buffer.First_Read := Buffer.Read'First; -- Wrap
Last := Buffer.Free_To_Read - 1;
else
Last := Buffer.Read'Last;
end if;
else
--
-- [ XXXXXXXXX ]
-- First_Read | | Free_To_Read
--
Last := Buffer.Free_To_Read - 1;
end if;
Offset := Last - Buffer.First_Read;
if Offset > Data'Last - Pointer then
Offset := Data'Last - Pointer;
Last := Buffer.First_Read + Offset;
end if;
Data (Pointer..Pointer + Offset) :=
Buffer.Read (Buffer.First_Read..Last);
Pointer := Pointer + Offset + 1;
if Last >= Buffer.Read'Last then
if Buffer.Free_To_Read <= Buffer.Read'Last then
Buffer.First_Read := Buffer.Read'First; -- Wrap
else
Buffer.First_Read := Last + 1; -- Not yet
end if;
else
Buffer.First_Read := Last + 1;
end if;
end loop;
end Pull;
procedure Push
( Client : in out Connection;
Data : Stream_Element_Array;
Last : out Stream_Element_Offset
) is
begin
if Client.Transport = null then
Send_Socket (Client.Socket_Listener.all, Client, Data, Last);
else
Encode (Client.Transport.all, Client, Data, Last);
end if;
if Last + 1 /= Data'First then
Client.Data_Sent := True;
if ( 0
/= ( Client.Socket_Listener.Factory.Trace_Flags
and
Trace_Decoded_Sent
) )
then
Trace_Sent
( Factory => Client.Socket_Listener.Factory.all,
Client => Client,
Data => Data,
From => Data'First,
To => Last,
Encoded => False
);
end if;
end if;
end Push;
procedure Queue
( Client : in out Connection;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset
) is
Buffer : Output_Buffer renames Client.Written;
Free : Stream_Element_Offset;
Count : Stream_Element_Offset := Data'Last - Pointer + 1;
begin
if Buffer.First_Written = Buffer.Free_To_Write then
--
-- Moving First_Written as far back as possible to diminish
-- buffer fragmenting. We cannot move it further than the
-- number of elements we put there, because of race condition,
-- when Free_To_Write is not yet set. But when Free_To_Write
-- points into the elements written everything is OK
--
-- [ ............ ]
-- |<--Count-->|
-- | Free_To_Write = First_Written
-- new First_Written
--
Count :=
Stream_Element_Offset'Min
( Buffer.Written'Length - 1,
Count
);
Free := Stream_Element_Offset'Max
( Buffer.Written'First,
Buffer.Free_To_Write - Count
);
Buffer.Written (Free..Free + Count - 1) :=
Data (Pointer..Pointer + Count - 1);
Pointer := Pointer + Count;
Buffer.First_Written := Free;
Buffer.Free_To_Write := Free + Count;
return;
elsif Buffer.First_Written < Buffer.Free_To_Write then
--
-- [ XXXXXXXXXXXXXXX ]
-- | |
-- First_Written Free_To_Write
--
Free :=
( Buffer.Written'Length
- Buffer.Free_To_Write
+ Buffer.First_Written
- 1 -- Last element is never written
);
if Free <= 0 then
return;
end if;
declare
Tail : constant Stream_Element_Offset :=
Stream_Element_Offset'Min
( Buffer.Written'Last - Buffer.Free_To_Write + 1,
Free
);
begin
if Count <= Tail then -- Can queue all Count elements
Buffer.Written
( Buffer.Free_To_Write
.. Buffer.Free_To_Write + Count - 1
) := Data (Pointer..Data'Last);
Pointer := Data'Last + 1;
Free := Buffer.Free_To_Write + Count;
if Free > Buffer.Written'Last then
Buffer.Free_To_Write := Buffer.Written'First;
else
Buffer.Free_To_Write := Free;
end if;
return;
end if; -- Can queue only Tail elements
Buffer.Written
( Buffer.Free_To_Write
.. Buffer.Free_To_Write + Tail - 1
) := Data (Pointer..Pointer + Tail - 1);
Pointer := Pointer + Tail;
Count := Count - Tail;
Free := Free - Tail;
if Buffer.Free_To_Write + Tail > Buffer.Written'Last then
Buffer.Free_To_Write := Buffer.Written'First;
else
Buffer.Free_To_Write := Buffer.Free_To_Write + Tail;
end if;
end;
else
--
-- [XXXXX XXXXXXXX]
-- | |
-- Free_To_Write First_Written
--
Free :=
( Buffer.First_Written
+ Buffer.Free_To_Write
- 1 -- Last element is never written
);
end if;
if Free <= 0 then
return;
end if;
Count := Stream_Element_Offset'Min (Count, Free);
Buffer.Written
( Buffer.Free_To_Write
.. Buffer.Free_To_Write + Count - 1
) := Data (Pointer..Pointer + Count - 1);
Pointer := Pointer + Count;
Buffer.Free_To_Write := Buffer.Free_To_Write + Count;
end Queue;
function Queued_To_Send (Client : Connection)
return Stream_Element_Count is
begin
return Used (Client.Written);
end Queued_To_Send;
procedure Read
( Client : in out Connection;
Factory : in out Connections_Factory'Class
) is
Buffer : Input_Buffer renames Client.Read;
Last : Stream_Element_Offset;
begin
if Client.Overlapped_Read < Queued_To_Send (Client) then
return; -- Not ready to read yet
elsif Buffer.Free_To_Read < Buffer.First_Read then
--
-- [XXXXXXXXXXXXXX XXXXX]
-- Free_To_Read | First_Read |
--
Last := Buffer.First_Read - 2;
if Last <= Buffer.First_Read then -- Read buffer is full
return;
end if;
else
--
-- [ XXXXXXXXX ]
-- First_Read | | Free_To_Read
--
if ( Buffer.Free_To_Read - Buffer.First_Read
>= Buffer.Read'Length
)
then -- Read buffer is full
return;
elsif Buffer.Free_To_Read > Buffer.Read'Last then -- Wrap
Buffer.Free_To_Read := Buffer.Read'First;
Last := Buffer.First_Read - 2;
else
Last := Buffer.Read'Last;
end if;
end if;
Receive_Socket
( Client.Socket_Listener.all,
Client,
Buffer.Read (Buffer.Free_To_Read..Last),
Last
);
Received
( Factory,
Client,
Buffer.Read,
Buffer.Free_To_Read,
Last
);
if Last = Buffer.Free_To_Read - 1 then -- Nothing read
raise Connection_Error;
end if;
Buffer.Expected :=
Stream_Element_Offset'Max
( Buffer.Expected - (Last - Buffer.Free_To_Read + 1),
0
);
Buffer.Free_To_Read := Last + 1;
exception
when Error : Socket_Error | Layout_Error =>
Receive_Error (Client, Error);
raise Connection_Error;
end Read;
procedure Receive_Socket
( Listener : in out Connections_Server;
Client : in out Connection'Class;
Data : in out Stream_Element_Array;
Last : out Stream_Element_Offset
) is
begin
Receive_Socket (Client.Socket, Data, Last);
end Receive_Socket;
procedure Received
( Factory : in out Connections_Factory;
Client : in out Connection'Class;
Data : Stream_Element_Array;
From : Stream_Element_Offset;
To : Stream_Element_Offset
) is
begin
if Client.Transport = null then
if 0 /= (Factory.Trace_Flags and Trace_Decoded_Received) then
Trace_Received
( Factory => Connections_Factory'Class (Factory),
Client => Client,
Data => Data,
From => From,
To => To,
Encoded => False
);
end if;
else
if 0 /= (Factory.Trace_Flags and Trace_Encoded_Received) then
Trace_Received
( Factory => Connections_Factory'Class (Factory),
Client => Client,
Data => Data,
From => From,
To => To,
Encoded => True
);
end if;
end if;
end Received;
procedure Reconnect (Client : in out Connection) is
begin
if Client.Socket = No_Socket then
Raise_Exception
( Use_Error'Identity,
"No connection"
);
elsif not Client.Client then
Raise_Exception
( Mode_Error'Identity,
"Server connection"
);
elsif Client.Session /= Session_Down then
if Client.Socket_Listener /= null then
Request_Disconnect
( Client.Socket_Listener.all,
Client,
True
);
return;
end if;
Client.Session := Session_Down;
end if;
Raise_Exception
( Status_Error'Identity,
"Downed connection"
);
end Reconnect;
procedure Received
( Client : in out Connection;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset
) is
begin
raise Connection_Error;
end Received;
procedure Released (Client : in out Connection) is
begin
null;
end Released;
procedure Remove
( List : in out Connection_Ptr;
Item : in out Connection'Class;
Count : in out Integer
) is
begin
if Item.Successor /= null then
Count := Count - 1;
if List = Item.Successor.Predecessor then -- First in the list
if List = List.Successor then -- The single item of the list
List := null;
Item.Successor := null;
return;
else
List := Item.Successor;
end if;
end if;
Item.Predecessor.Successor := Item.Successor;
Item.Successor.Predecessor := Item.Predecessor;
Item.Successor := null;
end if;
end Remove;
procedure Receive_Error
( Client : in out Connection;
Occurrence : Exception_Occurrence
) is
begin
null;
end Receive_Error;
procedure Request_Disconnect
( Listener : in out Connections_Server;
Client : in out Connection'Class;
Reconnect : Boolean
) is
begin
Client.Failed := True;
if Reconnect then
Client.Try_To_Reconnect := True;
Client.Action_Request := Reconnect_Connection;
else
Client.Try_To_Reconnect := False;
Client.Action_Request := Shutdown_Connection;
end if;
Client.Socket_Listener.Shutdown_Request := True;
if Client.Socket_Listener.Doer /= null then
Abort_Selector (Client.Socket_Listener.Selector);
end if;
end Request_Disconnect;
procedure Save_Occurrence
( Client : in out Connection;
Source : Exception_Occurrence
) is
begin
Save_Occurrence (Client.Last_Error, Source);
end Save_Occurrence;
procedure Send
( Client : in out Connection;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset
) is
Buffer : Output_Buffer renames Client.Written;
begin
if ( Pointer < Data'First
or else
( Pointer > Data'Last
and then
Pointer - 1 > Data'Last
) )
then
Raise_Exception (Layout_Error'Identity, "Subscript error");
end if;
Queue (Client, Data, Pointer);
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Data : String;
Pointer : in out Integer
) is
Buffer : Output_Buffer renames Client.Written;
begin
Pointer := Data'Last + 1;
for Index in Data'Range loop
if Used (Buffer) + 1 >= Buffer.Written'Length then
Pointer := Index;
exit;
end if;
Buffer.Written (Buffer.Free_To_Write) :=
Stream_Element (Character'Pos (Data (Index)));
if Buffer.Free_To_Write = Buffer.Written'Last then
Buffer.Free_To_Write := Buffer.Written'First;
else
Buffer.Free_To_Write := Buffer.Free_To_Write + 1;
end if;
end loop;
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
End_Of_Stream : out Boolean
) is
Buffer : Output_Buffer renames Client.Written;
Last : Stream_Element_Offset;
Next : Stream_Element_Offset;
begin
Fill_From_Stream
( Buffer => Buffer,
Stream => Stream,
Count => Stream_Element_Count'Last,
Reserve => 1,
Last => Last,
Next => Next,
Done => End_Of_Stream
);
Buffer.Free_To_Write := Next;
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
Count : in out Stream_Element_Count;
End_Of_Stream : out Boolean
) is
Buffer : Output_Buffer renames Client.Written;
Last : Stream_Element_Offset;
Next : Stream_Element_Offset;
begin
Fill_From_Stream
( Buffer => Buffer,
Stream => Stream,
Count => Count,
Reserve => 1,
Last => Last,
Next => Next,
Done => End_Of_Stream
);
Count := Count - (Last + 1 - Buffer.Free_To_Write);
Buffer.Free_To_Write := Next;
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
Reserve : Stream_Element_Count;
Get_Prefix : Create_Stream_Element_Array;
Get_Suffix : Create_Stream_Element_Array;
End_Of_Stream : out Boolean
) is
Count : Stream_Element_Count := Stream_Element_Count'Last;
begin
Send
( Client => Client,
Stream => Stream,
Count => Count,
Reserve => Reserve,
Get_Prefix => Get_Prefix,
Get_Suffix => Get_Suffix,
End_Of_Stream => End_Of_Stream
);
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
Count : in out Stream_Element_Count;
Reserve : Stream_Element_Count;
Get_Prefix : Create_Stream_Element_Array;
Get_Suffix : Create_Stream_Element_Array;
End_Of_Stream : out Boolean
) is
Buffer : Output_Buffer renames Client.Written;
Last : Stream_Element_Offset;
Next : Stream_Element_Offset;
begin
if Buffer.Free_To_Write = Buffer.First_Written then
if Buffer.Written'Length <= Reserve then
Raise_Exception
( Data_Error'Identity,
( "Output buffer size"
& Stream_Element_Count'Image (Buffer.Written'Length)
& " is less than required"
& Stream_Element_Count'Image (Reserve + 1)
& " elements"
) );
end if;
Fill_From_Stream
( Buffer => Buffer,
Stream => Stream,
Count => Count,
Reserve => Reserve + 1,
Last => Last,
Next => Next,
Done => End_Of_Stream
);
Count := Count - (Last + 1 - Buffer.Free_To_Write);
declare
Header : constant Stream_Element_Array :=
Get_Prefix.all
( Client'Unchecked_Access,
Buffer.Written (Buffer.Free_To_Write..Last),
End_Of_Stream
);
Tail : constant Stream_Element_Array :=
Get_Suffix.all
( Client'Unchecked_Access,
Buffer.Written (Buffer.Free_To_Write..Last),
End_Of_Stream
);
begin
if Header'Length + Tail'Length > Reserve then
Raise_Exception
( Data_Error'Identity,
( "Prefix returns more than"
& Stream_Element_Count'Image (Reserve)
& " elements"
) );
elsif Header'Length > 0 then
Last := Buffer.First_Written;
for Index in reverse Header'Range loop
if Last = Buffer.Written'First then
Last := Buffer.Written'Last;
else
Last := Last - 1;
end if;
Buffer.Written (Last) := Header (Index);
end loop;
end if;
Buffer.First_Written := Last;
Buffer.Free_To_Write := Next;
if Tail'Length > 0 then
Last := Tail'First;
Queue (Client, Tail, Last);
end if;
end;
else
End_Of_Stream := False;
end if;
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
Count : in out Stream_Element_Count;
Reserve : Natural;
Get_Prefix : Create_String;
Get_Suffix : Create_String;
End_Of_Stream : out Boolean
) is
Buffer : Output_Buffer renames Client.Written;
Last : Stream_Element_Offset;
Next : Stream_Element_Offset;
begin
if Buffer.Free_To_Write = Buffer.First_Written then
if Buffer.Written'Length <= Reserve then
Raise_Exception
( Data_Error'Identity,
( "Output buffer size"
& Stream_Element_Count'Image (Buffer.Written'Length)
& " is less than required"
& Integer'Image (Reserve + 1)
& " elements"
) );
end if;
Fill_From_Stream
( Buffer => Buffer,
Stream => Stream,
Count => Count,
Reserve => Stream_Element_Count (Reserve) + 1,
Last => Last,
Next => Next,
Done => End_Of_Stream
);
Count := Count - (Last + 1 - Buffer.Free_To_Write);
declare
Header : constant String :=
Get_Prefix.all
( Client'Unchecked_Access,
Buffer.Written (Buffer.Free_To_Write..Last),
End_Of_Stream
);
Tail : constant String :=
Get_Suffix.all
( Client'Unchecked_Access,
Buffer.Written (Buffer.Free_To_Write..Last),
End_Of_Stream
);
begin
if Header'Length + Tail'Length > Reserve then
Raise_Exception
( Data_Error'Identity,
( "Prefix returns more than"
& Integer'Image (Reserve)
& " elements"
) );
elsif Header'Length > 0 then
Last := Buffer.First_Written;
for Index in reverse Header'Range loop
if Last = Buffer.Written'First then
Last := Buffer.Written'Last;
else
Last := Last - 1;
end if;
Buffer.Written (Last) :=
Stream_Element (Character'Pos (Header (Index)));
end loop;
end if;
Buffer.First_Written := Last;
Buffer.Free_To_Write := Next;
if Tail'Length > 0 then
declare
Pointer : Integer := Tail'First;
begin
Send (Client, Tail, Pointer);
end;
end if;
end;
else
End_Of_Stream := False;
end if;
if Buffer.Free_To_Write /= Buffer.First_Written then
Unblock_Send (Client.Socket_Listener.all, Client);
end if;
end Send;
procedure Send
( Client : in out Connection;
Stream : in out Root_Stream_Type'Class;
Reserve : Natural;
Get_Prefix : Create_String;
Get_Suffix : Create_String;
End_Of_Stream : out Boolean
) is
Count : Stream_Element_Count := Stream_Element_Count'Last;
begin
Send
( Client => Client,
Stream => Stream,
Count => Count,
Reserve => Reserve,
Get_Prefix => Get_Prefix,
Get_Suffix => Get_Suffix,
End_Of_Stream => End_Of_Stream
);
end Send;
procedure Send_Error
( Client : in out Connection;
Occurrence : Exception_Occurrence
) is
begin
null;
end Send_Error;
procedure Send_Socket
( Listener : in out Connections_Server;
Client : in out Connection'Class;
Data : Stream_Element_Array;
Last : out Stream_Element_Offset
) is
begin
Send_Socket (Client.Socket, Data, Last);
end Send_Socket;
procedure Sent (Client : in out Connection) is
begin
null;
end Sent;
procedure Set_Client_Data
( Client : in out Connection;
Address : Sock_Addr_Type;
Listener : Connections_Server_Ptr
) is
begin
if Client.Socket_Listener /= null then
Raise_Exception
( Constraint_Error'Identity,
"The client has a connections server set"
);
end if;
Client.Client_Address := Address;
Client.Socket_Listener := Listener;
end Set_Client_Data;
procedure Set_Expected_Count
( Client : in out Connection;
Count : Stream_Element_Count
) is
begin
Client.Read.Expected := Count;
end Set_Expected_Count;
procedure Service_Postponed (Listener : in out Connections_Server) is
Leftover : Connection_Ptr;
Client : Connection_Ptr;
Data_Left : Boolean;
begin
loop
Client := Listener.Postponed;
exit when Client = null;
Remove
( Listener.Postponed,
Client.all,
Listener.Postponed_Count
);
begin
Process
( Connections_Server'Class (Listener),
Client,
Data_Left
);
if Data_Left then
Append (Leftover, Client, Listener.Postponed_Count);
end if;
exception
when Connection_Error =>
Stop (Listener, Client);
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Postponed service",
Error
);
Stop (Listener, Client);
end;
end loop;
Listener.Postponed := Leftover;
end Service_Postponed;
procedure Set_Failed
( Client : in out Connection;
Error : Exception_Occurrence
) is
begin
Save_Occurrence (Client.Last_Error, Error);
Client.Failed := True;
end Set_Failed;
procedure Set_Overlapped_Size
( Client : in out Connection;
Size : Stream_Element_Count
) is
begin
Client.Overlapped_Read := Size;
end Set_Overlapped_Size;
procedure Shutdown (Client : in out Connection) is
begin
if Client.Session /= Session_Down then
if Client.Socket_Listener = null then
Client.Session := Session_Down;
else
Request_Disconnect
( Client.Socket_Listener.all,
Client,
False
);
Shutdown (Client.Socket_Listener.all, Client);
end if;
end if;
end Shutdown;
procedure Shutdown
( Listener : in out Connections_Server;
Client : in out Connection'Class
) is
begin
null;
end Shutdown;
procedure Stop
( Listener : in out Connections_Server'Class;
Client : in out Connection_Ptr
) is
Old_Socket : constant Socket_Type := Client.Socket;
Reconnect : Boolean :=
Client.Action_Request /= Shutdown_Connection;
begin
Trace_Sending
( Listener.Factory.all,
Client.all,
False,
", dropping connection"
);
Client.Action_Request := Keep_Connection;
Clear (Listener.Read_Sockets, Client.Socket);
Clear (Listener.Blocked_Sockets, Client.Socket);
Clear (Listener.Ready_To_Read, Client.Socket);
Clear (Listener.Ready_To_Write, Client.Socket);
Clear (Listener.Write_Sockets, Client.Socket);
Clear (Listener.Ready_To_Write, Client.Socket);
Free (Client.Transport);
if Client.Session in Session_Connected..Session_Busy then
begin
Disconnected (Listener, Client.all);
exception
when Connection_Error =>
Reconnect := False;
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Disconnected (server)",
Error
);
end;
begin -- Disconnected
Client.Session := Session_Disconnected;
Disconnected (Client.all);
exception
when Connection_Error =>
Reconnect := False;
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Disconnected (client)",
Error
);
end;
end if;
if Client.Client then -- Try to reconnect
if ( Reconnect
and then
not Listener.Finalizing
and then
Client.Try_To_Reconnect
and then
Client.Session /= Session_Down
and then
Client.Action_Request /= Shutdown_Connection
)
then
begin
Close (Client.Socket);
declare
Option : Request_Type := (Non_Blocking_IO, True);
begin
Create_Socket (Client.Socket);
Set_Socket_Option
( Client.Socket,
Socket_Level,
(Reuse_Address, True)
);
end;
if Old_Socket /= Client.Socket then -- Move client
Put (Listener.Connections, Client.Socket, Client);
Put (Listener.Connections, Old_Socket, null);
end if;
Set (Listener.Write_Sockets, Client.Socket);
Do_Connect (Listener, Client);
return;
exception
when Error : Socket_Error => -- Kill the object
Trace_Error
( Listener.Factory.all,
"Reconnecting",
Error
);
end;
end if;
Listener.Servers := Listener.Servers - 1;
else
Listener.Clients := Listener.Clients - 1;
end if;
Close (Client.Socket);
Client.Session := Session_Down;
Client.Failed := False;
Client.Action_Request := Keep_Connection;
begin
Downed (Listener, Client.all);
exception
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Downed (server)",
Error
);
end;
begin
Downed (Client.all);
exception
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Downed (client)",
Error
);
end;
begin
Released (Client.all);
exception
when others =>
null;
end;
if Get (Listener.Connections, Old_Socket) = Client then
Put (Listener.Connections, Old_Socket, null);
end if;
Client := null;
exception
when Error : others =>
Trace_Error (Listener.Factory.all, "Stopping", Error);
raise;
end Stop;
function To_Addr (Host : String) return Inet_Addr_Type is
begin
for Index in Host'Range loop
case Host (Index) is
when '.' | '0'..'9' =>
null;
when others =>
return Addresses (Get_Host_By_Name (Host), 1);
end case;
end loop;
return Inet_Addr (Host);
end To_Addr;
function To_String (Data : Stream_Element_Array) return String is
Result : String (1..Data'Length);
Index : Integer := Result'First;
begin
for Item in Data'Range loop
Result (Index) := Character'Val (Data (Item));
Index := Index + 1;
end loop;
return Result;
end To_String;
procedure Trace
( Factory : in out Connections_Factory;
Message : String
) is
use Ada.Text_IO;
begin
if 0 /= (Factory.Trace_Flags and Standard_Output) then
Put_Line (Message);
end if;
if Is_Open (Factory.Trace_File) then
Put_Line (Factory.Trace_File, Message);
end if;
end Trace;
procedure Trace_Error
( Factory : in out Connections_Factory;
Context : String;
Occurrence : Exception_Occurrence
) is
begin
Trace
( Connections_Factory'Class (Factory),
Context & ": " & Exception_Information (Occurrence)
);
end Trace_Error;
procedure Trace_Off (Factory : in out Connections_Factory) is
use Ada.Text_IO;
begin
if Is_Open (Factory.Trace_File) then
Close (Factory.Trace_File);
end if;
Factory.Trace_Flags :=
Factory.Trace_Flags and not Standard_Output;
end Trace_Off;
procedure Trace_On
( Factory : in out Connections_Factory;
Received : IO_Tracing_Mode := Trace_None;
Sent : IO_Tracing_Mode := Trace_None
) is
Flags : Factory_Flags := Standard_Output;
begin
case Received is
when Trace_Any =>
Flags := Flags
or Trace_Decoded_Received
or Trace_Encoded_Received;
when Trace_Decoded =>
Flags := Flags or Trace_Decoded_Received;
when Trace_Encoded =>
Flags := Flags or Trace_Encoded_Received;
when Trace_None =>
null;
end case;
case Sent is
when Trace_Any =>
Flags := Flags or Trace_Decoded_Sent or Trace_Encoded_Sent;
when Trace_Decoded =>
Flags := Flags or Trace_Decoded_Sent;
when Trace_Encoded =>
Flags := Flags or Trace_Encoded_Sent;
when Trace_None =>
null;
end case;
Factory.Trace_Flags := Flags;
end Trace_On;
procedure Trace_On
( Factory : in out Connections_Factory;
Name : String;
Received : IO_Tracing_Mode := Trace_None;
Sent : IO_Tracing_Mode := Trace_None
) is
use Ada.Text_IO;
Flags : Factory_Flags := 0;
begin
if Is_Open (Factory.Trace_File) then
Close (Factory.Trace_File);
end if;
Create (File => Factory.Trace_File, Name => Name);
case Received is
when Trace_Any =>
Flags := Flags
or Trace_Decoded_Received
or Trace_Encoded_Received;
when Trace_Decoded =>
Flags := Flags or Trace_Decoded_Received;
when Trace_Encoded =>
Flags := Flags or Trace_Encoded_Received;
when Trace_None =>
null;
end case;
case Sent is
when Trace_Any =>
Flags := Flags or Trace_Decoded_Sent or Trace_Encoded_Sent;
when Trace_Decoded =>
Flags := Flags or Trace_Decoded_Sent;
when Trace_Encoded =>
Flags := Flags or Trace_Encoded_Sent;
when Trace_None =>
null;
end case;
Factory.Trace_Flags := Flags;
end Trace_On;
procedure Trace_Received
( Factory : in out Connections_Factory;
Client : Connection'Class;
Data : Stream_Element_Array;
From : Stream_Element_Offset;
To : Stream_Element_Offset;
Encoded : Boolean := False
) is
This : Connections_Factory'Class renames
Connections_Factory'Class (Factory);
begin
if Encoded then
Trace
( This,
( Get_Client_Name (This, Client)
& " encoded> |"
& Image (Data (From..To))
& "| "
& Image (From)
& ".."
& Image (To)
) );
else
Trace
( This,
( Get_Client_Name (This, Client)
& " > |"
& Image (Data (From..To))
& "| "
& Image (From)
& ".."
& Image (To)
) );
end if;
end Trace_Received;
procedure Trace_Sending
( Factory : in out Connections_Factory;
Client : Connection'Class;
Enabled : Boolean;
Reason : String
) is
This : Connections_Factory'Class renames
Connections_Factory'Class (Factory);
begin
if Enabled then
Trace
( This,
( Get_Client_Name (This, Client)
& " < +++ Resume polling"
& Reason
) );
else
Trace
( This,
( Get_Client_Name (This, Client)
& " < --- Stop polling"
& Reason
) );
end if;
end Trace_Sending;
procedure Trace_Sent
( Factory : in out Connections_Factory;
Client : Connection'Class;
Data : Stream_Element_Array;
From : Stream_Element_Offset;
To : Stream_Element_Offset;
Encoded : Boolean := False
) is
This : Connections_Factory'Class renames
Connections_Factory'Class (Factory);
begin
if Encoded then
Trace
( This,
( Get_Client_Name (This, Client)
& " <encoded |"
& Image (Data (From..To))
& "| "
& Image (From)
& ".."
& Image (To)
) );
else
Trace
( This,
( Get_Client_Name (This, Client)
& " < |"
& Image (Data (From..To))
& "| "
& Image (From)
& ".."
& Image (To)
) );
end if;
end Trace_Sent;
procedure Trace_Service_Loop
( Factory : in out Connections_Factory;
Stage : Service_Loop_Stage;
Server : in out Connections_Server'Class
) is
begin
null;
end Trace_Service_Loop;
procedure Unblock_Send
( Listener : in out Connections_Server;
Client : in out Connection'Class
) is
Buffer : Output_Buffer renames Client.Written;
begin
if Buffer.Send_Blocked then -- Request socket unblocking
Buffer.Send_Blocked := False;
Listener.Unblock_Send := True;
if Listener.Doer /= null then
Abort_Selector (Listener.Selector);
end if;
end if;
end Unblock_Send;
procedure Unblock_Send (Client : in out Connection) is
begin
Unblock_Send (Client.Socket_Listener.all, Client);
end Unblock_Send;
function Used (Buffer : Input_Buffer) return Stream_Element_Count is
Diff : constant Stream_Element_Offset :=
Buffer.Free_To_Read - Buffer.First_Read;
begin
if Diff < 0 then
return Buffer.Read'Length - Diff;
else
return Diff;
end if;
end Used;
function Used (Buffer : Output_Buffer) return Stream_Element_Count is
begin
if Buffer.Free_To_Write >= Buffer.First_Written then
return Buffer.Free_To_Write - Buffer.First_Written;
else
return Buffer.Written'Length - Buffer.First_Written +
Buffer.Free_To_Write;
end if;
end Used;
procedure Write
( Client : in out Connection;
Factory : in out Connections_Factory'Class;
Blocked : out Boolean
) is
Buffer : Output_Buffer renames Client.Written;
Next : Stream_Element_Count;
begin
Blocked := Buffer.First_Written = Buffer.Free_To_Write;
if Blocked then
if Client.Dont_Block then
Blocked := False;
Client.Data_Sent := True;
Client.Dont_Block := False;
end if;
else
loop
if Buffer.First_Written > Buffer.Free_To_Write then
--
-- [XXXXX XXXXXXX]
-- | |
-- Free_To_Write First_Written
--
if Client.Transport = null then
Send_Socket
( Client.Socket_Listener.all,
Client,
Buffer.Written
( Buffer.First_Written
.. Buffer.Written'Last
),
Next
);
else
Encode
( Client.Transport.all,
Client,
Buffer.Written
( Buffer.First_Written
.. Buffer.Written'Last
),
Next
);
end if;
Next := Next + 1;
if Next = Buffer.First_Written then
exit; -- Cannot send anything right now
elsif Next <= Buffer.Written'Last then
if 0 /= (Factory.Trace_Flags and Trace_Decoded_Sent)
then
Trace_Sent
( Factory => Factory,
Client => Client,
Data => Buffer.Written,
From => Buffer.First_Written,
To => Next - 1,
Encoded => False
);
end if;
Buffer.First_Written := Next;
Client.Data_Sent := True;
exit;
end if;
if 0 /= (Factory.Trace_Flags and Trace_Decoded_Sent) then
Trace_Sent
( Factory => Factory,
Client => Client,
Data => Buffer.Written,
From => Buffer.First_Written,
To => Next - 1,
Encoded => False
);
end if;
Buffer.First_Written := 0;
Client.Data_Sent := True;
else
--
-- [ XXXXXXXXXXXXXXX ]
-- | |
-- First_Written Free_To_Write
--
if Client.Transport = null then
Send_Socket
( Client.Socket_Listener.all,
Client,
Buffer.Written
( Buffer.First_Written
.. Buffer.Free_To_Write - 1
),
Next
);
else
Encode
( Client.Transport.all,
Client,
Buffer.Written
( Buffer.First_Written
.. Buffer.Free_To_Write - 1
),
Next
);
end if;
Next := Next + 1;
if Next = Buffer.First_Written then
exit;
elsif Next <= Buffer.Free_To_Write then
if 0 /= (Factory.Trace_Flags and Trace_Decoded_Sent)
then
Trace_Sent
( Factory => Factory,
Client => Client,
Data => Buffer.Written,
From => Buffer.First_Written,
To => Next - 1,
Encoded => False
);
end if;
Buffer.First_Written := Next;
Client.Data_Sent := True;
exit;
end if;
if 0 /= (Factory.Trace_Flags and Trace_Decoded_Sent) then
Trace_Sent
( Factory => Factory,
Client => Client,
Data => Buffer.Written,
From => Buffer.First_Written,
To => Next - 1,
Encoded => False
);
end if;
Buffer.First_Written := Next;
Client.Data_Sent := True;
end if;
exit when Buffer.First_Written = Buffer.Free_To_Write;
end loop;
end if;
end Write;
task body Worker is
Address : Sock_Addr_Type :=
Get_Server_Address (Listener.all);
Server_Socket : Socket_Type := No_Socket;
Client_Socket : Socket_Type;
That_Time : Time := Clock;
This_Time : Time;
Status : Selector_Status;
function Set_Image (Socket : Socket_Type) return String is
begin
return
( Image (Socket)
& ", listener"
& " read: " & Image (Listener.Read_Sockets)
& ", write: " & Image (Listener.Write_Sockets)
& ", blocked: " & Image (Listener.Blocked_Sockets)
& ", ready"
& " read: " & Image (Listener.Ready_To_Read)
& ", write: " & Image (Listener.Ready_To_Write)
);
end Set_Image;
procedure Check (Sockets : Socket_Set_Type) is
Socket : Socket_Type;
List : Socket_Set_Type := Sockets;
begin
loop
Get (List, Socket);
exit when Socket = No_Socket;
if Socket /= Server_Socket then
declare
Client : Connection_Ptr :=
Get (Listener.Connections, Socket);
begin
if Client = null then
Trace
( Listener.Factory.all,
( "Missing client when checking socket "
& Set_Image (Socket)
) );
Clear (Listener.Read_Sockets, Socket);
Clear (Listener.Write_Sockets, Socket);
Clear (Listener.Blocked_Sockets, Socket);
elsif Client.Failed then
if ( Client.Action_Request = Keep_Connection
and then
( Exception_Identity (Client.Last_Error)
/= Connection_Error'Identity
) )
then
Trace_Error
( Listener.Factory.all,
"Dropping connection on request",
Client.Last_Error
);
end if;
Stop (Listener.all, Client);
end if;
end;
end if;
end loop;
end Check;
procedure Unblock (Requested_Only : Boolean) is
Socket : Socket_Type;
begin
while not Listener.Finalizing loop
Get (Listener.Blocked_Sockets, Socket);
exit when Socket = No_Socket;
if Socket /= Server_Socket then
declare
Client : Connection_Ptr :=
Get (Listener.Connections, Socket);
begin
if Client = null then
Trace
( Listener.Factory.all,
( "Missing client when unblocking socket "
& Set_Image (Socket)
) );
Clear (Listener.Read_Sockets, Socket);
Clear (Listener.Write_Sockets, Socket);
Clear (Listener.Ready_To_Write, Socket);
elsif Client.Failed then
if ( Client.Session /= Session_Down
and then
Client.Action_Request = Keep_Connection
and then
( Exception_Identity (Client.Last_Error)
/= Connection_Error'Identity
) )
then
Trace_Error
( Listener.Factory.all,
"Unblocking socket",
Client.Last_Error
);
end if;
Stop (Listener.all, Client);
elsif ( Requested_Only
and then
Client.Written.Send_Blocked
) then -- Keep it blocked
Set (Listener.Ready_To_Read, Client.Socket);
else -- Unblock
Set (Listener.Write_Sockets, Client.Socket);
Set (Listener.Ready_To_Write, Client.Socket);
Status := Completed; -- Make sure it written later
Client.Written.Send_Blocked := False;
Client.Data_Sent := True;
if ( 0
/= ( Listener.Factory.Trace_Flags
and
(Trace_Encoded_Sent or Trace_Decoded_Sent)
) )
then
if Requested_Only then
Trace_Sending
( Listener.Factory.all,
Client.all,
True,
", some data to send"
);
else
Trace_Sending
( Listener.Factory.all,
Client.all,
True,
", blocking timeout expired"
);
end if;
end if;
end if;
end;
end if;
end loop;
end Unblock;
Exit_Error : exception;
begin
On_Worker_Start (Listener.all);
if Address.Port /= 0 then
Create_Socket (Listener.all, Server_Socket, Address);
if Server_Socket = No_Socket then
raise Exit_Error;
end if;
Set (Listener.Read_Sockets, Server_Socket);
end if;
Listener.Request.Activate;
loop
Trace_Service_Loop
( Listener.Factory.all,
Service_Loop_Begin,
Listener.all
);
if Listener.Shutdown_Request then
Listener.Shutdown_Request := False;
Check (Listener.Read_Sockets);
end if;
if Listener.Connect_Request then
declare
Client : Connection_Ptr;
begin
loop
Listener.Request.Get (Client);
exit when Client = null;
Set (Listener.Write_Sockets, Client.Socket);
Put (Listener.Connections, Client.Socket, Client);
declare
use Object;
Ptr : Entity_Ptr := Client.all'Unchecked_Access;
begin
Release (Ptr);
end;
Listener.Servers := Listener.Servers + 1;
Do_Connect (Listener.all, Client);
end loop;
end;
end if;
Copy (Listener.Read_Sockets, Listener.Ready_To_Read);
Copy (Listener.Write_Sockets, Listener.Ready_To_Write);
Check_Selector
( Selector => Listener.Selector,
R_Socket_Set => Listener.Ready_To_Read,
W_Socket_Set => Listener.Ready_To_Write,
Status => Status,
Timeout => Listener.IO_Timeout
);
exit when Listener.Finalizing;
if Status = Completed then
Trace_Service_Loop
( Listener.Factory.all,
Service_Loop_Reading,
Listener.all
);
loop -- Reading from sockets
Get (Listener.Ready_To_Read, Client_Socket);
exit when Client_Socket = No_Socket;
if Client_Socket = Server_Socket then
Accept_Socket
( Server_Socket,
Client_Socket,
Address
);
declare
Client : Connection_Ptr;
begin
Client :=
Create (Listener.Factory, Listener, Address);
if Client = null then
Close (Client_Socket);
else
declare
This : Connection'Class renames Client.all;
begin
This.Client := False;
This.Connect_No := 0;
This.Client_Address := Address;
This.Socket := Client_Socket;
This.Try_To_Reconnect := False;
Clear (This);
This.Socket_Listener :=
Listener.all'Unchecked_Access;
Set (Listener.Read_Sockets, Client_Socket);
Set (Listener.Write_Sockets, Client_Socket);
Put
( Listener.Connections,
Client_Socket,
Client
);
Listener.Clients := Listener.Clients + 1;
if not Is_Opportunistic (This) then
This.Transport :=
Create_Transport
( Listener.Factory,
Listener,
Client
);
end if;
if This.Transport = null then -- Ready
This.Session := Session_Connected;
Connected (This);
Connected (Listener.all, This);
This.Session := Session_Active;
Activated (This);
else
This.Session := Session_Handshaking;
end if;
end;
end if;
exception
when Connection_Error =>
if Client /= null then
Stop (Listener.all, Client);
end if;
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Accept socket",
Error
);
if Client /= null then
Stop (Listener.all, Client);
end if;
end;
else
declare
Client : Connection_Ptr :=
Get (Listener.Connections, Client_Socket);
begin
if Client = null then
Trace
( Listener.Factory.all,
( "Missing client when reading from socket "
& Set_Image (Client_Socket)
) );
Clear (Listener.Read_Sockets, Client_Socket);
Clear (Listener.Write_Sockets, Client_Socket);
Clear (Listener.Blocked_Sockets, Client_Socket);
Clear (Listener.Ready_To_Write, Client_Socket);
elsif Client.Failed then
if ( Client.Session /= Session_Down
and then
Client.Action_Request = Keep_Connection
and then
( Exception_Identity (Client.Last_Error)
/= Connection_Error'Identity
) )
then
Trace_Error
( Listener.Factory.all,
"Preparing to receive",
Client.Last_Error
);
end if;
Stop (Listener.all, Client);
else
begin
Read (Client.all, Listener.Factory.all);
exception
when Connection_Error =>
Stop (Listener.all, Client);
when Error : Socket_Error =>
Send_Error (Client.all, Error);
Stop (Listener.all, Client);
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Receive socket",
Error
);
Stop (Listener.all, Client);
end;
declare
Data_Left : Boolean;
begin
if Client /= null then
Process (Listener.all, Client, Data_Left);
if Data_Left then
Append
( Listener.Postponed,
Client,
Listener.Postponed_Count
);
end if;
end if;
exception
when Connection_Error =>
Stop (Listener.all, Client);
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Processing received",
Error
);
Stop (Listener.all, Client);
end;
end if;
end;
end if;
end loop;
else
Empty (Listener.Ready_To_Read); -- Clear the set
end if;
Trace_Service_Loop
( Listener.Factory.all,
Service_Loop_Unblocking,
Listener.all
);
This_Time := Clock;
if This_Time - That_Time > Listener.Polling_Timeout then
-- Unblock everything now
That_Time := This_Time;
Unblock (False);
if ( Server_Socket /= No_Socket
and then
not Is_Set (Listener.Read_Sockets, Server_Socket)
)
then
Trace
( Listener.Factory.all,
"Server socket fell out of the read sockets list"
);
Set (Listener.Read_Sockets, Server_Socket);
end if;
else
-- Checking for explicit unblocking requests
while Listener.Unblock_Send loop
Listener.Unblock_Send := False;
Unblock (True); -- Still blocked are now in Ready_To_Read
Copy (Listener.Ready_To_Read, Listener.Blocked_Sockets);
Empty (Listener.Ready_To_Read); -- Clear the set
end loop;
end if;
if Status = Completed then
Trace_Service_Loop
( Listener.Factory.all,
Service_Loop_Writing,
Listener.all
);
loop -- Writing sockets
Get (Listener.Ready_To_Write, Client_Socket);
exit when Client_Socket = No_Socket;
if Client_Socket /= Server_Socket then
declare
Client : Connection_Ptr :=
Get (Listener.Connections, Client_Socket);
begin
if Client = null then
Trace
( Listener.Factory.all,
( "Missing client when writing to socket "
& Set_Image (Client_Socket)
) );
Clear (Listener.Read_Sockets, Client_Socket);
Clear (Listener.Write_Sockets, Client_Socket);
Clear (Listener.Blocked_Sockets, Client_Socket);
elsif Client.Failed then
if ( Client.Session /= Session_Down
and then
Client.Action_Request = Keep_Connection
and then
( Exception_Identity (Client.Last_Error)
/= Connection_Error'Identity
) )
then
Trace_Error
( Listener.Factory.all,
"Preparing to send",
Client.Last_Error
);
end if;
Stop (Listener.all, Client);
elsif Client.Session = Session_Connecting then
declare
This : Connection'Class renames Client.all;
Code : constant Error_Type :=
Get_Socket_Option
( Client.Socket,
Socket_Level,
Error
) .Error;
begin
if Code = Success then -- Connected
On_Connected (Listener.all, This);
Set
( Listener.Read_Sockets,
Client_Socket
);
else -- Connect error
Trace_Sending
( Listener.Factory.all,
This,
False,
( ", failed to connect to "
& Image (This.Client_Address)
& ": " & Image (Code)
) );
Connect_Error (This, Code);
Do_Connect (Listener.all, Client);
end if;
exception
when Connection_Error =>
if Client /= null then
Client.Try_To_Reconnect := False;
Stop (Listener.all, Client);
end if;
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Connect socket",
Error
);
if Client /= null then
Client.Try_To_Reconnect := False;
Stop (Listener.all, Client);
end if;
end;
else -- Have space to write
declare
Block : Boolean;
begin
Write
( Client.all,
Listener.Factory.all,
Block
);
if ( Block
and then
not Client.Written.Send_Blocked
)
then
Client.Written.Send_Blocked := True;
Set
( Client.Socket_Listener.Blocked_Sockets,
Client.Socket
);
Clear
( Client.Socket_Listener.Write_Sockets,
Client.Socket
);
if ( 0
/= ( Listener.Factory.Trace_Flags
and
( Trace_Encoded_Sent
or Trace_Decoded_Sent
) ) )
then
Trace_Sending
( Listener.Factory.all,
Client.all,
False,
", nothing to send"
);
end if;
end if;
exception
when Connection_Error =>
Stop (Listener.all, Client);
when Error : Socket_Error =>
Send_Error (Client.all, Error);
Stop (Listener.all, Client);
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Send socket",
Error
);
Stop (Listener.all, Client);
end;
begin
if Client /= null and then Client.Data_Sent
then
Data_Sent (Listener.all, Client);
end if;
exception
when Connection_Error =>
Stop (Listener.all, Client);
when Error : others =>
Trace_Error
( Listener.Factory.all,
"Processing sent notification",
Error
);
Stop (Listener.all, Client);
end;
end if;
end;
end if;
end loop;
else
Empty (Listener.Ready_To_Write); -- Clear the set
end if;
exit when Listener.Finalizing;
Trace_Service_Loop
( Listener.Factory.all,
Service_Loop_Postponed,
Listener.all
);
Service_Postponed (Listener.all);
end loop;
declare
Client : Connection_Ptr;
begin
loop
Listener.Request.Get (Client);
exit when Client = null;
declare
use Object;
Ptr : Entity_Ptr := Client.all'Unchecked_Access;
begin
Release (Ptr);
end;
end loop;
end;
Close (Server_Socket);
Trace (Listener.Factory.all, "Worker task exiting");
exception
when Exit_Error =>
Trace (Listener.Factory.all, "Worker task exiting");
when Error : others =>
Close (Server_Socket);
Trace_Error (Listener.Factory.all, "Worker task", Error);
end Worker;
protected body Box is
entry Connect (Client : Connection_Ptr)
when Active and then Pending = null is
begin
if Client /= null then
Pending := Client;
Client.Socket_Listener.Connect_Request := True;
Abort_Selector (Listener.Selector);
end if;
end Connect;
procedure Activate is
begin
Active := True;
end Activate;
procedure Get (Client : out Connection_Ptr) is
begin
if Pending = null then
Client := null;
else
Client := Pending;
Pending := null;
Client.Socket_Listener.Connect_Request := False;
end if;
end Get;
end Box;
end GNAT.Sockets.Server;
|
[
{
"context": "-- WORDS, a Latin dictionary, by Colonel William Whitaker (USAF, Retired)\n--\n-- Copyright William A. Whitak",
"end": 57,
"score": 0.9998485445976257,
"start": 33,
"tag": "NAME",
"value": "Colonel William Whitaker"
},
{
"context": "l William Whitaker (USAF, Retired)\n--\n-- Copyright William A. Whitaker (1936–2010)\n--\n-- This is a free program, which m",
"end": 109,
"score": 0.9998469948768616,
"start": 90,
"tag": "NAME",
"value": "William A. Whitaker"
}
] | src/latin_utils/latin_utils-dictionary_package.adb | spr93/whitakers-words | 204 | -- WORDS, a Latin dictionary, by Colonel William Whitaker (USAF, Retired)
--
-- Copyright William A. Whitaker (1936–2010)
--
-- This is a free program, which means it is proper to copy it and pass
-- it on to your friends. Consider it a developmental item for which
-- there is no charge. However, just for form, it is Copyrighted
-- (c). Permission is hereby freely given for any and all use of program
-- and data. You can sell it as your own, but at least tell me.
--
-- This version is distributed without obligation, but the developer
-- would appreciate comments and suggestions.
--
-- All parts of the WORDS system, source code and data files, are made freely
-- available to anyone who wishes to use them, for whatever purpose.
with Latin_Utils.Strings_Package; use Latin_Utils.Strings_Package;
package body Latin_Utils.Dictionary_Package is
---------------------------------------------------------------------------
MNPC_IO_Default_Width : constant Natural := 6;
Numeral_Value_Type_IO_Default_Width : constant Natural := 5;
---------------------------------------------------------------------------
function Number_Of_Stems (Part : Part_Of_Speech_Type) return Stem_Key_Type is
begin
case Part is
when N => return 2;
when Pron => return 2;
when Pack => return 2;
when Adj => return 4;
when Num => return 4;
when Adv => return 3;
when V => return 4;
when Vpar => return 0;
when Supine => return 0;
when Prep => return 1;
when Conj => return 1;
when Interj => return 1;
when X => return 0;
when Tackon .. Suffix => return 0;
end case;
end Number_Of_Stems;
---------------------------------------------------------------------------
package body Parse_Record_IO is separate;
package body Noun_Entry_IO is separate;
package body Pronoun_Entry_IO is separate;
package body Propack_Entry_IO is separate;
package body Adjective_Entry_IO is separate;
package body Numeral_Entry_IO is separate;
package body Adverb_Entry_IO is separate;
package body Verb_Entry_IO is separate;
package body Preposition_Entry_IO is separate;
package body Conjunction_Entry_IO is separate;
package body Interjection_Entry_IO is separate;
package body Part_Entry_IO is separate;
package body Kind_Entry_IO is separate;
package body Translation_Record_IO is separate;
package body Dictionary_Entry_IO is separate;
---------------------------------------------------------------------------
function "<" (Left, Right : Part_Entry) return Boolean is
begin
if Left.Pofs = Right.Pofs then
case Left.Pofs is
when N =>
if Left.N.Decl < Right.N.Decl or else
(Left.N.Decl = Right.N.Decl and then
Left.N.Gender < Right.N.Gender) or else
((Left.N.Decl = Right.N.Decl and
Left.N.Gender = Right.N.Gender) and then
Left.N.Kind < Right.N.Kind)
then
return True;
end if;
when Pron =>
if Left.Pron.Decl < Right.Pron.Decl or else
(Left.Pron.Decl = Right.Pron.Decl and then
Left.Pron.Kind < Right.Pron.Kind)
then
return True;
end if;
when Pack =>
if Left.Pack.Decl < Right.Pack.Decl or else
(Left.Pack.Decl = Right.Pack.Decl and then
Left.Pack.Kind < Right.Pack.Kind)
then
return True;
end if;
when Adj =>
if Left.Adj.Decl < Right.Adj.Decl or else
(Left.Adj.Decl = Right.Adj.Decl and then
Left.Adj.Co < Right.Adj.Co)
then
return True;
end if;
when Num =>
if Left.Num.Decl < Right.Num.Decl or else
(Left.Num.Decl = Right.Num.Decl and then
Left.Num.Sort < Right.Num.Sort) or else
((Left.Num.Decl = Right.Num.Decl) and then
(Left.Num.Sort = Right.Num.Sort) and then
Left.Num.Value < Right.Num.Value)
then
return True;
end if;
when Adv =>
return Left.Adv.Co < Right.Adv.Co;
when V =>
if (Left.V.Con < Right.V.Con) or else
(Left.V.Con = Right.V.Con and then
Left.V.Kind < Right.V.Kind)
then
return True;
end if;
when Prep =>
return Left.Prep.Obj < Right.Prep.Obj;
when Vpar .. Supine =>
null;
when X =>
null;
when Conj .. Suffix =>
null;
end case;
else
return Left.Pofs < Right.Pofs;
end if;
return False;
exception
when Constraint_Error =>
return Left.Pofs < Right.Pofs;
end "<";
---------------------------------------------------------------------------
overriding function "<=" (Left, Right : Area_Type) return Boolean is
begin
if Right = Left or else Right = X then
return True;
else
return False;
end if;
end "<=";
---------------------------------------------------------------------------
-- Used to initialize Latin_Utils Dictionary_Package by setting various vars.
-- FIXME: Make AT LEAST some of these initializations to happen in spec,
-- thus eliminating risks of someone modifying them and in result breaking
-- every nested package.
procedure Initialize
is
begin
Dictionary_Kind_IO.Default_Width := Dictionary_Kind'Width;
Area_Type_IO.Default_Width := Area_Type'Width;
Geo_Type_IO.Default_Width := Geo_Type'Width;
Frequency_Type_IO.Default_Width := Frequency_Type'Width;
Source_Type_IO.Default_Width := Source_Type'Width;
Parse_Record_IO.Default_Width :=
Stem_Type_IO.Default_Width + 1 +
Inflection_Record_IO.Default_Width + 1 +
Dictionary_Kind_IO.Default_Width + 1 +
MNPC_IO_Default_Width;
Noun_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Gender_Type_IO.Default_Width + 1 +
Noun_Kind_Type_IO.Default_Width;
Pronoun_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Pronoun_Kind_Type_IO.Default_Width;
Propack_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Pronoun_Kind_Type_IO.Default_Width;
Adjective_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Comparison_Type_IO.Default_Width;
Adverb_Entry_IO.Default_Width :=
Comparison_Type_IO.Default_Width;
Verb_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Verb_Kind_Type_IO.Default_Width;
Preposition_Entry_IO.Default_Width := 0;
Conjunction_Entry_IO.Default_Width := 0;
Interjection_Entry_IO.Default_Width := 0;
Numeral_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Numeral_Sort_Type_IO.Default_Width + 1 +
Numeral_Value_Type_IO_Default_Width;
Part_Entry_IO.Default_Width := Part_Of_Speech_Type_IO.Default_Width + 1 +
Numeral_Entry_IO.Default_Width; -- Largest
Translation_Record_IO.Default_Width :=
Age_Type_IO.Default_Width + 1 +
Area_Type_IO.Default_Width + 1 +
Geo_Type_IO.Default_Width + 1 +
Frequency_Type_IO.Default_Width + 1 +
Source_Type_IO.Default_Width;
Dictionary_Entry_IO.Default_Width := 4 * (Max_Stem_Size + 1) +
Part_Entry_IO.Default_Width + 1 +
Translation_Record_IO.Default_Width + 1 +
Max_Meaning_Size;
end Initialize;
---------------------------------------------------------------------------
begin
Initialize;
end Latin_Utils.Dictionary_Package;
| 21633 | -- WORDS, a Latin dictionary, by <NAME> (USAF, Retired)
--
-- Copyright <NAME> (1936–2010)
--
-- This is a free program, which means it is proper to copy it and pass
-- it on to your friends. Consider it a developmental item for which
-- there is no charge. However, just for form, it is Copyrighted
-- (c). Permission is hereby freely given for any and all use of program
-- and data. You can sell it as your own, but at least tell me.
--
-- This version is distributed without obligation, but the developer
-- would appreciate comments and suggestions.
--
-- All parts of the WORDS system, source code and data files, are made freely
-- available to anyone who wishes to use them, for whatever purpose.
with Latin_Utils.Strings_Package; use Latin_Utils.Strings_Package;
package body Latin_Utils.Dictionary_Package is
---------------------------------------------------------------------------
MNPC_IO_Default_Width : constant Natural := 6;
Numeral_Value_Type_IO_Default_Width : constant Natural := 5;
---------------------------------------------------------------------------
function Number_Of_Stems (Part : Part_Of_Speech_Type) return Stem_Key_Type is
begin
case Part is
when N => return 2;
when Pron => return 2;
when Pack => return 2;
when Adj => return 4;
when Num => return 4;
when Adv => return 3;
when V => return 4;
when Vpar => return 0;
when Supine => return 0;
when Prep => return 1;
when Conj => return 1;
when Interj => return 1;
when X => return 0;
when Tackon .. Suffix => return 0;
end case;
end Number_Of_Stems;
---------------------------------------------------------------------------
package body Parse_Record_IO is separate;
package body Noun_Entry_IO is separate;
package body Pronoun_Entry_IO is separate;
package body Propack_Entry_IO is separate;
package body Adjective_Entry_IO is separate;
package body Numeral_Entry_IO is separate;
package body Adverb_Entry_IO is separate;
package body Verb_Entry_IO is separate;
package body Preposition_Entry_IO is separate;
package body Conjunction_Entry_IO is separate;
package body Interjection_Entry_IO is separate;
package body Part_Entry_IO is separate;
package body Kind_Entry_IO is separate;
package body Translation_Record_IO is separate;
package body Dictionary_Entry_IO is separate;
---------------------------------------------------------------------------
function "<" (Left, Right : Part_Entry) return Boolean is
begin
if Left.Pofs = Right.Pofs then
case Left.Pofs is
when N =>
if Left.N.Decl < Right.N.Decl or else
(Left.N.Decl = Right.N.Decl and then
Left.N.Gender < Right.N.Gender) or else
((Left.N.Decl = Right.N.Decl and
Left.N.Gender = Right.N.Gender) and then
Left.N.Kind < Right.N.Kind)
then
return True;
end if;
when Pron =>
if Left.Pron.Decl < Right.Pron.Decl or else
(Left.Pron.Decl = Right.Pron.Decl and then
Left.Pron.Kind < Right.Pron.Kind)
then
return True;
end if;
when Pack =>
if Left.Pack.Decl < Right.Pack.Decl or else
(Left.Pack.Decl = Right.Pack.Decl and then
Left.Pack.Kind < Right.Pack.Kind)
then
return True;
end if;
when Adj =>
if Left.Adj.Decl < Right.Adj.Decl or else
(Left.Adj.Decl = Right.Adj.Decl and then
Left.Adj.Co < Right.Adj.Co)
then
return True;
end if;
when Num =>
if Left.Num.Decl < Right.Num.Decl or else
(Left.Num.Decl = Right.Num.Decl and then
Left.Num.Sort < Right.Num.Sort) or else
((Left.Num.Decl = Right.Num.Decl) and then
(Left.Num.Sort = Right.Num.Sort) and then
Left.Num.Value < Right.Num.Value)
then
return True;
end if;
when Adv =>
return Left.Adv.Co < Right.Adv.Co;
when V =>
if (Left.V.Con < Right.V.Con) or else
(Left.V.Con = Right.V.Con and then
Left.V.Kind < Right.V.Kind)
then
return True;
end if;
when Prep =>
return Left.Prep.Obj < Right.Prep.Obj;
when Vpar .. Supine =>
null;
when X =>
null;
when Conj .. Suffix =>
null;
end case;
else
return Left.Pofs < Right.Pofs;
end if;
return False;
exception
when Constraint_Error =>
return Left.Pofs < Right.Pofs;
end "<";
---------------------------------------------------------------------------
overriding function "<=" (Left, Right : Area_Type) return Boolean is
begin
if Right = Left or else Right = X then
return True;
else
return False;
end if;
end "<=";
---------------------------------------------------------------------------
-- Used to initialize Latin_Utils Dictionary_Package by setting various vars.
-- FIXME: Make AT LEAST some of these initializations to happen in spec,
-- thus eliminating risks of someone modifying them and in result breaking
-- every nested package.
procedure Initialize
is
begin
Dictionary_Kind_IO.Default_Width := Dictionary_Kind'Width;
Area_Type_IO.Default_Width := Area_Type'Width;
Geo_Type_IO.Default_Width := Geo_Type'Width;
Frequency_Type_IO.Default_Width := Frequency_Type'Width;
Source_Type_IO.Default_Width := Source_Type'Width;
Parse_Record_IO.Default_Width :=
Stem_Type_IO.Default_Width + 1 +
Inflection_Record_IO.Default_Width + 1 +
Dictionary_Kind_IO.Default_Width + 1 +
MNPC_IO_Default_Width;
Noun_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Gender_Type_IO.Default_Width + 1 +
Noun_Kind_Type_IO.Default_Width;
Pronoun_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Pronoun_Kind_Type_IO.Default_Width;
Propack_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Pronoun_Kind_Type_IO.Default_Width;
Adjective_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Comparison_Type_IO.Default_Width;
Adverb_Entry_IO.Default_Width :=
Comparison_Type_IO.Default_Width;
Verb_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Verb_Kind_Type_IO.Default_Width;
Preposition_Entry_IO.Default_Width := 0;
Conjunction_Entry_IO.Default_Width := 0;
Interjection_Entry_IO.Default_Width := 0;
Numeral_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Numeral_Sort_Type_IO.Default_Width + 1 +
Numeral_Value_Type_IO_Default_Width;
Part_Entry_IO.Default_Width := Part_Of_Speech_Type_IO.Default_Width + 1 +
Numeral_Entry_IO.Default_Width; -- Largest
Translation_Record_IO.Default_Width :=
Age_Type_IO.Default_Width + 1 +
Area_Type_IO.Default_Width + 1 +
Geo_Type_IO.Default_Width + 1 +
Frequency_Type_IO.Default_Width + 1 +
Source_Type_IO.Default_Width;
Dictionary_Entry_IO.Default_Width := 4 * (Max_Stem_Size + 1) +
Part_Entry_IO.Default_Width + 1 +
Translation_Record_IO.Default_Width + 1 +
Max_Meaning_Size;
end Initialize;
---------------------------------------------------------------------------
begin
Initialize;
end Latin_Utils.Dictionary_Package;
| true | -- WORDS, a Latin dictionary, by PI:NAME:<NAME>END_PI (USAF, Retired)
--
-- Copyright PI:NAME:<NAME>END_PI (1936–2010)
--
-- This is a free program, which means it is proper to copy it and pass
-- it on to your friends. Consider it a developmental item for which
-- there is no charge. However, just for form, it is Copyrighted
-- (c). Permission is hereby freely given for any and all use of program
-- and data. You can sell it as your own, but at least tell me.
--
-- This version is distributed without obligation, but the developer
-- would appreciate comments and suggestions.
--
-- All parts of the WORDS system, source code and data files, are made freely
-- available to anyone who wishes to use them, for whatever purpose.
with Latin_Utils.Strings_Package; use Latin_Utils.Strings_Package;
package body Latin_Utils.Dictionary_Package is
---------------------------------------------------------------------------
MNPC_IO_Default_Width : constant Natural := 6;
Numeral_Value_Type_IO_Default_Width : constant Natural := 5;
---------------------------------------------------------------------------
function Number_Of_Stems (Part : Part_Of_Speech_Type) return Stem_Key_Type is
begin
case Part is
when N => return 2;
when Pron => return 2;
when Pack => return 2;
when Adj => return 4;
when Num => return 4;
when Adv => return 3;
when V => return 4;
when Vpar => return 0;
when Supine => return 0;
when Prep => return 1;
when Conj => return 1;
when Interj => return 1;
when X => return 0;
when Tackon .. Suffix => return 0;
end case;
end Number_Of_Stems;
---------------------------------------------------------------------------
package body Parse_Record_IO is separate;
package body Noun_Entry_IO is separate;
package body Pronoun_Entry_IO is separate;
package body Propack_Entry_IO is separate;
package body Adjective_Entry_IO is separate;
package body Numeral_Entry_IO is separate;
package body Adverb_Entry_IO is separate;
package body Verb_Entry_IO is separate;
package body Preposition_Entry_IO is separate;
package body Conjunction_Entry_IO is separate;
package body Interjection_Entry_IO is separate;
package body Part_Entry_IO is separate;
package body Kind_Entry_IO is separate;
package body Translation_Record_IO is separate;
package body Dictionary_Entry_IO is separate;
---------------------------------------------------------------------------
function "<" (Left, Right : Part_Entry) return Boolean is
begin
if Left.Pofs = Right.Pofs then
case Left.Pofs is
when N =>
if Left.N.Decl < Right.N.Decl or else
(Left.N.Decl = Right.N.Decl and then
Left.N.Gender < Right.N.Gender) or else
((Left.N.Decl = Right.N.Decl and
Left.N.Gender = Right.N.Gender) and then
Left.N.Kind < Right.N.Kind)
then
return True;
end if;
when Pron =>
if Left.Pron.Decl < Right.Pron.Decl or else
(Left.Pron.Decl = Right.Pron.Decl and then
Left.Pron.Kind < Right.Pron.Kind)
then
return True;
end if;
when Pack =>
if Left.Pack.Decl < Right.Pack.Decl or else
(Left.Pack.Decl = Right.Pack.Decl and then
Left.Pack.Kind < Right.Pack.Kind)
then
return True;
end if;
when Adj =>
if Left.Adj.Decl < Right.Adj.Decl or else
(Left.Adj.Decl = Right.Adj.Decl and then
Left.Adj.Co < Right.Adj.Co)
then
return True;
end if;
when Num =>
if Left.Num.Decl < Right.Num.Decl or else
(Left.Num.Decl = Right.Num.Decl and then
Left.Num.Sort < Right.Num.Sort) or else
((Left.Num.Decl = Right.Num.Decl) and then
(Left.Num.Sort = Right.Num.Sort) and then
Left.Num.Value < Right.Num.Value)
then
return True;
end if;
when Adv =>
return Left.Adv.Co < Right.Adv.Co;
when V =>
if (Left.V.Con < Right.V.Con) or else
(Left.V.Con = Right.V.Con and then
Left.V.Kind < Right.V.Kind)
then
return True;
end if;
when Prep =>
return Left.Prep.Obj < Right.Prep.Obj;
when Vpar .. Supine =>
null;
when X =>
null;
when Conj .. Suffix =>
null;
end case;
else
return Left.Pofs < Right.Pofs;
end if;
return False;
exception
when Constraint_Error =>
return Left.Pofs < Right.Pofs;
end "<";
---------------------------------------------------------------------------
overriding function "<=" (Left, Right : Area_Type) return Boolean is
begin
if Right = Left or else Right = X then
return True;
else
return False;
end if;
end "<=";
---------------------------------------------------------------------------
-- Used to initialize Latin_Utils Dictionary_Package by setting various vars.
-- FIXME: Make AT LEAST some of these initializations to happen in spec,
-- thus eliminating risks of someone modifying them and in result breaking
-- every nested package.
procedure Initialize
is
begin
Dictionary_Kind_IO.Default_Width := Dictionary_Kind'Width;
Area_Type_IO.Default_Width := Area_Type'Width;
Geo_Type_IO.Default_Width := Geo_Type'Width;
Frequency_Type_IO.Default_Width := Frequency_Type'Width;
Source_Type_IO.Default_Width := Source_Type'Width;
Parse_Record_IO.Default_Width :=
Stem_Type_IO.Default_Width + 1 +
Inflection_Record_IO.Default_Width + 1 +
Dictionary_Kind_IO.Default_Width + 1 +
MNPC_IO_Default_Width;
Noun_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Gender_Type_IO.Default_Width + 1 +
Noun_Kind_Type_IO.Default_Width;
Pronoun_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Pronoun_Kind_Type_IO.Default_Width;
Propack_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Pronoun_Kind_Type_IO.Default_Width;
Adjective_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Comparison_Type_IO.Default_Width;
Adverb_Entry_IO.Default_Width :=
Comparison_Type_IO.Default_Width;
Verb_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Verb_Kind_Type_IO.Default_Width;
Preposition_Entry_IO.Default_Width := 0;
Conjunction_Entry_IO.Default_Width := 0;
Interjection_Entry_IO.Default_Width := 0;
Numeral_Entry_IO.Default_Width :=
Decn_Record_IO.Default_Width + 1 +
Numeral_Sort_Type_IO.Default_Width + 1 +
Numeral_Value_Type_IO_Default_Width;
Part_Entry_IO.Default_Width := Part_Of_Speech_Type_IO.Default_Width + 1 +
Numeral_Entry_IO.Default_Width; -- Largest
Translation_Record_IO.Default_Width :=
Age_Type_IO.Default_Width + 1 +
Area_Type_IO.Default_Width + 1 +
Geo_Type_IO.Default_Width + 1 +
Frequency_Type_IO.Default_Width + 1 +
Source_Type_IO.Default_Width;
Dictionary_Entry_IO.Default_Width := 4 * (Max_Stem_Size + 1) +
Part_Entry_IO.Default_Width + 1 +
Translation_Record_IO.Default_Width + 1 +
Max_Meaning_Size;
end Initialize;
---------------------------------------------------------------------------
begin
Initialize;
end Latin_Utils.Dictionary_Package;
|
[
{
"context": "le DirectMedia Layer\n -- Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>\n -- This software is provi",
"end": 1062,
"score": 0.9998801946640015,
"start": 1050,
"tag": "NAME",
"value": "Sam Lantinga"
},
{
"context": "Layer\n -- Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>\n -- This software is provided 'as-is', without",
"end": 1082,
"score": 0.9999293088912964,
"start": 1064,
"tag": "EMAIL",
"value": "slouken@libsdl.org"
}
] | extern/gnat_sdl/gnat_sdl2/src/sdl_h.ads | AdaCore/training_material | 15 | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with SDL_stdinc_h;
package SDL_h is
SDL_INIT_TIMER : constant := 16#00000001#; -- ..\SDL2_tmp\SDL.h:77
SDL_INIT_AUDIO : constant := 16#00000010#; -- ..\SDL2_tmp\SDL.h:78
SDL_INIT_VIDEO : constant := 16#00000020#; -- ..\SDL2_tmp\SDL.h:79
SDL_INIT_JOYSTICK : constant := 16#00000200#; -- ..\SDL2_tmp\SDL.h:80
SDL_INIT_HAPTIC : constant := 16#00001000#; -- ..\SDL2_tmp\SDL.h:81
SDL_INIT_GAMECONTROLLER : constant := 16#00002000#; -- ..\SDL2_tmp\SDL.h:82
SDL_INIT_EVENTS : constant := 16#00004000#; -- ..\SDL2_tmp\SDL.h:83
SDL_INIT_SENSOR : constant := 16#00008000#; -- ..\SDL2_tmp\SDL.h:84
SDL_INIT_NOPARACHUTE : constant := 16#00100000#; -- ..\SDL2_tmp\SDL.h:85
-- unsupported macro: SDL_INIT_EVERYTHING ( SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | SDL_INIT_SENSOR )
-- Simple DirectMedia Layer
-- Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
-- 3. This notice may not be removed or altered from any source distribution.
--
--*
-- * \file SDL.h
-- *
-- * Main include header for the SDL library
--
-- Set up for C function definitions, even when using C++
-- As of version 0.5, SDL is loaded dynamically into the application
--*
-- * \name SDL_INIT_*
-- *
-- * These are the flags which may be passed to SDL_Init(). You should
-- * specify the subsystems which you will be using in your application.
--
-- @{
-- @}
--*
-- * This function initializes the subsystems specified by \c flags
--
function SDL_Init (flags : SDL_stdinc_h.Uint32) return int; -- ..\SDL2_tmp\SDL.h:95
pragma Import (C, SDL_Init, "SDL_Init");
--*
-- * This function initializes specific SDL subsystems
-- *
-- * Subsystem initialization is ref-counted, you must call
-- * SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly
-- * shutdown a subsystem manually (or call SDL_Quit() to force shutdown).
-- * If a subsystem is already loaded then this call will
-- * increase the ref-count and return.
--
function SDL_InitSubSystem (flags : SDL_stdinc_h.Uint32) return int; -- ..\SDL2_tmp\SDL.h:106
pragma Import (C, SDL_InitSubSystem, "SDL_InitSubSystem");
--*
-- * This function cleans up specific SDL subsystems
--
procedure SDL_QuitSubSystem (flags : SDL_stdinc_h.Uint32); -- ..\SDL2_tmp\SDL.h:111
pragma Import (C, SDL_QuitSubSystem, "SDL_QuitSubSystem");
--*
-- * This function returns a mask of the specified subsystems which have
-- * previously been initialized.
-- *
-- * If \c flags is 0, it returns a mask of all initialized subsystems.
--
function SDL_WasInit (flags : SDL_stdinc_h.Uint32) return SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL.h:119
pragma Import (C, SDL_WasInit, "SDL_WasInit");
--*
-- * This function cleans up all initialized subsystems. You should
-- * call it upon all exit conditions.
--
procedure SDL_Quit; -- ..\SDL2_tmp\SDL.h:125
pragma Import (C, SDL_Quit, "SDL_Quit");
-- Ends C function definitions when using C++
-- vi: set ts=4 sw=4 expandtab:
end SDL_h;
| 2296 | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with SDL_stdinc_h;
package SDL_h is
SDL_INIT_TIMER : constant := 16#00000001#; -- ..\SDL2_tmp\SDL.h:77
SDL_INIT_AUDIO : constant := 16#00000010#; -- ..\SDL2_tmp\SDL.h:78
SDL_INIT_VIDEO : constant := 16#00000020#; -- ..\SDL2_tmp\SDL.h:79
SDL_INIT_JOYSTICK : constant := 16#00000200#; -- ..\SDL2_tmp\SDL.h:80
SDL_INIT_HAPTIC : constant := 16#00001000#; -- ..\SDL2_tmp\SDL.h:81
SDL_INIT_GAMECONTROLLER : constant := 16#00002000#; -- ..\SDL2_tmp\SDL.h:82
SDL_INIT_EVENTS : constant := 16#00004000#; -- ..\SDL2_tmp\SDL.h:83
SDL_INIT_SENSOR : constant := 16#00008000#; -- ..\SDL2_tmp\SDL.h:84
SDL_INIT_NOPARACHUTE : constant := 16#00100000#; -- ..\SDL2_tmp\SDL.h:85
-- unsupported macro: SDL_INIT_EVERYTHING ( SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | SDL_INIT_SENSOR )
-- Simple DirectMedia Layer
-- Copyright (C) 1997-2018 <NAME> <<EMAIL>>
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
-- 3. This notice may not be removed or altered from any source distribution.
--
--*
-- * \file SDL.h
-- *
-- * Main include header for the SDL library
--
-- Set up for C function definitions, even when using C++
-- As of version 0.5, SDL is loaded dynamically into the application
--*
-- * \name SDL_INIT_*
-- *
-- * These are the flags which may be passed to SDL_Init(). You should
-- * specify the subsystems which you will be using in your application.
--
-- @{
-- @}
--*
-- * This function initializes the subsystems specified by \c flags
--
function SDL_Init (flags : SDL_stdinc_h.Uint32) return int; -- ..\SDL2_tmp\SDL.h:95
pragma Import (C, SDL_Init, "SDL_Init");
--*
-- * This function initializes specific SDL subsystems
-- *
-- * Subsystem initialization is ref-counted, you must call
-- * SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly
-- * shutdown a subsystem manually (or call SDL_Quit() to force shutdown).
-- * If a subsystem is already loaded then this call will
-- * increase the ref-count and return.
--
function SDL_InitSubSystem (flags : SDL_stdinc_h.Uint32) return int; -- ..\SDL2_tmp\SDL.h:106
pragma Import (C, SDL_InitSubSystem, "SDL_InitSubSystem");
--*
-- * This function cleans up specific SDL subsystems
--
procedure SDL_QuitSubSystem (flags : SDL_stdinc_h.Uint32); -- ..\SDL2_tmp\SDL.h:111
pragma Import (C, SDL_QuitSubSystem, "SDL_QuitSubSystem");
--*
-- * This function returns a mask of the specified subsystems which have
-- * previously been initialized.
-- *
-- * If \c flags is 0, it returns a mask of all initialized subsystems.
--
function SDL_WasInit (flags : SDL_stdinc_h.Uint32) return SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL.h:119
pragma Import (C, SDL_WasInit, "SDL_WasInit");
--*
-- * This function cleans up all initialized subsystems. You should
-- * call it upon all exit conditions.
--
procedure SDL_Quit; -- ..\SDL2_tmp\SDL.h:125
pragma Import (C, SDL_Quit, "SDL_Quit");
-- Ends C function definitions when using C++
-- vi: set ts=4 sw=4 expandtab:
end SDL_h;
| true | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with SDL_stdinc_h;
package SDL_h is
SDL_INIT_TIMER : constant := 16#00000001#; -- ..\SDL2_tmp\SDL.h:77
SDL_INIT_AUDIO : constant := 16#00000010#; -- ..\SDL2_tmp\SDL.h:78
SDL_INIT_VIDEO : constant := 16#00000020#; -- ..\SDL2_tmp\SDL.h:79
SDL_INIT_JOYSTICK : constant := 16#00000200#; -- ..\SDL2_tmp\SDL.h:80
SDL_INIT_HAPTIC : constant := 16#00001000#; -- ..\SDL2_tmp\SDL.h:81
SDL_INIT_GAMECONTROLLER : constant := 16#00002000#; -- ..\SDL2_tmp\SDL.h:82
SDL_INIT_EVENTS : constant := 16#00004000#; -- ..\SDL2_tmp\SDL.h:83
SDL_INIT_SENSOR : constant := 16#00008000#; -- ..\SDL2_tmp\SDL.h:84
SDL_INIT_NOPARACHUTE : constant := 16#00100000#; -- ..\SDL2_tmp\SDL.h:85
-- unsupported macro: SDL_INIT_EVERYTHING ( SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | SDL_INIT_SENSOR )
-- Simple DirectMedia Layer
-- Copyright (C) 1997-2018 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
-- 3. This notice may not be removed or altered from any source distribution.
--
--*
-- * \file SDL.h
-- *
-- * Main include header for the SDL library
--
-- Set up for C function definitions, even when using C++
-- As of version 0.5, SDL is loaded dynamically into the application
--*
-- * \name SDL_INIT_*
-- *
-- * These are the flags which may be passed to SDL_Init(). You should
-- * specify the subsystems which you will be using in your application.
--
-- @{
-- @}
--*
-- * This function initializes the subsystems specified by \c flags
--
function SDL_Init (flags : SDL_stdinc_h.Uint32) return int; -- ..\SDL2_tmp\SDL.h:95
pragma Import (C, SDL_Init, "SDL_Init");
--*
-- * This function initializes specific SDL subsystems
-- *
-- * Subsystem initialization is ref-counted, you must call
-- * SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly
-- * shutdown a subsystem manually (or call SDL_Quit() to force shutdown).
-- * If a subsystem is already loaded then this call will
-- * increase the ref-count and return.
--
function SDL_InitSubSystem (flags : SDL_stdinc_h.Uint32) return int; -- ..\SDL2_tmp\SDL.h:106
pragma Import (C, SDL_InitSubSystem, "SDL_InitSubSystem");
--*
-- * This function cleans up specific SDL subsystems
--
procedure SDL_QuitSubSystem (flags : SDL_stdinc_h.Uint32); -- ..\SDL2_tmp\SDL.h:111
pragma Import (C, SDL_QuitSubSystem, "SDL_QuitSubSystem");
--*
-- * This function returns a mask of the specified subsystems which have
-- * previously been initialized.
-- *
-- * If \c flags is 0, it returns a mask of all initialized subsystems.
--
function SDL_WasInit (flags : SDL_stdinc_h.Uint32) return SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL.h:119
pragma Import (C, SDL_WasInit, "SDL_WasInit");
--*
-- * This function cleans up all initialized subsystems. You should
-- * call it upon all exit conditions.
--
procedure SDL_Quit; -- ..\SDL2_tmp\SDL.h:125
pragma Import (C, SDL_Quit, "SDL_Quit");
-- Ends C function definitions when using C++
-- vi: set ts=4 sw=4 expandtab:
end SDL_h;
|
[
{
"context": "-- Ada Unit Library\n--\n-- Authors: Emanuel Regnath (emanuel.regnath@tum.de)\n--\n-- Description: Libra",
"end": 50,
"score": 0.9998912811279297,
"start": 35,
"tag": "NAME",
"value": "Emanuel Regnath"
},
{
"context": " Ada Unit Library\n--\n-- Authors: Emanuel Regnath (emanuel.regnath@tum.de)\n--\n-- Description: Library for physical calculat",
"end": 74,
"score": 0.9999281764030457,
"start": 52,
"tag": "EMAIL",
"value": "emanuel.regnath@tum.de"
}
] | software/lib/units-vectors.ads | TUM-EI-RCS/StratoX | 12 | -- Ada Unit Library
--
-- Authors: Emanuel Regnath (emanuel.regnath@tum.de)
--
-- Description: Library for physical calculations
--
-- ToDo:
-- [ ] rename to Units.Mechanics3D or Physics.Units, Physics.Vector3D
with Ada.Numerics.Generic_Real_Arrays;
package Units.Vectors with SPARK_Mode is
package Unit_Arrays_Pack is new Ada.Numerics.Generic_Real_Arrays(Base_Unit_Type);
subtype Scalar is Base_Unit_Type;
type Vector3D_Type is array(1 .. 3) of Base_Unit_Type;
type Polar_Coordinates_Type is (Phi, Rho, Psi);
type Earth_Coordinates_Type is (LONGITUDE, LATITUDE, ALTITUDE);
type Cartesian_Coordinates_Type is (X, Y, Z);
type Cartesian_Vector_Type is array(Cartesian_Coordinates_Type) of Base_Unit_Type;
subtype Translation_Vector_Array is Vector3D_Type; -- of Length_Type;
--subtype Position_Vector is Karthesian_Vector_Type with Dimension => (Symbol => 'm', Meter => 1, others => 0);
-- type Dim_Vector_Type is array(Cartesian_Coordinates_Type) of Base_Unit_Type with Dimension_System =>
-- ((Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
-- (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
-- (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
-- (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
-- (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Theta"),
-- (Unit_Name => Radian, Unit_Symbol => "Rad", Dim_Symbol => "A"));
type Translation_Vector is array(Cartesian_Coordinates_Type) of Length_Type; -- of Length_Type;
type Linear_Velocity_Vector is array(Cartesian_Coordinates_Type) of Linear_Velocity_Type;
type Linear_Acceleration_Vector is array(Cartesian_Coordinates_Type) of Linear_Acceleration_Type;
--
--
-- type Orientation_Dimension_Type is (R, P, Y);
-- subtype Orientation_Vector_Type is Unit_Arrays.Real_Vector(Orientation_Dimension_Type) of Angle_Type;
--
-- subtype Orientation_Vector is Orientation_Vector_Type of Angle_Type;
-- subtype Rotation_Vector is Orientation_Vector_Type of Angle_Type;
type Magnetic_Flux_Density_Vector is array(Cartesian_Coordinates_Type) of Magnetic_Flux_Density_Type;
-- Rotation Systems
type Tait_Bryan_Angle_Type is (ROLL, PITCH, YAW);
type Euler_Angle_Type is (X1, Z2, X3);
type Angular_Vector is array(Cartesian_Coordinates_Type) of Base_Unit_Type;
type Unit_Vector is array(Tait_Bryan_Angle_Type) of Angle_Type;
type Angle_Vector is array(Cartesian_Coordinates_Type) of Angle_Type;
type Rotation_Vector is array(Cartesian_Coordinates_Type) of Angle_Type;
type Angular_Velocity_Vector is array(Cartesian_Coordinates_Type) of Angular_Velocity_Type;
type Angular_Acceleration_Vector is array(Cartesian_Coordinates_Type) of Angular_Velocity_Type;
function "+" (Left, Right : Translation_Vector) return Translation_Vector is
( ( Left(X) + Right(X),
Left(Y) + Right(Y),
Left(Z) + Right(Z)
) );
function "+" (Left, Right : Angle_Vector) return Angle_Vector is
( Left(X) + Right(X), Left(Y) + Right(Y), Left(Z) + Right(Z) );
function "+" (Left, Right : Rotation_Vector) return Rotation_Vector is
( Left(X) + Right(X), Left(Y) + Right(Y), Left(Z) + Right(Z) );
function "*" (Left : Base_Unit_Type; Right : Rotation_Vector) return Rotation_Vector is
( ( Unit_Type(Left) * Right(X), Unit_Type(Left) * Right(Y), Unit_Type(Left) * Right(Z) ) );
function "+" (Left, Right : Angular_Velocity_Vector) return Angular_Velocity_Vector is
( ( Left(X) + Right(X),
Left(Y) + Right(Y),
Left(Z) + Right(Z)
) );
function "-" (Left, Right : Angular_Velocity_Vector) return Angular_Velocity_Vector is
( ( Left(X) - Right(X),
Left(Y) - Right(Y),
Left(Z) - Right(Z)
) );
function "*" (Left : Angular_Velocity_Vector; Right : Time_Type) return Rotation_Vector is
( ( Left(X) * Right, Left(Y) * Right, Left(Z) * Right ) );
function "*" (Left : Linear_Velocity_Vector; Right : Time_Type) return Translation_Vector is
( ( Left(X) * Right, Left(Y) * Right, Left(Z) * Right ) );
function Unit_Square (val : Base_Unit_Type) return Base_Unit_Type with
Post => Unit_Square'Result >= Base_Unit_Type (0.0);
-- numerically safe power val*val
procedure rotate(vector : in out Cartesian_Vector_Type; axis : Cartesian_Coordinates_Type; angle : Angle_Type);
function "abs" (vector : Cartesian_Vector_Type) return Base_Unit_Type;
function "abs" (vector : Angular_Vector) return Base_Unit_Type;
function "abs" (vector : Linear_Acceleration_Vector) return Linear_Acceleration_Type;
-- Matrices
subtype Unit_Matrix is Unit_Arrays_Pack.Real_Matrix; -- array(Natural <>, Natural <>) of
type Unit_Vector2D is array(1..2) of Base_Unit_Type;
type Unit_Matrix2D is array(1..2, 1..2) of Base_Unit_Type;
-- subtype Unit_Vector2D is Unit_Arrays_Pack.Real_Vector(1..2);
--subtype Unit_Vector3D is Unit_Arrays_Pack.Real_Vector(1..3);
subtype Unit_Matrix3D is Unit_Arrays_Pack.Real_Matrix(1..3, 1..3);
function "+" (Left, Right : Unit_Vector2D) return Unit_Vector2D is
( Left(1) + Right(1), Left(2) + Right(2) );
function "-" (Left, Right : Unit_Vector2D) return Unit_Vector2D is
( Left(1) - Right(1), Left(2) - Right(2) );
-- n×n Identity Matrix
function Eye( n : Natural ) return Unit_Matrix;
-- with Pre => n > 0;
-- n×n Matrix with all elements 1.0
function Ones( n : Natural ) return Unit_Matrix;
-- with Pre => n > 0;
-- n×n Matrix with all elements 0.0
function Zeros( n : Natural ) return Unit_Matrix;
-- with Pre => n > 0;
procedure setOnes( A : in out Unit_Matrix; first : Natural; last : Natural);
end Units.Vectors;
| 19221 | -- Ada Unit Library
--
-- Authors: <NAME> (<EMAIL>)
--
-- Description: Library for physical calculations
--
-- ToDo:
-- [ ] rename to Units.Mechanics3D or Physics.Units, Physics.Vector3D
with Ada.Numerics.Generic_Real_Arrays;
package Units.Vectors with SPARK_Mode is
package Unit_Arrays_Pack is new Ada.Numerics.Generic_Real_Arrays(Base_Unit_Type);
subtype Scalar is Base_Unit_Type;
type Vector3D_Type is array(1 .. 3) of Base_Unit_Type;
type Polar_Coordinates_Type is (Phi, Rho, Psi);
type Earth_Coordinates_Type is (LONGITUDE, LATITUDE, ALTITUDE);
type Cartesian_Coordinates_Type is (X, Y, Z);
type Cartesian_Vector_Type is array(Cartesian_Coordinates_Type) of Base_Unit_Type;
subtype Translation_Vector_Array is Vector3D_Type; -- of Length_Type;
--subtype Position_Vector is Karthesian_Vector_Type with Dimension => (Symbol => 'm', Meter => 1, others => 0);
-- type Dim_Vector_Type is array(Cartesian_Coordinates_Type) of Base_Unit_Type with Dimension_System =>
-- ((Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
-- (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
-- (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
-- (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
-- (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Theta"),
-- (Unit_Name => Radian, Unit_Symbol => "Rad", Dim_Symbol => "A"));
type Translation_Vector is array(Cartesian_Coordinates_Type) of Length_Type; -- of Length_Type;
type Linear_Velocity_Vector is array(Cartesian_Coordinates_Type) of Linear_Velocity_Type;
type Linear_Acceleration_Vector is array(Cartesian_Coordinates_Type) of Linear_Acceleration_Type;
--
--
-- type Orientation_Dimension_Type is (R, P, Y);
-- subtype Orientation_Vector_Type is Unit_Arrays.Real_Vector(Orientation_Dimension_Type) of Angle_Type;
--
-- subtype Orientation_Vector is Orientation_Vector_Type of Angle_Type;
-- subtype Rotation_Vector is Orientation_Vector_Type of Angle_Type;
type Magnetic_Flux_Density_Vector is array(Cartesian_Coordinates_Type) of Magnetic_Flux_Density_Type;
-- Rotation Systems
type Tait_Bryan_Angle_Type is (ROLL, PITCH, YAW);
type Euler_Angle_Type is (X1, Z2, X3);
type Angular_Vector is array(Cartesian_Coordinates_Type) of Base_Unit_Type;
type Unit_Vector is array(Tait_Bryan_Angle_Type) of Angle_Type;
type Angle_Vector is array(Cartesian_Coordinates_Type) of Angle_Type;
type Rotation_Vector is array(Cartesian_Coordinates_Type) of Angle_Type;
type Angular_Velocity_Vector is array(Cartesian_Coordinates_Type) of Angular_Velocity_Type;
type Angular_Acceleration_Vector is array(Cartesian_Coordinates_Type) of Angular_Velocity_Type;
function "+" (Left, Right : Translation_Vector) return Translation_Vector is
( ( Left(X) + Right(X),
Left(Y) + Right(Y),
Left(Z) + Right(Z)
) );
function "+" (Left, Right : Angle_Vector) return Angle_Vector is
( Left(X) + Right(X), Left(Y) + Right(Y), Left(Z) + Right(Z) );
function "+" (Left, Right : Rotation_Vector) return Rotation_Vector is
( Left(X) + Right(X), Left(Y) + Right(Y), Left(Z) + Right(Z) );
function "*" (Left : Base_Unit_Type; Right : Rotation_Vector) return Rotation_Vector is
( ( Unit_Type(Left) * Right(X), Unit_Type(Left) * Right(Y), Unit_Type(Left) * Right(Z) ) );
function "+" (Left, Right : Angular_Velocity_Vector) return Angular_Velocity_Vector is
( ( Left(X) + Right(X),
Left(Y) + Right(Y),
Left(Z) + Right(Z)
) );
function "-" (Left, Right : Angular_Velocity_Vector) return Angular_Velocity_Vector is
( ( Left(X) - Right(X),
Left(Y) - Right(Y),
Left(Z) - Right(Z)
) );
function "*" (Left : Angular_Velocity_Vector; Right : Time_Type) return Rotation_Vector is
( ( Left(X) * Right, Left(Y) * Right, Left(Z) * Right ) );
function "*" (Left : Linear_Velocity_Vector; Right : Time_Type) return Translation_Vector is
( ( Left(X) * Right, Left(Y) * Right, Left(Z) * Right ) );
function Unit_Square (val : Base_Unit_Type) return Base_Unit_Type with
Post => Unit_Square'Result >= Base_Unit_Type (0.0);
-- numerically safe power val*val
procedure rotate(vector : in out Cartesian_Vector_Type; axis : Cartesian_Coordinates_Type; angle : Angle_Type);
function "abs" (vector : Cartesian_Vector_Type) return Base_Unit_Type;
function "abs" (vector : Angular_Vector) return Base_Unit_Type;
function "abs" (vector : Linear_Acceleration_Vector) return Linear_Acceleration_Type;
-- Matrices
subtype Unit_Matrix is Unit_Arrays_Pack.Real_Matrix; -- array(Natural <>, Natural <>) of
type Unit_Vector2D is array(1..2) of Base_Unit_Type;
type Unit_Matrix2D is array(1..2, 1..2) of Base_Unit_Type;
-- subtype Unit_Vector2D is Unit_Arrays_Pack.Real_Vector(1..2);
--subtype Unit_Vector3D is Unit_Arrays_Pack.Real_Vector(1..3);
subtype Unit_Matrix3D is Unit_Arrays_Pack.Real_Matrix(1..3, 1..3);
function "+" (Left, Right : Unit_Vector2D) return Unit_Vector2D is
( Left(1) + Right(1), Left(2) + Right(2) );
function "-" (Left, Right : Unit_Vector2D) return Unit_Vector2D is
( Left(1) - Right(1), Left(2) - Right(2) );
-- n×n Identity Matrix
function Eye( n : Natural ) return Unit_Matrix;
-- with Pre => n > 0;
-- n×n Matrix with all elements 1.0
function Ones( n : Natural ) return Unit_Matrix;
-- with Pre => n > 0;
-- n×n Matrix with all elements 0.0
function Zeros( n : Natural ) return Unit_Matrix;
-- with Pre => n > 0;
procedure setOnes( A : in out Unit_Matrix; first : Natural; last : Natural);
end Units.Vectors;
| true | -- Ada Unit Library
--
-- Authors: PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
--
-- Description: Library for physical calculations
--
-- ToDo:
-- [ ] rename to Units.Mechanics3D or Physics.Units, Physics.Vector3D
with Ada.Numerics.Generic_Real_Arrays;
package Units.Vectors with SPARK_Mode is
package Unit_Arrays_Pack is new Ada.Numerics.Generic_Real_Arrays(Base_Unit_Type);
subtype Scalar is Base_Unit_Type;
type Vector3D_Type is array(1 .. 3) of Base_Unit_Type;
type Polar_Coordinates_Type is (Phi, Rho, Psi);
type Earth_Coordinates_Type is (LONGITUDE, LATITUDE, ALTITUDE);
type Cartesian_Coordinates_Type is (X, Y, Z);
type Cartesian_Vector_Type is array(Cartesian_Coordinates_Type) of Base_Unit_Type;
subtype Translation_Vector_Array is Vector3D_Type; -- of Length_Type;
--subtype Position_Vector is Karthesian_Vector_Type with Dimension => (Symbol => 'm', Meter => 1, others => 0);
-- type Dim_Vector_Type is array(Cartesian_Coordinates_Type) of Base_Unit_Type with Dimension_System =>
-- ((Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
-- (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
-- (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
-- (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
-- (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Theta"),
-- (Unit_Name => Radian, Unit_Symbol => "Rad", Dim_Symbol => "A"));
type Translation_Vector is array(Cartesian_Coordinates_Type) of Length_Type; -- of Length_Type;
type Linear_Velocity_Vector is array(Cartesian_Coordinates_Type) of Linear_Velocity_Type;
type Linear_Acceleration_Vector is array(Cartesian_Coordinates_Type) of Linear_Acceleration_Type;
--
--
-- type Orientation_Dimension_Type is (R, P, Y);
-- subtype Orientation_Vector_Type is Unit_Arrays.Real_Vector(Orientation_Dimension_Type) of Angle_Type;
--
-- subtype Orientation_Vector is Orientation_Vector_Type of Angle_Type;
-- subtype Rotation_Vector is Orientation_Vector_Type of Angle_Type;
type Magnetic_Flux_Density_Vector is array(Cartesian_Coordinates_Type) of Magnetic_Flux_Density_Type;
-- Rotation Systems
type Tait_Bryan_Angle_Type is (ROLL, PITCH, YAW);
type Euler_Angle_Type is (X1, Z2, X3);
type Angular_Vector is array(Cartesian_Coordinates_Type) of Base_Unit_Type;
type Unit_Vector is array(Tait_Bryan_Angle_Type) of Angle_Type;
type Angle_Vector is array(Cartesian_Coordinates_Type) of Angle_Type;
type Rotation_Vector is array(Cartesian_Coordinates_Type) of Angle_Type;
type Angular_Velocity_Vector is array(Cartesian_Coordinates_Type) of Angular_Velocity_Type;
type Angular_Acceleration_Vector is array(Cartesian_Coordinates_Type) of Angular_Velocity_Type;
function "+" (Left, Right : Translation_Vector) return Translation_Vector is
( ( Left(X) + Right(X),
Left(Y) + Right(Y),
Left(Z) + Right(Z)
) );
function "+" (Left, Right : Angle_Vector) return Angle_Vector is
( Left(X) + Right(X), Left(Y) + Right(Y), Left(Z) + Right(Z) );
function "+" (Left, Right : Rotation_Vector) return Rotation_Vector is
( Left(X) + Right(X), Left(Y) + Right(Y), Left(Z) + Right(Z) );
function "*" (Left : Base_Unit_Type; Right : Rotation_Vector) return Rotation_Vector is
( ( Unit_Type(Left) * Right(X), Unit_Type(Left) * Right(Y), Unit_Type(Left) * Right(Z) ) );
function "+" (Left, Right : Angular_Velocity_Vector) return Angular_Velocity_Vector is
( ( Left(X) + Right(X),
Left(Y) + Right(Y),
Left(Z) + Right(Z)
) );
function "-" (Left, Right : Angular_Velocity_Vector) return Angular_Velocity_Vector is
( ( Left(X) - Right(X),
Left(Y) - Right(Y),
Left(Z) - Right(Z)
) );
function "*" (Left : Angular_Velocity_Vector; Right : Time_Type) return Rotation_Vector is
( ( Left(X) * Right, Left(Y) * Right, Left(Z) * Right ) );
function "*" (Left : Linear_Velocity_Vector; Right : Time_Type) return Translation_Vector is
( ( Left(X) * Right, Left(Y) * Right, Left(Z) * Right ) );
function Unit_Square (val : Base_Unit_Type) return Base_Unit_Type with
Post => Unit_Square'Result >= Base_Unit_Type (0.0);
-- numerically safe power val*val
procedure rotate(vector : in out Cartesian_Vector_Type; axis : Cartesian_Coordinates_Type; angle : Angle_Type);
function "abs" (vector : Cartesian_Vector_Type) return Base_Unit_Type;
function "abs" (vector : Angular_Vector) return Base_Unit_Type;
function "abs" (vector : Linear_Acceleration_Vector) return Linear_Acceleration_Type;
-- Matrices
subtype Unit_Matrix is Unit_Arrays_Pack.Real_Matrix; -- array(Natural <>, Natural <>) of
type Unit_Vector2D is array(1..2) of Base_Unit_Type;
type Unit_Matrix2D is array(1..2, 1..2) of Base_Unit_Type;
-- subtype Unit_Vector2D is Unit_Arrays_Pack.Real_Vector(1..2);
--subtype Unit_Vector3D is Unit_Arrays_Pack.Real_Vector(1..3);
subtype Unit_Matrix3D is Unit_Arrays_Pack.Real_Matrix(1..3, 1..3);
function "+" (Left, Right : Unit_Vector2D) return Unit_Vector2D is
( Left(1) + Right(1), Left(2) + Right(2) );
function "-" (Left, Right : Unit_Vector2D) return Unit_Vector2D is
( Left(1) - Right(1), Left(2) - Right(2) );
-- n×n Identity Matrix
function Eye( n : Natural ) return Unit_Matrix;
-- with Pre => n > 0;
-- n×n Matrix with all elements 1.0
function Ones( n : Natural ) return Unit_Matrix;
-- with Pre => n > 0;
-- n×n Matrix with all elements 0.0
function Zeros( n : Natural ) return Unit_Matrix;
-- with Pre => n > 0;
procedure setOnes( A : in out Unit_Matrix; first : Natural; last : Natural);
end Units.Vectors;
|
[
{
"context": "xed;\nwith Ada.Integer_Text_IO;\n\n-- Copyright 2021 Melwyn Francis Carlo\n\nprocedure A030 is\n\n use Ada.Strings.Fixed;\n ",
"end": 90,
"score": 0.9998484253883362,
"start": 70,
"tag": "NAME",
"value": "Melwyn Francis Carlo"
}
] | problems/030/a030.adb | melwyncarlo/ProjectEuler | 0 | with Ada.Strings.Fixed;
with Ada.Integer_Text_IO;
-- Copyright 2021 Melwyn Francis Carlo
procedure A030 is
use Ada.Strings.Fixed;
use Ada.Integer_Text_IO;
Sum : Integer := 0;
Sum_Of_Powers : Integer := 0;
Num_len : Integer;
begin
for I in 2 .. 1_000_000 loop
Sum_Of_Powers := 0;
Num_len := Trim (Integer'Image (I), Ada.Strings.Both)'Length;
for J in 1 .. Num_len loop
Sum_Of_Powers := Sum_Of_Powers
+ ((Character'Pos (Trim (Integer'Image (I),
Ada.Strings.Both) (J)) - Character'Pos ('0')) ** 5);
end loop;
if Sum_Of_Powers = I then
Sum := Sum + I;
end if;
end loop;
Put (Sum, Width => 0);
end A030;
| 8807 | with Ada.Strings.Fixed;
with Ada.Integer_Text_IO;
-- Copyright 2021 <NAME>
procedure A030 is
use Ada.Strings.Fixed;
use Ada.Integer_Text_IO;
Sum : Integer := 0;
Sum_Of_Powers : Integer := 0;
Num_len : Integer;
begin
for I in 2 .. 1_000_000 loop
Sum_Of_Powers := 0;
Num_len := Trim (Integer'Image (I), Ada.Strings.Both)'Length;
for J in 1 .. Num_len loop
Sum_Of_Powers := Sum_Of_Powers
+ ((Character'Pos (Trim (Integer'Image (I),
Ada.Strings.Both) (J)) - Character'Pos ('0')) ** 5);
end loop;
if Sum_Of_Powers = I then
Sum := Sum + I;
end if;
end loop;
Put (Sum, Width => 0);
end A030;
| true | with Ada.Strings.Fixed;
with Ada.Integer_Text_IO;
-- Copyright 2021 PI:NAME:<NAME>END_PI
procedure A030 is
use Ada.Strings.Fixed;
use Ada.Integer_Text_IO;
Sum : Integer := 0;
Sum_Of_Powers : Integer := 0;
Num_len : Integer;
begin
for I in 2 .. 1_000_000 loop
Sum_Of_Powers := 0;
Num_len := Trim (Integer'Image (I), Ada.Strings.Both)'Length;
for J in 1 .. Num_len loop
Sum_Of_Powers := Sum_Of_Powers
+ ((Character'Pos (Trim (Integer'Image (I),
Ada.Strings.Both) (J)) - Character'Pos ('0')) ** 5);
end loop;
if Sum_Of_Powers = I then
Sum := Sum + I;
end if;
end loop;
Put (Sum, Width => 0);
end A030;
|
[
{
"context": " --\n-- Copyright © 2013, Vadim Godunko <vgodunko@gmail.com> --\n-- Al",
"end": 824,
"score": 0.9998860359191895,
"start": 811,
"tag": "NAME",
"value": "Vadim Godunko"
},
{
"context": " --\n-- Copyright © 2013, Vadim Godunko <vgodunko@gmail.com> --\n-- All rights reserved. ",
"end": 844,
"score": 0.9999326467514038,
"start": 826,
"tag": "EMAIL",
"value": "vgodunko@gmail.com"
},
{
"context": " --\n-- * Neither the name of the Vadim Godunko, IE nor the names of its --\n-- contribu",
"end": 1939,
"score": 0.9782343506813049,
"start": 1926,
"tag": "NAME",
"value": "Vadim Godunko"
}
] | source/web/tools/wsdl2ada/wsdl-meps.ads | svn2github/matreshka | 24 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 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 provides abstract declaration for MEP representation.
------------------------------------------------------------------------------
with Ada.Containers.Hashed_Maps;
with League.Strings;
with WSDL.AST;
package WSDL.MEPs is
pragma Preelaborate;
package Interface_Fault_Reference_Maps is
new Ada.Containers.Hashed_Maps
(WSDL.AST.Qualified_Name,
WSDL.AST.Interface_Fault_Reference_Access,
WSDL.AST.Hash,
WSDL.AST."=",
WSDL.AST."=");
type Message_Placeholder is record
Label : League.Strings.Universal_String;
Direction : WSDL.AST.Message_Directions;
Message : WSDL.AST.Interface_Message_Access;
-- Interface Message Reference actually mapped to this placeholder.
Faults : Interface_Fault_Reference_Maps.Map;
-- Interface Fault References actually associated with this placeholder.
end record;
type Message_Placeholder_Array is
array (Positive range <>) of Message_Placeholder;
type Fault_Propagation_Rules is
(Fault_Replaces_Message,
Message_Triggers_Fault,
No_Faults);
type MEP (Length : Natural) is limited record
IRI : League.Strings.Universal_String;
Placeholders : Message_Placeholder_Array (1 .. Length);
-- Placeholder messages of the MEP.
FPR : Fault_Propagation_Rules;
-- Fault propagation rule of the MEP.
Has_In : Boolean;
-- MEP has at least one 'in' placeholder message.
Has_Out : Boolean;
-- MEP has at least one 'out' placeholder message.
Has_Single_In : Boolean;
-- MEP has only one 'in' placeholder message.
Has_Single_Out : Boolean;
-- MEP has only one 'out' placeholder message.
Has_In_Fault : Boolean;
-- MEP supports at least one fault in the 'In' direction.
Has_Out_Fault : Boolean;
-- MEP supports at least one fault in the 'Out' direction.
Has_Single_In_Fault : Boolean;
-- MEP supports only one fault in the 'In' direction.
Has_Single_Out_Fault : Boolean;
-- MEP supports only one fault in the 'Out' direction.
end record;
type MEP_Access is access all MEP;
end WSDL.MEPs;
| 25583 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the <NAME>, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- 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 abstract declaration for MEP representation.
------------------------------------------------------------------------------
with Ada.Containers.Hashed_Maps;
with League.Strings;
with WSDL.AST;
package WSDL.MEPs is
pragma Preelaborate;
package Interface_Fault_Reference_Maps is
new Ada.Containers.Hashed_Maps
(WSDL.AST.Qualified_Name,
WSDL.AST.Interface_Fault_Reference_Access,
WSDL.AST.Hash,
WSDL.AST."=",
WSDL.AST."=");
type Message_Placeholder is record
Label : League.Strings.Universal_String;
Direction : WSDL.AST.Message_Directions;
Message : WSDL.AST.Interface_Message_Access;
-- Interface Message Reference actually mapped to this placeholder.
Faults : Interface_Fault_Reference_Maps.Map;
-- Interface Fault References actually associated with this placeholder.
end record;
type Message_Placeholder_Array is
array (Positive range <>) of Message_Placeholder;
type Fault_Propagation_Rules is
(Fault_Replaces_Message,
Message_Triggers_Fault,
No_Faults);
type MEP (Length : Natural) is limited record
IRI : League.Strings.Universal_String;
Placeholders : Message_Placeholder_Array (1 .. Length);
-- Placeholder messages of the MEP.
FPR : Fault_Propagation_Rules;
-- Fault propagation rule of the MEP.
Has_In : Boolean;
-- MEP has at least one 'in' placeholder message.
Has_Out : Boolean;
-- MEP has at least one 'out' placeholder message.
Has_Single_In : Boolean;
-- MEP has only one 'in' placeholder message.
Has_Single_Out : Boolean;
-- MEP has only one 'out' placeholder message.
Has_In_Fault : Boolean;
-- MEP supports at least one fault in the 'In' direction.
Has_Out_Fault : Boolean;
-- MEP supports at least one fault in the 'Out' direction.
Has_Single_In_Fault : Boolean;
-- MEP supports only one fault in the 'In' direction.
Has_Single_Out_Fault : Boolean;
-- MEP supports only one fault in the 'Out' direction.
end record;
type MEP_Access is access all MEP;
end WSDL.MEPs;
| true | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> --
-- 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 PI:NAME:<NAME>END_PI, 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 abstract declaration for MEP representation.
------------------------------------------------------------------------------
with Ada.Containers.Hashed_Maps;
with League.Strings;
with WSDL.AST;
package WSDL.MEPs is
pragma Preelaborate;
package Interface_Fault_Reference_Maps is
new Ada.Containers.Hashed_Maps
(WSDL.AST.Qualified_Name,
WSDL.AST.Interface_Fault_Reference_Access,
WSDL.AST.Hash,
WSDL.AST."=",
WSDL.AST."=");
type Message_Placeholder is record
Label : League.Strings.Universal_String;
Direction : WSDL.AST.Message_Directions;
Message : WSDL.AST.Interface_Message_Access;
-- Interface Message Reference actually mapped to this placeholder.
Faults : Interface_Fault_Reference_Maps.Map;
-- Interface Fault References actually associated with this placeholder.
end record;
type Message_Placeholder_Array is
array (Positive range <>) of Message_Placeholder;
type Fault_Propagation_Rules is
(Fault_Replaces_Message,
Message_Triggers_Fault,
No_Faults);
type MEP (Length : Natural) is limited record
IRI : League.Strings.Universal_String;
Placeholders : Message_Placeholder_Array (1 .. Length);
-- Placeholder messages of the MEP.
FPR : Fault_Propagation_Rules;
-- Fault propagation rule of the MEP.
Has_In : Boolean;
-- MEP has at least one 'in' placeholder message.
Has_Out : Boolean;
-- MEP has at least one 'out' placeholder message.
Has_Single_In : Boolean;
-- MEP has only one 'in' placeholder message.
Has_Single_Out : Boolean;
-- MEP has only one 'out' placeholder message.
Has_In_Fault : Boolean;
-- MEP supports at least one fault in the 'In' direction.
Has_Out_Fault : Boolean;
-- MEP supports at least one fault in the 'Out' direction.
Has_Single_In_Fault : Boolean;
-- MEP supports only one fault in the 'In' direction.
Has_Single_Out_Fault : Boolean;
-- MEP supports only one fault in the 'Out' direction.
end record;
type MEP_Access is access all MEP;
end WSDL.MEPs;
|
[
{
"context": ").\n -- *\n -- * Copyright (C) 1996-2020 by\n -- * David Turner, Robert Wilhelm, and Werner Lemberg.\n -- *\n -- ",
"end": 362,
"score": 0.9998388886451721,
"start": 350,
"tag": "NAME",
"value": "David Turner"
},
{
"context": " * Copyright (C) 1996-2020 by\n -- * David Turner, Robert Wilhelm, and Werner Lemberg.\n -- *\n -- * This file is p",
"end": 378,
"score": 0.999799907207489,
"start": 364,
"tag": "NAME",
"value": "Robert Wilhelm"
},
{
"context": "6-2020 by\n -- * David Turner, Robert Wilhelm, and Werner Lemberg.\n -- *\n -- * This file is part of the FreeType ",
"end": 398,
"score": 0.9998065829277039,
"start": 384,
"tag": "NAME",
"value": "Werner Lemberg"
}
] | include/ftsystem.ads | docandrew/troodon | 5 | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with System;
package ftsystem is
--***************************************************************************
-- *
-- * ftsystem.h
-- *
-- * FreeType low-level system interface definition (specification).
-- *
-- * Copyright (C) 1996-2020 by
-- * David Turner, Robert Wilhelm, and Werner Lemberg.
-- *
-- * This file is part of the FreeType project, and may only be used,
-- * modified, and distributed under the terms of the FreeType project
-- * license, LICENSE.TXT. By continuing to use, modify, or distribute
-- * this file you indicate that you have read the license and
-- * understand and accept it fully.
-- *
--
--*************************************************************************
-- *
-- * @section:
-- * system_interface
-- *
-- * @title:
-- * System Interface
-- *
-- * @abstract:
-- * How FreeType manages memory and i/o.
-- *
-- * @description:
-- * This section contains various definitions related to memory management
-- * and i/o access. You need to understand this information if you want to
-- * use a custom memory manager or you own i/o streams.
-- *
--
--*************************************************************************
-- *
-- * M E M O R Y M A N A G E M E N T
-- *
--
--*************************************************************************
-- *
-- * @type:
-- * FT_Memory
-- *
-- * @description:
-- * A handle to a given memory manager object, defined with an
-- * @FT_MemoryRec structure.
-- *
--
type FT_MemoryRec_u;
type FT_Memory is access all FT_MemoryRec_u; -- /usr/include/freetype2/freetype/ftsystem.h:64
--*************************************************************************
-- *
-- * @functype:
-- * FT_Alloc_Func
-- *
-- * @description:
-- * A function used to allocate `size` bytes from `memory`.
-- *
-- * @input:
-- * memory ::
-- * A handle to the source memory manager.
-- *
-- * size ::
-- * The size in bytes to allocate.
-- *
-- * @return:
-- * Address of new memory block. 0~in case of failure.
-- *
--
type FT_Alloc_Func is access function (arg1 : FT_Memory; arg2 : long) return System.Address
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:87
--*************************************************************************
-- *
-- * @functype:
-- * FT_Free_Func
-- *
-- * @description:
-- * A function used to release a given block of memory.
-- *
-- * @input:
-- * memory ::
-- * A handle to the source memory manager.
-- *
-- * block ::
-- * The address of the target memory block.
-- *
--
type FT_Free_Func is access procedure (arg1 : FT_Memory; arg2 : System.Address)
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:108
--*************************************************************************
-- *
-- * @functype:
-- * FT_Realloc_Func
-- *
-- * @description:
-- * A function used to re-allocate a given block of memory.
-- *
-- * @input:
-- * memory ::
-- * A handle to the source memory manager.
-- *
-- * cur_size ::
-- * The block's current size in bytes.
-- *
-- * new_size ::
-- * The block's requested new size.
-- *
-- * block ::
-- * The block's current address.
-- *
-- * @return:
-- * New block address. 0~in case of memory shortage.
-- *
-- * @note:
-- * In case of error, the old block must still be available.
-- *
--
type FT_Realloc_Func is access function
(arg1 : FT_Memory;
arg2 : long;
arg3 : long;
arg4 : System.Address) return System.Address
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:141
--*************************************************************************
-- *
-- * @struct:
-- * FT_MemoryRec
-- *
-- * @description:
-- * A structure used to describe a given memory manager to FreeType~2.
-- *
-- * @fields:
-- * user ::
-- * A generic typeless pointer for user data.
-- *
-- * alloc ::
-- * A pointer type to an allocation function.
-- *
-- * free ::
-- * A pointer type to an memory freeing function.
-- *
-- * realloc ::
-- * A pointer type to a reallocation function.
-- *
--
type FT_MemoryRec_u is record
user : System.Address; -- /usr/include/freetype2/freetype/ftsystem.h:171
alloc : FT_Alloc_Func; -- /usr/include/freetype2/freetype/ftsystem.h:172
free : FT_Free_Func; -- /usr/include/freetype2/freetype/ftsystem.h:173
realloc : FT_Realloc_Func; -- /usr/include/freetype2/freetype/ftsystem.h:174
end record
with Convention => C_Pass_By_Copy; -- /usr/include/freetype2/freetype/ftsystem.h:169
--*************************************************************************
-- *
-- * I / O M A N A G E M E N T
-- *
--
--*************************************************************************
-- *
-- * @type:
-- * FT_Stream
-- *
-- * @description:
-- * A handle to an input stream.
-- *
-- * @also:
-- * See @FT_StreamRec for the publicly accessible fields of a given stream
-- * object.
-- *
--
type FT_StreamRec_u;
type FT_Stream is access all FT_StreamRec_u; -- /usr/include/freetype2/freetype/ftsystem.h:198
--*************************************************************************
-- *
-- * @struct:
-- * FT_StreamDesc
-- *
-- * @description:
-- * A union type used to store either a long or a pointer. This is used
-- * to store a file descriptor or a `FILE*` in an input stream.
-- *
--
type FT_StreamDesc_u (discr : unsigned := 0) is record
case discr is
when 0 =>
value : aliased long; -- /usr/include/freetype2/freetype/ftsystem.h:213
when others =>
pointer : System.Address; -- /usr/include/freetype2/freetype/ftsystem.h:214
end case;
end record
with Convention => C_Pass_By_Copy,
Unchecked_Union => True; -- /usr/include/freetype2/freetype/ftsystem.h:211
subtype FT_StreamDesc is FT_StreamDesc_u; -- /usr/include/freetype2/freetype/ftsystem.h:216
--*************************************************************************
-- *
-- * @functype:
-- * FT_Stream_IoFunc
-- *
-- * @description:
-- * A function used to seek and read data from a given input stream.
-- *
-- * @input:
-- * stream ::
-- * A handle to the source stream.
-- *
-- * offset ::
-- * The offset of read in stream (always from start).
-- *
-- * buffer ::
-- * The address of the read buffer.
-- *
-- * count ::
-- * The number of bytes to read from the stream.
-- *
-- * @return:
-- * The number of bytes effectively read by the stream.
-- *
-- * @note:
-- * This function might be called to perform a seek or skip operation with
-- * a `count` of~0. A non-zero return value then indicates an error.
-- *
--
type FT_Stream_IoFunc is access function
(arg1 : FT_Stream;
arg2 : unsigned_long;
arg3 : access unsigned_char;
arg4 : unsigned_long) return unsigned_long
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:249
--*************************************************************************
-- *
-- * @functype:
-- * FT_Stream_CloseFunc
-- *
-- * @description:
-- * A function used to close a given input stream.
-- *
-- * @input:
-- * stream ::
-- * A handle to the target stream.
-- *
--
type FT_Stream_CloseFunc is access procedure (arg1 : FT_Stream)
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:269
--*************************************************************************
-- *
-- * @struct:
-- * FT_StreamRec
-- *
-- * @description:
-- * A structure used to describe an input stream.
-- *
-- * @input:
-- * base ::
-- * For memory-based streams, this is the address of the first stream
-- * byte in memory. This field should always be set to `NULL` for
-- * disk-based streams.
-- *
-- * size ::
-- * The stream size in bytes.
-- *
-- * In case of compressed streams where the size is unknown before
-- * actually doing the decompression, the value is set to 0x7FFFFFFF.
-- * (Note that this size value can occur for normal streams also; it is
-- * thus just a hint.)
-- *
-- * pos ::
-- * The current position within the stream.
-- *
-- * descriptor ::
-- * This field is a union that can hold an integer or a pointer. It is
-- * used by stream implementations to store file descriptors or `FILE*`
-- * pointers.
-- *
-- * pathname ::
-- * This field is completely ignored by FreeType. However, it is often
-- * useful during debugging to use it to store the stream's filename
-- * (where available).
-- *
-- * read ::
-- * The stream's input function.
-- *
-- * close ::
-- * The stream's close function.
-- *
-- * memory ::
-- * The memory manager to use to preload frames. This is set internally
-- * by FreeType and shouldn't be touched by stream implementations.
-- *
-- * cursor ::
-- * This field is set and used internally by FreeType when parsing
-- * frames. In particular, the `FT_GET_XXX` macros use this instead of
-- * the `pos` field.
-- *
-- * limit ::
-- * This field is set and used internally by FreeType when parsing
-- * frames.
-- *
--
type FT_StreamRec_u is record
base : access unsigned_char; -- /usr/include/freetype2/freetype/ftsystem.h:329
size : aliased unsigned_long; -- /usr/include/freetype2/freetype/ftsystem.h:330
pos : aliased unsigned_long; -- /usr/include/freetype2/freetype/ftsystem.h:331
descriptor : aliased FT_StreamDesc; -- /usr/include/freetype2/freetype/ftsystem.h:333
pathname : aliased FT_StreamDesc; -- /usr/include/freetype2/freetype/ftsystem.h:334
read : FT_Stream_IoFunc; -- /usr/include/freetype2/freetype/ftsystem.h:335
close : FT_Stream_CloseFunc; -- /usr/include/freetype2/freetype/ftsystem.h:336
memory : FT_Memory; -- /usr/include/freetype2/freetype/ftsystem.h:338
cursor : access unsigned_char; -- /usr/include/freetype2/freetype/ftsystem.h:339
limit : access unsigned_char; -- /usr/include/freetype2/freetype/ftsystem.h:340
end record
with Convention => C_Pass_By_Copy; -- /usr/include/freetype2/freetype/ftsystem.h:327
subtype FT_StreamRec is FT_StreamRec_u; -- /usr/include/freetype2/freetype/ftsystem.h:342
--
-- END
end ftsystem;
| 29489 | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with System;
package ftsystem is
--***************************************************************************
-- *
-- * ftsystem.h
-- *
-- * FreeType low-level system interface definition (specification).
-- *
-- * Copyright (C) 1996-2020 by
-- * <NAME>, <NAME>, and <NAME>.
-- *
-- * This file is part of the FreeType project, and may only be used,
-- * modified, and distributed under the terms of the FreeType project
-- * license, LICENSE.TXT. By continuing to use, modify, or distribute
-- * this file you indicate that you have read the license and
-- * understand and accept it fully.
-- *
--
--*************************************************************************
-- *
-- * @section:
-- * system_interface
-- *
-- * @title:
-- * System Interface
-- *
-- * @abstract:
-- * How FreeType manages memory and i/o.
-- *
-- * @description:
-- * This section contains various definitions related to memory management
-- * and i/o access. You need to understand this information if you want to
-- * use a custom memory manager or you own i/o streams.
-- *
--
--*************************************************************************
-- *
-- * M E M O R Y M A N A G E M E N T
-- *
--
--*************************************************************************
-- *
-- * @type:
-- * FT_Memory
-- *
-- * @description:
-- * A handle to a given memory manager object, defined with an
-- * @FT_MemoryRec structure.
-- *
--
type FT_MemoryRec_u;
type FT_Memory is access all FT_MemoryRec_u; -- /usr/include/freetype2/freetype/ftsystem.h:64
--*************************************************************************
-- *
-- * @functype:
-- * FT_Alloc_Func
-- *
-- * @description:
-- * A function used to allocate `size` bytes from `memory`.
-- *
-- * @input:
-- * memory ::
-- * A handle to the source memory manager.
-- *
-- * size ::
-- * The size in bytes to allocate.
-- *
-- * @return:
-- * Address of new memory block. 0~in case of failure.
-- *
--
type FT_Alloc_Func is access function (arg1 : FT_Memory; arg2 : long) return System.Address
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:87
--*************************************************************************
-- *
-- * @functype:
-- * FT_Free_Func
-- *
-- * @description:
-- * A function used to release a given block of memory.
-- *
-- * @input:
-- * memory ::
-- * A handle to the source memory manager.
-- *
-- * block ::
-- * The address of the target memory block.
-- *
--
type FT_Free_Func is access procedure (arg1 : FT_Memory; arg2 : System.Address)
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:108
--*************************************************************************
-- *
-- * @functype:
-- * FT_Realloc_Func
-- *
-- * @description:
-- * A function used to re-allocate a given block of memory.
-- *
-- * @input:
-- * memory ::
-- * A handle to the source memory manager.
-- *
-- * cur_size ::
-- * The block's current size in bytes.
-- *
-- * new_size ::
-- * The block's requested new size.
-- *
-- * block ::
-- * The block's current address.
-- *
-- * @return:
-- * New block address. 0~in case of memory shortage.
-- *
-- * @note:
-- * In case of error, the old block must still be available.
-- *
--
type FT_Realloc_Func is access function
(arg1 : FT_Memory;
arg2 : long;
arg3 : long;
arg4 : System.Address) return System.Address
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:141
--*************************************************************************
-- *
-- * @struct:
-- * FT_MemoryRec
-- *
-- * @description:
-- * A structure used to describe a given memory manager to FreeType~2.
-- *
-- * @fields:
-- * user ::
-- * A generic typeless pointer for user data.
-- *
-- * alloc ::
-- * A pointer type to an allocation function.
-- *
-- * free ::
-- * A pointer type to an memory freeing function.
-- *
-- * realloc ::
-- * A pointer type to a reallocation function.
-- *
--
type FT_MemoryRec_u is record
user : System.Address; -- /usr/include/freetype2/freetype/ftsystem.h:171
alloc : FT_Alloc_Func; -- /usr/include/freetype2/freetype/ftsystem.h:172
free : FT_Free_Func; -- /usr/include/freetype2/freetype/ftsystem.h:173
realloc : FT_Realloc_Func; -- /usr/include/freetype2/freetype/ftsystem.h:174
end record
with Convention => C_Pass_By_Copy; -- /usr/include/freetype2/freetype/ftsystem.h:169
--*************************************************************************
-- *
-- * I / O M A N A G E M E N T
-- *
--
--*************************************************************************
-- *
-- * @type:
-- * FT_Stream
-- *
-- * @description:
-- * A handle to an input stream.
-- *
-- * @also:
-- * See @FT_StreamRec for the publicly accessible fields of a given stream
-- * object.
-- *
--
type FT_StreamRec_u;
type FT_Stream is access all FT_StreamRec_u; -- /usr/include/freetype2/freetype/ftsystem.h:198
--*************************************************************************
-- *
-- * @struct:
-- * FT_StreamDesc
-- *
-- * @description:
-- * A union type used to store either a long or a pointer. This is used
-- * to store a file descriptor or a `FILE*` in an input stream.
-- *
--
type FT_StreamDesc_u (discr : unsigned := 0) is record
case discr is
when 0 =>
value : aliased long; -- /usr/include/freetype2/freetype/ftsystem.h:213
when others =>
pointer : System.Address; -- /usr/include/freetype2/freetype/ftsystem.h:214
end case;
end record
with Convention => C_Pass_By_Copy,
Unchecked_Union => True; -- /usr/include/freetype2/freetype/ftsystem.h:211
subtype FT_StreamDesc is FT_StreamDesc_u; -- /usr/include/freetype2/freetype/ftsystem.h:216
--*************************************************************************
-- *
-- * @functype:
-- * FT_Stream_IoFunc
-- *
-- * @description:
-- * A function used to seek and read data from a given input stream.
-- *
-- * @input:
-- * stream ::
-- * A handle to the source stream.
-- *
-- * offset ::
-- * The offset of read in stream (always from start).
-- *
-- * buffer ::
-- * The address of the read buffer.
-- *
-- * count ::
-- * The number of bytes to read from the stream.
-- *
-- * @return:
-- * The number of bytes effectively read by the stream.
-- *
-- * @note:
-- * This function might be called to perform a seek or skip operation with
-- * a `count` of~0. A non-zero return value then indicates an error.
-- *
--
type FT_Stream_IoFunc is access function
(arg1 : FT_Stream;
arg2 : unsigned_long;
arg3 : access unsigned_char;
arg4 : unsigned_long) return unsigned_long
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:249
--*************************************************************************
-- *
-- * @functype:
-- * FT_Stream_CloseFunc
-- *
-- * @description:
-- * A function used to close a given input stream.
-- *
-- * @input:
-- * stream ::
-- * A handle to the target stream.
-- *
--
type FT_Stream_CloseFunc is access procedure (arg1 : FT_Stream)
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:269
--*************************************************************************
-- *
-- * @struct:
-- * FT_StreamRec
-- *
-- * @description:
-- * A structure used to describe an input stream.
-- *
-- * @input:
-- * base ::
-- * For memory-based streams, this is the address of the first stream
-- * byte in memory. This field should always be set to `NULL` for
-- * disk-based streams.
-- *
-- * size ::
-- * The stream size in bytes.
-- *
-- * In case of compressed streams where the size is unknown before
-- * actually doing the decompression, the value is set to 0x7FFFFFFF.
-- * (Note that this size value can occur for normal streams also; it is
-- * thus just a hint.)
-- *
-- * pos ::
-- * The current position within the stream.
-- *
-- * descriptor ::
-- * This field is a union that can hold an integer or a pointer. It is
-- * used by stream implementations to store file descriptors or `FILE*`
-- * pointers.
-- *
-- * pathname ::
-- * This field is completely ignored by FreeType. However, it is often
-- * useful during debugging to use it to store the stream's filename
-- * (where available).
-- *
-- * read ::
-- * The stream's input function.
-- *
-- * close ::
-- * The stream's close function.
-- *
-- * memory ::
-- * The memory manager to use to preload frames. This is set internally
-- * by FreeType and shouldn't be touched by stream implementations.
-- *
-- * cursor ::
-- * This field is set and used internally by FreeType when parsing
-- * frames. In particular, the `FT_GET_XXX` macros use this instead of
-- * the `pos` field.
-- *
-- * limit ::
-- * This field is set and used internally by FreeType when parsing
-- * frames.
-- *
--
type FT_StreamRec_u is record
base : access unsigned_char; -- /usr/include/freetype2/freetype/ftsystem.h:329
size : aliased unsigned_long; -- /usr/include/freetype2/freetype/ftsystem.h:330
pos : aliased unsigned_long; -- /usr/include/freetype2/freetype/ftsystem.h:331
descriptor : aliased FT_StreamDesc; -- /usr/include/freetype2/freetype/ftsystem.h:333
pathname : aliased FT_StreamDesc; -- /usr/include/freetype2/freetype/ftsystem.h:334
read : FT_Stream_IoFunc; -- /usr/include/freetype2/freetype/ftsystem.h:335
close : FT_Stream_CloseFunc; -- /usr/include/freetype2/freetype/ftsystem.h:336
memory : FT_Memory; -- /usr/include/freetype2/freetype/ftsystem.h:338
cursor : access unsigned_char; -- /usr/include/freetype2/freetype/ftsystem.h:339
limit : access unsigned_char; -- /usr/include/freetype2/freetype/ftsystem.h:340
end record
with Convention => C_Pass_By_Copy; -- /usr/include/freetype2/freetype/ftsystem.h:327
subtype FT_StreamRec is FT_StreamRec_u; -- /usr/include/freetype2/freetype/ftsystem.h:342
--
-- END
end ftsystem;
| true | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with System;
package ftsystem is
--***************************************************************************
-- *
-- * ftsystem.h
-- *
-- * FreeType low-level system interface definition (specification).
-- *
-- * Copyright (C) 1996-2020 by
-- * PI:NAME:<NAME>END_PI, PI:NAME:<NAME>END_PI, and PI:NAME:<NAME>END_PI.
-- *
-- * This file is part of the FreeType project, and may only be used,
-- * modified, and distributed under the terms of the FreeType project
-- * license, LICENSE.TXT. By continuing to use, modify, or distribute
-- * this file you indicate that you have read the license and
-- * understand and accept it fully.
-- *
--
--*************************************************************************
-- *
-- * @section:
-- * system_interface
-- *
-- * @title:
-- * System Interface
-- *
-- * @abstract:
-- * How FreeType manages memory and i/o.
-- *
-- * @description:
-- * This section contains various definitions related to memory management
-- * and i/o access. You need to understand this information if you want to
-- * use a custom memory manager or you own i/o streams.
-- *
--
--*************************************************************************
-- *
-- * M E M O R Y M A N A G E M E N T
-- *
--
--*************************************************************************
-- *
-- * @type:
-- * FT_Memory
-- *
-- * @description:
-- * A handle to a given memory manager object, defined with an
-- * @FT_MemoryRec structure.
-- *
--
type FT_MemoryRec_u;
type FT_Memory is access all FT_MemoryRec_u; -- /usr/include/freetype2/freetype/ftsystem.h:64
--*************************************************************************
-- *
-- * @functype:
-- * FT_Alloc_Func
-- *
-- * @description:
-- * A function used to allocate `size` bytes from `memory`.
-- *
-- * @input:
-- * memory ::
-- * A handle to the source memory manager.
-- *
-- * size ::
-- * The size in bytes to allocate.
-- *
-- * @return:
-- * Address of new memory block. 0~in case of failure.
-- *
--
type FT_Alloc_Func is access function (arg1 : FT_Memory; arg2 : long) return System.Address
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:87
--*************************************************************************
-- *
-- * @functype:
-- * FT_Free_Func
-- *
-- * @description:
-- * A function used to release a given block of memory.
-- *
-- * @input:
-- * memory ::
-- * A handle to the source memory manager.
-- *
-- * block ::
-- * The address of the target memory block.
-- *
--
type FT_Free_Func is access procedure (arg1 : FT_Memory; arg2 : System.Address)
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:108
--*************************************************************************
-- *
-- * @functype:
-- * FT_Realloc_Func
-- *
-- * @description:
-- * A function used to re-allocate a given block of memory.
-- *
-- * @input:
-- * memory ::
-- * A handle to the source memory manager.
-- *
-- * cur_size ::
-- * The block's current size in bytes.
-- *
-- * new_size ::
-- * The block's requested new size.
-- *
-- * block ::
-- * The block's current address.
-- *
-- * @return:
-- * New block address. 0~in case of memory shortage.
-- *
-- * @note:
-- * In case of error, the old block must still be available.
-- *
--
type FT_Realloc_Func is access function
(arg1 : FT_Memory;
arg2 : long;
arg3 : long;
arg4 : System.Address) return System.Address
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:141
--*************************************************************************
-- *
-- * @struct:
-- * FT_MemoryRec
-- *
-- * @description:
-- * A structure used to describe a given memory manager to FreeType~2.
-- *
-- * @fields:
-- * user ::
-- * A generic typeless pointer for user data.
-- *
-- * alloc ::
-- * A pointer type to an allocation function.
-- *
-- * free ::
-- * A pointer type to an memory freeing function.
-- *
-- * realloc ::
-- * A pointer type to a reallocation function.
-- *
--
type FT_MemoryRec_u is record
user : System.Address; -- /usr/include/freetype2/freetype/ftsystem.h:171
alloc : FT_Alloc_Func; -- /usr/include/freetype2/freetype/ftsystem.h:172
free : FT_Free_Func; -- /usr/include/freetype2/freetype/ftsystem.h:173
realloc : FT_Realloc_Func; -- /usr/include/freetype2/freetype/ftsystem.h:174
end record
with Convention => C_Pass_By_Copy; -- /usr/include/freetype2/freetype/ftsystem.h:169
--*************************************************************************
-- *
-- * I / O M A N A G E M E N T
-- *
--
--*************************************************************************
-- *
-- * @type:
-- * FT_Stream
-- *
-- * @description:
-- * A handle to an input stream.
-- *
-- * @also:
-- * See @FT_StreamRec for the publicly accessible fields of a given stream
-- * object.
-- *
--
type FT_StreamRec_u;
type FT_Stream is access all FT_StreamRec_u; -- /usr/include/freetype2/freetype/ftsystem.h:198
--*************************************************************************
-- *
-- * @struct:
-- * FT_StreamDesc
-- *
-- * @description:
-- * A union type used to store either a long or a pointer. This is used
-- * to store a file descriptor or a `FILE*` in an input stream.
-- *
--
type FT_StreamDesc_u (discr : unsigned := 0) is record
case discr is
when 0 =>
value : aliased long; -- /usr/include/freetype2/freetype/ftsystem.h:213
when others =>
pointer : System.Address; -- /usr/include/freetype2/freetype/ftsystem.h:214
end case;
end record
with Convention => C_Pass_By_Copy,
Unchecked_Union => True; -- /usr/include/freetype2/freetype/ftsystem.h:211
subtype FT_StreamDesc is FT_StreamDesc_u; -- /usr/include/freetype2/freetype/ftsystem.h:216
--*************************************************************************
-- *
-- * @functype:
-- * FT_Stream_IoFunc
-- *
-- * @description:
-- * A function used to seek and read data from a given input stream.
-- *
-- * @input:
-- * stream ::
-- * A handle to the source stream.
-- *
-- * offset ::
-- * The offset of read in stream (always from start).
-- *
-- * buffer ::
-- * The address of the read buffer.
-- *
-- * count ::
-- * The number of bytes to read from the stream.
-- *
-- * @return:
-- * The number of bytes effectively read by the stream.
-- *
-- * @note:
-- * This function might be called to perform a seek or skip operation with
-- * a `count` of~0. A non-zero return value then indicates an error.
-- *
--
type FT_Stream_IoFunc is access function
(arg1 : FT_Stream;
arg2 : unsigned_long;
arg3 : access unsigned_char;
arg4 : unsigned_long) return unsigned_long
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:249
--*************************************************************************
-- *
-- * @functype:
-- * FT_Stream_CloseFunc
-- *
-- * @description:
-- * A function used to close a given input stream.
-- *
-- * @input:
-- * stream ::
-- * A handle to the target stream.
-- *
--
type FT_Stream_CloseFunc is access procedure (arg1 : FT_Stream)
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:269
--*************************************************************************
-- *
-- * @struct:
-- * FT_StreamRec
-- *
-- * @description:
-- * A structure used to describe an input stream.
-- *
-- * @input:
-- * base ::
-- * For memory-based streams, this is the address of the first stream
-- * byte in memory. This field should always be set to `NULL` for
-- * disk-based streams.
-- *
-- * size ::
-- * The stream size in bytes.
-- *
-- * In case of compressed streams where the size is unknown before
-- * actually doing the decompression, the value is set to 0x7FFFFFFF.
-- * (Note that this size value can occur for normal streams also; it is
-- * thus just a hint.)
-- *
-- * pos ::
-- * The current position within the stream.
-- *
-- * descriptor ::
-- * This field is a union that can hold an integer or a pointer. It is
-- * used by stream implementations to store file descriptors or `FILE*`
-- * pointers.
-- *
-- * pathname ::
-- * This field is completely ignored by FreeType. However, it is often
-- * useful during debugging to use it to store the stream's filename
-- * (where available).
-- *
-- * read ::
-- * The stream's input function.
-- *
-- * close ::
-- * The stream's close function.
-- *
-- * memory ::
-- * The memory manager to use to preload frames. This is set internally
-- * by FreeType and shouldn't be touched by stream implementations.
-- *
-- * cursor ::
-- * This field is set and used internally by FreeType when parsing
-- * frames. In particular, the `FT_GET_XXX` macros use this instead of
-- * the `pos` field.
-- *
-- * limit ::
-- * This field is set and used internally by FreeType when parsing
-- * frames.
-- *
--
type FT_StreamRec_u is record
base : access unsigned_char; -- /usr/include/freetype2/freetype/ftsystem.h:329
size : aliased unsigned_long; -- /usr/include/freetype2/freetype/ftsystem.h:330
pos : aliased unsigned_long; -- /usr/include/freetype2/freetype/ftsystem.h:331
descriptor : aliased FT_StreamDesc; -- /usr/include/freetype2/freetype/ftsystem.h:333
pathname : aliased FT_StreamDesc; -- /usr/include/freetype2/freetype/ftsystem.h:334
read : FT_Stream_IoFunc; -- /usr/include/freetype2/freetype/ftsystem.h:335
close : FT_Stream_CloseFunc; -- /usr/include/freetype2/freetype/ftsystem.h:336
memory : FT_Memory; -- /usr/include/freetype2/freetype/ftsystem.h:338
cursor : access unsigned_char; -- /usr/include/freetype2/freetype/ftsystem.h:339
limit : access unsigned_char; -- /usr/include/freetype2/freetype/ftsystem.h:340
end record
with Convention => C_Pass_By_Copy; -- /usr/include/freetype2/freetype/ftsystem.h:327
subtype FT_StreamRec is FT_StreamRec_u; -- /usr/include/freetype2/freetype/ftsystem.h:342
--
-- END
end ftsystem;
|
[
{
"context": "-- Copyright (c) 2020 Maxim Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifi",
"end": 35,
"score": 0.9998563528060913,
"start": 23,
"tag": "NAME",
"value": "Maxim Reznik"
},
{
"context": "-- Copyright (c) 2020 Maxim Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifier: MIT\n-- License-",
"end": 55,
"score": 0.9999305009841919,
"start": 37,
"tag": "EMAIL",
"value": "reznikmm@gmail.com"
}
] | source/jws-to_base_64_url.adb | reznikmm/jwt | 8 | -- Copyright (c) 2020 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with League.Base_Codecs;
function JWS.To_Base_64_URL
(Data : League.Stream_Element_Vectors.Stream_Element_Vector)
return League.Strings.Universal_String
is
Result : constant League.Strings.Universal_String :=
League.Base_Codecs.To_Base_64_URL (Data);
begin
if Result.Ends_With ("==") then
return Result.Head_To (Result.Length - 2);
elsif Result.Ends_With ("=") then
return Result.Head_To (Result.Length - 1);
else
return Result;
end if;
end JWS.To_Base_64_URL;
| 3845 | -- Copyright (c) 2020 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with League.Base_Codecs;
function JWS.To_Base_64_URL
(Data : League.Stream_Element_Vectors.Stream_Element_Vector)
return League.Strings.Universal_String
is
Result : constant League.Strings.Universal_String :=
League.Base_Codecs.To_Base_64_URL (Data);
begin
if Result.Ends_With ("==") then
return Result.Head_To (Result.Length - 2);
elsif Result.Ends_With ("=") then
return Result.Head_To (Result.Length - 1);
else
return Result;
end if;
end JWS.To_Base_64_URL;
| true | -- Copyright (c) 2020 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with League.Base_Codecs;
function JWS.To_Base_64_URL
(Data : League.Stream_Element_Vectors.Stream_Element_Vector)
return League.Strings.Universal_String
is
Result : constant League.Strings.Universal_String :=
League.Base_Codecs.To_Base_64_URL (Data);
begin
if Result.Ends_With ("==") then
return Result.Head_To (Result.Length - 2);
elsif Result.Ends_With ("=") then
return Result.Head_To (Result.Length - 1);
else
return Result;
end if;
end JWS.To_Base_64_URL;
|
[
{
"context": "--\n-- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr>\n-- - Ryad Benadjila\n-- - Arnauld Michel",
"end": 64,
"score": 0.9999324679374695,
"start": 46,
"tag": "EMAIL",
"value": "wookey@ssi.gouv.fr"
},
{
"context": "he wookey project team <wookey@ssi.gouv.fr>\n-- - Ryad Benadjila\n-- - Arnauld Michelizza\n-- - Mathieu Renard",
"end": 91,
"score": 0.9974812865257263,
"start": 73,
"tag": "NAME",
"value": "Ryad Benadjila"
},
{
"context": "okey@ssi.gouv.fr>\n-- - Ryad Benadjila\n-- - Arnauld Michelizza\n-- - Mathieu Renard\n-- - Philippe Thierry\n--",
"end": 118,
"score": 0.9836058616638184,
"start": 99,
"tag": "NAME",
"value": "Arnauld Michelizza"
},
{
"context": "ad Benadjila\n-- - Arnauld Michelizza\n-- - Mathieu Renard\n-- - Philippe Thierry\n-- - Philippe Trebuchet",
"end": 141,
"score": 0.8895496129989624,
"start": 126,
"tag": "NAME",
"value": "Mathieu Renard"
},
{
"context": " Arnauld Michelizza\n-- - Mathieu Renard\n-- - Philippe Thierry\n-- - Philippe Trebuchet\n--\n-- Licensed under th",
"end": 165,
"score": 0.9998324513435364,
"start": 149,
"tag": "NAME",
"value": "Philippe Thierry"
},
{
"context": " - Mathieu Renard\n-- - Philippe Thierry\n-- - Philippe Trebuchet\n--\n-- Licensed under the Apache License, Version ",
"end": 191,
"score": 0.9998639225959778,
"start": 173,
"tag": "NAME",
"value": "Philippe Trebuchet"
}
] | src/rings.ads | PThierry/ewok-kernel | 0 | --
-- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
--
-- Ring buffer generic implementation
--
generic
type object is private;
size : in integer := 512;
package rings is
pragma Preelaborate;
type ring is private;
type ring_state is (EMPTY, USED, FULL);
procedure init
(r : out ring);
-- write some new data and increment top counter
procedure write
(r : out ring;
item : in object;
success : out boolean);
-- read some data and increment bottom counter
procedure read
(r : in out ring;
item : out object;
success : out boolean);
-- decrement top counter
procedure unwrite
(r : out ring;
success : out boolean);
-- return ring state (empty, used or full)
function state
(r : in ring)
return ring_state;
pragma inline (state);
private
type ring_range is new integer range 1 .. size;
type buffer is array (ring_range) of object;
type ring is
record
buf : buffer;
top : ring_range := ring_range'first; -- place to write
bottom : ring_range := ring_range'first; -- place to read
state : ring_state := EMPTY;
end record;
end rings;
| 6140 | --
-- Copyright 2018 The wookey project team <<EMAIL>>
-- - <NAME>
-- - <NAME>
-- - <NAME>
-- - <NAME>
-- - <NAME>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
--
-- Ring buffer generic implementation
--
generic
type object is private;
size : in integer := 512;
package rings is
pragma Preelaborate;
type ring is private;
type ring_state is (EMPTY, USED, FULL);
procedure init
(r : out ring);
-- write some new data and increment top counter
procedure write
(r : out ring;
item : in object;
success : out boolean);
-- read some data and increment bottom counter
procedure read
(r : in out ring;
item : out object;
success : out boolean);
-- decrement top counter
procedure unwrite
(r : out ring;
success : out boolean);
-- return ring state (empty, used or full)
function state
(r : in ring)
return ring_state;
pragma inline (state);
private
type ring_range is new integer range 1 .. size;
type buffer is array (ring_range) of object;
type ring is
record
buf : buffer;
top : ring_range := ring_range'first; -- place to write
bottom : ring_range := ring_range'first; -- place to read
state : ring_state := EMPTY;
end record;
end rings;
| true | --
-- Copyright 2018 The wookey project team <PI:EMAIL:<EMAIL>END_PI>
-- - PI:NAME:<NAME>END_PI
-- - PI:NAME:<NAME>END_PI
-- - PI:NAME:<NAME>END_PI
-- - PI:NAME:<NAME>END_PI
-- - PI:NAME:<NAME>END_PI
--
-- 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.
--
--
--
-- Ring buffer generic implementation
--
generic
type object is private;
size : in integer := 512;
package rings is
pragma Preelaborate;
type ring is private;
type ring_state is (EMPTY, USED, FULL);
procedure init
(r : out ring);
-- write some new data and increment top counter
procedure write
(r : out ring;
item : in object;
success : out boolean);
-- read some data and increment bottom counter
procedure read
(r : in out ring;
item : out object;
success : out boolean);
-- decrement top counter
procedure unwrite
(r : out ring;
success : out boolean);
-- return ring state (empty, used or full)
function state
(r : in ring)
return ring_state;
pragma inline (state);
private
type ring_range is new integer range 1 .. size;
type buffer is array (ring_range) of object;
type ring is
record
buf : buffer;
top : ring_range := ring_range'first; -- place to write
bottom : ring_range := ring_range'first; -- place to read
state : ring_state := EMPTY;
end record;
end rings;
|
[
{
"context": " (symexpr)\n--\n-- Copyright (C) 2012, Riccardo Bernardini\n--\n-- This file is part of symexpr.\n--\n-- ",
"end": 181,
"score": 0.999835729598999,
"start": 162,
"tag": "NAME",
"value": "Riccardo Bernardini"
},
{
"context": "Result,\n Var_Name => Name,\n Value => Eleme",
"end": 11501,
"score": 0.5067917704582214,
"start": 11497,
"tag": "NAME",
"value": "Name"
}
] | src/Sym_Expr/symbolic_expressions.adb | fintatarta/eugen | 0 | ----------------------------------------------------------------------------
-- Symbolic Expressions (symexpr)
--
-- Copyright (C) 2012, Riccardo Bernardini
--
-- This file is part of symexpr.
--
-- symexpr is free software: you can redistribute it and/or modify
-- it under the terms of the Lesser GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- symexpr 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 Lesser GNU General Public License
-- along with gclp. If not, see <http://www.gnu.org/licenses/>.
----------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Ada.Strings.Fixed;
with Ada.Strings.Unbounded;
package body Symbolic_Expressions is
-- Set to True to enable few debug prints
Verbose : constant Boolean := False;
pragma Unreferenced (Verbose);
---------
-- "+" --
---------
function "+" (L : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Unary_Plus,
Term => Duplicate (L.Expr)));
end "+";
---------
-- "-" --
---------
function "-" (L : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Unary_Minus,
Term => Duplicate (L.Expr)));
end "-";
---------
-- "+" --
---------
function "+" (L, R : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Sum,
Left => Duplicate (L.Expr),
Right => Duplicate (R.Expr)));
end "+";
---------
-- "-" --
---------
function "-" (L, R : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Sub,
Left => Duplicate (L.Expr),
Right => Duplicate (R.Expr)));
end "-";
---------
-- "*" --
---------
function "*" (L, R : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Mult,
Left => Duplicate (L.Expr),
Right => Duplicate (R.Expr)));
end "*";
---------
-- "/" --
---------
function "/" (L, R : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Div,
Left => Duplicate (L.Expr),
Right => Duplicate (R.Expr)));
end "/";
---------
-- "+" --
---------
function "+" (L : Symbolic_Expression; R : Scalar_Type)
return Symbolic_Expression
is
begin
return L + To_Expr (R);
end "+";
---------
-- "-" --
---------
function "-" (L : Symbolic_Expression; R : Scalar_Type)
return Symbolic_Expression
is
begin
return L - To_Expr (R);
end "-";
---------
-- "*" --
---------
function "*" (L : Symbolic_Expression; R : Scalar_Type)
return Symbolic_Expression
is
begin
return L * To_Expr (R);
end "*";
---------
-- "/" --
---------
function "/" (L : Symbolic_Expression; R : Scalar_Type)
return Symbolic_Expression
is
begin
return L / To_Expr (R);
end "/";
---------
-- "+" --
---------
function "+" (L : Scalar_Type; R : Symbolic_Expression)
return Symbolic_Expression
is
begin
return To_Expr (L) + R;
end "+";
---------
-- "-" --
---------
function "-" (L : Scalar_Type; R : Symbolic_Expression)
return Symbolic_Expression
is
begin
return To_Expr (L) - R;
end "-";
---------
-- "*" --
---------
function "*" (L : Scalar_Type; R : Symbolic_Expression)
return Symbolic_Expression
is
begin
return To_Expr (L) * R;
end "*";
---------
-- "/" --
---------
function "/" (L : Scalar_Type; R : Symbolic_Expression)
return Symbolic_Expression
is
begin
return To_Expr (L) / R;
end "/";
-----------------
-- Is_Constant --
-----------------
function Is_Constant (X : Node_Access) return Boolean is
begin
case X.Class is
when Unary_Plus | Unary_Minus =>
return Is_Constant (X.Term);
when Sum | Sub | Mult | Div =>
return Is_Constant (X.Left) and Is_Constant (X.Right);
when Fun_Call =>
for I in 1 .. X.N_Params loop
if not Is_Constant (X.Parameters (I)) then
return False;
end if;
end loop;
return True;
when Var =>
return False;
when Const =>
return True;
end case;
end Is_Constant;
function Is_Constant (X : Symbolic_Expression) return Boolean is
begin
return Is_Constant (X.Expr);
end Is_Constant;
-------------------
-- Constant_Expr --
-------------------
function To_Expr (X : Scalar_Type) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Const,
Value => X));
end To_Expr;
---------------
-- To_Scalar --
---------------
function To_Scalar (X : Node_Access) return Scalar_Type is
begin
case X.Class is
when Unary_Plus =>
return + To_Scalar (X.Term);
when Unary_Minus =>
return - To_Scalar (X.Term);
when Sum =>
return To_Scalar (X.Left) + To_Scalar (X.Right);
when Sub =>
return To_Scalar (X.Left) - To_Scalar (X.Right);
when Mult =>
return To_Scalar (X.Left) * To_Scalar (X.Right);
when Div =>
return To_Scalar (X.Left) / To_Scalar (X.Right);
when Fun_Call =>
declare
Param : Scalar_Array (1 .. X.N_Params);
begin
for I in Param'Range loop
Param (I) := To_Scalar (X.Parameters (I));
end loop;
return Call (Identifier(X.Fun_Name), Param);
end;
when Var =>
raise Not_A_Scalar;
when Const =>
return X.Value;
end case;
end To_Scalar;
function Eval (X : Symbolic_Expression) return Scalar_Type is
begin
return To_Scalar (X.Expr);
end Eval;
-------------------
-- Function_Call --
-------------------
function Function_Call
(Name : Function_Name;
Parameters : Expression_Array)
return Symbolic_Expression
is
Node : constant Node_Access :=
new Node_Type'(Class => Fun_Call,
Fun_Name => Name,
N_Params => Parameters'Length,
Parameters => <>);
begin
for I in Parameters'Range loop
Node.Parameters (I) := Duplicate (Parameters (I).Expr);
end loop;
return Symbolic_Expression'(Controlled with Expr => Node);
end Function_Call;
--------------
-- Variable --
--------------
function Variable
(Name : Variable_Name) return Symbolic_Expression
is
begin
return Symbolic_Expression'(Controlled with Expr =>
new Node_Type'(Class => Var,
Var_Name => Name));
end Variable;
function Replace
(Item : Node_Access;
Var_Name : Variable_Name;
Value : Node_Access)
return Node_Access
is
function Result_Class (Item : Node_Access;
Var_Name : Variable_Name) return Node_Class is
begin
if Item.Class = Var and then Item.Var_Name = Var_Name then
return Const;
else
return Item.Class;
end if;
end Result_Class;
pragma Unreferenced (Result_Class);
Result : Node_Access;
begin
-- Ada.Text_IO.Put_Line ("Bibi" & Item.Class'img);
case Item.Class is
when Unary_Plus | Unary_Minus =>
Result := new Node_Type (Item.Class);
Result.Term := Replace (Item.Term, Var_Name, Value);
pragma Assert (Result.Class = Item.Class);
when Sum | Sub | Mult | Div =>
Result := new Node_Type (Item.Class);
Result.Left := Replace (Item.Left, Var_Name, Value);
Result.Right := Replace (Item.Right, Var_Name, Value);
pragma Assert (Result.Class = Item.Class);
when Fun_Call =>
Result := new Node_Type (Item.Class);
Result.Fun_Name := Item.Fun_Name;
Result.N_Params := Item.N_Params;
for I in 1 .. Result.N_Params loop
Result.Parameters (I) := Replace (Item.Parameters (I), Var_Name, Value);
end loop;
pragma Assert (Result.Class = Fun_Call);
when Var =>
-- Ada.Text_Io.Put_Line ("'" & To_String (Var_Name) & "' '"
-- & To_String (Item.Var_Name) & "'");
if Item.Var_Name = Var_Name then
Result := Duplicate (Value);
else
Result := Duplicate (Item);
end if;
when Const =>
Result := Duplicate (Item);
end case;
-- Ada.Text_IO.Put_Line ("Bobo" & Item.Class'img);
return Result;
end Replace;
-------------
-- Replace --
-------------
function Replace
(Item : Symbolic_Expression;
Var_Name : Variable_Name;
Value : Symbolic_Expression)
return Symbolic_Expression
is
begin
return Symbolic_Expression'
(Controlled with
Expr => Replace (Item => Item.Expr,
Var_Name => Var_Name,
Value => Value.Expr));
end Replace;
function Replace (Item : Symbolic_Expression;
Table : Variable_Tables.Map)
return Symbolic_Expression
is
Result : Symbolic_Expression := Item;
procedure Process (Name : Variable_Name) is
use Variable_Tables;
Pos : constant Cursor := Table.Find (Name);
begin
if Pos = No_Element then
return;
else
Result := Replace (Item => Result,
Var_Name => Name,
Value => Element (Pos));
end if;
end Process;
begin
Iterate_On_Vars (Item, Process'Access);
return Result;
end Replace;
function Replace (Item : Symbolic_Expression;
Var_Name : Variable_Name;
Value : Scalar_Type)
return Symbolic_Expression
is
begin
return Symbolic_Expression'
(Controlled with
Expr => Replace (Item.Expr, Var_Name, To_Expr(Value).Expr));
end Replace;
function Free_Variables (Item : Symbolic_Expression)
return Variable_Sets.Set
is
procedure Fill_List (Item : Node_Access;
Names : in out Variable_Sets.Set)
is
begin
case Item.Class is
when Unary_Plus | Unary_Minus =>
Fill_List (Item.Term, Names);
when Sum | Sub | Mult | Div =>
Fill_List (Item.Left, Names);
Fill_List (Item.Right, Names);
when Fun_Call =>
for I in 1 .. Item.N_Params loop
Fill_List (Item.Parameters (I), Names);
end loop;
when Var =>
Names.Include (Item.Var_Name);
when Const =>
null;
end case;
end Fill_List;
Result : Variable_Sets.Set;
begin
Fill_List (Item.Expr, Result);
return Result;
end Free_Variables;
---------------------
-- Iterate_On_Vars --
---------------------
procedure Iterate_On_Vars
(Item : Symbolic_Expression;
Process : access procedure (Var_Name : Variable_Name))
is
use Variable_Sets;
-- Variables : Var_Lists.Set :=
procedure Call (Pos : Cursor) is
begin
Process (Element (Pos));
end Call;
begin
Free_Variables (Item).Iterate (Call'Access);
end Iterate_On_Vars;
---------------
-- Normalize --
---------------
-- procedure Normalize (Item : in out Symbolic_Expression) is
-- pragma Unreferenced (Item);
-- begin
-- -- Generated stub: replace with real body!
-- pragma Compile_Time_Warning (Standard.False, "Normalize unimplemented");
-- raise Program_Error with "Unimplemented procedure Normalize";
-- end Normalize;
function Duplicate (Item : Node_Access) return Node_Access
is
Result : constant Node_Access := new Node_Type (Item.Class);
begin
if Item = null then
return null;
end if;
case Item.Class is
when Unary_Plus | Unary_Minus =>
Result.Term := Duplicate (Item.Term);
when Sum | Sub | Mult | Div =>
Result.Left := Duplicate (Item.Left);
Result.Right := Duplicate (Item.Right);
when Fun_Call =>
Result.Fun_Name := Item.Fun_Name;
Result.N_Params := Item.N_Params;
for I in 1 .. Result.N_Params loop
Result.Parameters (I) := Duplicate (Item.Parameters (I));
end loop;
when Var =>
Result.Var_Name := Item.Var_Name;
when Const =>
Result.Value := Item.Value;
end case;
return Result;
end Duplicate;
procedure Free (Item : in out Node_Access)
is
procedure Dealloc is
new Ada.Unchecked_Deallocation (Object => Node_Type,
Name => Node_Access);
begin
if Item = null then
return;
end if;
pragma Assert (Item /= null);
case Item.Class is
when Unary_Plus | Unary_Minus =>
Free (Item.Term);
when Sum | Sub | Mult | Div =>
Free (Item.Left);
Free (Item.Right);
when Fun_Call =>
for I in 1 .. Item.N_Params loop
Free (Item.Parameters (I));
end loop;
when Var =>
null;
when Const =>
null;
end case;
Dealloc (Item);
end Free;
function Dump (Item : Node_Access;
Level : Natural)
return String
is
use Ada.Strings.Fixed;
use Ada.Strings.Unbounded;
function Head (X : String) return Unbounded_String is
begin
return To_Unbounded_String (((Level * 3) * " ") & X);
end Head;
CRLF : constant String := Character'Val (13) & Character'Val (10);
Result : Unbounded_String;
begin
case Item.Class is
when Unary_Plus =>
Result := Head ("@+") & CRLF & Dump (Item.Term, Level + 1);
when Unary_Minus =>
Result := Head ("@-") & CRLF & Dump (Item.Term, Level + 1);
when Sum =>
Result := Head ("+")
& CRLF & Dump (Item.Left, Level + 1)
& CRLF & Dump (Item.Right, Level + 1);
when Sub =>
Result := Head ("-")
& CRLF & Dump (Item.Left, Level + 1)
& CRLF & Dump (Item.Right, Level + 1);
when Mult =>
Result := Head ("*")
& CRLF & Dump (Item.Left, Level + 1)
& CRLF & Dump (Item.Right, Level + 1);
when Div =>
Result := Head ("/")
& CRLF & Dump (Item.Left, Level + 1)
& CRLF & Dump (Item.Right, Level + 1);
when Fun_Call =>
Result := Head ("Call " & ID_Image (Item.Fun_Name));
for I in 1 .. Item.N_Params loop
Result := Result & CRLF & Dump (Item.Parameters (I), Level + 1);
end loop;
when Var =>
Result := Head ("Var ") & "(" & ID_Image (Item.Var_Name) & ")";
when Const =>
Result := Head ("Const ") & Image (Item.Value);
end case;
return To_String (Result);
end Dump;
function Dump (Item : Symbolic_Expression) return String
is
begin
return Dump (Item.Expr, 0);
end Dump;
overriding procedure Initialize (Item : in out Symbolic_Expression)
is
begin
Item.Expr := null;
end Initialize;
overriding procedure Finalize (Item : in out Symbolic_Expression)
is
begin
if Item.Expr /= null then
Free (Item.Expr);
end if;
end Finalize;
overriding procedure Adjust (Item : in out Symbolic_Expression)
is
begin
if Item.Expr /= null then
Item.Expr := Duplicate (Item.Expr);
end if;
end Adjust;
end Symbolic_Expressions;
| 687 | ----------------------------------------------------------------------------
-- Symbolic Expressions (symexpr)
--
-- Copyright (C) 2012, <NAME>
--
-- This file is part of symexpr.
--
-- symexpr is free software: you can redistribute it and/or modify
-- it under the terms of the Lesser GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- symexpr 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 Lesser GNU General Public License
-- along with gclp. If not, see <http://www.gnu.org/licenses/>.
----------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Ada.Strings.Fixed;
with Ada.Strings.Unbounded;
package body Symbolic_Expressions is
-- Set to True to enable few debug prints
Verbose : constant Boolean := False;
pragma Unreferenced (Verbose);
---------
-- "+" --
---------
function "+" (L : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Unary_Plus,
Term => Duplicate (L.Expr)));
end "+";
---------
-- "-" --
---------
function "-" (L : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Unary_Minus,
Term => Duplicate (L.Expr)));
end "-";
---------
-- "+" --
---------
function "+" (L, R : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Sum,
Left => Duplicate (L.Expr),
Right => Duplicate (R.Expr)));
end "+";
---------
-- "-" --
---------
function "-" (L, R : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Sub,
Left => Duplicate (L.Expr),
Right => Duplicate (R.Expr)));
end "-";
---------
-- "*" --
---------
function "*" (L, R : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Mult,
Left => Duplicate (L.Expr),
Right => Duplicate (R.Expr)));
end "*";
---------
-- "/" --
---------
function "/" (L, R : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Div,
Left => Duplicate (L.Expr),
Right => Duplicate (R.Expr)));
end "/";
---------
-- "+" --
---------
function "+" (L : Symbolic_Expression; R : Scalar_Type)
return Symbolic_Expression
is
begin
return L + To_Expr (R);
end "+";
---------
-- "-" --
---------
function "-" (L : Symbolic_Expression; R : Scalar_Type)
return Symbolic_Expression
is
begin
return L - To_Expr (R);
end "-";
---------
-- "*" --
---------
function "*" (L : Symbolic_Expression; R : Scalar_Type)
return Symbolic_Expression
is
begin
return L * To_Expr (R);
end "*";
---------
-- "/" --
---------
function "/" (L : Symbolic_Expression; R : Scalar_Type)
return Symbolic_Expression
is
begin
return L / To_Expr (R);
end "/";
---------
-- "+" --
---------
function "+" (L : Scalar_Type; R : Symbolic_Expression)
return Symbolic_Expression
is
begin
return To_Expr (L) + R;
end "+";
---------
-- "-" --
---------
function "-" (L : Scalar_Type; R : Symbolic_Expression)
return Symbolic_Expression
is
begin
return To_Expr (L) - R;
end "-";
---------
-- "*" --
---------
function "*" (L : Scalar_Type; R : Symbolic_Expression)
return Symbolic_Expression
is
begin
return To_Expr (L) * R;
end "*";
---------
-- "/" --
---------
function "/" (L : Scalar_Type; R : Symbolic_Expression)
return Symbolic_Expression
is
begin
return To_Expr (L) / R;
end "/";
-----------------
-- Is_Constant --
-----------------
function Is_Constant (X : Node_Access) return Boolean is
begin
case X.Class is
when Unary_Plus | Unary_Minus =>
return Is_Constant (X.Term);
when Sum | Sub | Mult | Div =>
return Is_Constant (X.Left) and Is_Constant (X.Right);
when Fun_Call =>
for I in 1 .. X.N_Params loop
if not Is_Constant (X.Parameters (I)) then
return False;
end if;
end loop;
return True;
when Var =>
return False;
when Const =>
return True;
end case;
end Is_Constant;
function Is_Constant (X : Symbolic_Expression) return Boolean is
begin
return Is_Constant (X.Expr);
end Is_Constant;
-------------------
-- Constant_Expr --
-------------------
function To_Expr (X : Scalar_Type) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Const,
Value => X));
end To_Expr;
---------------
-- To_Scalar --
---------------
function To_Scalar (X : Node_Access) return Scalar_Type is
begin
case X.Class is
when Unary_Plus =>
return + To_Scalar (X.Term);
when Unary_Minus =>
return - To_Scalar (X.Term);
when Sum =>
return To_Scalar (X.Left) + To_Scalar (X.Right);
when Sub =>
return To_Scalar (X.Left) - To_Scalar (X.Right);
when Mult =>
return To_Scalar (X.Left) * To_Scalar (X.Right);
when Div =>
return To_Scalar (X.Left) / To_Scalar (X.Right);
when Fun_Call =>
declare
Param : Scalar_Array (1 .. X.N_Params);
begin
for I in Param'Range loop
Param (I) := To_Scalar (X.Parameters (I));
end loop;
return Call (Identifier(X.Fun_Name), Param);
end;
when Var =>
raise Not_A_Scalar;
when Const =>
return X.Value;
end case;
end To_Scalar;
function Eval (X : Symbolic_Expression) return Scalar_Type is
begin
return To_Scalar (X.Expr);
end Eval;
-------------------
-- Function_Call --
-------------------
function Function_Call
(Name : Function_Name;
Parameters : Expression_Array)
return Symbolic_Expression
is
Node : constant Node_Access :=
new Node_Type'(Class => Fun_Call,
Fun_Name => Name,
N_Params => Parameters'Length,
Parameters => <>);
begin
for I in Parameters'Range loop
Node.Parameters (I) := Duplicate (Parameters (I).Expr);
end loop;
return Symbolic_Expression'(Controlled with Expr => Node);
end Function_Call;
--------------
-- Variable --
--------------
function Variable
(Name : Variable_Name) return Symbolic_Expression
is
begin
return Symbolic_Expression'(Controlled with Expr =>
new Node_Type'(Class => Var,
Var_Name => Name));
end Variable;
function Replace
(Item : Node_Access;
Var_Name : Variable_Name;
Value : Node_Access)
return Node_Access
is
function Result_Class (Item : Node_Access;
Var_Name : Variable_Name) return Node_Class is
begin
if Item.Class = Var and then Item.Var_Name = Var_Name then
return Const;
else
return Item.Class;
end if;
end Result_Class;
pragma Unreferenced (Result_Class);
Result : Node_Access;
begin
-- Ada.Text_IO.Put_Line ("Bibi" & Item.Class'img);
case Item.Class is
when Unary_Plus | Unary_Minus =>
Result := new Node_Type (Item.Class);
Result.Term := Replace (Item.Term, Var_Name, Value);
pragma Assert (Result.Class = Item.Class);
when Sum | Sub | Mult | Div =>
Result := new Node_Type (Item.Class);
Result.Left := Replace (Item.Left, Var_Name, Value);
Result.Right := Replace (Item.Right, Var_Name, Value);
pragma Assert (Result.Class = Item.Class);
when Fun_Call =>
Result := new Node_Type (Item.Class);
Result.Fun_Name := Item.Fun_Name;
Result.N_Params := Item.N_Params;
for I in 1 .. Result.N_Params loop
Result.Parameters (I) := Replace (Item.Parameters (I), Var_Name, Value);
end loop;
pragma Assert (Result.Class = Fun_Call);
when Var =>
-- Ada.Text_Io.Put_Line ("'" & To_String (Var_Name) & "' '"
-- & To_String (Item.Var_Name) & "'");
if Item.Var_Name = Var_Name then
Result := Duplicate (Value);
else
Result := Duplicate (Item);
end if;
when Const =>
Result := Duplicate (Item);
end case;
-- Ada.Text_IO.Put_Line ("Bobo" & Item.Class'img);
return Result;
end Replace;
-------------
-- Replace --
-------------
function Replace
(Item : Symbolic_Expression;
Var_Name : Variable_Name;
Value : Symbolic_Expression)
return Symbolic_Expression
is
begin
return Symbolic_Expression'
(Controlled with
Expr => Replace (Item => Item.Expr,
Var_Name => Var_Name,
Value => Value.Expr));
end Replace;
function Replace (Item : Symbolic_Expression;
Table : Variable_Tables.Map)
return Symbolic_Expression
is
Result : Symbolic_Expression := Item;
procedure Process (Name : Variable_Name) is
use Variable_Tables;
Pos : constant Cursor := Table.Find (Name);
begin
if Pos = No_Element then
return;
else
Result := Replace (Item => Result,
Var_Name => <NAME>,
Value => Element (Pos));
end if;
end Process;
begin
Iterate_On_Vars (Item, Process'Access);
return Result;
end Replace;
function Replace (Item : Symbolic_Expression;
Var_Name : Variable_Name;
Value : Scalar_Type)
return Symbolic_Expression
is
begin
return Symbolic_Expression'
(Controlled with
Expr => Replace (Item.Expr, Var_Name, To_Expr(Value).Expr));
end Replace;
function Free_Variables (Item : Symbolic_Expression)
return Variable_Sets.Set
is
procedure Fill_List (Item : Node_Access;
Names : in out Variable_Sets.Set)
is
begin
case Item.Class is
when Unary_Plus | Unary_Minus =>
Fill_List (Item.Term, Names);
when Sum | Sub | Mult | Div =>
Fill_List (Item.Left, Names);
Fill_List (Item.Right, Names);
when Fun_Call =>
for I in 1 .. Item.N_Params loop
Fill_List (Item.Parameters (I), Names);
end loop;
when Var =>
Names.Include (Item.Var_Name);
when Const =>
null;
end case;
end Fill_List;
Result : Variable_Sets.Set;
begin
Fill_List (Item.Expr, Result);
return Result;
end Free_Variables;
---------------------
-- Iterate_On_Vars --
---------------------
procedure Iterate_On_Vars
(Item : Symbolic_Expression;
Process : access procedure (Var_Name : Variable_Name))
is
use Variable_Sets;
-- Variables : Var_Lists.Set :=
procedure Call (Pos : Cursor) is
begin
Process (Element (Pos));
end Call;
begin
Free_Variables (Item).Iterate (Call'Access);
end Iterate_On_Vars;
---------------
-- Normalize --
---------------
-- procedure Normalize (Item : in out Symbolic_Expression) is
-- pragma Unreferenced (Item);
-- begin
-- -- Generated stub: replace with real body!
-- pragma Compile_Time_Warning (Standard.False, "Normalize unimplemented");
-- raise Program_Error with "Unimplemented procedure Normalize";
-- end Normalize;
function Duplicate (Item : Node_Access) return Node_Access
is
Result : constant Node_Access := new Node_Type (Item.Class);
begin
if Item = null then
return null;
end if;
case Item.Class is
when Unary_Plus | Unary_Minus =>
Result.Term := Duplicate (Item.Term);
when Sum | Sub | Mult | Div =>
Result.Left := Duplicate (Item.Left);
Result.Right := Duplicate (Item.Right);
when Fun_Call =>
Result.Fun_Name := Item.Fun_Name;
Result.N_Params := Item.N_Params;
for I in 1 .. Result.N_Params loop
Result.Parameters (I) := Duplicate (Item.Parameters (I));
end loop;
when Var =>
Result.Var_Name := Item.Var_Name;
when Const =>
Result.Value := Item.Value;
end case;
return Result;
end Duplicate;
procedure Free (Item : in out Node_Access)
is
procedure Dealloc is
new Ada.Unchecked_Deallocation (Object => Node_Type,
Name => Node_Access);
begin
if Item = null then
return;
end if;
pragma Assert (Item /= null);
case Item.Class is
when Unary_Plus | Unary_Minus =>
Free (Item.Term);
when Sum | Sub | Mult | Div =>
Free (Item.Left);
Free (Item.Right);
when Fun_Call =>
for I in 1 .. Item.N_Params loop
Free (Item.Parameters (I));
end loop;
when Var =>
null;
when Const =>
null;
end case;
Dealloc (Item);
end Free;
function Dump (Item : Node_Access;
Level : Natural)
return String
is
use Ada.Strings.Fixed;
use Ada.Strings.Unbounded;
function Head (X : String) return Unbounded_String is
begin
return To_Unbounded_String (((Level * 3) * " ") & X);
end Head;
CRLF : constant String := Character'Val (13) & Character'Val (10);
Result : Unbounded_String;
begin
case Item.Class is
when Unary_Plus =>
Result := Head ("@+") & CRLF & Dump (Item.Term, Level + 1);
when Unary_Minus =>
Result := Head ("@-") & CRLF & Dump (Item.Term, Level + 1);
when Sum =>
Result := Head ("+")
& CRLF & Dump (Item.Left, Level + 1)
& CRLF & Dump (Item.Right, Level + 1);
when Sub =>
Result := Head ("-")
& CRLF & Dump (Item.Left, Level + 1)
& CRLF & Dump (Item.Right, Level + 1);
when Mult =>
Result := Head ("*")
& CRLF & Dump (Item.Left, Level + 1)
& CRLF & Dump (Item.Right, Level + 1);
when Div =>
Result := Head ("/")
& CRLF & Dump (Item.Left, Level + 1)
& CRLF & Dump (Item.Right, Level + 1);
when Fun_Call =>
Result := Head ("Call " & ID_Image (Item.Fun_Name));
for I in 1 .. Item.N_Params loop
Result := Result & CRLF & Dump (Item.Parameters (I), Level + 1);
end loop;
when Var =>
Result := Head ("Var ") & "(" & ID_Image (Item.Var_Name) & ")";
when Const =>
Result := Head ("Const ") & Image (Item.Value);
end case;
return To_String (Result);
end Dump;
function Dump (Item : Symbolic_Expression) return String
is
begin
return Dump (Item.Expr, 0);
end Dump;
overriding procedure Initialize (Item : in out Symbolic_Expression)
is
begin
Item.Expr := null;
end Initialize;
overriding procedure Finalize (Item : in out Symbolic_Expression)
is
begin
if Item.Expr /= null then
Free (Item.Expr);
end if;
end Finalize;
overriding procedure Adjust (Item : in out Symbolic_Expression)
is
begin
if Item.Expr /= null then
Item.Expr := Duplicate (Item.Expr);
end if;
end Adjust;
end Symbolic_Expressions;
| true | ----------------------------------------------------------------------------
-- Symbolic Expressions (symexpr)
--
-- Copyright (C) 2012, PI:NAME:<NAME>END_PI
--
-- This file is part of symexpr.
--
-- symexpr is free software: you can redistribute it and/or modify
-- it under the terms of the Lesser GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- symexpr 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 Lesser GNU General Public License
-- along with gclp. If not, see <http://www.gnu.org/licenses/>.
----------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Ada.Strings.Fixed;
with Ada.Strings.Unbounded;
package body Symbolic_Expressions is
-- Set to True to enable few debug prints
Verbose : constant Boolean := False;
pragma Unreferenced (Verbose);
---------
-- "+" --
---------
function "+" (L : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Unary_Plus,
Term => Duplicate (L.Expr)));
end "+";
---------
-- "-" --
---------
function "-" (L : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Unary_Minus,
Term => Duplicate (L.Expr)));
end "-";
---------
-- "+" --
---------
function "+" (L, R : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Sum,
Left => Duplicate (L.Expr),
Right => Duplicate (R.Expr)));
end "+";
---------
-- "-" --
---------
function "-" (L, R : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Sub,
Left => Duplicate (L.Expr),
Right => Duplicate (R.Expr)));
end "-";
---------
-- "*" --
---------
function "*" (L, R : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Mult,
Left => Duplicate (L.Expr),
Right => Duplicate (R.Expr)));
end "*";
---------
-- "/" --
---------
function "/" (L, R : Symbolic_Expression) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Div,
Left => Duplicate (L.Expr),
Right => Duplicate (R.Expr)));
end "/";
---------
-- "+" --
---------
function "+" (L : Symbolic_Expression; R : Scalar_Type)
return Symbolic_Expression
is
begin
return L + To_Expr (R);
end "+";
---------
-- "-" --
---------
function "-" (L : Symbolic_Expression; R : Scalar_Type)
return Symbolic_Expression
is
begin
return L - To_Expr (R);
end "-";
---------
-- "*" --
---------
function "*" (L : Symbolic_Expression; R : Scalar_Type)
return Symbolic_Expression
is
begin
return L * To_Expr (R);
end "*";
---------
-- "/" --
---------
function "/" (L : Symbolic_Expression; R : Scalar_Type)
return Symbolic_Expression
is
begin
return L / To_Expr (R);
end "/";
---------
-- "+" --
---------
function "+" (L : Scalar_Type; R : Symbolic_Expression)
return Symbolic_Expression
is
begin
return To_Expr (L) + R;
end "+";
---------
-- "-" --
---------
function "-" (L : Scalar_Type; R : Symbolic_Expression)
return Symbolic_Expression
is
begin
return To_Expr (L) - R;
end "-";
---------
-- "*" --
---------
function "*" (L : Scalar_Type; R : Symbolic_Expression)
return Symbolic_Expression
is
begin
return To_Expr (L) * R;
end "*";
---------
-- "/" --
---------
function "/" (L : Scalar_Type; R : Symbolic_Expression)
return Symbolic_Expression
is
begin
return To_Expr (L) / R;
end "/";
-----------------
-- Is_Constant --
-----------------
function Is_Constant (X : Node_Access) return Boolean is
begin
case X.Class is
when Unary_Plus | Unary_Minus =>
return Is_Constant (X.Term);
when Sum | Sub | Mult | Div =>
return Is_Constant (X.Left) and Is_Constant (X.Right);
when Fun_Call =>
for I in 1 .. X.N_Params loop
if not Is_Constant (X.Parameters (I)) then
return False;
end if;
end loop;
return True;
when Var =>
return False;
when Const =>
return True;
end case;
end Is_Constant;
function Is_Constant (X : Symbolic_Expression) return Boolean is
begin
return Is_Constant (X.Expr);
end Is_Constant;
-------------------
-- Constant_Expr --
-------------------
function To_Expr (X : Scalar_Type) return Symbolic_Expression is
begin
return Symbolic_Expression'
(Controlled with
Expr => new Node_Type'(Class => Const,
Value => X));
end To_Expr;
---------------
-- To_Scalar --
---------------
function To_Scalar (X : Node_Access) return Scalar_Type is
begin
case X.Class is
when Unary_Plus =>
return + To_Scalar (X.Term);
when Unary_Minus =>
return - To_Scalar (X.Term);
when Sum =>
return To_Scalar (X.Left) + To_Scalar (X.Right);
when Sub =>
return To_Scalar (X.Left) - To_Scalar (X.Right);
when Mult =>
return To_Scalar (X.Left) * To_Scalar (X.Right);
when Div =>
return To_Scalar (X.Left) / To_Scalar (X.Right);
when Fun_Call =>
declare
Param : Scalar_Array (1 .. X.N_Params);
begin
for I in Param'Range loop
Param (I) := To_Scalar (X.Parameters (I));
end loop;
return Call (Identifier(X.Fun_Name), Param);
end;
when Var =>
raise Not_A_Scalar;
when Const =>
return X.Value;
end case;
end To_Scalar;
function Eval (X : Symbolic_Expression) return Scalar_Type is
begin
return To_Scalar (X.Expr);
end Eval;
-------------------
-- Function_Call --
-------------------
function Function_Call
(Name : Function_Name;
Parameters : Expression_Array)
return Symbolic_Expression
is
Node : constant Node_Access :=
new Node_Type'(Class => Fun_Call,
Fun_Name => Name,
N_Params => Parameters'Length,
Parameters => <>);
begin
for I in Parameters'Range loop
Node.Parameters (I) := Duplicate (Parameters (I).Expr);
end loop;
return Symbolic_Expression'(Controlled with Expr => Node);
end Function_Call;
--------------
-- Variable --
--------------
function Variable
(Name : Variable_Name) return Symbolic_Expression
is
begin
return Symbolic_Expression'(Controlled with Expr =>
new Node_Type'(Class => Var,
Var_Name => Name));
end Variable;
function Replace
(Item : Node_Access;
Var_Name : Variable_Name;
Value : Node_Access)
return Node_Access
is
function Result_Class (Item : Node_Access;
Var_Name : Variable_Name) return Node_Class is
begin
if Item.Class = Var and then Item.Var_Name = Var_Name then
return Const;
else
return Item.Class;
end if;
end Result_Class;
pragma Unreferenced (Result_Class);
Result : Node_Access;
begin
-- Ada.Text_IO.Put_Line ("Bibi" & Item.Class'img);
case Item.Class is
when Unary_Plus | Unary_Minus =>
Result := new Node_Type (Item.Class);
Result.Term := Replace (Item.Term, Var_Name, Value);
pragma Assert (Result.Class = Item.Class);
when Sum | Sub | Mult | Div =>
Result := new Node_Type (Item.Class);
Result.Left := Replace (Item.Left, Var_Name, Value);
Result.Right := Replace (Item.Right, Var_Name, Value);
pragma Assert (Result.Class = Item.Class);
when Fun_Call =>
Result := new Node_Type (Item.Class);
Result.Fun_Name := Item.Fun_Name;
Result.N_Params := Item.N_Params;
for I in 1 .. Result.N_Params loop
Result.Parameters (I) := Replace (Item.Parameters (I), Var_Name, Value);
end loop;
pragma Assert (Result.Class = Fun_Call);
when Var =>
-- Ada.Text_Io.Put_Line ("'" & To_String (Var_Name) & "' '"
-- & To_String (Item.Var_Name) & "'");
if Item.Var_Name = Var_Name then
Result := Duplicate (Value);
else
Result := Duplicate (Item);
end if;
when Const =>
Result := Duplicate (Item);
end case;
-- Ada.Text_IO.Put_Line ("Bobo" & Item.Class'img);
return Result;
end Replace;
-------------
-- Replace --
-------------
function Replace
(Item : Symbolic_Expression;
Var_Name : Variable_Name;
Value : Symbolic_Expression)
return Symbolic_Expression
is
begin
return Symbolic_Expression'
(Controlled with
Expr => Replace (Item => Item.Expr,
Var_Name => Var_Name,
Value => Value.Expr));
end Replace;
function Replace (Item : Symbolic_Expression;
Table : Variable_Tables.Map)
return Symbolic_Expression
is
Result : Symbolic_Expression := Item;
procedure Process (Name : Variable_Name) is
use Variable_Tables;
Pos : constant Cursor := Table.Find (Name);
begin
if Pos = No_Element then
return;
else
Result := Replace (Item => Result,
Var_Name => PI:NAME:<NAME>END_PI,
Value => Element (Pos));
end if;
end Process;
begin
Iterate_On_Vars (Item, Process'Access);
return Result;
end Replace;
function Replace (Item : Symbolic_Expression;
Var_Name : Variable_Name;
Value : Scalar_Type)
return Symbolic_Expression
is
begin
return Symbolic_Expression'
(Controlled with
Expr => Replace (Item.Expr, Var_Name, To_Expr(Value).Expr));
end Replace;
function Free_Variables (Item : Symbolic_Expression)
return Variable_Sets.Set
is
procedure Fill_List (Item : Node_Access;
Names : in out Variable_Sets.Set)
is
begin
case Item.Class is
when Unary_Plus | Unary_Minus =>
Fill_List (Item.Term, Names);
when Sum | Sub | Mult | Div =>
Fill_List (Item.Left, Names);
Fill_List (Item.Right, Names);
when Fun_Call =>
for I in 1 .. Item.N_Params loop
Fill_List (Item.Parameters (I), Names);
end loop;
when Var =>
Names.Include (Item.Var_Name);
when Const =>
null;
end case;
end Fill_List;
Result : Variable_Sets.Set;
begin
Fill_List (Item.Expr, Result);
return Result;
end Free_Variables;
---------------------
-- Iterate_On_Vars --
---------------------
procedure Iterate_On_Vars
(Item : Symbolic_Expression;
Process : access procedure (Var_Name : Variable_Name))
is
use Variable_Sets;
-- Variables : Var_Lists.Set :=
procedure Call (Pos : Cursor) is
begin
Process (Element (Pos));
end Call;
begin
Free_Variables (Item).Iterate (Call'Access);
end Iterate_On_Vars;
---------------
-- Normalize --
---------------
-- procedure Normalize (Item : in out Symbolic_Expression) is
-- pragma Unreferenced (Item);
-- begin
-- -- Generated stub: replace with real body!
-- pragma Compile_Time_Warning (Standard.False, "Normalize unimplemented");
-- raise Program_Error with "Unimplemented procedure Normalize";
-- end Normalize;
function Duplicate (Item : Node_Access) return Node_Access
is
Result : constant Node_Access := new Node_Type (Item.Class);
begin
if Item = null then
return null;
end if;
case Item.Class is
when Unary_Plus | Unary_Minus =>
Result.Term := Duplicate (Item.Term);
when Sum | Sub | Mult | Div =>
Result.Left := Duplicate (Item.Left);
Result.Right := Duplicate (Item.Right);
when Fun_Call =>
Result.Fun_Name := Item.Fun_Name;
Result.N_Params := Item.N_Params;
for I in 1 .. Result.N_Params loop
Result.Parameters (I) := Duplicate (Item.Parameters (I));
end loop;
when Var =>
Result.Var_Name := Item.Var_Name;
when Const =>
Result.Value := Item.Value;
end case;
return Result;
end Duplicate;
procedure Free (Item : in out Node_Access)
is
procedure Dealloc is
new Ada.Unchecked_Deallocation (Object => Node_Type,
Name => Node_Access);
begin
if Item = null then
return;
end if;
pragma Assert (Item /= null);
case Item.Class is
when Unary_Plus | Unary_Minus =>
Free (Item.Term);
when Sum | Sub | Mult | Div =>
Free (Item.Left);
Free (Item.Right);
when Fun_Call =>
for I in 1 .. Item.N_Params loop
Free (Item.Parameters (I));
end loop;
when Var =>
null;
when Const =>
null;
end case;
Dealloc (Item);
end Free;
function Dump (Item : Node_Access;
Level : Natural)
return String
is
use Ada.Strings.Fixed;
use Ada.Strings.Unbounded;
function Head (X : String) return Unbounded_String is
begin
return To_Unbounded_String (((Level * 3) * " ") & X);
end Head;
CRLF : constant String := Character'Val (13) & Character'Val (10);
Result : Unbounded_String;
begin
case Item.Class is
when Unary_Plus =>
Result := Head ("@+") & CRLF & Dump (Item.Term, Level + 1);
when Unary_Minus =>
Result := Head ("@-") & CRLF & Dump (Item.Term, Level + 1);
when Sum =>
Result := Head ("+")
& CRLF & Dump (Item.Left, Level + 1)
& CRLF & Dump (Item.Right, Level + 1);
when Sub =>
Result := Head ("-")
& CRLF & Dump (Item.Left, Level + 1)
& CRLF & Dump (Item.Right, Level + 1);
when Mult =>
Result := Head ("*")
& CRLF & Dump (Item.Left, Level + 1)
& CRLF & Dump (Item.Right, Level + 1);
when Div =>
Result := Head ("/")
& CRLF & Dump (Item.Left, Level + 1)
& CRLF & Dump (Item.Right, Level + 1);
when Fun_Call =>
Result := Head ("Call " & ID_Image (Item.Fun_Name));
for I in 1 .. Item.N_Params loop
Result := Result & CRLF & Dump (Item.Parameters (I), Level + 1);
end loop;
when Var =>
Result := Head ("Var ") & "(" & ID_Image (Item.Var_Name) & ")";
when Const =>
Result := Head ("Const ") & Image (Item.Value);
end case;
return To_String (Result);
end Dump;
function Dump (Item : Symbolic_Expression) return String
is
begin
return Dump (Item.Expr, 0);
end Dump;
overriding procedure Initialize (Item : in out Symbolic_Expression)
is
begin
Item.Expr := null;
end Initialize;
overriding procedure Finalize (Item : in out Symbolic_Expression)
is
begin
if Item.Expr /= null then
Free (Item.Expr);
end if;
end Finalize;
overriding procedure Adjust (Item : in out Symbolic_Expression)
is
begin
if Item.Expr /= null then
Item.Expr := Duplicate (Item.Expr);
end if;
end Adjust;
end Symbolic_Expressions;
|
[
{
"context": "---------------------\n-- Copyright (c) 2006-2013, Maxim Reznik\n-- All rights reserved.\n--\n-- Redistribution an",
"end": 3576,
"score": 0.9998590350151062,
"start": 3564,
"tag": "NAME",
"value": "Maxim Reznik"
}
] | source/asis/xasis/xasis-types.ads | faelys/gela-asis | 4 | ------------------------------------------------------------------------------
-- G E L A X A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
-- Purpose:
-- Collect basic type declaration
-- Should be initialized manualy
with Asis;
package XASIS.Types is
function Universal_Integer return Asis.Declaration;
function Universal_Real return Asis.Declaration;
function Universal_Fixed return Asis.Declaration;
function Universal_Access return Asis.Declaration;
function Root_Integer return Asis.Declaration;
function Root_Real return Asis.Declaration;
function System_Address return Asis.Declaration;
function System_Bit_Order return Asis.Declaration;
function Integer return Asis.Declaration;
function String return Asis.Declaration;
function Wide_String return Asis.Declaration;
function Wide_Wide_String return Asis.Declaration;
function Boolean return Asis.Declaration;
function Exception_Id return Asis.Declaration;
function Exception_Occurrence return Asis.Declaration;
function Task_Id return Asis.Declaration;
function Root_Storage_Pool return Asis.Declaration;
function Tag return Asis.Declaration;
function Natural return Asis.Declaration;
function Duration return Asis.Declaration;
function Character return Asis.Declaration;
function Wide_Character return Asis.Declaration;
function Wide_Wide_Character return Asis.Declaration;
function Root_Stream_Type return Asis.Declaration;
procedure Initialize
(Universal_Integer : Asis.Declaration;
Universal_Real : Asis.Declaration;
Universal_Fixed : Asis.Declaration;
Universal_Access : Asis.Declaration;
Root_Integer : Asis.Declaration;
Root_Real : Asis.Declaration;
String : Asis.Declaration;
Wide_String : Asis.Declaration;
Wide_Wide_String : Asis.Declaration;
Float : Asis.Declaration;
Boolean : Asis.Declaration;
Duration : Asis.Declaration;
Integer : Asis.Declaration;
Natural : Asis.Declaration;
Wide_Wide_Character : Asis.Declaration;
Wide_Character : Asis.Declaration;
Character : Asis.Declaration);
procedure Initialize
(System_Address : Asis.Declaration;
System_Bit_Order : Asis.Declaration);
procedure Initialize (Root_Storage_Pool : Asis.Declaration);
procedure Initialize_Task_Id (Task_Id : Asis.Declaration);
procedure Initialize_Exception
(Exception_Id : Asis.Declaration;
Exception_Occurrence : Asis.Declaration);
procedure Initialize_Tag (Tag : Asis.Declaration);
procedure Initialize_Root_Stream (Root : Asis.Declaration);
end XASIS.Types;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, Maxim Reznik
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the Maxim Reznik, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
| 18601 | ------------------------------------------------------------------------------
-- G E L A X A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
-- Purpose:
-- Collect basic type declaration
-- Should be initialized manualy
with Asis;
package XASIS.Types is
function Universal_Integer return Asis.Declaration;
function Universal_Real return Asis.Declaration;
function Universal_Fixed return Asis.Declaration;
function Universal_Access return Asis.Declaration;
function Root_Integer return Asis.Declaration;
function Root_Real return Asis.Declaration;
function System_Address return Asis.Declaration;
function System_Bit_Order return Asis.Declaration;
function Integer return Asis.Declaration;
function String return Asis.Declaration;
function Wide_String return Asis.Declaration;
function Wide_Wide_String return Asis.Declaration;
function Boolean return Asis.Declaration;
function Exception_Id return Asis.Declaration;
function Exception_Occurrence return Asis.Declaration;
function Task_Id return Asis.Declaration;
function Root_Storage_Pool return Asis.Declaration;
function Tag return Asis.Declaration;
function Natural return Asis.Declaration;
function Duration return Asis.Declaration;
function Character return Asis.Declaration;
function Wide_Character return Asis.Declaration;
function Wide_Wide_Character return Asis.Declaration;
function Root_Stream_Type return Asis.Declaration;
procedure Initialize
(Universal_Integer : Asis.Declaration;
Universal_Real : Asis.Declaration;
Universal_Fixed : Asis.Declaration;
Universal_Access : Asis.Declaration;
Root_Integer : Asis.Declaration;
Root_Real : Asis.Declaration;
String : Asis.Declaration;
Wide_String : Asis.Declaration;
Wide_Wide_String : Asis.Declaration;
Float : Asis.Declaration;
Boolean : Asis.Declaration;
Duration : Asis.Declaration;
Integer : Asis.Declaration;
Natural : Asis.Declaration;
Wide_Wide_Character : Asis.Declaration;
Wide_Character : Asis.Declaration;
Character : Asis.Declaration);
procedure Initialize
(System_Address : Asis.Declaration;
System_Bit_Order : Asis.Declaration);
procedure Initialize (Root_Storage_Pool : Asis.Declaration);
procedure Initialize_Task_Id (Task_Id : Asis.Declaration);
procedure Initialize_Exception
(Exception_Id : Asis.Declaration;
Exception_Occurrence : Asis.Declaration);
procedure Initialize_Tag (Tag : Asis.Declaration);
procedure Initialize_Root_Stream (Root : Asis.Declaration);
end XASIS.Types;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, <NAME>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the Maxim Reznik, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
| true | ------------------------------------------------------------------------------
-- G E L A X A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
-- Purpose:
-- Collect basic type declaration
-- Should be initialized manualy
with Asis;
package XASIS.Types is
function Universal_Integer return Asis.Declaration;
function Universal_Real return Asis.Declaration;
function Universal_Fixed return Asis.Declaration;
function Universal_Access return Asis.Declaration;
function Root_Integer return Asis.Declaration;
function Root_Real return Asis.Declaration;
function System_Address return Asis.Declaration;
function System_Bit_Order return Asis.Declaration;
function Integer return Asis.Declaration;
function String return Asis.Declaration;
function Wide_String return Asis.Declaration;
function Wide_Wide_String return Asis.Declaration;
function Boolean return Asis.Declaration;
function Exception_Id return Asis.Declaration;
function Exception_Occurrence return Asis.Declaration;
function Task_Id return Asis.Declaration;
function Root_Storage_Pool return Asis.Declaration;
function Tag return Asis.Declaration;
function Natural return Asis.Declaration;
function Duration return Asis.Declaration;
function Character return Asis.Declaration;
function Wide_Character return Asis.Declaration;
function Wide_Wide_Character return Asis.Declaration;
function Root_Stream_Type return Asis.Declaration;
procedure Initialize
(Universal_Integer : Asis.Declaration;
Universal_Real : Asis.Declaration;
Universal_Fixed : Asis.Declaration;
Universal_Access : Asis.Declaration;
Root_Integer : Asis.Declaration;
Root_Real : Asis.Declaration;
String : Asis.Declaration;
Wide_String : Asis.Declaration;
Wide_Wide_String : Asis.Declaration;
Float : Asis.Declaration;
Boolean : Asis.Declaration;
Duration : Asis.Declaration;
Integer : Asis.Declaration;
Natural : Asis.Declaration;
Wide_Wide_Character : Asis.Declaration;
Wide_Character : Asis.Declaration;
Character : Asis.Declaration);
procedure Initialize
(System_Address : Asis.Declaration;
System_Bit_Order : Asis.Declaration);
procedure Initialize (Root_Storage_Pool : Asis.Declaration);
procedure Initialize_Task_Id (Task_Id : Asis.Declaration);
procedure Initialize_Exception
(Exception_Id : Asis.Declaration;
Exception_Occurrence : Asis.Declaration);
procedure Initialize_Tag (Tag : Asis.Declaration);
procedure Initialize_Root_Stream (Root : Asis.Declaration);
end XASIS.Types;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, PI:NAME:<NAME>END_PI
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the Maxim Reznik, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
|
[
{
"context": "e-Identifier: Apache-2.0\n--\n-- Copyright (c) 2020 onox <denkpadje@gmail.com>\n--\n-- Licensed under the A",
"end": 70,
"score": 0.9992996454238892,
"start": 66,
"tag": "USERNAME",
"value": "onox"
},
{
"context": "ifier: Apache-2.0\n--\n-- Copyright (c) 2020 onox <denkpadje@gmail.com>\n--\n-- Licensed under the Apache License, Versio",
"end": 91,
"score": 0.9999240040779114,
"start": 72,
"tag": "EMAIL",
"value": "denkpadje@gmail.com"
}
] | orka_egl/src/egl-objects-contexts.adb | onox/orka | 52 | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 onox <denkpadje@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.Unchecked_Conversion;
with EGL.API;
with EGL.Errors;
package body EGL.Objects.Contexts is
Major_Version : constant Int := 16#3098#;
Minor_Version : constant Int := 16#30FB#;
Context_Flags_Bits : constant Int := 16#30FC#;
OpenGL_Profile_Mask : constant Int := 16#30FD#;
-- EGL 1.5
-- OpenGL_Debug : constant Int := 16#31B0#;
-- OpenGL_Forward_Compatible : constant Int := 16#31B1#;
-- OpenGL_Robust : constant Int := 16#31B2#;
OpenGL_No_Error : constant Int := 16#31B3#;
OpenGL_Reset_Notification_Strategy : constant Int := 16#31BD#;
Context_Release_Behavior : constant Int := 16#2097#;
Context_Release_Behavior_None : constant Int := 0;
-- Context_Release_Behavior_Flush : constant Int := 16#2098#;
No_Reset_Notification : constant Int := 16#31BE#;
Lose_Context_On_Reset : constant Int := 16#31BF#;
OpenGL_Core_Profile : constant Int := 16#0000_0001#;
type Flag_Bits is record
Debug : Boolean := False;
Forward : Boolean := True;
Robust : Boolean := False;
end record;
for Flag_Bits use record
Debug at 0 range 0 .. 0;
Forward at 0 range 1 .. 1;
Robust at 0 range 2 .. 2;
end record;
for Flag_Bits'Size use Int'Size;
function Create_Context
(Display : Displays.Display;
Version : Context_Version;
Flags : Context_Flags) return Context
is
No_Config : constant ID_Type := ID_Type (System.Null_Address);
No_Context : constant ID_Type := ID_Type (System.Null_Address);
function Convert is new Ada.Unchecked_Conversion (Flag_Bits, Int);
Flags_Mask : constant Flag_Bits :=
(Debug => Flags.Debug,
Forward => True,
Robust => Flags.Robust);
Attributes : constant Int_Array :=
(Major_Version, Int (Version.Major),
Minor_Version, Int (Version.Minor),
Context_Flags_Bits, Convert (Flags_Mask),
OpenGL_Profile_Mask, OpenGL_Core_Profile,
-- EGL 1.5
-- OpenGL_Debug, (if Flags.Debug then 1 else 0),
-- OpenGL_Forward_Compatible, 1,
-- OpenGL_Robust, (if Flags.Robust then 1 else 0),
OpenGL_Reset_Notification_Strategy,
(if Flags.Robust then Lose_Context_On_Reset else No_Reset_Notification));
-- Requires EGL_KHR_create_context or EGL 1.5
No_Error : constant Int_Array := (OpenGL_No_Error, 1);
No_Flush : constant Int_Array := (Context_Release_Behavior, Context_Release_Behavior_None);
Extensions : constant String_List := Display.Extensions;
begin
if not Boolean (API.Bind_API (OpenGL_API)) then
Errors.Raise_Exception_On_EGL_Error;
end if;
Check_Extension (Extensions, "EGL_KHR_create_context");
Check_Extension (Extensions, "EGL_KHR_no_config_context");
Check_Extension (Extensions, "EGL_KHR_surfaceless_context");
declare
Can_Have_No_Error : constant Boolean :=
Flags.No_Error and then Has_Extension (Extensions, "EGL_KHR_create_context_no_error");
Can_Have_Release_Context : constant Boolean :=
Has_Extension (Extensions, "EGL_KHR_context_flush_control");
ID : constant ID_Type :=
API.Create_Context (Display.ID, No_Config, No_Context,
Attributes &
(if Can_Have_No_Error then No_Error else (1 .. 0 => <>)) &
(if Can_Have_Release_Context then No_Flush else (1 .. 0 => <>)) &
None);
-- TODO Support shared context (replace No_Context with Shared_Context.ID)
begin
if ID = No_Context then
Errors.Raise_Exception_On_EGL_Error;
end if;
return Result : Context (Display.Platform) do
Result.Reference.ID := ID;
Result.Display := Display;
end return;
end;
end Create_Context;
function Buffer (Object : Context) return Buffer_Kind is
Result : Buffer_Kind;
begin
if not Boolean (API.Query_Context (Object.Display.ID, Object.ID, Render_Buffer, Result)) then
Errors.Raise_Exception_On_EGL_Error;
end if;
return Result;
end Buffer;
function Is_Current (Object : Context; Kind : Task_Kind) return Boolean is
begin
case Kind is
when Current_Task =>
return API.Get_Current_Context = Object.ID;
when Any_Task =>
return Object.Reference.Active;
end case;
end Is_Current;
procedure Make_Current (Object : Context) is
No_Surface : constant ID_Type := ID_Type (System.Null_Address);
begin
if not API.Make_Current (Object.Display.ID, No_Surface, No_Surface, Object.ID) then
Errors.Raise_Exception_On_EGL_Error;
end if;
Object.Reference.Active := True;
end Make_Current;
procedure Make_Current (Object : Context; Surface : Surfaces.Surface) is
begin
if not API.Make_Current (Object.Display.ID, Surface.ID, Surface.ID, Object.ID) then
Errors.Raise_Exception_On_EGL_Error;
end if;
Object.Reference.Active := True;
end Make_Current;
procedure Make_Not_Current (Object : Context) is
No_Context : constant ID_Type := ID_Type (System.Null_Address);
No_Surface : constant ID_Type := ID_Type (System.Null_Address);
begin
if not API.Make_Current (Object.Display.ID, No_Surface, No_Surface, No_Context) then
Errors.Raise_Exception_On_EGL_Error;
end if;
Object.Reference.Active := False;
end Make_Not_Current;
procedure Set_Swap_Interval (Object : Context; Value : Natural) is
begin
if not Boolean (API.Swap_Interval (Object.Display.ID, Int (Value))) then
Errors.Raise_Exception_On_EGL_Error;
end if;
end Set_Swap_Interval;
overriding procedure Pre_Finalize (Object : in out Context) is
No_Context : constant ID_Type := ID_Type (System.Null_Address);
begin
pragma Assert (Object.ID /= No_Context);
if Object.Is_Current (Current_Task) then
Object.Make_Not_Current;
end if;
if not Boolean (API.Destroy_Context (Object.Display.ID, Object.ID)) then
Errors.Raise_Exception_On_EGL_Error;
end if;
Object.Reference.ID := No_Context;
end Pre_Finalize;
end EGL.Objects.Contexts;
| 19345 | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 onox <<EMAIL>>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Unchecked_Conversion;
with EGL.API;
with EGL.Errors;
package body EGL.Objects.Contexts is
Major_Version : constant Int := 16#3098#;
Minor_Version : constant Int := 16#30FB#;
Context_Flags_Bits : constant Int := 16#30FC#;
OpenGL_Profile_Mask : constant Int := 16#30FD#;
-- EGL 1.5
-- OpenGL_Debug : constant Int := 16#31B0#;
-- OpenGL_Forward_Compatible : constant Int := 16#31B1#;
-- OpenGL_Robust : constant Int := 16#31B2#;
OpenGL_No_Error : constant Int := 16#31B3#;
OpenGL_Reset_Notification_Strategy : constant Int := 16#31BD#;
Context_Release_Behavior : constant Int := 16#2097#;
Context_Release_Behavior_None : constant Int := 0;
-- Context_Release_Behavior_Flush : constant Int := 16#2098#;
No_Reset_Notification : constant Int := 16#31BE#;
Lose_Context_On_Reset : constant Int := 16#31BF#;
OpenGL_Core_Profile : constant Int := 16#0000_0001#;
type Flag_Bits is record
Debug : Boolean := False;
Forward : Boolean := True;
Robust : Boolean := False;
end record;
for Flag_Bits use record
Debug at 0 range 0 .. 0;
Forward at 0 range 1 .. 1;
Robust at 0 range 2 .. 2;
end record;
for Flag_Bits'Size use Int'Size;
function Create_Context
(Display : Displays.Display;
Version : Context_Version;
Flags : Context_Flags) return Context
is
No_Config : constant ID_Type := ID_Type (System.Null_Address);
No_Context : constant ID_Type := ID_Type (System.Null_Address);
function Convert is new Ada.Unchecked_Conversion (Flag_Bits, Int);
Flags_Mask : constant Flag_Bits :=
(Debug => Flags.Debug,
Forward => True,
Robust => Flags.Robust);
Attributes : constant Int_Array :=
(Major_Version, Int (Version.Major),
Minor_Version, Int (Version.Minor),
Context_Flags_Bits, Convert (Flags_Mask),
OpenGL_Profile_Mask, OpenGL_Core_Profile,
-- EGL 1.5
-- OpenGL_Debug, (if Flags.Debug then 1 else 0),
-- OpenGL_Forward_Compatible, 1,
-- OpenGL_Robust, (if Flags.Robust then 1 else 0),
OpenGL_Reset_Notification_Strategy,
(if Flags.Robust then Lose_Context_On_Reset else No_Reset_Notification));
-- Requires EGL_KHR_create_context or EGL 1.5
No_Error : constant Int_Array := (OpenGL_No_Error, 1);
No_Flush : constant Int_Array := (Context_Release_Behavior, Context_Release_Behavior_None);
Extensions : constant String_List := Display.Extensions;
begin
if not Boolean (API.Bind_API (OpenGL_API)) then
Errors.Raise_Exception_On_EGL_Error;
end if;
Check_Extension (Extensions, "EGL_KHR_create_context");
Check_Extension (Extensions, "EGL_KHR_no_config_context");
Check_Extension (Extensions, "EGL_KHR_surfaceless_context");
declare
Can_Have_No_Error : constant Boolean :=
Flags.No_Error and then Has_Extension (Extensions, "EGL_KHR_create_context_no_error");
Can_Have_Release_Context : constant Boolean :=
Has_Extension (Extensions, "EGL_KHR_context_flush_control");
ID : constant ID_Type :=
API.Create_Context (Display.ID, No_Config, No_Context,
Attributes &
(if Can_Have_No_Error then No_Error else (1 .. 0 => <>)) &
(if Can_Have_Release_Context then No_Flush else (1 .. 0 => <>)) &
None);
-- TODO Support shared context (replace No_Context with Shared_Context.ID)
begin
if ID = No_Context then
Errors.Raise_Exception_On_EGL_Error;
end if;
return Result : Context (Display.Platform) do
Result.Reference.ID := ID;
Result.Display := Display;
end return;
end;
end Create_Context;
function Buffer (Object : Context) return Buffer_Kind is
Result : Buffer_Kind;
begin
if not Boolean (API.Query_Context (Object.Display.ID, Object.ID, Render_Buffer, Result)) then
Errors.Raise_Exception_On_EGL_Error;
end if;
return Result;
end Buffer;
function Is_Current (Object : Context; Kind : Task_Kind) return Boolean is
begin
case Kind is
when Current_Task =>
return API.Get_Current_Context = Object.ID;
when Any_Task =>
return Object.Reference.Active;
end case;
end Is_Current;
procedure Make_Current (Object : Context) is
No_Surface : constant ID_Type := ID_Type (System.Null_Address);
begin
if not API.Make_Current (Object.Display.ID, No_Surface, No_Surface, Object.ID) then
Errors.Raise_Exception_On_EGL_Error;
end if;
Object.Reference.Active := True;
end Make_Current;
procedure Make_Current (Object : Context; Surface : Surfaces.Surface) is
begin
if not API.Make_Current (Object.Display.ID, Surface.ID, Surface.ID, Object.ID) then
Errors.Raise_Exception_On_EGL_Error;
end if;
Object.Reference.Active := True;
end Make_Current;
procedure Make_Not_Current (Object : Context) is
No_Context : constant ID_Type := ID_Type (System.Null_Address);
No_Surface : constant ID_Type := ID_Type (System.Null_Address);
begin
if not API.Make_Current (Object.Display.ID, No_Surface, No_Surface, No_Context) then
Errors.Raise_Exception_On_EGL_Error;
end if;
Object.Reference.Active := False;
end Make_Not_Current;
procedure Set_Swap_Interval (Object : Context; Value : Natural) is
begin
if not Boolean (API.Swap_Interval (Object.Display.ID, Int (Value))) then
Errors.Raise_Exception_On_EGL_Error;
end if;
end Set_Swap_Interval;
overriding procedure Pre_Finalize (Object : in out Context) is
No_Context : constant ID_Type := ID_Type (System.Null_Address);
begin
pragma Assert (Object.ID /= No_Context);
if Object.Is_Current (Current_Task) then
Object.Make_Not_Current;
end if;
if not Boolean (API.Destroy_Context (Object.Display.ID, Object.ID)) then
Errors.Raise_Exception_On_EGL_Error;
end if;
Object.Reference.ID := No_Context;
end Pre_Finalize;
end EGL.Objects.Contexts;
| true | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 onox <PI:EMAIL:<EMAIL>END_PI>
--
-- 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 EGL.API;
with EGL.Errors;
package body EGL.Objects.Contexts is
Major_Version : constant Int := 16#3098#;
Minor_Version : constant Int := 16#30FB#;
Context_Flags_Bits : constant Int := 16#30FC#;
OpenGL_Profile_Mask : constant Int := 16#30FD#;
-- EGL 1.5
-- OpenGL_Debug : constant Int := 16#31B0#;
-- OpenGL_Forward_Compatible : constant Int := 16#31B1#;
-- OpenGL_Robust : constant Int := 16#31B2#;
OpenGL_No_Error : constant Int := 16#31B3#;
OpenGL_Reset_Notification_Strategy : constant Int := 16#31BD#;
Context_Release_Behavior : constant Int := 16#2097#;
Context_Release_Behavior_None : constant Int := 0;
-- Context_Release_Behavior_Flush : constant Int := 16#2098#;
No_Reset_Notification : constant Int := 16#31BE#;
Lose_Context_On_Reset : constant Int := 16#31BF#;
OpenGL_Core_Profile : constant Int := 16#0000_0001#;
type Flag_Bits is record
Debug : Boolean := False;
Forward : Boolean := True;
Robust : Boolean := False;
end record;
for Flag_Bits use record
Debug at 0 range 0 .. 0;
Forward at 0 range 1 .. 1;
Robust at 0 range 2 .. 2;
end record;
for Flag_Bits'Size use Int'Size;
function Create_Context
(Display : Displays.Display;
Version : Context_Version;
Flags : Context_Flags) return Context
is
No_Config : constant ID_Type := ID_Type (System.Null_Address);
No_Context : constant ID_Type := ID_Type (System.Null_Address);
function Convert is new Ada.Unchecked_Conversion (Flag_Bits, Int);
Flags_Mask : constant Flag_Bits :=
(Debug => Flags.Debug,
Forward => True,
Robust => Flags.Robust);
Attributes : constant Int_Array :=
(Major_Version, Int (Version.Major),
Minor_Version, Int (Version.Minor),
Context_Flags_Bits, Convert (Flags_Mask),
OpenGL_Profile_Mask, OpenGL_Core_Profile,
-- EGL 1.5
-- OpenGL_Debug, (if Flags.Debug then 1 else 0),
-- OpenGL_Forward_Compatible, 1,
-- OpenGL_Robust, (if Flags.Robust then 1 else 0),
OpenGL_Reset_Notification_Strategy,
(if Flags.Robust then Lose_Context_On_Reset else No_Reset_Notification));
-- Requires EGL_KHR_create_context or EGL 1.5
No_Error : constant Int_Array := (OpenGL_No_Error, 1);
No_Flush : constant Int_Array := (Context_Release_Behavior, Context_Release_Behavior_None);
Extensions : constant String_List := Display.Extensions;
begin
if not Boolean (API.Bind_API (OpenGL_API)) then
Errors.Raise_Exception_On_EGL_Error;
end if;
Check_Extension (Extensions, "EGL_KHR_create_context");
Check_Extension (Extensions, "EGL_KHR_no_config_context");
Check_Extension (Extensions, "EGL_KHR_surfaceless_context");
declare
Can_Have_No_Error : constant Boolean :=
Flags.No_Error and then Has_Extension (Extensions, "EGL_KHR_create_context_no_error");
Can_Have_Release_Context : constant Boolean :=
Has_Extension (Extensions, "EGL_KHR_context_flush_control");
ID : constant ID_Type :=
API.Create_Context (Display.ID, No_Config, No_Context,
Attributes &
(if Can_Have_No_Error then No_Error else (1 .. 0 => <>)) &
(if Can_Have_Release_Context then No_Flush else (1 .. 0 => <>)) &
None);
-- TODO Support shared context (replace No_Context with Shared_Context.ID)
begin
if ID = No_Context then
Errors.Raise_Exception_On_EGL_Error;
end if;
return Result : Context (Display.Platform) do
Result.Reference.ID := ID;
Result.Display := Display;
end return;
end;
end Create_Context;
function Buffer (Object : Context) return Buffer_Kind is
Result : Buffer_Kind;
begin
if not Boolean (API.Query_Context (Object.Display.ID, Object.ID, Render_Buffer, Result)) then
Errors.Raise_Exception_On_EGL_Error;
end if;
return Result;
end Buffer;
function Is_Current (Object : Context; Kind : Task_Kind) return Boolean is
begin
case Kind is
when Current_Task =>
return API.Get_Current_Context = Object.ID;
when Any_Task =>
return Object.Reference.Active;
end case;
end Is_Current;
procedure Make_Current (Object : Context) is
No_Surface : constant ID_Type := ID_Type (System.Null_Address);
begin
if not API.Make_Current (Object.Display.ID, No_Surface, No_Surface, Object.ID) then
Errors.Raise_Exception_On_EGL_Error;
end if;
Object.Reference.Active := True;
end Make_Current;
procedure Make_Current (Object : Context; Surface : Surfaces.Surface) is
begin
if not API.Make_Current (Object.Display.ID, Surface.ID, Surface.ID, Object.ID) then
Errors.Raise_Exception_On_EGL_Error;
end if;
Object.Reference.Active := True;
end Make_Current;
procedure Make_Not_Current (Object : Context) is
No_Context : constant ID_Type := ID_Type (System.Null_Address);
No_Surface : constant ID_Type := ID_Type (System.Null_Address);
begin
if not API.Make_Current (Object.Display.ID, No_Surface, No_Surface, No_Context) then
Errors.Raise_Exception_On_EGL_Error;
end if;
Object.Reference.Active := False;
end Make_Not_Current;
procedure Set_Swap_Interval (Object : Context; Value : Natural) is
begin
if not Boolean (API.Swap_Interval (Object.Display.ID, Int (Value))) then
Errors.Raise_Exception_On_EGL_Error;
end if;
end Set_Swap_Interval;
overriding procedure Pre_Finalize (Object : in out Context) is
No_Context : constant ID_Type := ID_Type (System.Null_Address);
begin
pragma Assert (Object.ID /= No_Context);
if Object.Is_Current (Current_Task) then
Object.Make_Not_Current;
end if;
if not Boolean (API.Destroy_Context (Object.Display.ID, Object.ID)) then
Errors.Raise_Exception_On_EGL_Error;
end if;
Object.Reference.ID := No_Context;
end Pre_Finalize;
end EGL.Objects.Contexts;
|
[
{
"context": "-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>\n-- MIT license. Please refer t",
"end": 36,
"score": 0.9998743534088135,
"start": 22,
"tag": "NAME",
"value": "Thierry Rascle"
},
{
"context": "-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>\n-- MIT license. Please refer to the LICENSE file",
"end": 54,
"score": 0.9999327659606934,
"start": 38,
"tag": "EMAIL",
"value": "thierr26@free.fr"
}
] | src/apsepp-test_node_class-case_stub.ads | thierr26/ada-apsepp | 0 | -- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
with Apsepp.Test_Node_Class.Generic_Case_And_Suite_Run_Body;
package Apsepp.Test_Node_Class.Case_Stub is
type Test_Case_Stub is limited new Test_Node_Interfa with private
with Type_Invariant'Class =>
Test_Case_Stub.Invariant_Class_Test_Case_Stub;
not overriding
function Invariant_Class_Test_Case_Stub
(Obj : Test_Case_Stub) return Boolean
is (Test_Case_Stub'Class (Obj).Child_Count = 0
and then
Test_Case_Stub'Class (Obj).No_Subtasking);
overriding
function Routine_Count (Obj : Test_Case_Stub) return Test_Routine_Count
is (0);
overriding
function Routine (Obj : Test_Case_Stub;
K : Test_Routine_Index) return Test_Routine;
overriding
procedure Run (Obj : in out Test_Case_Stub;
Outcome : out Test_Outcome;
Kind : Run_Kind := Assert_Cond_And_Run_Test);
overriding
function Child_Count (Obj : Test_Case_Stub) return Test_Node_Count
is (0);
overriding
function Child (Obj : Test_Case_Stub;
K : Test_Node_Index) return Test_Node_Access;
overriding
function No_Subtasking (Obj : Test_Case_Stub) return Boolean
is (True);
procedure Run_Body
is new Generic_Case_And_Suite_Run_Body (Work => Run_Test_Routines);
overriding
function Has_Early_Test (Obj : Test_Case_Stub) return Boolean
is (False);
overriding
function Early_Run_Done (Obj : Test_Case_Stub) return Boolean
is (True);
overriding
procedure Early_Run (Obj : in out Test_Case_Stub) is null;
private
type Test_Case_Stub is limited new Test_Node_Interfa with null record;
end Apsepp.Test_Node_Class.Case_Stub;
| 30830 | -- Copyright (C) 2019 <NAME> <<EMAIL>>
-- MIT license. Please refer to the LICENSE file.
with Apsepp.Test_Node_Class.Generic_Case_And_Suite_Run_Body;
package Apsepp.Test_Node_Class.Case_Stub is
type Test_Case_Stub is limited new Test_Node_Interfa with private
with Type_Invariant'Class =>
Test_Case_Stub.Invariant_Class_Test_Case_Stub;
not overriding
function Invariant_Class_Test_Case_Stub
(Obj : Test_Case_Stub) return Boolean
is (Test_Case_Stub'Class (Obj).Child_Count = 0
and then
Test_Case_Stub'Class (Obj).No_Subtasking);
overriding
function Routine_Count (Obj : Test_Case_Stub) return Test_Routine_Count
is (0);
overriding
function Routine (Obj : Test_Case_Stub;
K : Test_Routine_Index) return Test_Routine;
overriding
procedure Run (Obj : in out Test_Case_Stub;
Outcome : out Test_Outcome;
Kind : Run_Kind := Assert_Cond_And_Run_Test);
overriding
function Child_Count (Obj : Test_Case_Stub) return Test_Node_Count
is (0);
overriding
function Child (Obj : Test_Case_Stub;
K : Test_Node_Index) return Test_Node_Access;
overriding
function No_Subtasking (Obj : Test_Case_Stub) return Boolean
is (True);
procedure Run_Body
is new Generic_Case_And_Suite_Run_Body (Work => Run_Test_Routines);
overriding
function Has_Early_Test (Obj : Test_Case_Stub) return Boolean
is (False);
overriding
function Early_Run_Done (Obj : Test_Case_Stub) return Boolean
is (True);
overriding
procedure Early_Run (Obj : in out Test_Case_Stub) is null;
private
type Test_Case_Stub is limited new Test_Node_Interfa with null record;
end Apsepp.Test_Node_Class.Case_Stub;
| true | -- Copyright (C) 2019 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
-- MIT license. Please refer to the LICENSE file.
with Apsepp.Test_Node_Class.Generic_Case_And_Suite_Run_Body;
package Apsepp.Test_Node_Class.Case_Stub is
type Test_Case_Stub is limited new Test_Node_Interfa with private
with Type_Invariant'Class =>
Test_Case_Stub.Invariant_Class_Test_Case_Stub;
not overriding
function Invariant_Class_Test_Case_Stub
(Obj : Test_Case_Stub) return Boolean
is (Test_Case_Stub'Class (Obj).Child_Count = 0
and then
Test_Case_Stub'Class (Obj).No_Subtasking);
overriding
function Routine_Count (Obj : Test_Case_Stub) return Test_Routine_Count
is (0);
overriding
function Routine (Obj : Test_Case_Stub;
K : Test_Routine_Index) return Test_Routine;
overriding
procedure Run (Obj : in out Test_Case_Stub;
Outcome : out Test_Outcome;
Kind : Run_Kind := Assert_Cond_And_Run_Test);
overriding
function Child_Count (Obj : Test_Case_Stub) return Test_Node_Count
is (0);
overriding
function Child (Obj : Test_Case_Stub;
K : Test_Node_Index) return Test_Node_Access;
overriding
function No_Subtasking (Obj : Test_Case_Stub) return Boolean
is (True);
procedure Run_Body
is new Generic_Case_And_Suite_Run_Body (Work => Run_Test_Routines);
overriding
function Has_Early_Test (Obj : Test_Case_Stub) return Boolean
is (False);
overriding
function Early_Run_Done (Obj : Test_Case_Stub) return Boolean
is (True);
overriding
procedure Early_Run (Obj : in out Test_Case_Stub) is null;
private
type Test_Case_Stub is limited new Test_Node_Interfa with null record;
end Apsepp.Test_Node_Class.Case_Stub;
|
[
{
"context": " --\n-- Copyright © 2010-2012, Vadim Godunko <vgodunko@gmail.com> --\n-- All rig",
"end": 829,
"score": 0.9998857975006104,
"start": 816,
"tag": "NAME",
"value": "Vadim Godunko"
},
{
"context": " --\n-- Copyright © 2010-2012, Vadim Godunko <vgodunko@gmail.com> --\n-- All rights reserved. ",
"end": 849,
"score": 0.9999328851699829,
"start": 831,
"tag": "EMAIL",
"value": "vgodunko@gmail.com"
}
] | source/amf/dd/amf-internals-tables-dg_metamodel.ads | svn2github/matreshka | 24 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2012, 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 file is generated, don't edit it.
------------------------------------------------------------------------------
package AMF.Internals.Tables.DG_Metamodel is
pragma Preelaborate;
function MM_DG_DG return AMF.Internals.CMOF_Element;
function MC_DG_Close_Path return AMF.Internals.CMOF_Element;
function MC_DG_Cubic_Curve_To return AMF.Internals.CMOF_Element;
function MC_DG_Elliptical_Arc_To return AMF.Internals.CMOF_Element;
function MC_DG_Gradient_Stop return AMF.Internals.CMOF_Element;
function MC_DG_Line_To return AMF.Internals.CMOF_Element;
function MC_DG_Matrix return AMF.Internals.CMOF_Element;
function MC_DG_Move_To return AMF.Internals.CMOF_Element;
function MC_DG_Path_Command return AMF.Internals.CMOF_Element;
function MC_DG_Quadratic_Curve_To return AMF.Internals.CMOF_Element;
function MC_DG_Rotate return AMF.Internals.CMOF_Element;
function MC_DG_Scale return AMF.Internals.CMOF_Element;
function MC_DG_Skew return AMF.Internals.CMOF_Element;
function MC_DG_Transform return AMF.Internals.CMOF_Element;
function MC_DG_Translate return AMF.Internals.CMOF_Element;
function MP_DG_Cubic_Curve_To_End_Control return AMF.Internals.CMOF_Element;
function MP_DG_Cubic_Curve_To_Point return AMF.Internals.CMOF_Element;
function MP_DG_Cubic_Curve_To_Start_Control return AMF.Internals.CMOF_Element;
function MP_DG_Elliptical_Arc_To_Is_Large_Arc return AMF.Internals.CMOF_Element;
function MP_DG_Elliptical_Arc_To_Is_Sweep return AMF.Internals.CMOF_Element;
function MP_DG_Elliptical_Arc_To_Point return AMF.Internals.CMOF_Element;
function MP_DG_Elliptical_Arc_To_Radii return AMF.Internals.CMOF_Element;
function MP_DG_Elliptical_Arc_To_Rotation return AMF.Internals.CMOF_Element;
function MP_DG_Gradient_Stop_Color return AMF.Internals.CMOF_Element;
function MP_DG_Gradient_Stop_Offset return AMF.Internals.CMOF_Element;
function MP_DG_Gradient_Stop_Opacity return AMF.Internals.CMOF_Element;
function MP_DG_Line_To_Point return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_A return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_B return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_C return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_D return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_E return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_F return AMF.Internals.CMOF_Element;
function MP_DG_Move_To_Point return AMF.Internals.CMOF_Element;
function MP_DG_Path_Command_Is_Relative return AMF.Internals.CMOF_Element;
function MP_DG_Quadratic_Curve_To_Control return AMF.Internals.CMOF_Element;
function MP_DG_Quadratic_Curve_To_Point return AMF.Internals.CMOF_Element;
function MP_DG_Rotate_Angle return AMF.Internals.CMOF_Element;
function MP_DG_Rotate_Center return AMF.Internals.CMOF_Element;
function MP_DG_Scale_Factor_X return AMF.Internals.CMOF_Element;
function MP_DG_Scale_Factor_Y return AMF.Internals.CMOF_Element;
function MP_DG_Skew_Angle_X return AMF.Internals.CMOF_Element;
function MP_DG_Skew_Angle_Y return AMF.Internals.CMOF_Element;
function MP_DG_Translate_Delta_X return AMF.Internals.CMOF_Element;
function MP_DG_Translate_Delta_Y return AMF.Internals.CMOF_Element;
function MC_DG_Canvas return AMF.Internals.CMOF_Element;
function MC_DG_Circle return AMF.Internals.CMOF_Element;
function MC_DG_Clip_Path return AMF.Internals.CMOF_Element;
function MC_DG_Ellipse return AMF.Internals.CMOF_Element;
function MC_DG_Fill return AMF.Internals.CMOF_Element;
function MC_DG_Gradient return AMF.Internals.CMOF_Element;
function MC_DG_Graphical_Element return AMF.Internals.CMOF_Element;
function MC_DG_Group return AMF.Internals.CMOF_Element;
function MC_DG_Image return AMF.Internals.CMOF_Element;
function MC_DG_Line return AMF.Internals.CMOF_Element;
function MC_DG_Linear_Gradient return AMF.Internals.CMOF_Element;
function MC_DG_Marked_Element return AMF.Internals.CMOF_Element;
function MC_DG_Marker return AMF.Internals.CMOF_Element;
function MC_DG_Path return AMF.Internals.CMOF_Element;
function MC_DG_Pattern return AMF.Internals.CMOF_Element;
function MC_DG_Polygon return AMF.Internals.CMOF_Element;
function MC_DG_Polyline return AMF.Internals.CMOF_Element;
function MC_DG_Radial_Gradient return AMF.Internals.CMOF_Element;
function MC_DG_Rectangle return AMF.Internals.CMOF_Element;
function MC_DG_Style return AMF.Internals.CMOF_Element;
function MC_DG_Text return AMF.Internals.CMOF_Element;
function MP_DG_Canvas_Background_Color return AMF.Internals.CMOF_Element;
function MP_DG_Canvas_Background_Fill_A_Canvas return AMF.Internals.CMOF_Element;
function MP_DG_Canvas_Packaged_Fill_Fill_Canvas return AMF.Internals.CMOF_Element;
function MP_DG_Canvas_Packaged_Marker_Marker_Canvas return AMF.Internals.CMOF_Element;
function MP_DG_Canvas_Packaged_Style_A_Canvas return AMF.Internals.CMOF_Element;
function MP_DG_Circle_Center return AMF.Internals.CMOF_Element;
function MP_DG_Circle_Radius return AMF.Internals.CMOF_Element;
function MP_DG_Clip_Path_Clipped_Element_Graphical_Element_Clip_Path return AMF.Internals.CMOF_Element;
function MP_DG_Ellipse_Center return AMF.Internals.CMOF_Element;
function MP_DG_Ellipse_Radii return AMF.Internals.CMOF_Element;
function MP_DG_Fill_Canvas_Canvas_Packaged_Fill return AMF.Internals.CMOF_Element;
function MP_DG_Fill_Transform return AMF.Internals.CMOF_Element;
function MP_DG_Gradient_Stop return AMF.Internals.CMOF_Element;
function MP_DG_Graphical_Element_Clip_Path_Clip_Path_Clipped_Element return AMF.Internals.CMOF_Element;
function MP_DG_Graphical_Element_Group_Group_Member return AMF.Internals.CMOF_Element;
function MP_DG_Graphical_Element_Local_Style_A_Styled_Element return AMF.Internals.CMOF_Element;
function MP_DG_Graphical_Element_Shared_Style_A_Styled_Element return AMF.Internals.CMOF_Element;
function MP_DG_Graphical_Element_Transform return AMF.Internals.CMOF_Element;
function MP_DG_Group_Member_Graphical_Element_Group return AMF.Internals.CMOF_Element;
function MP_DG_Image_Bounds return AMF.Internals.CMOF_Element;
function MP_DG_Image_Is_Aspect_Ratio_Preserved return AMF.Internals.CMOF_Element;
function MP_DG_Image_Source return AMF.Internals.CMOF_Element;
function MP_DG_Line_End return AMF.Internals.CMOF_Element;
function MP_DG_Line_Start return AMF.Internals.CMOF_Element;
function MP_DG_Linear_Gradient_X1 return AMF.Internals.CMOF_Element;
function MP_DG_Linear_Gradient_X2 return AMF.Internals.CMOF_Element;
function MP_DG_Linear_Gradient_Y1 return AMF.Internals.CMOF_Element;
function MP_DG_Linear_Gradient_Y2 return AMF.Internals.CMOF_Element;
function MP_DG_Marked_Element_End_Marker_A_Marked_Element return AMF.Internals.CMOF_Element;
function MP_DG_Marked_Element_Mid_Marker_A_Marked_Element return AMF.Internals.CMOF_Element;
function MP_DG_Marked_Element_Start_Marker_A_Marked_Element return AMF.Internals.CMOF_Element;
function MP_DG_Marker_Canvas_Canvas_Packaged_Marker return AMF.Internals.CMOF_Element;
function MP_DG_Marker_Reference return AMF.Internals.CMOF_Element;
function MP_DG_Marker_Size return AMF.Internals.CMOF_Element;
function MP_DG_Path_Command return AMF.Internals.CMOF_Element;
function MP_DG_Pattern_Bounds return AMF.Internals.CMOF_Element;
function MP_DG_Pattern_Tile_A_Pattern return AMF.Internals.CMOF_Element;
function MP_DG_Polygon_Point return AMF.Internals.CMOF_Element;
function MP_DG_Polyline_Point return AMF.Internals.CMOF_Element;
function MP_DG_Radial_Gradient_Center_X return AMF.Internals.CMOF_Element;
function MP_DG_Radial_Gradient_Center_Y return AMF.Internals.CMOF_Element;
function MP_DG_Radial_Gradient_Focus_X return AMF.Internals.CMOF_Element;
function MP_DG_Radial_Gradient_Focus_Y return AMF.Internals.CMOF_Element;
function MP_DG_Radial_Gradient_Radius return AMF.Internals.CMOF_Element;
function MP_DG_Rectangle_Bounds return AMF.Internals.CMOF_Element;
function MP_DG_Rectangle_Corner_Radius return AMF.Internals.CMOF_Element;
function MP_DG_Style_Fill_A_Style return AMF.Internals.CMOF_Element;
function MP_DG_Style_Fill_Color return AMF.Internals.CMOF_Element;
function MP_DG_Style_Fill_Opacity return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Bold return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Color return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Italic return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Name return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Size return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Strike_Through return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Underline return AMF.Internals.CMOF_Element;
function MP_DG_Style_Stroke_Color return AMF.Internals.CMOF_Element;
function MP_DG_Style_Stroke_Dash_Length return AMF.Internals.CMOF_Element;
function MP_DG_Style_Stroke_Opacity return AMF.Internals.CMOF_Element;
function MP_DG_Style_Stroke_Width return AMF.Internals.CMOF_Element;
function MP_DG_Text_Alignment return AMF.Internals.CMOF_Element;
function MP_DG_Text_Bounds return AMF.Internals.CMOF_Element;
function MP_DG_Text_Data return AMF.Internals.CMOF_Element;
function MP_DG_A_Pattern_Pattern_Tile return AMF.Internals.CMOF_Element;
function MP_DG_A_Canvas_Canvas_Packaged_Style return AMF.Internals.CMOF_Element;
function MP_DG_A_Marked_Element_Marked_Element_Start_Marker return AMF.Internals.CMOF_Element;
function MP_DG_A_Marked_Element_Marked_Element_End_Marker return AMF.Internals.CMOF_Element;
function MP_DG_A_Marked_Element_Marked_Element_Mid_Marker return AMF.Internals.CMOF_Element;
function MP_DG_A_Styled_Element_Graphical_Element_Local_Style return AMF.Internals.CMOF_Element;
function MP_DG_A_Style_Style_Fill return AMF.Internals.CMOF_Element;
function MP_DG_A_Styled_Element_Graphical_Element_Shared_Style return AMF.Internals.CMOF_Element;
function MP_DG_A_Canvas_Canvas_Background_Fill return AMF.Internals.CMOF_Element;
function MA_DG_Pattern_Tile_Pattern return AMF.Internals.CMOF_Element;
function MA_DG_Canvas_Packaged_Style_Canvas return AMF.Internals.CMOF_Element;
function MA_DG_Marked_Element_Start_Marker_Marked_Element return AMF.Internals.CMOF_Element;
function MA_DG_Marked_Element_End_Marker_Marked_Element return AMF.Internals.CMOF_Element;
function MA_DG_Group_Member_Group return AMF.Internals.CMOF_Element;
function MA_DG_Marked_Element_Mid_Marker_Marked_Element return AMF.Internals.CMOF_Element;
function MA_DG_Canvas_Packaged_Marker_Canvas return AMF.Internals.CMOF_Element;
function MA_DG_Graphical_Element_Clip_Path_Clipped_Element return AMF.Internals.CMOF_Element;
function MA_DG_Graphical_Element_Local_Style_Styled_Element return AMF.Internals.CMOF_Element;
function MA_DG_Canvas_Packaged_Fill_Canvas return AMF.Internals.CMOF_Element;
function MA_DG_Style_Fill_Style return AMF.Internals.CMOF_Element;
function MA_DG_Graphical_Element_Shared_Style_Styled_Element return AMF.Internals.CMOF_Element;
function MA_DG_Canvas_Background_Fill_Canvas return AMF.Internals.CMOF_Element;
function MB_DG return AMF.Internals.AMF_Element;
function ML_DG return AMF.Internals.AMF_Element;
private
Base : AMF.Internals.CMOF_Element := 0;
end AMF.Internals.Tables.DG_Metamodel;
| 148 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2012, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
package AMF.Internals.Tables.DG_Metamodel is
pragma Preelaborate;
function MM_DG_DG return AMF.Internals.CMOF_Element;
function MC_DG_Close_Path return AMF.Internals.CMOF_Element;
function MC_DG_Cubic_Curve_To return AMF.Internals.CMOF_Element;
function MC_DG_Elliptical_Arc_To return AMF.Internals.CMOF_Element;
function MC_DG_Gradient_Stop return AMF.Internals.CMOF_Element;
function MC_DG_Line_To return AMF.Internals.CMOF_Element;
function MC_DG_Matrix return AMF.Internals.CMOF_Element;
function MC_DG_Move_To return AMF.Internals.CMOF_Element;
function MC_DG_Path_Command return AMF.Internals.CMOF_Element;
function MC_DG_Quadratic_Curve_To return AMF.Internals.CMOF_Element;
function MC_DG_Rotate return AMF.Internals.CMOF_Element;
function MC_DG_Scale return AMF.Internals.CMOF_Element;
function MC_DG_Skew return AMF.Internals.CMOF_Element;
function MC_DG_Transform return AMF.Internals.CMOF_Element;
function MC_DG_Translate return AMF.Internals.CMOF_Element;
function MP_DG_Cubic_Curve_To_End_Control return AMF.Internals.CMOF_Element;
function MP_DG_Cubic_Curve_To_Point return AMF.Internals.CMOF_Element;
function MP_DG_Cubic_Curve_To_Start_Control return AMF.Internals.CMOF_Element;
function MP_DG_Elliptical_Arc_To_Is_Large_Arc return AMF.Internals.CMOF_Element;
function MP_DG_Elliptical_Arc_To_Is_Sweep return AMF.Internals.CMOF_Element;
function MP_DG_Elliptical_Arc_To_Point return AMF.Internals.CMOF_Element;
function MP_DG_Elliptical_Arc_To_Radii return AMF.Internals.CMOF_Element;
function MP_DG_Elliptical_Arc_To_Rotation return AMF.Internals.CMOF_Element;
function MP_DG_Gradient_Stop_Color return AMF.Internals.CMOF_Element;
function MP_DG_Gradient_Stop_Offset return AMF.Internals.CMOF_Element;
function MP_DG_Gradient_Stop_Opacity return AMF.Internals.CMOF_Element;
function MP_DG_Line_To_Point return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_A return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_B return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_C return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_D return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_E return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_F return AMF.Internals.CMOF_Element;
function MP_DG_Move_To_Point return AMF.Internals.CMOF_Element;
function MP_DG_Path_Command_Is_Relative return AMF.Internals.CMOF_Element;
function MP_DG_Quadratic_Curve_To_Control return AMF.Internals.CMOF_Element;
function MP_DG_Quadratic_Curve_To_Point return AMF.Internals.CMOF_Element;
function MP_DG_Rotate_Angle return AMF.Internals.CMOF_Element;
function MP_DG_Rotate_Center return AMF.Internals.CMOF_Element;
function MP_DG_Scale_Factor_X return AMF.Internals.CMOF_Element;
function MP_DG_Scale_Factor_Y return AMF.Internals.CMOF_Element;
function MP_DG_Skew_Angle_X return AMF.Internals.CMOF_Element;
function MP_DG_Skew_Angle_Y return AMF.Internals.CMOF_Element;
function MP_DG_Translate_Delta_X return AMF.Internals.CMOF_Element;
function MP_DG_Translate_Delta_Y return AMF.Internals.CMOF_Element;
function MC_DG_Canvas return AMF.Internals.CMOF_Element;
function MC_DG_Circle return AMF.Internals.CMOF_Element;
function MC_DG_Clip_Path return AMF.Internals.CMOF_Element;
function MC_DG_Ellipse return AMF.Internals.CMOF_Element;
function MC_DG_Fill return AMF.Internals.CMOF_Element;
function MC_DG_Gradient return AMF.Internals.CMOF_Element;
function MC_DG_Graphical_Element return AMF.Internals.CMOF_Element;
function MC_DG_Group return AMF.Internals.CMOF_Element;
function MC_DG_Image return AMF.Internals.CMOF_Element;
function MC_DG_Line return AMF.Internals.CMOF_Element;
function MC_DG_Linear_Gradient return AMF.Internals.CMOF_Element;
function MC_DG_Marked_Element return AMF.Internals.CMOF_Element;
function MC_DG_Marker return AMF.Internals.CMOF_Element;
function MC_DG_Path return AMF.Internals.CMOF_Element;
function MC_DG_Pattern return AMF.Internals.CMOF_Element;
function MC_DG_Polygon return AMF.Internals.CMOF_Element;
function MC_DG_Polyline return AMF.Internals.CMOF_Element;
function MC_DG_Radial_Gradient return AMF.Internals.CMOF_Element;
function MC_DG_Rectangle return AMF.Internals.CMOF_Element;
function MC_DG_Style return AMF.Internals.CMOF_Element;
function MC_DG_Text return AMF.Internals.CMOF_Element;
function MP_DG_Canvas_Background_Color return AMF.Internals.CMOF_Element;
function MP_DG_Canvas_Background_Fill_A_Canvas return AMF.Internals.CMOF_Element;
function MP_DG_Canvas_Packaged_Fill_Fill_Canvas return AMF.Internals.CMOF_Element;
function MP_DG_Canvas_Packaged_Marker_Marker_Canvas return AMF.Internals.CMOF_Element;
function MP_DG_Canvas_Packaged_Style_A_Canvas return AMF.Internals.CMOF_Element;
function MP_DG_Circle_Center return AMF.Internals.CMOF_Element;
function MP_DG_Circle_Radius return AMF.Internals.CMOF_Element;
function MP_DG_Clip_Path_Clipped_Element_Graphical_Element_Clip_Path return AMF.Internals.CMOF_Element;
function MP_DG_Ellipse_Center return AMF.Internals.CMOF_Element;
function MP_DG_Ellipse_Radii return AMF.Internals.CMOF_Element;
function MP_DG_Fill_Canvas_Canvas_Packaged_Fill return AMF.Internals.CMOF_Element;
function MP_DG_Fill_Transform return AMF.Internals.CMOF_Element;
function MP_DG_Gradient_Stop return AMF.Internals.CMOF_Element;
function MP_DG_Graphical_Element_Clip_Path_Clip_Path_Clipped_Element return AMF.Internals.CMOF_Element;
function MP_DG_Graphical_Element_Group_Group_Member return AMF.Internals.CMOF_Element;
function MP_DG_Graphical_Element_Local_Style_A_Styled_Element return AMF.Internals.CMOF_Element;
function MP_DG_Graphical_Element_Shared_Style_A_Styled_Element return AMF.Internals.CMOF_Element;
function MP_DG_Graphical_Element_Transform return AMF.Internals.CMOF_Element;
function MP_DG_Group_Member_Graphical_Element_Group return AMF.Internals.CMOF_Element;
function MP_DG_Image_Bounds return AMF.Internals.CMOF_Element;
function MP_DG_Image_Is_Aspect_Ratio_Preserved return AMF.Internals.CMOF_Element;
function MP_DG_Image_Source return AMF.Internals.CMOF_Element;
function MP_DG_Line_End return AMF.Internals.CMOF_Element;
function MP_DG_Line_Start return AMF.Internals.CMOF_Element;
function MP_DG_Linear_Gradient_X1 return AMF.Internals.CMOF_Element;
function MP_DG_Linear_Gradient_X2 return AMF.Internals.CMOF_Element;
function MP_DG_Linear_Gradient_Y1 return AMF.Internals.CMOF_Element;
function MP_DG_Linear_Gradient_Y2 return AMF.Internals.CMOF_Element;
function MP_DG_Marked_Element_End_Marker_A_Marked_Element return AMF.Internals.CMOF_Element;
function MP_DG_Marked_Element_Mid_Marker_A_Marked_Element return AMF.Internals.CMOF_Element;
function MP_DG_Marked_Element_Start_Marker_A_Marked_Element return AMF.Internals.CMOF_Element;
function MP_DG_Marker_Canvas_Canvas_Packaged_Marker return AMF.Internals.CMOF_Element;
function MP_DG_Marker_Reference return AMF.Internals.CMOF_Element;
function MP_DG_Marker_Size return AMF.Internals.CMOF_Element;
function MP_DG_Path_Command return AMF.Internals.CMOF_Element;
function MP_DG_Pattern_Bounds return AMF.Internals.CMOF_Element;
function MP_DG_Pattern_Tile_A_Pattern return AMF.Internals.CMOF_Element;
function MP_DG_Polygon_Point return AMF.Internals.CMOF_Element;
function MP_DG_Polyline_Point return AMF.Internals.CMOF_Element;
function MP_DG_Radial_Gradient_Center_X return AMF.Internals.CMOF_Element;
function MP_DG_Radial_Gradient_Center_Y return AMF.Internals.CMOF_Element;
function MP_DG_Radial_Gradient_Focus_X return AMF.Internals.CMOF_Element;
function MP_DG_Radial_Gradient_Focus_Y return AMF.Internals.CMOF_Element;
function MP_DG_Radial_Gradient_Radius return AMF.Internals.CMOF_Element;
function MP_DG_Rectangle_Bounds return AMF.Internals.CMOF_Element;
function MP_DG_Rectangle_Corner_Radius return AMF.Internals.CMOF_Element;
function MP_DG_Style_Fill_A_Style return AMF.Internals.CMOF_Element;
function MP_DG_Style_Fill_Color return AMF.Internals.CMOF_Element;
function MP_DG_Style_Fill_Opacity return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Bold return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Color return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Italic return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Name return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Size return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Strike_Through return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Underline return AMF.Internals.CMOF_Element;
function MP_DG_Style_Stroke_Color return AMF.Internals.CMOF_Element;
function MP_DG_Style_Stroke_Dash_Length return AMF.Internals.CMOF_Element;
function MP_DG_Style_Stroke_Opacity return AMF.Internals.CMOF_Element;
function MP_DG_Style_Stroke_Width return AMF.Internals.CMOF_Element;
function MP_DG_Text_Alignment return AMF.Internals.CMOF_Element;
function MP_DG_Text_Bounds return AMF.Internals.CMOF_Element;
function MP_DG_Text_Data return AMF.Internals.CMOF_Element;
function MP_DG_A_Pattern_Pattern_Tile return AMF.Internals.CMOF_Element;
function MP_DG_A_Canvas_Canvas_Packaged_Style return AMF.Internals.CMOF_Element;
function MP_DG_A_Marked_Element_Marked_Element_Start_Marker return AMF.Internals.CMOF_Element;
function MP_DG_A_Marked_Element_Marked_Element_End_Marker return AMF.Internals.CMOF_Element;
function MP_DG_A_Marked_Element_Marked_Element_Mid_Marker return AMF.Internals.CMOF_Element;
function MP_DG_A_Styled_Element_Graphical_Element_Local_Style return AMF.Internals.CMOF_Element;
function MP_DG_A_Style_Style_Fill return AMF.Internals.CMOF_Element;
function MP_DG_A_Styled_Element_Graphical_Element_Shared_Style return AMF.Internals.CMOF_Element;
function MP_DG_A_Canvas_Canvas_Background_Fill return AMF.Internals.CMOF_Element;
function MA_DG_Pattern_Tile_Pattern return AMF.Internals.CMOF_Element;
function MA_DG_Canvas_Packaged_Style_Canvas return AMF.Internals.CMOF_Element;
function MA_DG_Marked_Element_Start_Marker_Marked_Element return AMF.Internals.CMOF_Element;
function MA_DG_Marked_Element_End_Marker_Marked_Element return AMF.Internals.CMOF_Element;
function MA_DG_Group_Member_Group return AMF.Internals.CMOF_Element;
function MA_DG_Marked_Element_Mid_Marker_Marked_Element return AMF.Internals.CMOF_Element;
function MA_DG_Canvas_Packaged_Marker_Canvas return AMF.Internals.CMOF_Element;
function MA_DG_Graphical_Element_Clip_Path_Clipped_Element return AMF.Internals.CMOF_Element;
function MA_DG_Graphical_Element_Local_Style_Styled_Element return AMF.Internals.CMOF_Element;
function MA_DG_Canvas_Packaged_Fill_Canvas return AMF.Internals.CMOF_Element;
function MA_DG_Style_Fill_Style return AMF.Internals.CMOF_Element;
function MA_DG_Graphical_Element_Shared_Style_Styled_Element return AMF.Internals.CMOF_Element;
function MA_DG_Canvas_Background_Fill_Canvas return AMF.Internals.CMOF_Element;
function MB_DG return AMF.Internals.AMF_Element;
function ML_DG return AMF.Internals.AMF_Element;
private
Base : AMF.Internals.CMOF_Element := 0;
end AMF.Internals.Tables.DG_Metamodel;
| true | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2012, PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
package AMF.Internals.Tables.DG_Metamodel is
pragma Preelaborate;
function MM_DG_DG return AMF.Internals.CMOF_Element;
function MC_DG_Close_Path return AMF.Internals.CMOF_Element;
function MC_DG_Cubic_Curve_To return AMF.Internals.CMOF_Element;
function MC_DG_Elliptical_Arc_To return AMF.Internals.CMOF_Element;
function MC_DG_Gradient_Stop return AMF.Internals.CMOF_Element;
function MC_DG_Line_To return AMF.Internals.CMOF_Element;
function MC_DG_Matrix return AMF.Internals.CMOF_Element;
function MC_DG_Move_To return AMF.Internals.CMOF_Element;
function MC_DG_Path_Command return AMF.Internals.CMOF_Element;
function MC_DG_Quadratic_Curve_To return AMF.Internals.CMOF_Element;
function MC_DG_Rotate return AMF.Internals.CMOF_Element;
function MC_DG_Scale return AMF.Internals.CMOF_Element;
function MC_DG_Skew return AMF.Internals.CMOF_Element;
function MC_DG_Transform return AMF.Internals.CMOF_Element;
function MC_DG_Translate return AMF.Internals.CMOF_Element;
function MP_DG_Cubic_Curve_To_End_Control return AMF.Internals.CMOF_Element;
function MP_DG_Cubic_Curve_To_Point return AMF.Internals.CMOF_Element;
function MP_DG_Cubic_Curve_To_Start_Control return AMF.Internals.CMOF_Element;
function MP_DG_Elliptical_Arc_To_Is_Large_Arc return AMF.Internals.CMOF_Element;
function MP_DG_Elliptical_Arc_To_Is_Sweep return AMF.Internals.CMOF_Element;
function MP_DG_Elliptical_Arc_To_Point return AMF.Internals.CMOF_Element;
function MP_DG_Elliptical_Arc_To_Radii return AMF.Internals.CMOF_Element;
function MP_DG_Elliptical_Arc_To_Rotation return AMF.Internals.CMOF_Element;
function MP_DG_Gradient_Stop_Color return AMF.Internals.CMOF_Element;
function MP_DG_Gradient_Stop_Offset return AMF.Internals.CMOF_Element;
function MP_DG_Gradient_Stop_Opacity return AMF.Internals.CMOF_Element;
function MP_DG_Line_To_Point return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_A return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_B return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_C return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_D return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_E return AMF.Internals.CMOF_Element;
function MP_DG_Matrix_F return AMF.Internals.CMOF_Element;
function MP_DG_Move_To_Point return AMF.Internals.CMOF_Element;
function MP_DG_Path_Command_Is_Relative return AMF.Internals.CMOF_Element;
function MP_DG_Quadratic_Curve_To_Control return AMF.Internals.CMOF_Element;
function MP_DG_Quadratic_Curve_To_Point return AMF.Internals.CMOF_Element;
function MP_DG_Rotate_Angle return AMF.Internals.CMOF_Element;
function MP_DG_Rotate_Center return AMF.Internals.CMOF_Element;
function MP_DG_Scale_Factor_X return AMF.Internals.CMOF_Element;
function MP_DG_Scale_Factor_Y return AMF.Internals.CMOF_Element;
function MP_DG_Skew_Angle_X return AMF.Internals.CMOF_Element;
function MP_DG_Skew_Angle_Y return AMF.Internals.CMOF_Element;
function MP_DG_Translate_Delta_X return AMF.Internals.CMOF_Element;
function MP_DG_Translate_Delta_Y return AMF.Internals.CMOF_Element;
function MC_DG_Canvas return AMF.Internals.CMOF_Element;
function MC_DG_Circle return AMF.Internals.CMOF_Element;
function MC_DG_Clip_Path return AMF.Internals.CMOF_Element;
function MC_DG_Ellipse return AMF.Internals.CMOF_Element;
function MC_DG_Fill return AMF.Internals.CMOF_Element;
function MC_DG_Gradient return AMF.Internals.CMOF_Element;
function MC_DG_Graphical_Element return AMF.Internals.CMOF_Element;
function MC_DG_Group return AMF.Internals.CMOF_Element;
function MC_DG_Image return AMF.Internals.CMOF_Element;
function MC_DG_Line return AMF.Internals.CMOF_Element;
function MC_DG_Linear_Gradient return AMF.Internals.CMOF_Element;
function MC_DG_Marked_Element return AMF.Internals.CMOF_Element;
function MC_DG_Marker return AMF.Internals.CMOF_Element;
function MC_DG_Path return AMF.Internals.CMOF_Element;
function MC_DG_Pattern return AMF.Internals.CMOF_Element;
function MC_DG_Polygon return AMF.Internals.CMOF_Element;
function MC_DG_Polyline return AMF.Internals.CMOF_Element;
function MC_DG_Radial_Gradient return AMF.Internals.CMOF_Element;
function MC_DG_Rectangle return AMF.Internals.CMOF_Element;
function MC_DG_Style return AMF.Internals.CMOF_Element;
function MC_DG_Text return AMF.Internals.CMOF_Element;
function MP_DG_Canvas_Background_Color return AMF.Internals.CMOF_Element;
function MP_DG_Canvas_Background_Fill_A_Canvas return AMF.Internals.CMOF_Element;
function MP_DG_Canvas_Packaged_Fill_Fill_Canvas return AMF.Internals.CMOF_Element;
function MP_DG_Canvas_Packaged_Marker_Marker_Canvas return AMF.Internals.CMOF_Element;
function MP_DG_Canvas_Packaged_Style_A_Canvas return AMF.Internals.CMOF_Element;
function MP_DG_Circle_Center return AMF.Internals.CMOF_Element;
function MP_DG_Circle_Radius return AMF.Internals.CMOF_Element;
function MP_DG_Clip_Path_Clipped_Element_Graphical_Element_Clip_Path return AMF.Internals.CMOF_Element;
function MP_DG_Ellipse_Center return AMF.Internals.CMOF_Element;
function MP_DG_Ellipse_Radii return AMF.Internals.CMOF_Element;
function MP_DG_Fill_Canvas_Canvas_Packaged_Fill return AMF.Internals.CMOF_Element;
function MP_DG_Fill_Transform return AMF.Internals.CMOF_Element;
function MP_DG_Gradient_Stop return AMF.Internals.CMOF_Element;
function MP_DG_Graphical_Element_Clip_Path_Clip_Path_Clipped_Element return AMF.Internals.CMOF_Element;
function MP_DG_Graphical_Element_Group_Group_Member return AMF.Internals.CMOF_Element;
function MP_DG_Graphical_Element_Local_Style_A_Styled_Element return AMF.Internals.CMOF_Element;
function MP_DG_Graphical_Element_Shared_Style_A_Styled_Element return AMF.Internals.CMOF_Element;
function MP_DG_Graphical_Element_Transform return AMF.Internals.CMOF_Element;
function MP_DG_Group_Member_Graphical_Element_Group return AMF.Internals.CMOF_Element;
function MP_DG_Image_Bounds return AMF.Internals.CMOF_Element;
function MP_DG_Image_Is_Aspect_Ratio_Preserved return AMF.Internals.CMOF_Element;
function MP_DG_Image_Source return AMF.Internals.CMOF_Element;
function MP_DG_Line_End return AMF.Internals.CMOF_Element;
function MP_DG_Line_Start return AMF.Internals.CMOF_Element;
function MP_DG_Linear_Gradient_X1 return AMF.Internals.CMOF_Element;
function MP_DG_Linear_Gradient_X2 return AMF.Internals.CMOF_Element;
function MP_DG_Linear_Gradient_Y1 return AMF.Internals.CMOF_Element;
function MP_DG_Linear_Gradient_Y2 return AMF.Internals.CMOF_Element;
function MP_DG_Marked_Element_End_Marker_A_Marked_Element return AMF.Internals.CMOF_Element;
function MP_DG_Marked_Element_Mid_Marker_A_Marked_Element return AMF.Internals.CMOF_Element;
function MP_DG_Marked_Element_Start_Marker_A_Marked_Element return AMF.Internals.CMOF_Element;
function MP_DG_Marker_Canvas_Canvas_Packaged_Marker return AMF.Internals.CMOF_Element;
function MP_DG_Marker_Reference return AMF.Internals.CMOF_Element;
function MP_DG_Marker_Size return AMF.Internals.CMOF_Element;
function MP_DG_Path_Command return AMF.Internals.CMOF_Element;
function MP_DG_Pattern_Bounds return AMF.Internals.CMOF_Element;
function MP_DG_Pattern_Tile_A_Pattern return AMF.Internals.CMOF_Element;
function MP_DG_Polygon_Point return AMF.Internals.CMOF_Element;
function MP_DG_Polyline_Point return AMF.Internals.CMOF_Element;
function MP_DG_Radial_Gradient_Center_X return AMF.Internals.CMOF_Element;
function MP_DG_Radial_Gradient_Center_Y return AMF.Internals.CMOF_Element;
function MP_DG_Radial_Gradient_Focus_X return AMF.Internals.CMOF_Element;
function MP_DG_Radial_Gradient_Focus_Y return AMF.Internals.CMOF_Element;
function MP_DG_Radial_Gradient_Radius return AMF.Internals.CMOF_Element;
function MP_DG_Rectangle_Bounds return AMF.Internals.CMOF_Element;
function MP_DG_Rectangle_Corner_Radius return AMF.Internals.CMOF_Element;
function MP_DG_Style_Fill_A_Style return AMF.Internals.CMOF_Element;
function MP_DG_Style_Fill_Color return AMF.Internals.CMOF_Element;
function MP_DG_Style_Fill_Opacity return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Bold return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Color return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Italic return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Name return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Size return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Strike_Through return AMF.Internals.CMOF_Element;
function MP_DG_Style_Font_Underline return AMF.Internals.CMOF_Element;
function MP_DG_Style_Stroke_Color return AMF.Internals.CMOF_Element;
function MP_DG_Style_Stroke_Dash_Length return AMF.Internals.CMOF_Element;
function MP_DG_Style_Stroke_Opacity return AMF.Internals.CMOF_Element;
function MP_DG_Style_Stroke_Width return AMF.Internals.CMOF_Element;
function MP_DG_Text_Alignment return AMF.Internals.CMOF_Element;
function MP_DG_Text_Bounds return AMF.Internals.CMOF_Element;
function MP_DG_Text_Data return AMF.Internals.CMOF_Element;
function MP_DG_A_Pattern_Pattern_Tile return AMF.Internals.CMOF_Element;
function MP_DG_A_Canvas_Canvas_Packaged_Style return AMF.Internals.CMOF_Element;
function MP_DG_A_Marked_Element_Marked_Element_Start_Marker return AMF.Internals.CMOF_Element;
function MP_DG_A_Marked_Element_Marked_Element_End_Marker return AMF.Internals.CMOF_Element;
function MP_DG_A_Marked_Element_Marked_Element_Mid_Marker return AMF.Internals.CMOF_Element;
function MP_DG_A_Styled_Element_Graphical_Element_Local_Style return AMF.Internals.CMOF_Element;
function MP_DG_A_Style_Style_Fill return AMF.Internals.CMOF_Element;
function MP_DG_A_Styled_Element_Graphical_Element_Shared_Style return AMF.Internals.CMOF_Element;
function MP_DG_A_Canvas_Canvas_Background_Fill return AMF.Internals.CMOF_Element;
function MA_DG_Pattern_Tile_Pattern return AMF.Internals.CMOF_Element;
function MA_DG_Canvas_Packaged_Style_Canvas return AMF.Internals.CMOF_Element;
function MA_DG_Marked_Element_Start_Marker_Marked_Element return AMF.Internals.CMOF_Element;
function MA_DG_Marked_Element_End_Marker_Marked_Element return AMF.Internals.CMOF_Element;
function MA_DG_Group_Member_Group return AMF.Internals.CMOF_Element;
function MA_DG_Marked_Element_Mid_Marker_Marked_Element return AMF.Internals.CMOF_Element;
function MA_DG_Canvas_Packaged_Marker_Canvas return AMF.Internals.CMOF_Element;
function MA_DG_Graphical_Element_Clip_Path_Clipped_Element return AMF.Internals.CMOF_Element;
function MA_DG_Graphical_Element_Local_Style_Styled_Element return AMF.Internals.CMOF_Element;
function MA_DG_Canvas_Packaged_Fill_Canvas return AMF.Internals.CMOF_Element;
function MA_DG_Style_Fill_Style return AMF.Internals.CMOF_Element;
function MA_DG_Graphical_Element_Shared_Style_Styled_Element return AMF.Internals.CMOF_Element;
function MA_DG_Canvas_Background_Fill_Canvas return AMF.Internals.CMOF_Element;
function MB_DG return AMF.Internals.AMF_Element;
function ML_DG return AMF.Internals.AMF_Element;
private
Base : AMF.Internals.CMOF_Element := 0;
end AMF.Internals.Tables.DG_Metamodel;
|
[
{
"context": "-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifi",
"end": 35,
"score": 0.9998575448989868,
"start": 23,
"tag": "NAME",
"value": "Maxim Reznik"
},
{
"context": "-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifier: MIT\n-- License-",
"end": 55,
"score": 0.9999313354492188,
"start": 37,
"tag": "EMAIL",
"value": "reznikmm@gmail.com"
}
] | source/coroutines.adb | reznikmm/coroutines | 3 | -- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with System.Address_To_Access_Conversions;
with Interfaces.C;
with Coroutines.Polling;
package body Coroutines is
-- void * create_stack (int size)
function create_context (size : Interfaces.C.int) return Context
with Import, Convention => C, External_Name => "create_context";
-- Allocate new stack with a header over it and guard page under it.
-- Return pointer to the header
-- init_context(context, code, arg1, arg2, cont)
procedure init_context
(Self : Context;
Wrapper : System.Address;
Code : System.Address;
Argument : System.Address;
Cleanup : Context)
with Import, Convention => C, External_Name => "init_context";
-- Initalize a context created by create_context function.
-- When this context gets execution control first time it calls
-- Wrapper (Code, Argument). When Wrapper returns it switches to
-- Cleanup context. The last switch doesn't modify Current variable.
procedure free_context (Object : Context)
with Import, Convention => C, External_Name => "free_context";
-- Destroy context created by create_context function
-- switch_context(context *from, context *to)
procedure swapcontext (prev, next : Context)
with Import => True, Convention => C, External_Name => "switch_context";
-- Suspend prev context execution and start executing next context
procedure Destroyer (Unused : System.Address) with Convention => C;
-- This procedure deallocates a finished coroutine. It takes context of
-- the finished coroutine from Current variable.
function Next_Context return Context;
-- Find next coroutine to execute.
procedure Run (Code, Unused : System.Address) with Convention => C;
-- A low level wrapper to launch parameterless coroutine.
type Destroy_Stack_Type is record
Stack : Wide_Wide_String (1 .. 256);
Stack_Pointer : System.Address;
end record with Convention => C;
Destroy_Stack : Destroy_Stack_Type; -- A stack for Destroy coroutine
Main_SP : aliased System.Address; -- A stack pointer for Main coro
Main : Context := Context (Main_SP'Address); -- Main coroutine
Current : Context; -- Current coroutine
Destroy : Context := Context (Destroy_Stack.Stack_Pointer'Address);
-- Cleanup coroutine
Total : Natural := 0;
-- Number of coroutines (excluding Main and Destroy)
-------------------
-- Generic_Start --
-------------------
procedure Generic_Start
(Runable : not null access procedure (Argument : Argument_Type);
Stack_Size : System.Storage_Elements.Storage_Count;
Argument : Argument_Type)
is
package Convert is new System.Address_To_Access_Conversions
(Object => Argument_Type);
procedure Run (Code, Argument : System.Address) with Convention => C;
-- A low level wrapper to launch a coroutine.
---------
-- Run --
---------
procedure Run (Code, Argument : System.Address) is
procedure Proc (Argument : Argument_Type)
with Import, Address => Code;
-- Copy Argument to new stack
Copy : constant Argument_Type := Convert.To_Pointer (Argument).all;
begin
Proc (Copy);
-- return to Destroyer
exception
when others =>
null;
end Run;
Prev : constant Context := Current;
Copy : aliased Argument_Type := Argument;
Next : constant Context :=
create_context (Interfaces.C.int (Stack_Size));
begin
init_context
(Self => Next,
Wrapper => Run'Address,
Code => Runable.all'Address,
Argument => Copy'Address,
Cleanup => Destroy);
Total := Total + 1;
if Prev = Main then
-- Dont activate main context after Start
Current := Next;
swapcontext (Prev, Current);
else
declare
Ready : Event_Id;
begin
Manager.Get_Always_Ready_Event (Ready);
Ready.Activate;
Current := Next;
swapcontext (Prev, Current);
Ready.Deactivate;
end;
end if;
end Generic_Start;
---------------
-- Destroyer --
---------------
procedure Destroyer (Unused : System.Address) is
begin
loop
free_context (Current);
Current := Destroy;
Total := Total - 1;
exit when Total = 0;
Yield (Wait => (1 .. 0 => <>));
end loop;
-- Return to main context
end Destroyer;
---------------------
-- Current_Context --
---------------------
function Current_Context return Context is
begin
return Current;
end Current_Context;
----------
-- Hash --
----------
function Hash (Self : Context) return Ada.Containers.Hash_Type is
begin
return Ada.Containers.Hash_Type'Mod
(System.Storage_Elements.To_Integer (System.Address (Self)));
end Hash;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
Main := Context (Main_SP'Address);
Destroy := Context (Destroy_Stack.Stack_Pointer'Address);
Current := Main;
init_context
(Self => Destroy,
Wrapper => Destroyer'Address,
Code => System.Null_Address,
Argument => System.Null_Address,
Cleanup => Main);
Coroutines.Polling.Initialize;
end Initialize;
Queue : Context_Vectors.Vector;
------------------
-- Next_Context --
------------------
function Next_Context return Context is
Result : Context;
begin
while Queue.Is_Empty loop
Manager.New_Round (Queue, Timeout => 300.0);
end loop;
Result := Queue.Last_Element;
Queue.Delete_Last;
return Result;
end Next_Context;
---------
-- Run --
---------
procedure Run (Code, Unused : System.Address) is
procedure Proc with Import, Address => Code;
begin
Proc;
-- return to Destroyer
exception
when others =>
null;
end Run;
-----------
-- Start --
-----------
procedure Start
(Runable : Runable_Code;
Stack_Size : System.Storage_Elements.Storage_Count)
is
Prev : constant Context := Current;
Next : constant Context :=
create_context (Interfaces.C.int (Stack_Size));
begin
init_context
(Self => Next,
Wrapper => Run'Address,
Code => Runable.all'Address,
Argument => System.Null_Address,
Cleanup => Destroy);
Total := Total + 1;
if Prev = Main then
-- Dont activate main context after Start
Current := Next;
swapcontext (Prev, Current);
else
declare
Ready : Event_Id;
begin
Manager.Get_Always_Ready_Event (Ready);
Ready.Activate;
Current := Next;
swapcontext (Prev, Current);
Ready.Deactivate;
end;
end if;
end Start;
-----------
-- Yield --
-----------
procedure Yield is
Ready : Event_Id;
begin
Manager.Get_Always_Ready_Event (Ready);
Yield ((1 => Ready));
end Yield;
-----------
-- Yield --
-----------
procedure Yield (Wait : Event_Id) is
begin
Yield ((1 => Wait));
end Yield;
-----------
-- Yield --
-----------
procedure Yield
(Wait : Event_Id_Array := (1 .. 0 => <>);
Result : access Natural := null)
is
Prev : constant Context := Current;
begin
for J of Wait loop
J.Activate;
end loop;
Current := Next_Context;
if Prev /= Current then
swapcontext (Prev, Current);
end if;
if Result /= null then
Result.all := 0;
for J in Wait'Range loop
if Wait (J).Ready then
Result.all := J;
exit;
end if;
end loop;
end if;
for J of Wait loop
J.Deactivate;
end loop;
end Yield;
end Coroutines;
| 10012 | -- Copyright (c) 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with System.Address_To_Access_Conversions;
with Interfaces.C;
with Coroutines.Polling;
package body Coroutines is
-- void * create_stack (int size)
function create_context (size : Interfaces.C.int) return Context
with Import, Convention => C, External_Name => "create_context";
-- Allocate new stack with a header over it and guard page under it.
-- Return pointer to the header
-- init_context(context, code, arg1, arg2, cont)
procedure init_context
(Self : Context;
Wrapper : System.Address;
Code : System.Address;
Argument : System.Address;
Cleanup : Context)
with Import, Convention => C, External_Name => "init_context";
-- Initalize a context created by create_context function.
-- When this context gets execution control first time it calls
-- Wrapper (Code, Argument). When Wrapper returns it switches to
-- Cleanup context. The last switch doesn't modify Current variable.
procedure free_context (Object : Context)
with Import, Convention => C, External_Name => "free_context";
-- Destroy context created by create_context function
-- switch_context(context *from, context *to)
procedure swapcontext (prev, next : Context)
with Import => True, Convention => C, External_Name => "switch_context";
-- Suspend prev context execution and start executing next context
procedure Destroyer (Unused : System.Address) with Convention => C;
-- This procedure deallocates a finished coroutine. It takes context of
-- the finished coroutine from Current variable.
function Next_Context return Context;
-- Find next coroutine to execute.
procedure Run (Code, Unused : System.Address) with Convention => C;
-- A low level wrapper to launch parameterless coroutine.
type Destroy_Stack_Type is record
Stack : Wide_Wide_String (1 .. 256);
Stack_Pointer : System.Address;
end record with Convention => C;
Destroy_Stack : Destroy_Stack_Type; -- A stack for Destroy coroutine
Main_SP : aliased System.Address; -- A stack pointer for Main coro
Main : Context := Context (Main_SP'Address); -- Main coroutine
Current : Context; -- Current coroutine
Destroy : Context := Context (Destroy_Stack.Stack_Pointer'Address);
-- Cleanup coroutine
Total : Natural := 0;
-- Number of coroutines (excluding Main and Destroy)
-------------------
-- Generic_Start --
-------------------
procedure Generic_Start
(Runable : not null access procedure (Argument : Argument_Type);
Stack_Size : System.Storage_Elements.Storage_Count;
Argument : Argument_Type)
is
package Convert is new System.Address_To_Access_Conversions
(Object => Argument_Type);
procedure Run (Code, Argument : System.Address) with Convention => C;
-- A low level wrapper to launch a coroutine.
---------
-- Run --
---------
procedure Run (Code, Argument : System.Address) is
procedure Proc (Argument : Argument_Type)
with Import, Address => Code;
-- Copy Argument to new stack
Copy : constant Argument_Type := Convert.To_Pointer (Argument).all;
begin
Proc (Copy);
-- return to Destroyer
exception
when others =>
null;
end Run;
Prev : constant Context := Current;
Copy : aliased Argument_Type := Argument;
Next : constant Context :=
create_context (Interfaces.C.int (Stack_Size));
begin
init_context
(Self => Next,
Wrapper => Run'Address,
Code => Runable.all'Address,
Argument => Copy'Address,
Cleanup => Destroy);
Total := Total + 1;
if Prev = Main then
-- Dont activate main context after Start
Current := Next;
swapcontext (Prev, Current);
else
declare
Ready : Event_Id;
begin
Manager.Get_Always_Ready_Event (Ready);
Ready.Activate;
Current := Next;
swapcontext (Prev, Current);
Ready.Deactivate;
end;
end if;
end Generic_Start;
---------------
-- Destroyer --
---------------
procedure Destroyer (Unused : System.Address) is
begin
loop
free_context (Current);
Current := Destroy;
Total := Total - 1;
exit when Total = 0;
Yield (Wait => (1 .. 0 => <>));
end loop;
-- Return to main context
end Destroyer;
---------------------
-- Current_Context --
---------------------
function Current_Context return Context is
begin
return Current;
end Current_Context;
----------
-- Hash --
----------
function Hash (Self : Context) return Ada.Containers.Hash_Type is
begin
return Ada.Containers.Hash_Type'Mod
(System.Storage_Elements.To_Integer (System.Address (Self)));
end Hash;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
Main := Context (Main_SP'Address);
Destroy := Context (Destroy_Stack.Stack_Pointer'Address);
Current := Main;
init_context
(Self => Destroy,
Wrapper => Destroyer'Address,
Code => System.Null_Address,
Argument => System.Null_Address,
Cleanup => Main);
Coroutines.Polling.Initialize;
end Initialize;
Queue : Context_Vectors.Vector;
------------------
-- Next_Context --
------------------
function Next_Context return Context is
Result : Context;
begin
while Queue.Is_Empty loop
Manager.New_Round (Queue, Timeout => 300.0);
end loop;
Result := Queue.Last_Element;
Queue.Delete_Last;
return Result;
end Next_Context;
---------
-- Run --
---------
procedure Run (Code, Unused : System.Address) is
procedure Proc with Import, Address => Code;
begin
Proc;
-- return to Destroyer
exception
when others =>
null;
end Run;
-----------
-- Start --
-----------
procedure Start
(Runable : Runable_Code;
Stack_Size : System.Storage_Elements.Storage_Count)
is
Prev : constant Context := Current;
Next : constant Context :=
create_context (Interfaces.C.int (Stack_Size));
begin
init_context
(Self => Next,
Wrapper => Run'Address,
Code => Runable.all'Address,
Argument => System.Null_Address,
Cleanup => Destroy);
Total := Total + 1;
if Prev = Main then
-- Dont activate main context after Start
Current := Next;
swapcontext (Prev, Current);
else
declare
Ready : Event_Id;
begin
Manager.Get_Always_Ready_Event (Ready);
Ready.Activate;
Current := Next;
swapcontext (Prev, Current);
Ready.Deactivate;
end;
end if;
end Start;
-----------
-- Yield --
-----------
procedure Yield is
Ready : Event_Id;
begin
Manager.Get_Always_Ready_Event (Ready);
Yield ((1 => Ready));
end Yield;
-----------
-- Yield --
-----------
procedure Yield (Wait : Event_Id) is
begin
Yield ((1 => Wait));
end Yield;
-----------
-- Yield --
-----------
procedure Yield
(Wait : Event_Id_Array := (1 .. 0 => <>);
Result : access Natural := null)
is
Prev : constant Context := Current;
begin
for J of Wait loop
J.Activate;
end loop;
Current := Next_Context;
if Prev /= Current then
swapcontext (Prev, Current);
end if;
if Result /= null then
Result.all := 0;
for J in Wait'Range loop
if Wait (J).Ready then
Result.all := J;
exit;
end if;
end loop;
end if;
for J of Wait loop
J.Deactivate;
end loop;
end Yield;
end Coroutines;
| true | -- Copyright (c) 2019 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with System.Address_To_Access_Conversions;
with Interfaces.C;
with Coroutines.Polling;
package body Coroutines is
-- void * create_stack (int size)
function create_context (size : Interfaces.C.int) return Context
with Import, Convention => C, External_Name => "create_context";
-- Allocate new stack with a header over it and guard page under it.
-- Return pointer to the header
-- init_context(context, code, arg1, arg2, cont)
procedure init_context
(Self : Context;
Wrapper : System.Address;
Code : System.Address;
Argument : System.Address;
Cleanup : Context)
with Import, Convention => C, External_Name => "init_context";
-- Initalize a context created by create_context function.
-- When this context gets execution control first time it calls
-- Wrapper (Code, Argument). When Wrapper returns it switches to
-- Cleanup context. The last switch doesn't modify Current variable.
procedure free_context (Object : Context)
with Import, Convention => C, External_Name => "free_context";
-- Destroy context created by create_context function
-- switch_context(context *from, context *to)
procedure swapcontext (prev, next : Context)
with Import => True, Convention => C, External_Name => "switch_context";
-- Suspend prev context execution and start executing next context
procedure Destroyer (Unused : System.Address) with Convention => C;
-- This procedure deallocates a finished coroutine. It takes context of
-- the finished coroutine from Current variable.
function Next_Context return Context;
-- Find next coroutine to execute.
procedure Run (Code, Unused : System.Address) with Convention => C;
-- A low level wrapper to launch parameterless coroutine.
type Destroy_Stack_Type is record
Stack : Wide_Wide_String (1 .. 256);
Stack_Pointer : System.Address;
end record with Convention => C;
Destroy_Stack : Destroy_Stack_Type; -- A stack for Destroy coroutine
Main_SP : aliased System.Address; -- A stack pointer for Main coro
Main : Context := Context (Main_SP'Address); -- Main coroutine
Current : Context; -- Current coroutine
Destroy : Context := Context (Destroy_Stack.Stack_Pointer'Address);
-- Cleanup coroutine
Total : Natural := 0;
-- Number of coroutines (excluding Main and Destroy)
-------------------
-- Generic_Start --
-------------------
procedure Generic_Start
(Runable : not null access procedure (Argument : Argument_Type);
Stack_Size : System.Storage_Elements.Storage_Count;
Argument : Argument_Type)
is
package Convert is new System.Address_To_Access_Conversions
(Object => Argument_Type);
procedure Run (Code, Argument : System.Address) with Convention => C;
-- A low level wrapper to launch a coroutine.
---------
-- Run --
---------
procedure Run (Code, Argument : System.Address) is
procedure Proc (Argument : Argument_Type)
with Import, Address => Code;
-- Copy Argument to new stack
Copy : constant Argument_Type := Convert.To_Pointer (Argument).all;
begin
Proc (Copy);
-- return to Destroyer
exception
when others =>
null;
end Run;
Prev : constant Context := Current;
Copy : aliased Argument_Type := Argument;
Next : constant Context :=
create_context (Interfaces.C.int (Stack_Size));
begin
init_context
(Self => Next,
Wrapper => Run'Address,
Code => Runable.all'Address,
Argument => Copy'Address,
Cleanup => Destroy);
Total := Total + 1;
if Prev = Main then
-- Dont activate main context after Start
Current := Next;
swapcontext (Prev, Current);
else
declare
Ready : Event_Id;
begin
Manager.Get_Always_Ready_Event (Ready);
Ready.Activate;
Current := Next;
swapcontext (Prev, Current);
Ready.Deactivate;
end;
end if;
end Generic_Start;
---------------
-- Destroyer --
---------------
procedure Destroyer (Unused : System.Address) is
begin
loop
free_context (Current);
Current := Destroy;
Total := Total - 1;
exit when Total = 0;
Yield (Wait => (1 .. 0 => <>));
end loop;
-- Return to main context
end Destroyer;
---------------------
-- Current_Context --
---------------------
function Current_Context return Context is
begin
return Current;
end Current_Context;
----------
-- Hash --
----------
function Hash (Self : Context) return Ada.Containers.Hash_Type is
begin
return Ada.Containers.Hash_Type'Mod
(System.Storage_Elements.To_Integer (System.Address (Self)));
end Hash;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
Main := Context (Main_SP'Address);
Destroy := Context (Destroy_Stack.Stack_Pointer'Address);
Current := Main;
init_context
(Self => Destroy,
Wrapper => Destroyer'Address,
Code => System.Null_Address,
Argument => System.Null_Address,
Cleanup => Main);
Coroutines.Polling.Initialize;
end Initialize;
Queue : Context_Vectors.Vector;
------------------
-- Next_Context --
------------------
function Next_Context return Context is
Result : Context;
begin
while Queue.Is_Empty loop
Manager.New_Round (Queue, Timeout => 300.0);
end loop;
Result := Queue.Last_Element;
Queue.Delete_Last;
return Result;
end Next_Context;
---------
-- Run --
---------
procedure Run (Code, Unused : System.Address) is
procedure Proc with Import, Address => Code;
begin
Proc;
-- return to Destroyer
exception
when others =>
null;
end Run;
-----------
-- Start --
-----------
procedure Start
(Runable : Runable_Code;
Stack_Size : System.Storage_Elements.Storage_Count)
is
Prev : constant Context := Current;
Next : constant Context :=
create_context (Interfaces.C.int (Stack_Size));
begin
init_context
(Self => Next,
Wrapper => Run'Address,
Code => Runable.all'Address,
Argument => System.Null_Address,
Cleanup => Destroy);
Total := Total + 1;
if Prev = Main then
-- Dont activate main context after Start
Current := Next;
swapcontext (Prev, Current);
else
declare
Ready : Event_Id;
begin
Manager.Get_Always_Ready_Event (Ready);
Ready.Activate;
Current := Next;
swapcontext (Prev, Current);
Ready.Deactivate;
end;
end if;
end Start;
-----------
-- Yield --
-----------
procedure Yield is
Ready : Event_Id;
begin
Manager.Get_Always_Ready_Event (Ready);
Yield ((1 => Ready));
end Yield;
-----------
-- Yield --
-----------
procedure Yield (Wait : Event_Id) is
begin
Yield ((1 => Wait));
end Yield;
-----------
-- Yield --
-----------
procedure Yield
(Wait : Event_Id_Array := (1 .. 0 => <>);
Result : access Natural := null)
is
Prev : constant Context := Current;
begin
for J of Wait loop
J.Activate;
end loop;
Current := Next_Context;
if Prev /= Current then
swapcontext (Prev, Current);
end if;
if Result /= null then
Result.all := 0;
for J in Wait'Range loop
if Wait (J).Ready then
Result.all := J;
exit;
end if;
end loop;
end if;
for J of Wait loop
J.Deactivate;
end loop;
end Yield;
end Coroutines;
|
[
{
"context": "--\n-- Radoslaw Kowalski 221454\n--\nwith Ada.Text_IO; use Ada.Text_IO",
"end": 23,
"score": 0.9998151063919067,
"start": 6,
"tag": "NAME",
"value": "Radoslaw Kowalski"
}
] | trains.ads | AfroMetal/concurrent-railroad-ada | 0 | --
-- Radoslaw Kowalski 221454
--
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Calendar;
with Rails; use Rails;
package Trains is
package Calendar renames Ada.Calendar;
type Train (Route_Length: Integer) is
record
Id : Integer;
Name : SU.Unbounded_String;
Speed : Integer;
Capacity : Integer;
Route : Route_Array(1 .. Route_Length);
Index : Integer;
Att : Track_Ptr;
end record;
type Train_Ptr is access Train;
procedure Connection(Self: Train_Ptr; From, To : out Track_Ptr);
function Move_To(Self: Train_Ptr; T : Track_Ptr) return Float;
function As_String(Self: Train_Ptr) return String;
function As_Verbose_String(Self: Train_Ptr) return String;
type Trains_Array is array(Integer range<>) of Train_Ptr;
type Trains_Ptr is access Trains_Array;
function New_Train (
Id : Integer;
Name : SU.Unbounded_String;
Speed : Integer;
Capacity : Integer;
Route : Route_Array) return Train_Ptr;
task type Simulation is
entry Init(S : Calendar.Time; SPH : Integer; H : Integer; M : Integer; V : Boolean);
entry Simulate(T : in Train_Ptr; C : in Connections_Ptr);
end Simulation;
type Simulation_Ptr is access Simulation;
type Time_Component_Type is
delta 1.0 digits 2 range 0.0 .. 60.0;
end Trains;
| 669 | --
-- <NAME> 221454
--
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Calendar;
with Rails; use Rails;
package Trains is
package Calendar renames Ada.Calendar;
type Train (Route_Length: Integer) is
record
Id : Integer;
Name : SU.Unbounded_String;
Speed : Integer;
Capacity : Integer;
Route : Route_Array(1 .. Route_Length);
Index : Integer;
Att : Track_Ptr;
end record;
type Train_Ptr is access Train;
procedure Connection(Self: Train_Ptr; From, To : out Track_Ptr);
function Move_To(Self: Train_Ptr; T : Track_Ptr) return Float;
function As_String(Self: Train_Ptr) return String;
function As_Verbose_String(Self: Train_Ptr) return String;
type Trains_Array is array(Integer range<>) of Train_Ptr;
type Trains_Ptr is access Trains_Array;
function New_Train (
Id : Integer;
Name : SU.Unbounded_String;
Speed : Integer;
Capacity : Integer;
Route : Route_Array) return Train_Ptr;
task type Simulation is
entry Init(S : Calendar.Time; SPH : Integer; H : Integer; M : Integer; V : Boolean);
entry Simulate(T : in Train_Ptr; C : in Connections_Ptr);
end Simulation;
type Simulation_Ptr is access Simulation;
type Time_Component_Type is
delta 1.0 digits 2 range 0.0 .. 60.0;
end Trains;
| true | --
-- PI:NAME:<NAME>END_PI 221454
--
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Calendar;
with Rails; use Rails;
package Trains is
package Calendar renames Ada.Calendar;
type Train (Route_Length: Integer) is
record
Id : Integer;
Name : SU.Unbounded_String;
Speed : Integer;
Capacity : Integer;
Route : Route_Array(1 .. Route_Length);
Index : Integer;
Att : Track_Ptr;
end record;
type Train_Ptr is access Train;
procedure Connection(Self: Train_Ptr; From, To : out Track_Ptr);
function Move_To(Self: Train_Ptr; T : Track_Ptr) return Float;
function As_String(Self: Train_Ptr) return String;
function As_Verbose_String(Self: Train_Ptr) return String;
type Trains_Array is array(Integer range<>) of Train_Ptr;
type Trains_Ptr is access Trains_Array;
function New_Train (
Id : Integer;
Name : SU.Unbounded_String;
Speed : Integer;
Capacity : Integer;
Route : Route_Array) return Train_Ptr;
task type Simulation is
entry Init(S : Calendar.Time; SPH : Integer; H : Integer; M : Integer; V : Boolean);
entry Simulate(T : in Train_Ptr; C : in Connections_Ptr);
end Simulation;
type Simulation_Ptr is access Simulation;
type Time_Component_Type is
delta 1.0 digits 2 range 0.0 .. 60.0;
end Trains;
|
[
{
"context": "larations not intended for user applications\n--\n-- Chip Richards, NiEstu, Phoenix AZ, Spring 2010\n\n-- This code is",
"end": 98,
"score": 0.9995594024658203,
"start": 85,
"tag": "NAME",
"value": "Chip Richards"
},
{
"context": "ntended for user applications\n--\n-- Chip Richards, NiEstu, Phoenix AZ, Spring 2010\n\n-- This code is covered",
"end": 106,
"score": 0.9998180866241455,
"start": 100,
"tag": "NAME",
"value": "NiEstu"
},
{
"context": "overed by the ISC License:\n--\n-- Copyright © 2010, NiEstu\n--\n-- Permission to use, copy, modify, and/or dis",
"end": 207,
"score": 0.9998354315757751,
"start": 201,
"tag": "NAME",
"value": "NiEstu"
}
] | src/x11/lumen-internal.ads | darkestkhan/lumen | 8 |
-- Lumen.Internal -- Internal declarations not intended for user applications
--
-- Chip Richards, NiEstu, Phoenix AZ, Spring 2010
-- This code is covered by the ISC License:
--
-- Copyright © 2010, NiEstu
--
-- 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.
-- Environment
with System;
package Lumen.Internal is
---------------------------------------------------------------------------
-- Xlib stuff needed for our window info record
type Atom is new Long_Integer;
type Display_Pointer is new System.Address;
Null_Display_Pointer : constant Display_Pointer :=
Display_Pointer (System.Null_Address);
type Screen_Depth is new Natural;
type Screen_Number is new Natural;
type Visual_ID is new Long_Integer;
type Window_ID is new Long_Integer;
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;
type X_Visual_Info_Pointer is access all X_Visual_Info;
---------------------------------------------------------------------------
-- The GL rendering context type
type GLX_Context is new System.Address;
Null_Context : constant GLX_Context := GLX_Context (System.Null_Address);
---------------------------------------------------------------------------
-- The native window type
type Window_Internal is record
Display : Display_Pointer := Null_Display_Pointer;
Window : Window_ID := 0;
Visual : X_Visual_Info_Pointer := null;
Width : Natural := 0;
Height : Natural := 0;
Context : GLX_Context := Null_Context;
end record;
---------------------------------------------------------------------------
-- Values used to compute record rep clause values that are portable
-- between 32- and 64-bit systems
Is_32 : constant := Boolean'Pos (System.Word_Size = 32);
Is_64 : constant := 1 - Is_32;
Word_Bytes : constant := Integer'Size / System.Storage_Unit;
Word_Bits : constant := Integer'Size - 1;
Long_Bytes : constant := Long_Integer'Size / System.Storage_Unit;
Long_Bits : constant := Long_Integer'Size - 1;
---------------------------------------------------------------------------
-- The maximum length of an event data record
type Padding is array (1 .. 23) of Long_Integer;
---------------------------------------------------------------------------
end Lumen.Internal;
| 98 |
-- Lumen.Internal -- Internal declarations not intended for user applications
--
-- <NAME>, <NAME>, Phoenix AZ, Spring 2010
-- This code is covered by the ISC License:
--
-- Copyright © 2010, <NAME>
--
-- 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.
-- Environment
with System;
package Lumen.Internal is
---------------------------------------------------------------------------
-- Xlib stuff needed for our window info record
type Atom is new Long_Integer;
type Display_Pointer is new System.Address;
Null_Display_Pointer : constant Display_Pointer :=
Display_Pointer (System.Null_Address);
type Screen_Depth is new Natural;
type Screen_Number is new Natural;
type Visual_ID is new Long_Integer;
type Window_ID is new Long_Integer;
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;
type X_Visual_Info_Pointer is access all X_Visual_Info;
---------------------------------------------------------------------------
-- The GL rendering context type
type GLX_Context is new System.Address;
Null_Context : constant GLX_Context := GLX_Context (System.Null_Address);
---------------------------------------------------------------------------
-- The native window type
type Window_Internal is record
Display : Display_Pointer := Null_Display_Pointer;
Window : Window_ID := 0;
Visual : X_Visual_Info_Pointer := null;
Width : Natural := 0;
Height : Natural := 0;
Context : GLX_Context := Null_Context;
end record;
---------------------------------------------------------------------------
-- Values used to compute record rep clause values that are portable
-- between 32- and 64-bit systems
Is_32 : constant := Boolean'Pos (System.Word_Size = 32);
Is_64 : constant := 1 - Is_32;
Word_Bytes : constant := Integer'Size / System.Storage_Unit;
Word_Bits : constant := Integer'Size - 1;
Long_Bytes : constant := Long_Integer'Size / System.Storage_Unit;
Long_Bits : constant := Long_Integer'Size - 1;
---------------------------------------------------------------------------
-- The maximum length of an event data record
type Padding is array (1 .. 23) of Long_Integer;
---------------------------------------------------------------------------
end Lumen.Internal;
| true |
-- Lumen.Internal -- Internal declarations not intended for user applications
--
-- PI:NAME:<NAME>END_PI, PI:NAME:<NAME>END_PI, Phoenix AZ, Spring 2010
-- This code is covered by the ISC License:
--
-- Copyright © 2010, PI:NAME:<NAME>END_PI
--
-- 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.
-- Environment
with System;
package Lumen.Internal is
---------------------------------------------------------------------------
-- Xlib stuff needed for our window info record
type Atom is new Long_Integer;
type Display_Pointer is new System.Address;
Null_Display_Pointer : constant Display_Pointer :=
Display_Pointer (System.Null_Address);
type Screen_Depth is new Natural;
type Screen_Number is new Natural;
type Visual_ID is new Long_Integer;
type Window_ID is new Long_Integer;
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;
type X_Visual_Info_Pointer is access all X_Visual_Info;
---------------------------------------------------------------------------
-- The GL rendering context type
type GLX_Context is new System.Address;
Null_Context : constant GLX_Context := GLX_Context (System.Null_Address);
---------------------------------------------------------------------------
-- The native window type
type Window_Internal is record
Display : Display_Pointer := Null_Display_Pointer;
Window : Window_ID := 0;
Visual : X_Visual_Info_Pointer := null;
Width : Natural := 0;
Height : Natural := 0;
Context : GLX_Context := Null_Context;
end record;
---------------------------------------------------------------------------
-- Values used to compute record rep clause values that are portable
-- between 32- and 64-bit systems
Is_32 : constant := Boolean'Pos (System.Word_Size = 32);
Is_64 : constant := 1 - Is_32;
Word_Bytes : constant := Integer'Size / System.Storage_Unit;
Word_Bits : constant := Integer'Size - 1;
Long_Bytes : constant := Long_Integer'Size / System.Storage_Unit;
Long_Bits : constant := Long_Integer'Size - 1;
---------------------------------------------------------------------------
-- The maximum length of an event data record
type Padding is array (1 .. 23) of Long_Integer;
---------------------------------------------------------------------------
end Lumen.Internal;
|
[
{
"context": " library specification\n-- Copyright (c) 2003-2018 Maxim Reznik <reznikmm@gmail.com>\n-- Copyright (c) 2004-2016 ",
"end": 97,
"score": 0.9997886419296265,
"start": 85,
"tag": "NAME",
"value": "Maxim Reznik"
},
{
"context": "ication\n-- Copyright (c) 2003-2018 Maxim Reznik <reznikmm@gmail.com>\n-- Copyright (c) 2004-2016 AXE Consultants\n-- ",
"end": 117,
"score": 0.9999309778213501,
"start": 99,
"tag": "EMAIL",
"value": "reznikmm@gmail.com"
}
] | ada-io_exceptions.ads | mgrojo/adalib | 15 | -- Standard Ada library specification
-- Copyright (c) 2003-2018 Maxim Reznik <reznikmm@gmail.com>
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
package Ada.IO_Exceptions is
pragma Pure (IO_Exceptions);
Status_Error : exception;
Mode_Error : exception;
Name_Error : exception;
Use_Error : exception;
Device_Error : exception;
End_Error : exception;
Data_Error : exception;
Layout_Error : exception;
end Ada.IO_Exceptions;
| 24614 | -- Standard Ada library specification
-- Copyright (c) 2003-2018 <NAME> <<EMAIL>>
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
package Ada.IO_Exceptions is
pragma Pure (IO_Exceptions);
Status_Error : exception;
Mode_Error : exception;
Name_Error : exception;
Use_Error : exception;
Device_Error : exception;
End_Error : exception;
Data_Error : exception;
Layout_Error : exception;
end Ada.IO_Exceptions;
| true | -- Standard Ada library specification
-- Copyright (c) 2003-2018 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
package Ada.IO_Exceptions is
pragma Pure (IO_Exceptions);
Status_Error : exception;
Mode_Error : exception;
Name_Error : exception;
Use_Error : exception;
Device_Error : exception;
End_Error : exception;
Data_Error : exception;
Layout_Error : exception;
end Ada.IO_Exceptions;
|
[
{
"context": "----------\n-- MIT License\n--\n-- Copyright (c) 2021 Zane Myers\n--\n-- Permission is hereby granted, free of charg",
"end": 131,
"score": 0.9997740983963013,
"start": 121,
"tag": "NAME",
"value": "Zane Myers"
}
] | test/dmat/vulkan-math-dmat4x3-test.adb | zrmyers/VulkanAda | 1 | --------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2021 Zane Myers
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--------------------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Characters.Latin_1;
with Vulkan.Test.Framework;
with Vulkan.Math.GenDMatrix;
with Vulkan.Math.Dmat4x3;
with Vulkan.Math.Dmat2x2;
with Vulkan.Math.Dmat2x4;
with Vulkan.Math.GenDType;
with Vulkan.Math.Dvec4;
with Vulkan.Math.Dvec3;
use Ada.Text_IO;
use Ada.Characters.Latin_1;
use Vulkan.Math.Dmat2x2;
use Vulkan.Math.Dmat4x3;
use Vulkan.Math.Dmat2x4;
use Vulkan.Math.GenDType;
use Vulkan.Math.Dvec4;
use Vulkan.Math.Dvec3;
use Vulkan.Test.Framework;
--------------------------------------------------------------------------------
--< @group Vulkan Math Basic Types
--------------------------------------------------------------------------------
--< @summary
--< This package provides tests for single precision floating point mat4x3.
--------------------------------------------------------------------------------
package body Vulkan.Math.Dmat4x3.Test is
-- Test Mat4x3
procedure Test_Dmat4x3 is
vec1 : Vkm_Dvec4 :=
Make_Dvec4(1.0, 2.0, 3.0, 4.0);
vec2 : Vkm_Dvec3 :=
Make_Dvec3(1.0, 2.0, 3.0);
mat1 : Vkm_Dmat4x3 :=
Make_Dmat4x3;
mat2 : Vkm_Dmat4x3 :=
Make_Dmat4x3(0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
mat3 : Vkm_Dmat4x3 :=
Make_Dmat4x3(vec2, - vec2, 2.0 * vec2, -2.0 * vec2);
mat4 : Vkm_Dmat4x3 :=
Make_Dmat4x3(mat2);
mat5 : Vkm_Dmat2x2 :=
Make_Dmat2x2(5.0);
mat6 : Vkm_Dmat4x3 :=
Make_Dmat4x3(mat5);
mat7 : Vkm_Dmat2x4 :=
Make_Dmat2x4( 1.0, -1.0, 0.5, 1.5,
-1.0, 2.0, 1.0, 1.0);
begin
Put_Line(LF & "Testing Mat4x3 Constructors...");
Put_Line("mat1 " & mat1.Image);
Assert_Dmat4x3_Equals(mat1, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0);
Put_Line("mat2 " & mat2.Image);
Assert_Dmat4x3_Equals(mat2, 0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
Put_Line("mat3 " & mat3.Image);
Assert_Dmat4x3_Equals(mat3, 1.0, 2.0, 3.0,
-1.0, -2.0, -3.0,
2.0, 4.0, 6.0,
-2.0, -4.0, -6.0);
Put_Line("mat4 " & mat4.Image);
Assert_Dmat4x3_Equals(mat4, 0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
Put_Line("mat6 " & mat6.Image);
Assert_Dmat4x3_Equals(mat6, 5.0, 0.0, 0.0,
0.0, 5.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0);
Put_Line("Testing '=' operator...");
Put_Line(" mat2 != mat3");
Assert_Vkm_Bool_Equals(mat2 = mat3, False);
Put_Line(" mat4 != mat5");
Assert_Vkm_Bool_Equals(mat4 = mat5, False);
Put_Line(" mat4 = mat2");
Assert_Vkm_Bool_Equals(mat4 = mat2, True);
Put_Line(" Testing unary '+/-' operator");
Put_Line(" + mat4 = " & Image(+ mat4));
Assert_Dmat4x3_Equals(+mat4, 0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
Put_Line(" - mat4 = " & Image(- mat4));
Assert_Dmat4x3_Equals(-mat4, 0.0, -1.0, -2.0,
-3.0, -4.0, -5.0,
-6.0, -7.0, -8.0,
-9.0, -10.0, -11.0);
Put_Line("+(- mat4) = " & Image(+(- mat4)));
Assert_Dmat4x3_Equals(+(-mat4), 0.0, -1.0, -2.0,
-3.0, -4.0, -5.0,
-6.0, -7.0, -8.0,
-9.0, -10.0, -11.0);
Put_Line("Testing 'abs' operator...");
Put_Line(" abs(- mat4) = " & Image(abs(-mat4)));
Assert_Dmat4x3_Equals(abs(-mat4), 0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
Put_Line("Testing '+' operator...");
Put_Line(" mat4 + mat3 = " & Image(mat4 + mat3));
Assert_Dmat4x3_Equals(mat4 + mat3, 1.0, 3.0, 5.0,
2.0, 2.0, 2.0,
8.0, 11.0, 14.0,
7.0, 6.0, 5.0);
Put_Line("Testing '-' operator...");
Put_Line(" mat4 - mat3 = " & Image(mat4 -mat3));
Assert_Dmat4x3_Equals(mat4 - mat3, -1.0, -1.0, -1.0,
4.0, 6.0, 8.0,
4.0, 3.0, 2.0,
11.0, 14.0, 17.0);
Put_Line("Testing '*' operator...");
Put_Line(" mat7 * mat4 = " & Image(mat7 * mat4));
Assert_Dmat2x3_Equals(mat7 * mat4, 13.5, 15.5, 17.5,
21.0, 24.0, 27.0);
Put_Line(" mat4 * vec2 = " & Image(mat4 * vec2));
Assert_Dvec4_Equals(mat4 * vec2, 8.0, 26.0, 44.0, 62.0);
Put_Line(" vec1 * mat4 = " & Image(vec1 * mat4));
Assert_Dvec3_Equals(vec1 * mat4, 60.0, 70.0, 80.0);
end Test_Dmat4x3;
end Vulkan.Math.Dmat4x3.Test;
| 28465 | --------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2021 <NAME>
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--------------------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Characters.Latin_1;
with Vulkan.Test.Framework;
with Vulkan.Math.GenDMatrix;
with Vulkan.Math.Dmat4x3;
with Vulkan.Math.Dmat2x2;
with Vulkan.Math.Dmat2x4;
with Vulkan.Math.GenDType;
with Vulkan.Math.Dvec4;
with Vulkan.Math.Dvec3;
use Ada.Text_IO;
use Ada.Characters.Latin_1;
use Vulkan.Math.Dmat2x2;
use Vulkan.Math.Dmat4x3;
use Vulkan.Math.Dmat2x4;
use Vulkan.Math.GenDType;
use Vulkan.Math.Dvec4;
use Vulkan.Math.Dvec3;
use Vulkan.Test.Framework;
--------------------------------------------------------------------------------
--< @group Vulkan Math Basic Types
--------------------------------------------------------------------------------
--< @summary
--< This package provides tests for single precision floating point mat4x3.
--------------------------------------------------------------------------------
package body Vulkan.Math.Dmat4x3.Test is
-- Test Mat4x3
procedure Test_Dmat4x3 is
vec1 : Vkm_Dvec4 :=
Make_Dvec4(1.0, 2.0, 3.0, 4.0);
vec2 : Vkm_Dvec3 :=
Make_Dvec3(1.0, 2.0, 3.0);
mat1 : Vkm_Dmat4x3 :=
Make_Dmat4x3;
mat2 : Vkm_Dmat4x3 :=
Make_Dmat4x3(0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
mat3 : Vkm_Dmat4x3 :=
Make_Dmat4x3(vec2, - vec2, 2.0 * vec2, -2.0 * vec2);
mat4 : Vkm_Dmat4x3 :=
Make_Dmat4x3(mat2);
mat5 : Vkm_Dmat2x2 :=
Make_Dmat2x2(5.0);
mat6 : Vkm_Dmat4x3 :=
Make_Dmat4x3(mat5);
mat7 : Vkm_Dmat2x4 :=
Make_Dmat2x4( 1.0, -1.0, 0.5, 1.5,
-1.0, 2.0, 1.0, 1.0);
begin
Put_Line(LF & "Testing Mat4x3 Constructors...");
Put_Line("mat1 " & mat1.Image);
Assert_Dmat4x3_Equals(mat1, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0);
Put_Line("mat2 " & mat2.Image);
Assert_Dmat4x3_Equals(mat2, 0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
Put_Line("mat3 " & mat3.Image);
Assert_Dmat4x3_Equals(mat3, 1.0, 2.0, 3.0,
-1.0, -2.0, -3.0,
2.0, 4.0, 6.0,
-2.0, -4.0, -6.0);
Put_Line("mat4 " & mat4.Image);
Assert_Dmat4x3_Equals(mat4, 0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
Put_Line("mat6 " & mat6.Image);
Assert_Dmat4x3_Equals(mat6, 5.0, 0.0, 0.0,
0.0, 5.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0);
Put_Line("Testing '=' operator...");
Put_Line(" mat2 != mat3");
Assert_Vkm_Bool_Equals(mat2 = mat3, False);
Put_Line(" mat4 != mat5");
Assert_Vkm_Bool_Equals(mat4 = mat5, False);
Put_Line(" mat4 = mat2");
Assert_Vkm_Bool_Equals(mat4 = mat2, True);
Put_Line(" Testing unary '+/-' operator");
Put_Line(" + mat4 = " & Image(+ mat4));
Assert_Dmat4x3_Equals(+mat4, 0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
Put_Line(" - mat4 = " & Image(- mat4));
Assert_Dmat4x3_Equals(-mat4, 0.0, -1.0, -2.0,
-3.0, -4.0, -5.0,
-6.0, -7.0, -8.0,
-9.0, -10.0, -11.0);
Put_Line("+(- mat4) = " & Image(+(- mat4)));
Assert_Dmat4x3_Equals(+(-mat4), 0.0, -1.0, -2.0,
-3.0, -4.0, -5.0,
-6.0, -7.0, -8.0,
-9.0, -10.0, -11.0);
Put_Line("Testing 'abs' operator...");
Put_Line(" abs(- mat4) = " & Image(abs(-mat4)));
Assert_Dmat4x3_Equals(abs(-mat4), 0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
Put_Line("Testing '+' operator...");
Put_Line(" mat4 + mat3 = " & Image(mat4 + mat3));
Assert_Dmat4x3_Equals(mat4 + mat3, 1.0, 3.0, 5.0,
2.0, 2.0, 2.0,
8.0, 11.0, 14.0,
7.0, 6.0, 5.0);
Put_Line("Testing '-' operator...");
Put_Line(" mat4 - mat3 = " & Image(mat4 -mat3));
Assert_Dmat4x3_Equals(mat4 - mat3, -1.0, -1.0, -1.0,
4.0, 6.0, 8.0,
4.0, 3.0, 2.0,
11.0, 14.0, 17.0);
Put_Line("Testing '*' operator...");
Put_Line(" mat7 * mat4 = " & Image(mat7 * mat4));
Assert_Dmat2x3_Equals(mat7 * mat4, 13.5, 15.5, 17.5,
21.0, 24.0, 27.0);
Put_Line(" mat4 * vec2 = " & Image(mat4 * vec2));
Assert_Dvec4_Equals(mat4 * vec2, 8.0, 26.0, 44.0, 62.0);
Put_Line(" vec1 * mat4 = " & Image(vec1 * mat4));
Assert_Dvec3_Equals(vec1 * mat4, 60.0, 70.0, 80.0);
end Test_Dmat4x3;
end Vulkan.Math.Dmat4x3.Test;
| true | --------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2021 PI:NAME:<NAME>END_PI
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--------------------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Characters.Latin_1;
with Vulkan.Test.Framework;
with Vulkan.Math.GenDMatrix;
with Vulkan.Math.Dmat4x3;
with Vulkan.Math.Dmat2x2;
with Vulkan.Math.Dmat2x4;
with Vulkan.Math.GenDType;
with Vulkan.Math.Dvec4;
with Vulkan.Math.Dvec3;
use Ada.Text_IO;
use Ada.Characters.Latin_1;
use Vulkan.Math.Dmat2x2;
use Vulkan.Math.Dmat4x3;
use Vulkan.Math.Dmat2x4;
use Vulkan.Math.GenDType;
use Vulkan.Math.Dvec4;
use Vulkan.Math.Dvec3;
use Vulkan.Test.Framework;
--------------------------------------------------------------------------------
--< @group Vulkan Math Basic Types
--------------------------------------------------------------------------------
--< @summary
--< This package provides tests for single precision floating point mat4x3.
--------------------------------------------------------------------------------
package body Vulkan.Math.Dmat4x3.Test is
-- Test Mat4x3
procedure Test_Dmat4x3 is
vec1 : Vkm_Dvec4 :=
Make_Dvec4(1.0, 2.0, 3.0, 4.0);
vec2 : Vkm_Dvec3 :=
Make_Dvec3(1.0, 2.0, 3.0);
mat1 : Vkm_Dmat4x3 :=
Make_Dmat4x3;
mat2 : Vkm_Dmat4x3 :=
Make_Dmat4x3(0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
mat3 : Vkm_Dmat4x3 :=
Make_Dmat4x3(vec2, - vec2, 2.0 * vec2, -2.0 * vec2);
mat4 : Vkm_Dmat4x3 :=
Make_Dmat4x3(mat2);
mat5 : Vkm_Dmat2x2 :=
Make_Dmat2x2(5.0);
mat6 : Vkm_Dmat4x3 :=
Make_Dmat4x3(mat5);
mat7 : Vkm_Dmat2x4 :=
Make_Dmat2x4( 1.0, -1.0, 0.5, 1.5,
-1.0, 2.0, 1.0, 1.0);
begin
Put_Line(LF & "Testing Mat4x3 Constructors...");
Put_Line("mat1 " & mat1.Image);
Assert_Dmat4x3_Equals(mat1, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0);
Put_Line("mat2 " & mat2.Image);
Assert_Dmat4x3_Equals(mat2, 0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
Put_Line("mat3 " & mat3.Image);
Assert_Dmat4x3_Equals(mat3, 1.0, 2.0, 3.0,
-1.0, -2.0, -3.0,
2.0, 4.0, 6.0,
-2.0, -4.0, -6.0);
Put_Line("mat4 " & mat4.Image);
Assert_Dmat4x3_Equals(mat4, 0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
Put_Line("mat6 " & mat6.Image);
Assert_Dmat4x3_Equals(mat6, 5.0, 0.0, 0.0,
0.0, 5.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0);
Put_Line("Testing '=' operator...");
Put_Line(" mat2 != mat3");
Assert_Vkm_Bool_Equals(mat2 = mat3, False);
Put_Line(" mat4 != mat5");
Assert_Vkm_Bool_Equals(mat4 = mat5, False);
Put_Line(" mat4 = mat2");
Assert_Vkm_Bool_Equals(mat4 = mat2, True);
Put_Line(" Testing unary '+/-' operator");
Put_Line(" + mat4 = " & Image(+ mat4));
Assert_Dmat4x3_Equals(+mat4, 0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
Put_Line(" - mat4 = " & Image(- mat4));
Assert_Dmat4x3_Equals(-mat4, 0.0, -1.0, -2.0,
-3.0, -4.0, -5.0,
-6.0, -7.0, -8.0,
-9.0, -10.0, -11.0);
Put_Line("+(- mat4) = " & Image(+(- mat4)));
Assert_Dmat4x3_Equals(+(-mat4), 0.0, -1.0, -2.0,
-3.0, -4.0, -5.0,
-6.0, -7.0, -8.0,
-9.0, -10.0, -11.0);
Put_Line("Testing 'abs' operator...");
Put_Line(" abs(- mat4) = " & Image(abs(-mat4)));
Assert_Dmat4x3_Equals(abs(-mat4), 0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
Put_Line("Testing '+' operator...");
Put_Line(" mat4 + mat3 = " & Image(mat4 + mat3));
Assert_Dmat4x3_Equals(mat4 + mat3, 1.0, 3.0, 5.0,
2.0, 2.0, 2.0,
8.0, 11.0, 14.0,
7.0, 6.0, 5.0);
Put_Line("Testing '-' operator...");
Put_Line(" mat4 - mat3 = " & Image(mat4 -mat3));
Assert_Dmat4x3_Equals(mat4 - mat3, -1.0, -1.0, -1.0,
4.0, 6.0, 8.0,
4.0, 3.0, 2.0,
11.0, 14.0, 17.0);
Put_Line("Testing '*' operator...");
Put_Line(" mat7 * mat4 = " & Image(mat7 * mat4));
Assert_Dmat2x3_Equals(mat7 * mat4, 13.5, 15.5, 17.5,
21.0, 24.0, 27.0);
Put_Line(" mat4 * vec2 = " & Image(mat4 * vec2));
Assert_Dvec4_Equals(mat4 * vec2, 8.0, 26.0, 44.0, 62.0);
Put_Line(" vec1 * mat4 = " & Image(vec1 * mat4));
Assert_Dvec3_Equals(vec1 * mat4, 60.0, 70.0, 80.0);
end Test_Dmat4x3;
end Vulkan.Math.Dmat4x3.Test;
|
[
{
"context": "-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifi",
"end": 43,
"score": 0.9998590350151062,
"start": 33,
"tag": "NAME",
"value": "Max Reznik"
},
{
"context": "-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifier: MIT\n------------",
"end": 63,
"score": 0.9999312162399292,
"start": 45,
"tag": "EMAIL",
"value": "reznikmm@gmail.com"
}
] | source/nodes/program-nodes-protected_definitions.ads | reznikmm/gela | 0 | -- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Element_Vectors;
with Program.Lexical_Elements;
with Program.Elements.Identifiers;
with Program.Elements.Protected_Definitions;
with Program.Element_Visitors;
package Program.Nodes.Protected_Definitions is
pragma Preelaborate;
type Protected_Definition is
new Program.Nodes.Node
and Program.Elements.Protected_Definitions.Protected_Definition
and Program.Elements.Protected_Definitions.Protected_Definition_Text
with private;
function Create
(Visible_Declarations : Program.Element_Vectors.Element_Vector_Access;
Private_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Private_Declarations : Program.Element_Vectors.Element_Vector_Access;
End_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
End_Name : Program.Elements.Identifiers.Identifier_Access)
return Protected_Definition;
type Implicit_Protected_Definition is
new Program.Nodes.Node
and Program.Elements.Protected_Definitions.Protected_Definition
with private;
function Create
(Visible_Declarations : Program.Element_Vectors.Element_Vector_Access;
Private_Declarations : Program.Element_Vectors.Element_Vector_Access;
End_Name : Program.Elements.Identifiers.Identifier_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Protected_Definition
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Protected_Definition is
abstract new Program.Nodes.Node
and Program.Elements.Protected_Definitions.Protected_Definition
with record
Visible_Declarations : Program.Element_Vectors.Element_Vector_Access;
Private_Declarations : Program.Element_Vectors.Element_Vector_Access;
End_Name : Program.Elements.Identifiers.Identifier_Access;
end record;
procedure Initialize (Self : in out Base_Protected_Definition'Class);
overriding procedure Visit
(Self : not null access Base_Protected_Definition;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Visible_Declarations
(Self : Base_Protected_Definition)
return Program.Element_Vectors.Element_Vector_Access;
overriding function Private_Declarations
(Self : Base_Protected_Definition)
return Program.Element_Vectors.Element_Vector_Access;
overriding function End_Name
(Self : Base_Protected_Definition)
return Program.Elements.Identifiers.Identifier_Access;
overriding function Is_Protected_Definition
(Self : Base_Protected_Definition)
return Boolean;
overriding function Is_Definition
(Self : Base_Protected_Definition)
return Boolean;
type Protected_Definition is
new Base_Protected_Definition
and Program.Elements.Protected_Definitions.Protected_Definition_Text
with record
Private_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
End_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Protected_Definition_Text
(Self : in out Protected_Definition)
return Program.Elements.Protected_Definitions
.Protected_Definition_Text_Access;
overriding function Private_Token
(Self : Protected_Definition)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function End_Token
(Self : Protected_Definition)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Protected_Definition is
new Base_Protected_Definition
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Protected_Definition_Text
(Self : in out Implicit_Protected_Definition)
return Program.Elements.Protected_Definitions
.Protected_Definition_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Protected_Definition)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Protected_Definition)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Protected_Definition)
return Boolean;
end Program.Nodes.Protected_Definitions;
| 4540 | -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Element_Vectors;
with Program.Lexical_Elements;
with Program.Elements.Identifiers;
with Program.Elements.Protected_Definitions;
with Program.Element_Visitors;
package Program.Nodes.Protected_Definitions is
pragma Preelaborate;
type Protected_Definition is
new Program.Nodes.Node
and Program.Elements.Protected_Definitions.Protected_Definition
and Program.Elements.Protected_Definitions.Protected_Definition_Text
with private;
function Create
(Visible_Declarations : Program.Element_Vectors.Element_Vector_Access;
Private_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Private_Declarations : Program.Element_Vectors.Element_Vector_Access;
End_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
End_Name : Program.Elements.Identifiers.Identifier_Access)
return Protected_Definition;
type Implicit_Protected_Definition is
new Program.Nodes.Node
and Program.Elements.Protected_Definitions.Protected_Definition
with private;
function Create
(Visible_Declarations : Program.Element_Vectors.Element_Vector_Access;
Private_Declarations : Program.Element_Vectors.Element_Vector_Access;
End_Name : Program.Elements.Identifiers.Identifier_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Protected_Definition
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Protected_Definition is
abstract new Program.Nodes.Node
and Program.Elements.Protected_Definitions.Protected_Definition
with record
Visible_Declarations : Program.Element_Vectors.Element_Vector_Access;
Private_Declarations : Program.Element_Vectors.Element_Vector_Access;
End_Name : Program.Elements.Identifiers.Identifier_Access;
end record;
procedure Initialize (Self : in out Base_Protected_Definition'Class);
overriding procedure Visit
(Self : not null access Base_Protected_Definition;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Visible_Declarations
(Self : Base_Protected_Definition)
return Program.Element_Vectors.Element_Vector_Access;
overriding function Private_Declarations
(Self : Base_Protected_Definition)
return Program.Element_Vectors.Element_Vector_Access;
overriding function End_Name
(Self : Base_Protected_Definition)
return Program.Elements.Identifiers.Identifier_Access;
overriding function Is_Protected_Definition
(Self : Base_Protected_Definition)
return Boolean;
overriding function Is_Definition
(Self : Base_Protected_Definition)
return Boolean;
type Protected_Definition is
new Base_Protected_Definition
and Program.Elements.Protected_Definitions.Protected_Definition_Text
with record
Private_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
End_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Protected_Definition_Text
(Self : in out Protected_Definition)
return Program.Elements.Protected_Definitions
.Protected_Definition_Text_Access;
overriding function Private_Token
(Self : Protected_Definition)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function End_Token
(Self : Protected_Definition)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Protected_Definition is
new Base_Protected_Definition
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Protected_Definition_Text
(Self : in out Implicit_Protected_Definition)
return Program.Elements.Protected_Definitions
.Protected_Definition_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Protected_Definition)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Protected_Definition)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Protected_Definition)
return Boolean;
end Program.Nodes.Protected_Definitions;
| true | -- SPDX-FileCopyrightText: 2019 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Element_Vectors;
with Program.Lexical_Elements;
with Program.Elements.Identifiers;
with Program.Elements.Protected_Definitions;
with Program.Element_Visitors;
package Program.Nodes.Protected_Definitions is
pragma Preelaborate;
type Protected_Definition is
new Program.Nodes.Node
and Program.Elements.Protected_Definitions.Protected_Definition
and Program.Elements.Protected_Definitions.Protected_Definition_Text
with private;
function Create
(Visible_Declarations : Program.Element_Vectors.Element_Vector_Access;
Private_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Private_Declarations : Program.Element_Vectors.Element_Vector_Access;
End_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
End_Name : Program.Elements.Identifiers.Identifier_Access)
return Protected_Definition;
type Implicit_Protected_Definition is
new Program.Nodes.Node
and Program.Elements.Protected_Definitions.Protected_Definition
with private;
function Create
(Visible_Declarations : Program.Element_Vectors.Element_Vector_Access;
Private_Declarations : Program.Element_Vectors.Element_Vector_Access;
End_Name : Program.Elements.Identifiers.Identifier_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Protected_Definition
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Protected_Definition is
abstract new Program.Nodes.Node
and Program.Elements.Protected_Definitions.Protected_Definition
with record
Visible_Declarations : Program.Element_Vectors.Element_Vector_Access;
Private_Declarations : Program.Element_Vectors.Element_Vector_Access;
End_Name : Program.Elements.Identifiers.Identifier_Access;
end record;
procedure Initialize (Self : in out Base_Protected_Definition'Class);
overriding procedure Visit
(Self : not null access Base_Protected_Definition;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Visible_Declarations
(Self : Base_Protected_Definition)
return Program.Element_Vectors.Element_Vector_Access;
overriding function Private_Declarations
(Self : Base_Protected_Definition)
return Program.Element_Vectors.Element_Vector_Access;
overriding function End_Name
(Self : Base_Protected_Definition)
return Program.Elements.Identifiers.Identifier_Access;
overriding function Is_Protected_Definition
(Self : Base_Protected_Definition)
return Boolean;
overriding function Is_Definition
(Self : Base_Protected_Definition)
return Boolean;
type Protected_Definition is
new Base_Protected_Definition
and Program.Elements.Protected_Definitions.Protected_Definition_Text
with record
Private_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
End_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Protected_Definition_Text
(Self : in out Protected_Definition)
return Program.Elements.Protected_Definitions
.Protected_Definition_Text_Access;
overriding function Private_Token
(Self : Protected_Definition)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function End_Token
(Self : Protected_Definition)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Protected_Definition is
new Base_Protected_Definition
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Protected_Definition_Text
(Self : in out Implicit_Protected_Definition)
return Program.Elements.Protected_Definitions
.Protected_Definition_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Protected_Definition)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Protected_Definition)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Protected_Definition)
return Boolean;
end Program.Nodes.Protected_Definitions;
|
[
{
"context": "--------------------------------\n-- Copyright 2020 Thomas E. Dickey --\n-- Co",
"end": 745,
"score": 0.9998407363891602,
"start": 729,
"tag": "NAME",
"value": "Thomas E. Dickey"
},
{
"context": "-------------------------------------\n-- Author: Juergen Pfeifer, 1996\n-- Version Control:\n-- $Revision: 1.21 $\n",
"end": 2872,
"score": 0.9998758435249329,
"start": 2857,
"tag": "NAME",
"value": "Juergen Pfeifer"
}
] | Ada95/src/terminal_interface-curses-forms-field_types-user-choice.adb | ProtonAOSP-platina/android_external_libncurses | 269 | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Forms.Field_Types.User.Choice --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright 2020 Thomas E. Dickey --
-- Copyright 1999-2011,2014 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision: 1.21 $
-- $Date: 2020/02/02 23:34:34 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with System.Address_To_Access_Conversions;
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
package body Terminal_Interface.Curses.Forms.Field_Types.User.Choice is
package Argument_Conversions is
new System.Address_To_Access_Conversions (Argument);
function Generic_Next (Fld : Field;
Usr : System.Address) return Curses_Bool
is
Result : Boolean;
Udf : constant User_Defined_Field_Type_With_Choice_Access :=
User_Defined_Field_Type_With_Choice_Access
(Argument_Access (Argument_Conversions.To_Pointer (Usr)).all.Typ);
begin
Result := Next (Fld, Udf.all);
return Curses_Bool (Boolean'Pos (Result));
end Generic_Next;
function Generic_Prev (Fld : Field;
Usr : System.Address) return Curses_Bool
is
Result : Boolean;
Udf : constant User_Defined_Field_Type_With_Choice_Access :=
User_Defined_Field_Type_With_Choice_Access
(Argument_Access (Argument_Conversions.To_Pointer (Usr)).all.Typ);
begin
Result := Previous (Fld, Udf.all);
return Curses_Bool (Boolean'Pos (Result));
end Generic_Prev;
-- -----------------------------------------------------------------------
--
function C_Generic_Choice return C_Field_Type
is
Res : Eti_Error;
T : C_Field_Type;
begin
if M_Generic_Choice = Null_Field_Type then
T := New_Fieldtype (Generic_Field_Check'Access,
Generic_Char_Check'Access);
if T = Null_Field_Type then
raise Form_Exception;
else
Res := Set_Fieldtype_Arg (T,
Make_Arg'Access,
Copy_Arg'Access,
Free_Arg'Access);
Eti_Exception (Res);
Res := Set_Fieldtype_Choice (T,
Generic_Next'Access,
Generic_Prev'Access);
Eti_Exception (Res);
end if;
M_Generic_Choice := T;
end if;
pragma Assert (M_Generic_Choice /= Null_Field_Type);
return M_Generic_Choice;
end C_Generic_Choice;
end Terminal_Interface.Curses.Forms.Field_Types.User.Choice;
| 8927 | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Forms.Field_Types.User.Choice --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright 2020 <NAME> --
-- Copyright 1999-2011,2014 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: <NAME>, 1996
-- Version Control:
-- $Revision: 1.21 $
-- $Date: 2020/02/02 23:34:34 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with System.Address_To_Access_Conversions;
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
package body Terminal_Interface.Curses.Forms.Field_Types.User.Choice is
package Argument_Conversions is
new System.Address_To_Access_Conversions (Argument);
function Generic_Next (Fld : Field;
Usr : System.Address) return Curses_Bool
is
Result : Boolean;
Udf : constant User_Defined_Field_Type_With_Choice_Access :=
User_Defined_Field_Type_With_Choice_Access
(Argument_Access (Argument_Conversions.To_Pointer (Usr)).all.Typ);
begin
Result := Next (Fld, Udf.all);
return Curses_Bool (Boolean'Pos (Result));
end Generic_Next;
function Generic_Prev (Fld : Field;
Usr : System.Address) return Curses_Bool
is
Result : Boolean;
Udf : constant User_Defined_Field_Type_With_Choice_Access :=
User_Defined_Field_Type_With_Choice_Access
(Argument_Access (Argument_Conversions.To_Pointer (Usr)).all.Typ);
begin
Result := Previous (Fld, Udf.all);
return Curses_Bool (Boolean'Pos (Result));
end Generic_Prev;
-- -----------------------------------------------------------------------
--
function C_Generic_Choice return C_Field_Type
is
Res : Eti_Error;
T : C_Field_Type;
begin
if M_Generic_Choice = Null_Field_Type then
T := New_Fieldtype (Generic_Field_Check'Access,
Generic_Char_Check'Access);
if T = Null_Field_Type then
raise Form_Exception;
else
Res := Set_Fieldtype_Arg (T,
Make_Arg'Access,
Copy_Arg'Access,
Free_Arg'Access);
Eti_Exception (Res);
Res := Set_Fieldtype_Choice (T,
Generic_Next'Access,
Generic_Prev'Access);
Eti_Exception (Res);
end if;
M_Generic_Choice := T;
end if;
pragma Assert (M_Generic_Choice /= Null_Field_Type);
return M_Generic_Choice;
end C_Generic_Choice;
end Terminal_Interface.Curses.Forms.Field_Types.User.Choice;
| true | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Forms.Field_Types.User.Choice --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright 2020 PI:NAME:<NAME>END_PI --
-- Copyright 1999-2011,2014 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: PI:NAME:<NAME>END_PI, 1996
-- Version Control:
-- $Revision: 1.21 $
-- $Date: 2020/02/02 23:34:34 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with System.Address_To_Access_Conversions;
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
package body Terminal_Interface.Curses.Forms.Field_Types.User.Choice is
package Argument_Conversions is
new System.Address_To_Access_Conversions (Argument);
function Generic_Next (Fld : Field;
Usr : System.Address) return Curses_Bool
is
Result : Boolean;
Udf : constant User_Defined_Field_Type_With_Choice_Access :=
User_Defined_Field_Type_With_Choice_Access
(Argument_Access (Argument_Conversions.To_Pointer (Usr)).all.Typ);
begin
Result := Next (Fld, Udf.all);
return Curses_Bool (Boolean'Pos (Result));
end Generic_Next;
function Generic_Prev (Fld : Field;
Usr : System.Address) return Curses_Bool
is
Result : Boolean;
Udf : constant User_Defined_Field_Type_With_Choice_Access :=
User_Defined_Field_Type_With_Choice_Access
(Argument_Access (Argument_Conversions.To_Pointer (Usr)).all.Typ);
begin
Result := Previous (Fld, Udf.all);
return Curses_Bool (Boolean'Pos (Result));
end Generic_Prev;
-- -----------------------------------------------------------------------
--
function C_Generic_Choice return C_Field_Type
is
Res : Eti_Error;
T : C_Field_Type;
begin
if M_Generic_Choice = Null_Field_Type then
T := New_Fieldtype (Generic_Field_Check'Access,
Generic_Char_Check'Access);
if T = Null_Field_Type then
raise Form_Exception;
else
Res := Set_Fieldtype_Arg (T,
Make_Arg'Access,
Copy_Arg'Access,
Free_Arg'Access);
Eti_Exception (Res);
Res := Set_Fieldtype_Choice (T,
Generic_Next'Access,
Generic_Prev'Access);
Eti_Exception (Res);
end if;
M_Generic_Choice := T;
end if;
pragma Assert (M_Generic_Choice /= Null_Field_Type);
return M_Generic_Choice;
end C_Generic_Choice;
end Terminal_Interface.Curses.Forms.Field_Types.User.Choice;
|
[
{
"context": " --\n-- Copyright (C) 2001 A.M.F.Vargas --\n-- Antonio M",
"end": 266,
"score": 0.9998714923858643,
"start": 254,
"tag": "NAME",
"value": "A.M.F.Vargas"
},
{
"context": "M.F.Vargas --\n-- Antonio M. F. Vargas --\n-- ",
"end": 327,
"score": 0.9998727440834045,
"start": 307,
"tag": "NAME",
"value": "Antonio M. F. Vargas"
},
{
"context": " --\n-- Ponta Delgada - Azores - Portugal --\n-- ",
"end": 389,
"score": 0.5144278407096863,
"start": 388,
"tag": "NAME",
"value": "g"
},
{
"context": " --\n-- http://www.adapower.net/~avargas --\n-- E-mail: av",
"end": 483,
"score": 0.6127126216888428,
"start": 476,
"tag": "USERNAME",
"value": "avargas"
},
{
"context": "gas --\n-- E-mail: avargas@adapower.net --\n-- ---------------------",
"end": 551,
"score": 0.9999325275421143,
"start": 531,
"tag": "EMAIL",
"value": "avargas@adapower.net"
}
] | thirdparty/adasdl/thin/adasdl/AdaSDL/binding/sdl-version.ads | Lucretia/old_nehe_ada95 | 0 |
-- ----------------------------------------------------------------- --
-- AdaSDL --
-- Binding to Simple Direct Media Layer --
-- Copyright (C) 2001 A.M.F.Vargas --
-- Antonio M. F. Vargas --
-- Ponta Delgada - Azores - Portugal --
-- http://www.adapower.net/~avargas --
-- E-mail: avargas@adapower.net --
-- ----------------------------------------------------------------- --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public --
-- License as published by the Free Software Foundation; either --
-- version 2 of the License, or (at your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public --
-- License along with this library; if not, write to the --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
-- ----------------------------------------------------------------- --
-- **************************************************************** --
-- This is an Ada binding to SDL ( Simple DirectMedia Layer from --
-- Sam Lantinga - www.libsld.org ) --
-- **************************************************************** --
-- In order to help the Ada programmer, the comments in this file --
-- are, in great extent, a direct copy of the original text in the --
-- SDL header files. --
-- **************************************************************** --
with SDL.Types; use SDL.Types;
package SDL.Version is
-- Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
SDL_MAJOR_VERSION : constant := 1;
SDL_MINOR_VERSION : constant := 1;
SDL_PATCHLEVEL : constant := 8;
type version is
record
major : Uint8;
minor : Uint8;
patch : Uint8;
end record;
pragma Convention (C, version);
type version_ptr is access all version;
pragma Convention (C, version_ptr);
-- This macro can be used to fill a version structure with the compile-time
-- version of the SDL library.
-- procedure SDL_VERSION (X : version_ptr);
-- pragma Inline (SDL_VERSION);
procedure SDL_VERSION (X : in out version);
pragma Inline (SDL_VERSION);
-- This original 'C" macro turns the version numbers into a numeric value:
-- (1,2,3) -> (1203)
-- This assumes that there will never be more than 100 patchlevels
function SDL_VERSIONNUM (
X : Uint8;
Y : Uint8;
Z : Uint8)
return C.int;
pragma Inline (SDL_VERSIONNUM);
-- This is the version number macro for the current SDL version
function SDL_COMPILEDVERSION return C.int;
pragma Inline (SDL_COMPILEDVERSION);
-- This macro will evaluate to True if compiled with SDL at least X.Y.Z
function SDL_VERSION_ATLEAST (X : Uint8; Y : Uint8; Z : Uint8) return Boolean;
pragma Inline (SDL_VERSION_ATLEAST);
-- This function gets the version of the dynamically linked SDL library.
-- it should NOT be used to fill a version structure, instead you should
-- use the Version inlined function.
function Linked_Version return version_ptr;
pragma Import (C, Linked_Version, "SDL_Linked_Version");
end SDL.Version;
| 5589 |
-- ----------------------------------------------------------------- --
-- AdaSDL --
-- Binding to Simple Direct Media Layer --
-- Copyright (C) 2001 <NAME> --
-- <NAME> --
-- Ponta Del<NAME>ada - Azores - Portugal --
-- http://www.adapower.net/~avargas --
-- E-mail: <EMAIL> --
-- ----------------------------------------------------------------- --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public --
-- License as published by the Free Software Foundation; either --
-- version 2 of the License, or (at your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public --
-- License along with this library; if not, write to the --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
-- ----------------------------------------------------------------- --
-- **************************************************************** --
-- This is an Ada binding to SDL ( Simple DirectMedia Layer from --
-- Sam Lantinga - www.libsld.org ) --
-- **************************************************************** --
-- In order to help the Ada programmer, the comments in this file --
-- are, in great extent, a direct copy of the original text in the --
-- SDL header files. --
-- **************************************************************** --
with SDL.Types; use SDL.Types;
package SDL.Version is
-- Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
SDL_MAJOR_VERSION : constant := 1;
SDL_MINOR_VERSION : constant := 1;
SDL_PATCHLEVEL : constant := 8;
type version is
record
major : Uint8;
minor : Uint8;
patch : Uint8;
end record;
pragma Convention (C, version);
type version_ptr is access all version;
pragma Convention (C, version_ptr);
-- This macro can be used to fill a version structure with the compile-time
-- version of the SDL library.
-- procedure SDL_VERSION (X : version_ptr);
-- pragma Inline (SDL_VERSION);
procedure SDL_VERSION (X : in out version);
pragma Inline (SDL_VERSION);
-- This original 'C" macro turns the version numbers into a numeric value:
-- (1,2,3) -> (1203)
-- This assumes that there will never be more than 100 patchlevels
function SDL_VERSIONNUM (
X : Uint8;
Y : Uint8;
Z : Uint8)
return C.int;
pragma Inline (SDL_VERSIONNUM);
-- This is the version number macro for the current SDL version
function SDL_COMPILEDVERSION return C.int;
pragma Inline (SDL_COMPILEDVERSION);
-- This macro will evaluate to True if compiled with SDL at least X.Y.Z
function SDL_VERSION_ATLEAST (X : Uint8; Y : Uint8; Z : Uint8) return Boolean;
pragma Inline (SDL_VERSION_ATLEAST);
-- This function gets the version of the dynamically linked SDL library.
-- it should NOT be used to fill a version structure, instead you should
-- use the Version inlined function.
function Linked_Version return version_ptr;
pragma Import (C, Linked_Version, "SDL_Linked_Version");
end SDL.Version;
| true |
-- ----------------------------------------------------------------- --
-- AdaSDL --
-- Binding to Simple Direct Media Layer --
-- Copyright (C) 2001 PI:NAME:<NAME>END_PI --
-- PI:NAME:<NAME>END_PI --
-- Ponta DelPI:NAME:<NAME>END_PIada - Azores - Portugal --
-- http://www.adapower.net/~avargas --
-- E-mail: PI:EMAIL:<EMAIL>END_PI --
-- ----------------------------------------------------------------- --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public --
-- License as published by the Free Software Foundation; either --
-- version 2 of the License, or (at your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public --
-- License along with this library; if not, write to the --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
-- ----------------------------------------------------------------- --
-- **************************************************************** --
-- This is an Ada binding to SDL ( Simple DirectMedia Layer from --
-- Sam Lantinga - www.libsld.org ) --
-- **************************************************************** --
-- In order to help the Ada programmer, the comments in this file --
-- are, in great extent, a direct copy of the original text in the --
-- SDL header files. --
-- **************************************************************** --
with SDL.Types; use SDL.Types;
package SDL.Version is
-- Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
SDL_MAJOR_VERSION : constant := 1;
SDL_MINOR_VERSION : constant := 1;
SDL_PATCHLEVEL : constant := 8;
type version is
record
major : Uint8;
minor : Uint8;
patch : Uint8;
end record;
pragma Convention (C, version);
type version_ptr is access all version;
pragma Convention (C, version_ptr);
-- This macro can be used to fill a version structure with the compile-time
-- version of the SDL library.
-- procedure SDL_VERSION (X : version_ptr);
-- pragma Inline (SDL_VERSION);
procedure SDL_VERSION (X : in out version);
pragma Inline (SDL_VERSION);
-- This original 'C" macro turns the version numbers into a numeric value:
-- (1,2,3) -> (1203)
-- This assumes that there will never be more than 100 patchlevels
function SDL_VERSIONNUM (
X : Uint8;
Y : Uint8;
Z : Uint8)
return C.int;
pragma Inline (SDL_VERSIONNUM);
-- This is the version number macro for the current SDL version
function SDL_COMPILEDVERSION return C.int;
pragma Inline (SDL_COMPILEDVERSION);
-- This macro will evaluate to True if compiled with SDL at least X.Y.Z
function SDL_VERSION_ATLEAST (X : Uint8; Y : Uint8; Z : Uint8) return Boolean;
pragma Inline (SDL_VERSION_ATLEAST);
-- This function gets the version of the dynamically linked SDL library.
-- it should NOT be used to fill a version structure, instead you should
-- use the Version inlined function.
function Linked_Version return version_ptr;
pragma Import (C, Linked_Version, "SDL_Linked_Version");
end SDL.Version;
|
[
{
"context": " --\n-- Copyright © 2010-2020, Vadim Godunko <vgodunko@gmail.com> --\n-- All rig",
"end": 829,
"score": 0.9998895525932312,
"start": 816,
"tag": "NAME",
"value": "Vadim Godunko"
},
{
"context": " --\n-- Copyright © 2010-2020, Vadim Godunko <vgodunko@gmail.com> --\n-- All rights reserved. ",
"end": 849,
"score": 0.9999306201934814,
"start": 831,
"tag": "EMAIL",
"value": "vgodunko@gmail.com"
}
] | source/league/matreshka-internals-strings-operations.adb | reznikmm/matreshka | 24 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2020, 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.Unchecked_Deallocation;
with Matreshka.Internals.Strings.Configuration;
package body Matreshka.Internals.Strings.Operations is
use Matreshka.Internals.Strings.Configuration;
use Matreshka.Internals.Unicode;
use Matreshka.Internals.Utf16;
procedure Free is
new Ada.Unchecked_Deallocation (Index_Map, Index_Map_Access);
------------
-- Append --
------------
procedure Append
(Self : in out not null Shared_String_Access;
Code : Matreshka.Internals.Unicode.Code_Point)
is
Next_Unused : Utf16_String_Index;
begin
-- Assigning of the "default" value to the variable and use of simple
-- operation in if statement helps to compiler to use conditional move
-- instruction instead of branch instruction.
Next_Unused := Self.Unused + 1;
if Code > 16#FFFF# then
Next_Unused := Self.Unused + 2;
end if;
if not Can_Be_Reused (Self, Next_Unused) then
declare
Old : Shared_String_Access := Self;
begin
Self := Allocate (Next_Unused);
Self.Value (Old.Value'Range) := Old.Value;
Self.Unused := Old.Unused;
Self.Length := Old.Length;
Dereference (Old);
end;
else
Free (Self.Index_Map);
end if;
Self.Length := Self.Length + 1;
Unchecked_Store (Self.Value, Self.Unused, Code);
String_Handler.Fill_Null_Terminator (Self);
end Append;
------------
-- Append --
------------
procedure Append
(Self : in out not null Shared_String_Access;
Item : Shared_String_Access)
is
Source : Shared_String_Access := Self;
Size : constant Utf16_String_Index := Source.Unused + Item.Unused;
begin
if Size = 0 then
if Self /= Shared_Empty'Access then
Dereference (Self);
Self := Shared_Empty'Access;
end if;
elsif Item.Unused = 0 then
null;
elsif Self.Unused = 0 then
Self := Item;
Reference (Self);
Dereference (Source);
else
if not Can_Be_Reused (Self, Size) then
Self := Allocate (Size);
end if;
Self.Value (Source.Unused .. Size - 1) :=
Item.Value (0 .. Item.Unused - 1);
Self.Unused := Size;
Self.Length := Source.Length + Item.Length;
Free (Self.Index_Map);
String_Handler.Fill_Null_Terminator (Self);
if Self /= Source then
Self.Value (0 .. Source.Unused - 1) :=
Source.Value (0 .. Source.Unused - 1);
Dereference (Source);
end if;
end if;
end Append;
----------------
-- Copy_Slice --
----------------
procedure Copy_Slice
(Self : in out not null Shared_String_Access;
Source : not null Shared_String_Access;
First : Matreshka.Internals.Utf16.Utf16_String_Index;
Size : Matreshka.Internals.Utf16.Utf16_String_Index;
Length : Natural)
is
pragma Assert (First < Source.Unused);
pragma Assert (First + Size <= Source.Unused);
pragma Assert (Utf16_String_Index (Length) in (Size + 1) / 2 .. Size);
begin
if Size = 0 then
if Self /= Shared_Empty'Access then
Dereference (Self);
Self := Shared_Empty'Access;
end if;
else
if not Can_Be_Reused (Self, Size) then
declare
Old : Shared_String_Access := Self;
begin
Self := Allocate (Size);
Dereference (Old);
end;
else
Free (Self.Index_Map);
end if;
Self.Value (0 .. Size - 1) :=
Source.Value (First .. First + Size - 1);
Self.Unused := Size;
Self.Length := Length;
String_Handler.Fill_Null_Terminator (Self);
end if;
end Copy_Slice;
-------------
-- Prepend --
-------------
procedure Prepend
(Target : in out not null Shared_String_Access;
Code : Matreshka.Internals.Unicode.Code_Point)
is
Source : Shared_String_Access := Target;
Position : Utf16_String_Index := 0;
Offset : Utf16_String_Index;
begin
if Source.Unused = 0 then
-- Source string is empty, allocate new shared string and save given
-- character into it. Length of the allocated shared string for any
-- one character is same on almost all platforms, so shared string is
-- allocated for longest possible character.
Target := Allocate (2);
Target.Unused := 0;
Target.Length := 1;
Unchecked_Store (Target.Value, Target.Unused, Code);
String_Handler.Fill_Null_Terminator (Target);
else
-- Assigning of the "default" value to the variable and use of simple
-- operation in if statement helps to compiler to use conditional
-- move instruction instead of branch instruction.
Offset := 1;
if Code > 16#FFFF# then
Offset := 2;
end if;
if not Can_Be_Reused (Source, Source.Unused + Offset) then
-- Allocate new shared string when shared source string can't be
-- reused.
Target := Allocate (Source.Unused + Offset);
end if;
-- Copy source data before store prepended character because source
-- string can be rewritten overwise.
Target.Value (Offset .. Offset + Source.Unused - 1) :=
Source.Value (0 .. Source.Unused - 1);
Unchecked_Store (Target.Value, Position, Code);
Target.Unused := Source.Unused + Offset;
Target.Length := Source.Length + 1;
Free (Target.Index_Map);
String_Handler.Fill_Null_Terminator (Target);
if Target /= Source then
-- Release shared source string when new shared string was
-- allocated for target.
Dereference (Source);
end if;
end if;
end Prepend;
-------------
-- Prepend --
-------------
procedure Prepend
(Target : in out not null Shared_String_Access;
Item : Shared_String_Access)
is
Source : Shared_String_Access := Target;
Size : constant Utf16_String_Index := Source.Unused + Item.Unused;
begin
if Item.Unused = 0 then
-- Prepended string is empty, nothing to be done.
null;
elsif Source.Unused = 0 then
-- Source string is empty, share data of prepended string.
Reference (Item);
Target := Item;
Dereference (Source);
else
if not Can_Be_Reused (Source, Size) then
-- Allocate new shared segment when source string can't be reused.
Target := Allocate (Size);
end if;
-- Copy data starting from the source string, because it can be
-- overwritten otherwise.
Target.Value (Item.Unused .. Item.Unused + Source.Unused - 1) :=
Source.Value (0 .. Source.Unused - 1);
Target.Value (0 .. Item.Unused - 1) :=
Item.Value (0 .. Item.Unused - 1);
Target.Unused := Size;
Target.Length := Source.Length + Item.Length;
Free (Target.Index_Map);
String_Handler.Fill_Null_Terminator (Target);
if Target /= Source then
-- Release shared source string when new shared string was
-- allocated for target.
Dereference (Source);
end if;
end if;
end Prepend;
-------------
-- Replace --
-------------
procedure Replace
(String : in out not null Shared_String_Access;
First : Matreshka.Internals.Utf16.Utf16_String_Index;
Size : Matreshka.Internals.Utf16.Utf16_String_Index;
Length : Natural;
By : not null Shared_String_Access)
is
pragma Assert (First < String.Unused);
pragma Assert (First + Size <= String.Unused);
pragma Assert (Utf16_String_Index (Length) in (Size + 1) / 2 .. Size);
Source : Shared_String_Access := String;
Destination : Shared_String_Access renames String;
New_Length : constant Natural := Source.Length - Length + By.Length;
New_Size : constant Matreshka.Internals.Utf16.Utf16_String_Index
:= Source.Unused - Size + By.Unused;
begin
if New_Size = 0 then
if Destination /= Shared_Empty'Access then
Dereference (Destination);
Destination := Shared_Empty'Access;
end if;
elsif By.Unused = New_Size then
Dereference (Source);
Destination := By;
Reference (Destination);
else
if not Can_Be_Reused (Source, New_Size) then
Destination := Allocate (New_Size);
else
Free (Destination.Index_Map);
Destination.Index_Map := null;
-- GNAT GPL 2014: Index_Map doesn't sets to null by Free.
end if;
Destination.Value (First + By.Unused .. New_Size - 1) :=
Source.Value (First + Size .. Source.Unused - 1);
if By.Length /= 0 then
Destination.Value (First .. First + By.Unused - 1) :=
By.Value (0 .. By.Unused - 1);
end if;
Destination.Unused := New_Size;
Destination.Length := New_Length;
String_Handler.Fill_Null_Terminator (Destination);
if Source /= Destination then
if First /= 0 then
Destination.Value (0 .. First - 1) :=
Source.Value (0 .. First - 1);
end if;
Dereference (Source);
end if;
end if;
end Replace;
-----------
-- Reset --
-----------
procedure Reset (Self : in out not null Shared_String_Access) is
begin
if Can_Be_Reused (Self, Self.Capacity) then
Free (Self.Index_Map);
Self.Unused := 0;
Self.Length := 0;
String_Handler.Fill_Null_Terminator (Self);
else
declare
Old : Shared_String_Access := Self;
begin
Self := Shared_Empty'Access;
Dereference (Old);
end;
end if;
end Reset;
-----------
-- Slice --
-----------
function Slice
(Source : not null Shared_String_Access;
First : Matreshka.Internals.Utf16.Utf16_String_Index;
Size : Matreshka.Internals.Utf16.Utf16_String_Index;
Length : Natural)
return not null Shared_String_Access
is
pragma Assert (Size = 0 or First < Source.Unused);
-- For convenience, it is allowied to get empty slice from any string;
-- otherwise First must be valid position of character.
pragma Assert (First + Size <= Source.Unused);
pragma Assert (Utf16_String_Index (Length) in (Size + 1) / 2 .. Size);
begin
if Size = 0 then
-- Requested slice is empty.
return Shared_Empty'Access;
elsif Size = Source.Unused then
-- Requested slice is whole string.
Reference (Source);
return Source;
else
return Destination : constant not null Shared_String_Access
:= Allocate (Size)
do
Destination.Value (0 .. Size - 1) :=
Source.Value (First .. First + Size - 1);
Destination.Unused := Size;
Destination.Length := Length;
String_Handler.Fill_Null_Terminator (Destination);
end return;
end if;
end Slice;
-----------
-- Slice --
-----------
procedure Slice
(Item : in out not null Shared_String_Access;
First : Matreshka.Internals.Utf16.Utf16_String_Index;
Size : Matreshka.Internals.Utf16.Utf16_String_Index;
Length : Natural)
is
pragma Assert (Size = 0 or First < Item.Unused);
-- For convenience, it is allowied to get empty slice from any string;
-- otherwise First must be valid position of character.
pragma Assert (First + Size <= Item.Unused);
pragma Assert (Utf16_String_Index (Length) in (Size + 1) / 2 .. Size);
Source : Shared_String_Access := Item;
Destination : Shared_String_Access renames Item;
begin
if Size = 0 then
-- Requested slice is empty.
Destination := Shared_Empty'Access;
Dereference (Source);
elsif Size = Source.Unused then
-- Requested slice is whole string.
null;
else
if not Can_Be_Reused (Source, Size) then
Destination := Allocate (Size);
end if;
Free (Destination.Index_Map);
Destination.Value (0 .. Size - 1) :=
Source.Value (First .. First + Size - 1);
Destination.Unused := Size;
Destination.Length := Length;
String_Handler.Fill_Null_Terminator (Destination);
if Source /= Destination then
Dereference (Source);
end if;
end if;
end Slice;
-------------------------
-- Unterminated_Append --
-------------------------
procedure Unterminated_Append
(Self : in out not null Shared_String_Access;
Code : Matreshka.Internals.Unicode.Code_Point)
is
Next_Unused : Utf16_String_Index;
begin
-- Assigning of the "default" value to the variable and use of simple
-- operation in if statement helps to compiler to use conditional move
-- instruction instead of branch instruction.
Next_Unused := Self.Unused + 1;
if Code > 16#FFFF# then
Next_Unused := Self.Unused + 2;
end if;
if not Can_Be_Reused (Self, Next_Unused) then
declare
Old : Shared_String_Access := Self;
begin
Self := Allocate (Next_Unused);
Self.Value (Old.Value'Range) := Old.Value;
Self.Unused := Old.Unused;
Self.Length := Old.Length;
Dereference (Old);
end;
else
Free (Self.Index_Map);
end if;
Self.Length := Self.Length + 1;
Unchecked_Store (Self.Value, Self.Unused, Code);
end Unterminated_Append;
end Matreshka.Internals.Strings.Operations;
| 28299 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2020, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Matreshka.Internals.Strings.Configuration;
package body Matreshka.Internals.Strings.Operations is
use Matreshka.Internals.Strings.Configuration;
use Matreshka.Internals.Unicode;
use Matreshka.Internals.Utf16;
procedure Free is
new Ada.Unchecked_Deallocation (Index_Map, Index_Map_Access);
------------
-- Append --
------------
procedure Append
(Self : in out not null Shared_String_Access;
Code : Matreshka.Internals.Unicode.Code_Point)
is
Next_Unused : Utf16_String_Index;
begin
-- Assigning of the "default" value to the variable and use of simple
-- operation in if statement helps to compiler to use conditional move
-- instruction instead of branch instruction.
Next_Unused := Self.Unused + 1;
if Code > 16#FFFF# then
Next_Unused := Self.Unused + 2;
end if;
if not Can_Be_Reused (Self, Next_Unused) then
declare
Old : Shared_String_Access := Self;
begin
Self := Allocate (Next_Unused);
Self.Value (Old.Value'Range) := Old.Value;
Self.Unused := Old.Unused;
Self.Length := Old.Length;
Dereference (Old);
end;
else
Free (Self.Index_Map);
end if;
Self.Length := Self.Length + 1;
Unchecked_Store (Self.Value, Self.Unused, Code);
String_Handler.Fill_Null_Terminator (Self);
end Append;
------------
-- Append --
------------
procedure Append
(Self : in out not null Shared_String_Access;
Item : Shared_String_Access)
is
Source : Shared_String_Access := Self;
Size : constant Utf16_String_Index := Source.Unused + Item.Unused;
begin
if Size = 0 then
if Self /= Shared_Empty'Access then
Dereference (Self);
Self := Shared_Empty'Access;
end if;
elsif Item.Unused = 0 then
null;
elsif Self.Unused = 0 then
Self := Item;
Reference (Self);
Dereference (Source);
else
if not Can_Be_Reused (Self, Size) then
Self := Allocate (Size);
end if;
Self.Value (Source.Unused .. Size - 1) :=
Item.Value (0 .. Item.Unused - 1);
Self.Unused := Size;
Self.Length := Source.Length + Item.Length;
Free (Self.Index_Map);
String_Handler.Fill_Null_Terminator (Self);
if Self /= Source then
Self.Value (0 .. Source.Unused - 1) :=
Source.Value (0 .. Source.Unused - 1);
Dereference (Source);
end if;
end if;
end Append;
----------------
-- Copy_Slice --
----------------
procedure Copy_Slice
(Self : in out not null Shared_String_Access;
Source : not null Shared_String_Access;
First : Matreshka.Internals.Utf16.Utf16_String_Index;
Size : Matreshka.Internals.Utf16.Utf16_String_Index;
Length : Natural)
is
pragma Assert (First < Source.Unused);
pragma Assert (First + Size <= Source.Unused);
pragma Assert (Utf16_String_Index (Length) in (Size + 1) / 2 .. Size);
begin
if Size = 0 then
if Self /= Shared_Empty'Access then
Dereference (Self);
Self := Shared_Empty'Access;
end if;
else
if not Can_Be_Reused (Self, Size) then
declare
Old : Shared_String_Access := Self;
begin
Self := Allocate (Size);
Dereference (Old);
end;
else
Free (Self.Index_Map);
end if;
Self.Value (0 .. Size - 1) :=
Source.Value (First .. First + Size - 1);
Self.Unused := Size;
Self.Length := Length;
String_Handler.Fill_Null_Terminator (Self);
end if;
end Copy_Slice;
-------------
-- Prepend --
-------------
procedure Prepend
(Target : in out not null Shared_String_Access;
Code : Matreshka.Internals.Unicode.Code_Point)
is
Source : Shared_String_Access := Target;
Position : Utf16_String_Index := 0;
Offset : Utf16_String_Index;
begin
if Source.Unused = 0 then
-- Source string is empty, allocate new shared string and save given
-- character into it. Length of the allocated shared string for any
-- one character is same on almost all platforms, so shared string is
-- allocated for longest possible character.
Target := Allocate (2);
Target.Unused := 0;
Target.Length := 1;
Unchecked_Store (Target.Value, Target.Unused, Code);
String_Handler.Fill_Null_Terminator (Target);
else
-- Assigning of the "default" value to the variable and use of simple
-- operation in if statement helps to compiler to use conditional
-- move instruction instead of branch instruction.
Offset := 1;
if Code > 16#FFFF# then
Offset := 2;
end if;
if not Can_Be_Reused (Source, Source.Unused + Offset) then
-- Allocate new shared string when shared source string can't be
-- reused.
Target := Allocate (Source.Unused + Offset);
end if;
-- Copy source data before store prepended character because source
-- string can be rewritten overwise.
Target.Value (Offset .. Offset + Source.Unused - 1) :=
Source.Value (0 .. Source.Unused - 1);
Unchecked_Store (Target.Value, Position, Code);
Target.Unused := Source.Unused + Offset;
Target.Length := Source.Length + 1;
Free (Target.Index_Map);
String_Handler.Fill_Null_Terminator (Target);
if Target /= Source then
-- Release shared source string when new shared string was
-- allocated for target.
Dereference (Source);
end if;
end if;
end Prepend;
-------------
-- Prepend --
-------------
procedure Prepend
(Target : in out not null Shared_String_Access;
Item : Shared_String_Access)
is
Source : Shared_String_Access := Target;
Size : constant Utf16_String_Index := Source.Unused + Item.Unused;
begin
if Item.Unused = 0 then
-- Prepended string is empty, nothing to be done.
null;
elsif Source.Unused = 0 then
-- Source string is empty, share data of prepended string.
Reference (Item);
Target := Item;
Dereference (Source);
else
if not Can_Be_Reused (Source, Size) then
-- Allocate new shared segment when source string can't be reused.
Target := Allocate (Size);
end if;
-- Copy data starting from the source string, because it can be
-- overwritten otherwise.
Target.Value (Item.Unused .. Item.Unused + Source.Unused - 1) :=
Source.Value (0 .. Source.Unused - 1);
Target.Value (0 .. Item.Unused - 1) :=
Item.Value (0 .. Item.Unused - 1);
Target.Unused := Size;
Target.Length := Source.Length + Item.Length;
Free (Target.Index_Map);
String_Handler.Fill_Null_Terminator (Target);
if Target /= Source then
-- Release shared source string when new shared string was
-- allocated for target.
Dereference (Source);
end if;
end if;
end Prepend;
-------------
-- Replace --
-------------
procedure Replace
(String : in out not null Shared_String_Access;
First : Matreshka.Internals.Utf16.Utf16_String_Index;
Size : Matreshka.Internals.Utf16.Utf16_String_Index;
Length : Natural;
By : not null Shared_String_Access)
is
pragma Assert (First < String.Unused);
pragma Assert (First + Size <= String.Unused);
pragma Assert (Utf16_String_Index (Length) in (Size + 1) / 2 .. Size);
Source : Shared_String_Access := String;
Destination : Shared_String_Access renames String;
New_Length : constant Natural := Source.Length - Length + By.Length;
New_Size : constant Matreshka.Internals.Utf16.Utf16_String_Index
:= Source.Unused - Size + By.Unused;
begin
if New_Size = 0 then
if Destination /= Shared_Empty'Access then
Dereference (Destination);
Destination := Shared_Empty'Access;
end if;
elsif By.Unused = New_Size then
Dereference (Source);
Destination := By;
Reference (Destination);
else
if not Can_Be_Reused (Source, New_Size) then
Destination := Allocate (New_Size);
else
Free (Destination.Index_Map);
Destination.Index_Map := null;
-- GNAT GPL 2014: Index_Map doesn't sets to null by Free.
end if;
Destination.Value (First + By.Unused .. New_Size - 1) :=
Source.Value (First + Size .. Source.Unused - 1);
if By.Length /= 0 then
Destination.Value (First .. First + By.Unused - 1) :=
By.Value (0 .. By.Unused - 1);
end if;
Destination.Unused := New_Size;
Destination.Length := New_Length;
String_Handler.Fill_Null_Terminator (Destination);
if Source /= Destination then
if First /= 0 then
Destination.Value (0 .. First - 1) :=
Source.Value (0 .. First - 1);
end if;
Dereference (Source);
end if;
end if;
end Replace;
-----------
-- Reset --
-----------
procedure Reset (Self : in out not null Shared_String_Access) is
begin
if Can_Be_Reused (Self, Self.Capacity) then
Free (Self.Index_Map);
Self.Unused := 0;
Self.Length := 0;
String_Handler.Fill_Null_Terminator (Self);
else
declare
Old : Shared_String_Access := Self;
begin
Self := Shared_Empty'Access;
Dereference (Old);
end;
end if;
end Reset;
-----------
-- Slice --
-----------
function Slice
(Source : not null Shared_String_Access;
First : Matreshka.Internals.Utf16.Utf16_String_Index;
Size : Matreshka.Internals.Utf16.Utf16_String_Index;
Length : Natural)
return not null Shared_String_Access
is
pragma Assert (Size = 0 or First < Source.Unused);
-- For convenience, it is allowied to get empty slice from any string;
-- otherwise First must be valid position of character.
pragma Assert (First + Size <= Source.Unused);
pragma Assert (Utf16_String_Index (Length) in (Size + 1) / 2 .. Size);
begin
if Size = 0 then
-- Requested slice is empty.
return Shared_Empty'Access;
elsif Size = Source.Unused then
-- Requested slice is whole string.
Reference (Source);
return Source;
else
return Destination : constant not null Shared_String_Access
:= Allocate (Size)
do
Destination.Value (0 .. Size - 1) :=
Source.Value (First .. First + Size - 1);
Destination.Unused := Size;
Destination.Length := Length;
String_Handler.Fill_Null_Terminator (Destination);
end return;
end if;
end Slice;
-----------
-- Slice --
-----------
procedure Slice
(Item : in out not null Shared_String_Access;
First : Matreshka.Internals.Utf16.Utf16_String_Index;
Size : Matreshka.Internals.Utf16.Utf16_String_Index;
Length : Natural)
is
pragma Assert (Size = 0 or First < Item.Unused);
-- For convenience, it is allowied to get empty slice from any string;
-- otherwise First must be valid position of character.
pragma Assert (First + Size <= Item.Unused);
pragma Assert (Utf16_String_Index (Length) in (Size + 1) / 2 .. Size);
Source : Shared_String_Access := Item;
Destination : Shared_String_Access renames Item;
begin
if Size = 0 then
-- Requested slice is empty.
Destination := Shared_Empty'Access;
Dereference (Source);
elsif Size = Source.Unused then
-- Requested slice is whole string.
null;
else
if not Can_Be_Reused (Source, Size) then
Destination := Allocate (Size);
end if;
Free (Destination.Index_Map);
Destination.Value (0 .. Size - 1) :=
Source.Value (First .. First + Size - 1);
Destination.Unused := Size;
Destination.Length := Length;
String_Handler.Fill_Null_Terminator (Destination);
if Source /= Destination then
Dereference (Source);
end if;
end if;
end Slice;
-------------------------
-- Unterminated_Append --
-------------------------
procedure Unterminated_Append
(Self : in out not null Shared_String_Access;
Code : Matreshka.Internals.Unicode.Code_Point)
is
Next_Unused : Utf16_String_Index;
begin
-- Assigning of the "default" value to the variable and use of simple
-- operation in if statement helps to compiler to use conditional move
-- instruction instead of branch instruction.
Next_Unused := Self.Unused + 1;
if Code > 16#FFFF# then
Next_Unused := Self.Unused + 2;
end if;
if not Can_Be_Reused (Self, Next_Unused) then
declare
Old : Shared_String_Access := Self;
begin
Self := Allocate (Next_Unused);
Self.Value (Old.Value'Range) := Old.Value;
Self.Unused := Old.Unused;
Self.Length := Old.Length;
Dereference (Old);
end;
else
Free (Self.Index_Map);
end if;
Self.Length := Self.Length + 1;
Unchecked_Store (Self.Value, Self.Unused, Code);
end Unterminated_Append;
end Matreshka.Internals.Strings.Operations;
| true | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2020, PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> --
-- 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.Unchecked_Deallocation;
with Matreshka.Internals.Strings.Configuration;
package body Matreshka.Internals.Strings.Operations is
use Matreshka.Internals.Strings.Configuration;
use Matreshka.Internals.Unicode;
use Matreshka.Internals.Utf16;
procedure Free is
new Ada.Unchecked_Deallocation (Index_Map, Index_Map_Access);
------------
-- Append --
------------
procedure Append
(Self : in out not null Shared_String_Access;
Code : Matreshka.Internals.Unicode.Code_Point)
is
Next_Unused : Utf16_String_Index;
begin
-- Assigning of the "default" value to the variable and use of simple
-- operation in if statement helps to compiler to use conditional move
-- instruction instead of branch instruction.
Next_Unused := Self.Unused + 1;
if Code > 16#FFFF# then
Next_Unused := Self.Unused + 2;
end if;
if not Can_Be_Reused (Self, Next_Unused) then
declare
Old : Shared_String_Access := Self;
begin
Self := Allocate (Next_Unused);
Self.Value (Old.Value'Range) := Old.Value;
Self.Unused := Old.Unused;
Self.Length := Old.Length;
Dereference (Old);
end;
else
Free (Self.Index_Map);
end if;
Self.Length := Self.Length + 1;
Unchecked_Store (Self.Value, Self.Unused, Code);
String_Handler.Fill_Null_Terminator (Self);
end Append;
------------
-- Append --
------------
procedure Append
(Self : in out not null Shared_String_Access;
Item : Shared_String_Access)
is
Source : Shared_String_Access := Self;
Size : constant Utf16_String_Index := Source.Unused + Item.Unused;
begin
if Size = 0 then
if Self /= Shared_Empty'Access then
Dereference (Self);
Self := Shared_Empty'Access;
end if;
elsif Item.Unused = 0 then
null;
elsif Self.Unused = 0 then
Self := Item;
Reference (Self);
Dereference (Source);
else
if not Can_Be_Reused (Self, Size) then
Self := Allocate (Size);
end if;
Self.Value (Source.Unused .. Size - 1) :=
Item.Value (0 .. Item.Unused - 1);
Self.Unused := Size;
Self.Length := Source.Length + Item.Length;
Free (Self.Index_Map);
String_Handler.Fill_Null_Terminator (Self);
if Self /= Source then
Self.Value (0 .. Source.Unused - 1) :=
Source.Value (0 .. Source.Unused - 1);
Dereference (Source);
end if;
end if;
end Append;
----------------
-- Copy_Slice --
----------------
procedure Copy_Slice
(Self : in out not null Shared_String_Access;
Source : not null Shared_String_Access;
First : Matreshka.Internals.Utf16.Utf16_String_Index;
Size : Matreshka.Internals.Utf16.Utf16_String_Index;
Length : Natural)
is
pragma Assert (First < Source.Unused);
pragma Assert (First + Size <= Source.Unused);
pragma Assert (Utf16_String_Index (Length) in (Size + 1) / 2 .. Size);
begin
if Size = 0 then
if Self /= Shared_Empty'Access then
Dereference (Self);
Self := Shared_Empty'Access;
end if;
else
if not Can_Be_Reused (Self, Size) then
declare
Old : Shared_String_Access := Self;
begin
Self := Allocate (Size);
Dereference (Old);
end;
else
Free (Self.Index_Map);
end if;
Self.Value (0 .. Size - 1) :=
Source.Value (First .. First + Size - 1);
Self.Unused := Size;
Self.Length := Length;
String_Handler.Fill_Null_Terminator (Self);
end if;
end Copy_Slice;
-------------
-- Prepend --
-------------
procedure Prepend
(Target : in out not null Shared_String_Access;
Code : Matreshka.Internals.Unicode.Code_Point)
is
Source : Shared_String_Access := Target;
Position : Utf16_String_Index := 0;
Offset : Utf16_String_Index;
begin
if Source.Unused = 0 then
-- Source string is empty, allocate new shared string and save given
-- character into it. Length of the allocated shared string for any
-- one character is same on almost all platforms, so shared string is
-- allocated for longest possible character.
Target := Allocate (2);
Target.Unused := 0;
Target.Length := 1;
Unchecked_Store (Target.Value, Target.Unused, Code);
String_Handler.Fill_Null_Terminator (Target);
else
-- Assigning of the "default" value to the variable and use of simple
-- operation in if statement helps to compiler to use conditional
-- move instruction instead of branch instruction.
Offset := 1;
if Code > 16#FFFF# then
Offset := 2;
end if;
if not Can_Be_Reused (Source, Source.Unused + Offset) then
-- Allocate new shared string when shared source string can't be
-- reused.
Target := Allocate (Source.Unused + Offset);
end if;
-- Copy source data before store prepended character because source
-- string can be rewritten overwise.
Target.Value (Offset .. Offset + Source.Unused - 1) :=
Source.Value (0 .. Source.Unused - 1);
Unchecked_Store (Target.Value, Position, Code);
Target.Unused := Source.Unused + Offset;
Target.Length := Source.Length + 1;
Free (Target.Index_Map);
String_Handler.Fill_Null_Terminator (Target);
if Target /= Source then
-- Release shared source string when new shared string was
-- allocated for target.
Dereference (Source);
end if;
end if;
end Prepend;
-------------
-- Prepend --
-------------
procedure Prepend
(Target : in out not null Shared_String_Access;
Item : Shared_String_Access)
is
Source : Shared_String_Access := Target;
Size : constant Utf16_String_Index := Source.Unused + Item.Unused;
begin
if Item.Unused = 0 then
-- Prepended string is empty, nothing to be done.
null;
elsif Source.Unused = 0 then
-- Source string is empty, share data of prepended string.
Reference (Item);
Target := Item;
Dereference (Source);
else
if not Can_Be_Reused (Source, Size) then
-- Allocate new shared segment when source string can't be reused.
Target := Allocate (Size);
end if;
-- Copy data starting from the source string, because it can be
-- overwritten otherwise.
Target.Value (Item.Unused .. Item.Unused + Source.Unused - 1) :=
Source.Value (0 .. Source.Unused - 1);
Target.Value (0 .. Item.Unused - 1) :=
Item.Value (0 .. Item.Unused - 1);
Target.Unused := Size;
Target.Length := Source.Length + Item.Length;
Free (Target.Index_Map);
String_Handler.Fill_Null_Terminator (Target);
if Target /= Source then
-- Release shared source string when new shared string was
-- allocated for target.
Dereference (Source);
end if;
end if;
end Prepend;
-------------
-- Replace --
-------------
procedure Replace
(String : in out not null Shared_String_Access;
First : Matreshka.Internals.Utf16.Utf16_String_Index;
Size : Matreshka.Internals.Utf16.Utf16_String_Index;
Length : Natural;
By : not null Shared_String_Access)
is
pragma Assert (First < String.Unused);
pragma Assert (First + Size <= String.Unused);
pragma Assert (Utf16_String_Index (Length) in (Size + 1) / 2 .. Size);
Source : Shared_String_Access := String;
Destination : Shared_String_Access renames String;
New_Length : constant Natural := Source.Length - Length + By.Length;
New_Size : constant Matreshka.Internals.Utf16.Utf16_String_Index
:= Source.Unused - Size + By.Unused;
begin
if New_Size = 0 then
if Destination /= Shared_Empty'Access then
Dereference (Destination);
Destination := Shared_Empty'Access;
end if;
elsif By.Unused = New_Size then
Dereference (Source);
Destination := By;
Reference (Destination);
else
if not Can_Be_Reused (Source, New_Size) then
Destination := Allocate (New_Size);
else
Free (Destination.Index_Map);
Destination.Index_Map := null;
-- GNAT GPL 2014: Index_Map doesn't sets to null by Free.
end if;
Destination.Value (First + By.Unused .. New_Size - 1) :=
Source.Value (First + Size .. Source.Unused - 1);
if By.Length /= 0 then
Destination.Value (First .. First + By.Unused - 1) :=
By.Value (0 .. By.Unused - 1);
end if;
Destination.Unused := New_Size;
Destination.Length := New_Length;
String_Handler.Fill_Null_Terminator (Destination);
if Source /= Destination then
if First /= 0 then
Destination.Value (0 .. First - 1) :=
Source.Value (0 .. First - 1);
end if;
Dereference (Source);
end if;
end if;
end Replace;
-----------
-- Reset --
-----------
procedure Reset (Self : in out not null Shared_String_Access) is
begin
if Can_Be_Reused (Self, Self.Capacity) then
Free (Self.Index_Map);
Self.Unused := 0;
Self.Length := 0;
String_Handler.Fill_Null_Terminator (Self);
else
declare
Old : Shared_String_Access := Self;
begin
Self := Shared_Empty'Access;
Dereference (Old);
end;
end if;
end Reset;
-----------
-- Slice --
-----------
function Slice
(Source : not null Shared_String_Access;
First : Matreshka.Internals.Utf16.Utf16_String_Index;
Size : Matreshka.Internals.Utf16.Utf16_String_Index;
Length : Natural)
return not null Shared_String_Access
is
pragma Assert (Size = 0 or First < Source.Unused);
-- For convenience, it is allowied to get empty slice from any string;
-- otherwise First must be valid position of character.
pragma Assert (First + Size <= Source.Unused);
pragma Assert (Utf16_String_Index (Length) in (Size + 1) / 2 .. Size);
begin
if Size = 0 then
-- Requested slice is empty.
return Shared_Empty'Access;
elsif Size = Source.Unused then
-- Requested slice is whole string.
Reference (Source);
return Source;
else
return Destination : constant not null Shared_String_Access
:= Allocate (Size)
do
Destination.Value (0 .. Size - 1) :=
Source.Value (First .. First + Size - 1);
Destination.Unused := Size;
Destination.Length := Length;
String_Handler.Fill_Null_Terminator (Destination);
end return;
end if;
end Slice;
-----------
-- Slice --
-----------
procedure Slice
(Item : in out not null Shared_String_Access;
First : Matreshka.Internals.Utf16.Utf16_String_Index;
Size : Matreshka.Internals.Utf16.Utf16_String_Index;
Length : Natural)
is
pragma Assert (Size = 0 or First < Item.Unused);
-- For convenience, it is allowied to get empty slice from any string;
-- otherwise First must be valid position of character.
pragma Assert (First + Size <= Item.Unused);
pragma Assert (Utf16_String_Index (Length) in (Size + 1) / 2 .. Size);
Source : Shared_String_Access := Item;
Destination : Shared_String_Access renames Item;
begin
if Size = 0 then
-- Requested slice is empty.
Destination := Shared_Empty'Access;
Dereference (Source);
elsif Size = Source.Unused then
-- Requested slice is whole string.
null;
else
if not Can_Be_Reused (Source, Size) then
Destination := Allocate (Size);
end if;
Free (Destination.Index_Map);
Destination.Value (0 .. Size - 1) :=
Source.Value (First .. First + Size - 1);
Destination.Unused := Size;
Destination.Length := Length;
String_Handler.Fill_Null_Terminator (Destination);
if Source /= Destination then
Dereference (Source);
end if;
end if;
end Slice;
-------------------------
-- Unterminated_Append --
-------------------------
procedure Unterminated_Append
(Self : in out not null Shared_String_Access;
Code : Matreshka.Internals.Unicode.Code_Point)
is
Next_Unused : Utf16_String_Index;
begin
-- Assigning of the "default" value to the variable and use of simple
-- operation in if statement helps to compiler to use conditional move
-- instruction instead of branch instruction.
Next_Unused := Self.Unused + 1;
if Code > 16#FFFF# then
Next_Unused := Self.Unused + 2;
end if;
if not Can_Be_Reused (Self, Next_Unused) then
declare
Old : Shared_String_Access := Self;
begin
Self := Allocate (Next_Unused);
Self.Value (Old.Value'Range) := Old.Value;
Self.Unused := Old.Unused;
Self.Length := Old.Length;
Dereference (Old);
end;
else
Free (Self.Index_Map);
end if;
Self.Length := Self.Length + 1;
Unchecked_Store (Self.Value, Self.Unused, Code);
end Unterminated_Append;
end Matreshka.Internals.Strings.Operations;
|
[
{
"context": "-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifi",
"end": 35,
"score": 0.9998539686203003,
"start": 23,
"tag": "NAME",
"value": "Maxim Reznik"
},
{
"context": "-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>\n--\n-- SPDX-License-Identifier: MIT\n-- License-",
"end": 55,
"score": 0.9999309778213501,
"start": 37,
"tag": "EMAIL",
"value": "reznikmm@gmail.com"
}
] | source/nodes/program-nodes-interface_types.ads | optikos/oasis | 0 | -- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Interface_Types;
with Program.Element_Visitors;
package Program.Nodes.Interface_Types is
pragma Preelaborate;
type Interface_Type is
new Program.Nodes.Node and Program.Elements.Interface_Types.Interface_Type
and Program.Elements.Interface_Types.Interface_Type_Text
with private;
function Create
(Limited_Token : Program.Lexical_Elements.Lexical_Element_Access;
Task_Token : Program.Lexical_Elements.Lexical_Element_Access;
Protected_Token : Program.Lexical_Elements.Lexical_Element_Access;
Synchronized_Token : Program.Lexical_Elements.Lexical_Element_Access;
Interface_Token : Program.Lexical_Elements.Lexical_Element_Access;
And_Token : Program.Lexical_Elements.Lexical_Element_Access;
Progenitors : Program.Elements.Expressions
.Expression_Vector_Access)
return Interface_Type;
type Implicit_Interface_Type is
new Program.Nodes.Node and Program.Elements.Interface_Types.Interface_Type
with private;
function Create
(Progenitors : Program.Elements.Expressions
.Expression_Vector_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Limited : Boolean := False;
Has_Task : Boolean := False;
Has_Protected : Boolean := False;
Has_Synchronized : Boolean := False)
return Implicit_Interface_Type
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Interface_Type is
abstract new Program.Nodes.Node
and Program.Elements.Interface_Types.Interface_Type
with record
Progenitors : Program.Elements.Expressions.Expression_Vector_Access;
end record;
procedure Initialize (Self : aliased in out Base_Interface_Type'Class);
overriding procedure Visit
(Self : not null access Base_Interface_Type;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Progenitors
(Self : Base_Interface_Type)
return Program.Elements.Expressions.Expression_Vector_Access;
overriding function Is_Interface_Type_Element
(Self : Base_Interface_Type)
return Boolean;
overriding function Is_Type_Definition_Element
(Self : Base_Interface_Type)
return Boolean;
overriding function Is_Definition_Element
(Self : Base_Interface_Type)
return Boolean;
type Interface_Type is
new Base_Interface_Type
and Program.Elements.Interface_Types.Interface_Type_Text
with record
Limited_Token : Program.Lexical_Elements.Lexical_Element_Access;
Task_Token : Program.Lexical_Elements.Lexical_Element_Access;
Protected_Token : Program.Lexical_Elements.Lexical_Element_Access;
Synchronized_Token : Program.Lexical_Elements.Lexical_Element_Access;
Interface_Token : Program.Lexical_Elements.Lexical_Element_Access;
And_Token : Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Interface_Type_Text
(Self : aliased in out Interface_Type)
return Program.Elements.Interface_Types.Interface_Type_Text_Access;
overriding function Limited_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Task_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Protected_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Synchronized_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Interface_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function And_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Has_Limited (Self : Interface_Type) return Boolean;
overriding function Has_Task (Self : Interface_Type) return Boolean;
overriding function Has_Protected (Self : Interface_Type) return Boolean;
overriding function Has_Synchronized (Self : Interface_Type) return Boolean;
type Implicit_Interface_Type is
new Base_Interface_Type
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
Has_Limited : Boolean;
Has_Task : Boolean;
Has_Protected : Boolean;
Has_Synchronized : Boolean;
end record;
overriding function To_Interface_Type_Text
(Self : aliased in out Implicit_Interface_Type)
return Program.Elements.Interface_Types.Interface_Type_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Has_Limited
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Has_Task
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Has_Protected
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Has_Synchronized
(Self : Implicit_Interface_Type)
return Boolean;
end Program.Nodes.Interface_Types;
| 9282 | -- Copyright (c) 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Interface_Types;
with Program.Element_Visitors;
package Program.Nodes.Interface_Types is
pragma Preelaborate;
type Interface_Type is
new Program.Nodes.Node and Program.Elements.Interface_Types.Interface_Type
and Program.Elements.Interface_Types.Interface_Type_Text
with private;
function Create
(Limited_Token : Program.Lexical_Elements.Lexical_Element_Access;
Task_Token : Program.Lexical_Elements.Lexical_Element_Access;
Protected_Token : Program.Lexical_Elements.Lexical_Element_Access;
Synchronized_Token : Program.Lexical_Elements.Lexical_Element_Access;
Interface_Token : Program.Lexical_Elements.Lexical_Element_Access;
And_Token : Program.Lexical_Elements.Lexical_Element_Access;
Progenitors : Program.Elements.Expressions
.Expression_Vector_Access)
return Interface_Type;
type Implicit_Interface_Type is
new Program.Nodes.Node and Program.Elements.Interface_Types.Interface_Type
with private;
function Create
(Progenitors : Program.Elements.Expressions
.Expression_Vector_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Limited : Boolean := False;
Has_Task : Boolean := False;
Has_Protected : Boolean := False;
Has_Synchronized : Boolean := False)
return Implicit_Interface_Type
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Interface_Type is
abstract new Program.Nodes.Node
and Program.Elements.Interface_Types.Interface_Type
with record
Progenitors : Program.Elements.Expressions.Expression_Vector_Access;
end record;
procedure Initialize (Self : aliased in out Base_Interface_Type'Class);
overriding procedure Visit
(Self : not null access Base_Interface_Type;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Progenitors
(Self : Base_Interface_Type)
return Program.Elements.Expressions.Expression_Vector_Access;
overriding function Is_Interface_Type_Element
(Self : Base_Interface_Type)
return Boolean;
overriding function Is_Type_Definition_Element
(Self : Base_Interface_Type)
return Boolean;
overriding function Is_Definition_Element
(Self : Base_Interface_Type)
return Boolean;
type Interface_Type is
new Base_Interface_Type
and Program.Elements.Interface_Types.Interface_Type_Text
with record
Limited_Token : Program.Lexical_Elements.Lexical_Element_Access;
Task_Token : Program.Lexical_Elements.Lexical_Element_Access;
Protected_Token : Program.Lexical_Elements.Lexical_Element_Access;
Synchronized_Token : Program.Lexical_Elements.Lexical_Element_Access;
Interface_Token : Program.Lexical_Elements.Lexical_Element_Access;
And_Token : Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Interface_Type_Text
(Self : aliased in out Interface_Type)
return Program.Elements.Interface_Types.Interface_Type_Text_Access;
overriding function Limited_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Task_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Protected_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Synchronized_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Interface_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function And_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Has_Limited (Self : Interface_Type) return Boolean;
overriding function Has_Task (Self : Interface_Type) return Boolean;
overriding function Has_Protected (Self : Interface_Type) return Boolean;
overriding function Has_Synchronized (Self : Interface_Type) return Boolean;
type Implicit_Interface_Type is
new Base_Interface_Type
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
Has_Limited : Boolean;
Has_Task : Boolean;
Has_Protected : Boolean;
Has_Synchronized : Boolean;
end record;
overriding function To_Interface_Type_Text
(Self : aliased in out Implicit_Interface_Type)
return Program.Elements.Interface_Types.Interface_Type_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Has_Limited
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Has_Task
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Has_Protected
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Has_Synchronized
(Self : Implicit_Interface_Type)
return Boolean;
end Program.Nodes.Interface_Types;
| true | -- Copyright (c) 2019 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Interface_Types;
with Program.Element_Visitors;
package Program.Nodes.Interface_Types is
pragma Preelaborate;
type Interface_Type is
new Program.Nodes.Node and Program.Elements.Interface_Types.Interface_Type
and Program.Elements.Interface_Types.Interface_Type_Text
with private;
function Create
(Limited_Token : Program.Lexical_Elements.Lexical_Element_Access;
Task_Token : Program.Lexical_Elements.Lexical_Element_Access;
Protected_Token : Program.Lexical_Elements.Lexical_Element_Access;
Synchronized_Token : Program.Lexical_Elements.Lexical_Element_Access;
Interface_Token : Program.Lexical_Elements.Lexical_Element_Access;
And_Token : Program.Lexical_Elements.Lexical_Element_Access;
Progenitors : Program.Elements.Expressions
.Expression_Vector_Access)
return Interface_Type;
type Implicit_Interface_Type is
new Program.Nodes.Node and Program.Elements.Interface_Types.Interface_Type
with private;
function Create
(Progenitors : Program.Elements.Expressions
.Expression_Vector_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Limited : Boolean := False;
Has_Task : Boolean := False;
Has_Protected : Boolean := False;
Has_Synchronized : Boolean := False)
return Implicit_Interface_Type
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Interface_Type is
abstract new Program.Nodes.Node
and Program.Elements.Interface_Types.Interface_Type
with record
Progenitors : Program.Elements.Expressions.Expression_Vector_Access;
end record;
procedure Initialize (Self : aliased in out Base_Interface_Type'Class);
overriding procedure Visit
(Self : not null access Base_Interface_Type;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Progenitors
(Self : Base_Interface_Type)
return Program.Elements.Expressions.Expression_Vector_Access;
overriding function Is_Interface_Type_Element
(Self : Base_Interface_Type)
return Boolean;
overriding function Is_Type_Definition_Element
(Self : Base_Interface_Type)
return Boolean;
overriding function Is_Definition_Element
(Self : Base_Interface_Type)
return Boolean;
type Interface_Type is
new Base_Interface_Type
and Program.Elements.Interface_Types.Interface_Type_Text
with record
Limited_Token : Program.Lexical_Elements.Lexical_Element_Access;
Task_Token : Program.Lexical_Elements.Lexical_Element_Access;
Protected_Token : Program.Lexical_Elements.Lexical_Element_Access;
Synchronized_Token : Program.Lexical_Elements.Lexical_Element_Access;
Interface_Token : Program.Lexical_Elements.Lexical_Element_Access;
And_Token : Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Interface_Type_Text
(Self : aliased in out Interface_Type)
return Program.Elements.Interface_Types.Interface_Type_Text_Access;
overriding function Limited_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Task_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Protected_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Synchronized_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Interface_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function And_Token
(Self : Interface_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Has_Limited (Self : Interface_Type) return Boolean;
overriding function Has_Task (Self : Interface_Type) return Boolean;
overriding function Has_Protected (Self : Interface_Type) return Boolean;
overriding function Has_Synchronized (Self : Interface_Type) return Boolean;
type Implicit_Interface_Type is
new Base_Interface_Type
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
Has_Limited : Boolean;
Has_Task : Boolean;
Has_Protected : Boolean;
Has_Synchronized : Boolean;
end record;
overriding function To_Interface_Type_Text
(Self : aliased in out Implicit_Interface_Type)
return Program.Elements.Interface_Types.Interface_Type_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Has_Limited
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Has_Task
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Has_Protected
(Self : Implicit_Interface_Type)
return Boolean;
overriding function Has_Synchronized
(Self : Implicit_Interface_Type)
return Boolean;
end Program.Nodes.Interface_Types;
|
[
{
"context": "-------\n-- Copyright (C) 2020 by Heisenbug Ltd. (gh+spat@heisenbug.eu)\n--\n-- This work is free. You can redistribute i",
"end": 141,
"score": 0.9999309182167053,
"start": 121,
"tag": "EMAIL",
"value": "gh+spat@heisenbug.eu"
}
] | src/app/run_spat.adb | HeisenbugLtd/spat | 20 | ------------------------------------------------------------------------------
-- 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);
------------------------------------------------------------------------------
--
-- SPARK Proof Analysis Tool
--
-- S.P.A.T. - Main program
--
------------------------------------------------------------------------------
with Ada.Command_Line;
with Ada.Containers.Vectors;
with Ada.Directories;
with GNAT.Regexp;
with GNATCOLL.JSON;
with GNATCOLL.Projects;
with GNATCOLL.VFS;
with SPAT.Command_Line;
with SPAT.GPR_Support;
with SPAT.Log;
with SPAT.Spark_Files;
with SPAT.Spark_Info;
with SPAT.Stop_Watch;
with SPAT.Strings;
with SPAT.Version;
with System;
------------------------------------------------------------------------------
-- Run_SPAT
------------------------------------------------------------------------------
procedure Run_SPAT is
package Reg_Exp_List is new
Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => GNAT.Regexp.Regexp,
"=" => GNAT.Regexp."=");
---------------------------------------------------------------------------
-- Print_Entities
---------------------------------------------------------------------------
procedure Print_Entities
(Info : in SPAT.Spark_Info.T;
Sort_By : in SPAT.Spark_Info.Sorting_Criterion;
Cut_Off : in Duration;
Entity_Filter : in Reg_Exp_List.Vector);
---------------------------------------------------------------------------
-- Print_Suggestion
---------------------------------------------------------------------------
procedure Print_Suggestion
(Info : in SPAT.Spark_Info.T;
File_Map : in SPAT.GPR_Support.SPARK_Source_Maps.Map);
---------------------------------------------------------------------------
-- Print_Summary
---------------------------------------------------------------------------
procedure Print_Summary (Info : in SPAT.Spark_Info.T;
Sort_By : in SPAT.Spark_Info.Sorting_Criterion;
Cut_Off : in Duration);
---------------------------------------------------------------------------
-- Print_Entities
---------------------------------------------------------------------------
procedure Print_Entities
(Info : in SPAT.Spark_Info.T;
Sort_By : in SPAT.Spark_Info.Sorting_Criterion;
Cut_Off : in Duration;
Entity_Filter : in Reg_Exp_List.Vector) is separate;
---------------------------------------------------------------------------
-- Print_Suggestion
---------------------------------------------------------------------------
procedure Print_Suggestion
(Info : in SPAT.Spark_Info.T;
File_Map : in SPAT.GPR_Support.SPARK_Source_Maps.Map) is separate;
---------------------------------------------------------------------------
-- Print_Summary
---------------------------------------------------------------------------
procedure Print_Summary (Info : in SPAT.Spark_Info.T;
Sort_By : in SPAT.Spark_Info.Sorting_Criterion;
Cut_Off : in Duration) is separate;
use type SPAT.Subject_Name;
Entity_Filter : Reg_Exp_List.Vector;
begin
if not SPAT.Command_Line.Parser.Parse then
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Failure);
return;
end if;
if SPAT.Command_Line.Version.Get then
SPAT.Log.Message
(Message =>
"run_spat V" & SPAT.Version.Number &
" (compiled by " & System.System_Name'Image & " " &
SPAT.Version.Compiler & ")");
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Success);
return;
end if;
if SPAT.Command_Line.Project.Get = SPAT.Null_Name then
-- The project file option is mandatory (AFAICS there is no way to
-- require an option argument).
SPAT.Log.Message
(Message => "Argument parsing failed: Missing project file argument");
SPAT.Log.Message (Message => SPAT.Command_Line.Parser.Help);
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Failure);
return;
end if;
-- If there were entity filter options given, try compiling the reg exps.
--
-- for Expression of SPAT.Command_Line.Entity_Filter.Get loop
-- The above triggers a GNAT bug box with GNAT CE 2020.
--
declare
Filter : constant SPAT.Command_Line.Entity_Filter.Result_Array
:= SPAT.Command_Line.Entity_Filter.Get;
begin
for Expression of Filter loop
begin
Entity_Filter.Append
(New_Item =>
GNAT.Regexp.Compile
(Pattern => SPAT.To_String (Expression),
Glob => False,
Case_Sensitive => False));
null;
exception
when GNAT.Regexp.Error_In_Regexp =>
SPAT.Log.Message
(Message =>
"Argument parsing failed: """ &
SPAT.To_String (Source => Expression) &
""" is not a valid regular expression.");
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status
(Code => Ada.Command_Line.Failure);
return;
end;
end loop;
end;
Do_Run_SPAT :
declare
SPARK_Files : SPAT.Spark_Files.T;
Timer : SPAT.Stop_Watch.T := SPAT.Stop_Watch.Create;
Sort_By : constant SPAT.Spark_Info.Sorting_Criterion :=
SPAT.Command_Line.Sort_By.Get;
Cut_Off : constant Duration := SPAT.Command_Line.Cut_Off.Get;
Report_Mode : constant SPAT.Command_Line.Report_Mode :=
SPAT.Command_Line.Report.Get;
Project_File : constant GNATCOLL.VFS.Filesystem_String :=
GNATCOLL.VFS."+" (S => SPAT.To_String (SPAT.Command_Line.Project.Get));
File_List : constant SPAT.GPR_Support.SPARK_Source_Maps.Map :=
SPAT.GPR_Support.Get_SPARK_Files (GPR_File => Project_File);
use type SPAT.Command_Line.Report_Mode;
begin
Collect_And_Parse :
begin
-- Step 2: Parse the files into JSON values.
if not File_List.Is_Empty then
SPAT.Log.Debug
(Message =>
"Using up to" & SPAT.Spark_Files.Num_Workers'Image &
" parsing threads.");
Timer.Start;
declare
File_Names : SPAT.Strings.SPARK_File_Names (Capacity => File_List.Length);
begin
for X in File_List.Iterate loop
File_Names.Append (SPAT.GPR_Support.SPARK_Source_Maps.Key (X));
end loop;
SPARK_Files.Read (Names => File_Names);
end;
SPAT.Log.Debug
(Message => "Parsing completed in " & Timer.Elapsed & ".");
end if;
end Collect_And_Parse;
Process_And_Output :
declare
Info : SPAT.Spark_Info.T;
begin
-- Step 3: Process the JSON data.
if not SPARK_Files.Is_Empty then
Timer.Start;
for C in SPARK_Files.Iterate loop
Parse_JSON_File :
declare
Read_Result : constant GNATCOLL.JSON.Read_Result :=
SPARK_Files (C);
File : constant SPAT.SPARK_File_Name :=
SPAT.Spark_Files.Key (C);
begin
if Read_Result.Success then
Info.Map_Spark_File (Root => Read_Result.Value,
File => File);
else
SPAT.Log.Warning
(Message =>
SPAT.To_String (Source => File) & ": " &
GNATCOLL.JSON.Format_Parsing_Error
(Error => Read_Result.Error));
end if;
end Parse_JSON_File;
end loop;
SPAT.Log.Debug
(Message => "Reading completed in " & Timer.Elapsed & ".");
end if;
SPAT.Log.Debug
(Message =>
"Collecting files completed in " & Timer.Elapsed_Total & ".");
SPAT.Log.Debug
(Message => "Cut off point set to " & SPAT.Image (Cut_Off) & ".");
-- Step 4: Output the JSON data.
if SPAT.Command_Line.Summary.Get then
Print_Summary (Info => Info,
Sort_By => Sort_By,
Cut_Off => Cut_Off);
end if;
if Report_Mode /= SPAT.Command_Line.None then
Print_Entities (Info => Info,
Sort_By => Sort_By,
Cut_Off => Cut_Off,
Entity_Filter => Entity_Filter);
end if;
if SPAT.Command_Line.Suggest.Get then
Print_Suggestion (Info => Info,
File_Map => File_List);
end if;
exception
when E : others =>
SPAT.Log.Dump_Exception
(E => E,
Message => "Internal error encountered when processing data!");
end Process_And_Output;
end Do_Run_SPAT;
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Success);
exception
when E : others =>
SPAT.Spark_Files.Shutdown;
-- This shouldn't happen, other exception handlers should have caught
-- such earlier.
SPAT.Log.Dump_Exception
(E => E,
Message => "Fatal error encountered in SPAT!");
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Failure);
end Run_SPAT;
| 13998 | ------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. (<EMAIL>)
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
------------------------------------------------------------------------------
pragma License (Unrestricted);
------------------------------------------------------------------------------
--
-- SPARK Proof Analysis Tool
--
-- S.P.A.T. - Main program
--
------------------------------------------------------------------------------
with Ada.Command_Line;
with Ada.Containers.Vectors;
with Ada.Directories;
with GNAT.Regexp;
with GNATCOLL.JSON;
with GNATCOLL.Projects;
with GNATCOLL.VFS;
with SPAT.Command_Line;
with SPAT.GPR_Support;
with SPAT.Log;
with SPAT.Spark_Files;
with SPAT.Spark_Info;
with SPAT.Stop_Watch;
with SPAT.Strings;
with SPAT.Version;
with System;
------------------------------------------------------------------------------
-- Run_SPAT
------------------------------------------------------------------------------
procedure Run_SPAT is
package Reg_Exp_List is new
Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => GNAT.Regexp.Regexp,
"=" => GNAT.Regexp."=");
---------------------------------------------------------------------------
-- Print_Entities
---------------------------------------------------------------------------
procedure Print_Entities
(Info : in SPAT.Spark_Info.T;
Sort_By : in SPAT.Spark_Info.Sorting_Criterion;
Cut_Off : in Duration;
Entity_Filter : in Reg_Exp_List.Vector);
---------------------------------------------------------------------------
-- Print_Suggestion
---------------------------------------------------------------------------
procedure Print_Suggestion
(Info : in SPAT.Spark_Info.T;
File_Map : in SPAT.GPR_Support.SPARK_Source_Maps.Map);
---------------------------------------------------------------------------
-- Print_Summary
---------------------------------------------------------------------------
procedure Print_Summary (Info : in SPAT.Spark_Info.T;
Sort_By : in SPAT.Spark_Info.Sorting_Criterion;
Cut_Off : in Duration);
---------------------------------------------------------------------------
-- Print_Entities
---------------------------------------------------------------------------
procedure Print_Entities
(Info : in SPAT.Spark_Info.T;
Sort_By : in SPAT.Spark_Info.Sorting_Criterion;
Cut_Off : in Duration;
Entity_Filter : in Reg_Exp_List.Vector) is separate;
---------------------------------------------------------------------------
-- Print_Suggestion
---------------------------------------------------------------------------
procedure Print_Suggestion
(Info : in SPAT.Spark_Info.T;
File_Map : in SPAT.GPR_Support.SPARK_Source_Maps.Map) is separate;
---------------------------------------------------------------------------
-- Print_Summary
---------------------------------------------------------------------------
procedure Print_Summary (Info : in SPAT.Spark_Info.T;
Sort_By : in SPAT.Spark_Info.Sorting_Criterion;
Cut_Off : in Duration) is separate;
use type SPAT.Subject_Name;
Entity_Filter : Reg_Exp_List.Vector;
begin
if not SPAT.Command_Line.Parser.Parse then
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Failure);
return;
end if;
if SPAT.Command_Line.Version.Get then
SPAT.Log.Message
(Message =>
"run_spat V" & SPAT.Version.Number &
" (compiled by " & System.System_Name'Image & " " &
SPAT.Version.Compiler & ")");
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Success);
return;
end if;
if SPAT.Command_Line.Project.Get = SPAT.Null_Name then
-- The project file option is mandatory (AFAICS there is no way to
-- require an option argument).
SPAT.Log.Message
(Message => "Argument parsing failed: Missing project file argument");
SPAT.Log.Message (Message => SPAT.Command_Line.Parser.Help);
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Failure);
return;
end if;
-- If there were entity filter options given, try compiling the reg exps.
--
-- for Expression of SPAT.Command_Line.Entity_Filter.Get loop
-- The above triggers a GNAT bug box with GNAT CE 2020.
--
declare
Filter : constant SPAT.Command_Line.Entity_Filter.Result_Array
:= SPAT.Command_Line.Entity_Filter.Get;
begin
for Expression of Filter loop
begin
Entity_Filter.Append
(New_Item =>
GNAT.Regexp.Compile
(Pattern => SPAT.To_String (Expression),
Glob => False,
Case_Sensitive => False));
null;
exception
when GNAT.Regexp.Error_In_Regexp =>
SPAT.Log.Message
(Message =>
"Argument parsing failed: """ &
SPAT.To_String (Source => Expression) &
""" is not a valid regular expression.");
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status
(Code => Ada.Command_Line.Failure);
return;
end;
end loop;
end;
Do_Run_SPAT :
declare
SPARK_Files : SPAT.Spark_Files.T;
Timer : SPAT.Stop_Watch.T := SPAT.Stop_Watch.Create;
Sort_By : constant SPAT.Spark_Info.Sorting_Criterion :=
SPAT.Command_Line.Sort_By.Get;
Cut_Off : constant Duration := SPAT.Command_Line.Cut_Off.Get;
Report_Mode : constant SPAT.Command_Line.Report_Mode :=
SPAT.Command_Line.Report.Get;
Project_File : constant GNATCOLL.VFS.Filesystem_String :=
GNATCOLL.VFS."+" (S => SPAT.To_String (SPAT.Command_Line.Project.Get));
File_List : constant SPAT.GPR_Support.SPARK_Source_Maps.Map :=
SPAT.GPR_Support.Get_SPARK_Files (GPR_File => Project_File);
use type SPAT.Command_Line.Report_Mode;
begin
Collect_And_Parse :
begin
-- Step 2: Parse the files into JSON values.
if not File_List.Is_Empty then
SPAT.Log.Debug
(Message =>
"Using up to" & SPAT.Spark_Files.Num_Workers'Image &
" parsing threads.");
Timer.Start;
declare
File_Names : SPAT.Strings.SPARK_File_Names (Capacity => File_List.Length);
begin
for X in File_List.Iterate loop
File_Names.Append (SPAT.GPR_Support.SPARK_Source_Maps.Key (X));
end loop;
SPARK_Files.Read (Names => File_Names);
end;
SPAT.Log.Debug
(Message => "Parsing completed in " & Timer.Elapsed & ".");
end if;
end Collect_And_Parse;
Process_And_Output :
declare
Info : SPAT.Spark_Info.T;
begin
-- Step 3: Process the JSON data.
if not SPARK_Files.Is_Empty then
Timer.Start;
for C in SPARK_Files.Iterate loop
Parse_JSON_File :
declare
Read_Result : constant GNATCOLL.JSON.Read_Result :=
SPARK_Files (C);
File : constant SPAT.SPARK_File_Name :=
SPAT.Spark_Files.Key (C);
begin
if Read_Result.Success then
Info.Map_Spark_File (Root => Read_Result.Value,
File => File);
else
SPAT.Log.Warning
(Message =>
SPAT.To_String (Source => File) & ": " &
GNATCOLL.JSON.Format_Parsing_Error
(Error => Read_Result.Error));
end if;
end Parse_JSON_File;
end loop;
SPAT.Log.Debug
(Message => "Reading completed in " & Timer.Elapsed & ".");
end if;
SPAT.Log.Debug
(Message =>
"Collecting files completed in " & Timer.Elapsed_Total & ".");
SPAT.Log.Debug
(Message => "Cut off point set to " & SPAT.Image (Cut_Off) & ".");
-- Step 4: Output the JSON data.
if SPAT.Command_Line.Summary.Get then
Print_Summary (Info => Info,
Sort_By => Sort_By,
Cut_Off => Cut_Off);
end if;
if Report_Mode /= SPAT.Command_Line.None then
Print_Entities (Info => Info,
Sort_By => Sort_By,
Cut_Off => Cut_Off,
Entity_Filter => Entity_Filter);
end if;
if SPAT.Command_Line.Suggest.Get then
Print_Suggestion (Info => Info,
File_Map => File_List);
end if;
exception
when E : others =>
SPAT.Log.Dump_Exception
(E => E,
Message => "Internal error encountered when processing data!");
end Process_And_Output;
end Do_Run_SPAT;
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Success);
exception
when E : others =>
SPAT.Spark_Files.Shutdown;
-- This shouldn't happen, other exception handlers should have caught
-- such earlier.
SPAT.Log.Dump_Exception
(E => E,
Message => "Fatal error encountered in SPAT!");
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Failure);
end Run_SPAT;
| true | ------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. (PI:EMAIL:<EMAIL>END_PI)
--
-- 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);
------------------------------------------------------------------------------
--
-- SPARK Proof Analysis Tool
--
-- S.P.A.T. - Main program
--
------------------------------------------------------------------------------
with Ada.Command_Line;
with Ada.Containers.Vectors;
with Ada.Directories;
with GNAT.Regexp;
with GNATCOLL.JSON;
with GNATCOLL.Projects;
with GNATCOLL.VFS;
with SPAT.Command_Line;
with SPAT.GPR_Support;
with SPAT.Log;
with SPAT.Spark_Files;
with SPAT.Spark_Info;
with SPAT.Stop_Watch;
with SPAT.Strings;
with SPAT.Version;
with System;
------------------------------------------------------------------------------
-- Run_SPAT
------------------------------------------------------------------------------
procedure Run_SPAT is
package Reg_Exp_List is new
Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => GNAT.Regexp.Regexp,
"=" => GNAT.Regexp."=");
---------------------------------------------------------------------------
-- Print_Entities
---------------------------------------------------------------------------
procedure Print_Entities
(Info : in SPAT.Spark_Info.T;
Sort_By : in SPAT.Spark_Info.Sorting_Criterion;
Cut_Off : in Duration;
Entity_Filter : in Reg_Exp_List.Vector);
---------------------------------------------------------------------------
-- Print_Suggestion
---------------------------------------------------------------------------
procedure Print_Suggestion
(Info : in SPAT.Spark_Info.T;
File_Map : in SPAT.GPR_Support.SPARK_Source_Maps.Map);
---------------------------------------------------------------------------
-- Print_Summary
---------------------------------------------------------------------------
procedure Print_Summary (Info : in SPAT.Spark_Info.T;
Sort_By : in SPAT.Spark_Info.Sorting_Criterion;
Cut_Off : in Duration);
---------------------------------------------------------------------------
-- Print_Entities
---------------------------------------------------------------------------
procedure Print_Entities
(Info : in SPAT.Spark_Info.T;
Sort_By : in SPAT.Spark_Info.Sorting_Criterion;
Cut_Off : in Duration;
Entity_Filter : in Reg_Exp_List.Vector) is separate;
---------------------------------------------------------------------------
-- Print_Suggestion
---------------------------------------------------------------------------
procedure Print_Suggestion
(Info : in SPAT.Spark_Info.T;
File_Map : in SPAT.GPR_Support.SPARK_Source_Maps.Map) is separate;
---------------------------------------------------------------------------
-- Print_Summary
---------------------------------------------------------------------------
procedure Print_Summary (Info : in SPAT.Spark_Info.T;
Sort_By : in SPAT.Spark_Info.Sorting_Criterion;
Cut_Off : in Duration) is separate;
use type SPAT.Subject_Name;
Entity_Filter : Reg_Exp_List.Vector;
begin
if not SPAT.Command_Line.Parser.Parse then
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Failure);
return;
end if;
if SPAT.Command_Line.Version.Get then
SPAT.Log.Message
(Message =>
"run_spat V" & SPAT.Version.Number &
" (compiled by " & System.System_Name'Image & " " &
SPAT.Version.Compiler & ")");
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Success);
return;
end if;
if SPAT.Command_Line.Project.Get = SPAT.Null_Name then
-- The project file option is mandatory (AFAICS there is no way to
-- require an option argument).
SPAT.Log.Message
(Message => "Argument parsing failed: Missing project file argument");
SPAT.Log.Message (Message => SPAT.Command_Line.Parser.Help);
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Failure);
return;
end if;
-- If there were entity filter options given, try compiling the reg exps.
--
-- for Expression of SPAT.Command_Line.Entity_Filter.Get loop
-- The above triggers a GNAT bug box with GNAT CE 2020.
--
declare
Filter : constant SPAT.Command_Line.Entity_Filter.Result_Array
:= SPAT.Command_Line.Entity_Filter.Get;
begin
for Expression of Filter loop
begin
Entity_Filter.Append
(New_Item =>
GNAT.Regexp.Compile
(Pattern => SPAT.To_String (Expression),
Glob => False,
Case_Sensitive => False));
null;
exception
when GNAT.Regexp.Error_In_Regexp =>
SPAT.Log.Message
(Message =>
"Argument parsing failed: """ &
SPAT.To_String (Source => Expression) &
""" is not a valid regular expression.");
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status
(Code => Ada.Command_Line.Failure);
return;
end;
end loop;
end;
Do_Run_SPAT :
declare
SPARK_Files : SPAT.Spark_Files.T;
Timer : SPAT.Stop_Watch.T := SPAT.Stop_Watch.Create;
Sort_By : constant SPAT.Spark_Info.Sorting_Criterion :=
SPAT.Command_Line.Sort_By.Get;
Cut_Off : constant Duration := SPAT.Command_Line.Cut_Off.Get;
Report_Mode : constant SPAT.Command_Line.Report_Mode :=
SPAT.Command_Line.Report.Get;
Project_File : constant GNATCOLL.VFS.Filesystem_String :=
GNATCOLL.VFS."+" (S => SPAT.To_String (SPAT.Command_Line.Project.Get));
File_List : constant SPAT.GPR_Support.SPARK_Source_Maps.Map :=
SPAT.GPR_Support.Get_SPARK_Files (GPR_File => Project_File);
use type SPAT.Command_Line.Report_Mode;
begin
Collect_And_Parse :
begin
-- Step 2: Parse the files into JSON values.
if not File_List.Is_Empty then
SPAT.Log.Debug
(Message =>
"Using up to" & SPAT.Spark_Files.Num_Workers'Image &
" parsing threads.");
Timer.Start;
declare
File_Names : SPAT.Strings.SPARK_File_Names (Capacity => File_List.Length);
begin
for X in File_List.Iterate loop
File_Names.Append (SPAT.GPR_Support.SPARK_Source_Maps.Key (X));
end loop;
SPARK_Files.Read (Names => File_Names);
end;
SPAT.Log.Debug
(Message => "Parsing completed in " & Timer.Elapsed & ".");
end if;
end Collect_And_Parse;
Process_And_Output :
declare
Info : SPAT.Spark_Info.T;
begin
-- Step 3: Process the JSON data.
if not SPARK_Files.Is_Empty then
Timer.Start;
for C in SPARK_Files.Iterate loop
Parse_JSON_File :
declare
Read_Result : constant GNATCOLL.JSON.Read_Result :=
SPARK_Files (C);
File : constant SPAT.SPARK_File_Name :=
SPAT.Spark_Files.Key (C);
begin
if Read_Result.Success then
Info.Map_Spark_File (Root => Read_Result.Value,
File => File);
else
SPAT.Log.Warning
(Message =>
SPAT.To_String (Source => File) & ": " &
GNATCOLL.JSON.Format_Parsing_Error
(Error => Read_Result.Error));
end if;
end Parse_JSON_File;
end loop;
SPAT.Log.Debug
(Message => "Reading completed in " & Timer.Elapsed & ".");
end if;
SPAT.Log.Debug
(Message =>
"Collecting files completed in " & Timer.Elapsed_Total & ".");
SPAT.Log.Debug
(Message => "Cut off point set to " & SPAT.Image (Cut_Off) & ".");
-- Step 4: Output the JSON data.
if SPAT.Command_Line.Summary.Get then
Print_Summary (Info => Info,
Sort_By => Sort_By,
Cut_Off => Cut_Off);
end if;
if Report_Mode /= SPAT.Command_Line.None then
Print_Entities (Info => Info,
Sort_By => Sort_By,
Cut_Off => Cut_Off,
Entity_Filter => Entity_Filter);
end if;
if SPAT.Command_Line.Suggest.Get then
Print_Suggestion (Info => Info,
File_Map => File_List);
end if;
exception
when E : others =>
SPAT.Log.Dump_Exception
(E => E,
Message => "Internal error encountered when processing data!");
end Process_And_Output;
end Do_Run_SPAT;
SPAT.Spark_Files.Shutdown;
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Success);
exception
when E : others =>
SPAT.Spark_Files.Shutdown;
-- This shouldn't happen, other exception handlers should have caught
-- such earlier.
SPAT.Log.Dump_Exception
(E => E,
Message => "Fatal error encountered in SPAT!");
Ada.Command_Line.Set_Exit_Status (Code => Ada.Command_Line.Failure);
end Run_SPAT;
|
[
{
"context": "wed to modify the data\n-- of the protected object, Barnes (Programming in Ada 2012) says:\n-- \"The implement",
"end": 1354,
"score": 0.9227275848388672,
"start": 1348,
"tag": "NAME",
"value": "Barnes"
}
] | src/protect.adb | shintakezou/adaplayground | 0 | --
-- One writer, one reader at a time, using
-- protected object.
--
-- Output can be intermixed (can another
-- protected object be used to streamline output?)
--
-- Each task has its reference start time; shouldn't it be
-- the same for all? (Another protected object, again;
-- anyway the differences should be small)
--
-------------------
-- OUTPUT EXAMPLE
--
-- 0.000004000 R1 reading...
-- 0.000222000 OAT starts reading...
-- 0.000033000 0.000128000 ET writes 1...
-- R2 works for 2s
-- 2.000336000 R2 reading...
-- 3.000359000 OAT ended read
-- 3.000268000 3.000418000 OAT starts writing...
-- ...R1 read 0
-- 8.000543000 OAT ended writing...
-- 8.000542000 ET has written 1
-- 8.000588000 OAT starts reading...
-- 11.000725000 OAT ended read
-- 11.000623000 ...R2 read 1
-- *** R2 exit ***
-- 11.000794000 OAT starts reading...
-- 14.000952000 OAT ended read
-- 14.000848000*** R1 exit ***
--
-- R1 reads at 0, end reading at 3
-- ET starts writing at 0, but OAT is already reading,
-- so it really begins writing at 3, hence ending at 8
-- R2 starts reading at 2, and ends at 11
--
-- ..........1.
-- 0....5....0.
-- R1 RRR-----rrrRRR
-- R2 --rrrrrrRRR
-- ET wwwWWWWW____
--
-- When using a function, which isn't allowed to modify the data
-- of the protected object, Barnes (Programming in Ada 2012) says:
-- "The implementation is consequently permitted to perform the
-- useful optimization of allowing multiple calls of functions
-- at the same time thus automatically solving the basic classic
-- readers and writers problem".
--
-- The results are consistent with the implementation NOT doing
-- anything like this, even if I've used a function for reading.
--
-- BUT, I am also using a delay, gnat warns me so
-- potentially blocking operation in protected operation
-- for both the function and the procedure. Anyway, could the
-- delay be the bottleneck? (The delay waits itself...?)
--
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
procedure Protect is
procedure Put_Time_Diff (D : in Time) is
T : Duration := Clock - D;
begin
Put (Duration'Image (T));
end Put_Time_Diff;
protected One_A_Time is
function Read return Integer;
-- Reading takes 3s
procedure Write (X : Integer);
-- Writing takes 5s
private
V : Integer := 0;
T : Time := Clock;
end One_A_Time;
protected body One_A_Time is
function Read return Integer is
begin
Put_Time_Diff (T); Put_Line (" OAT starts reading...");
delay 3.0;
Put_Time_Diff (T); Put_Line (" OAT ended read");
return V;
end Read;
procedure Write (X : Integer) is
begin
Put_Time_Diff (T); Put_Line (" OAT starts writing...");
delay 5.0;
V := X;
Put_Time_Diff (T); Put_Line (" OAT ended writing...");
end Write;
end One_A_Time;
task Reader1;
task Reader2;
task body Reader1 is
I : Integer;
T : Time := Clock;
begin
Put_Time_Diff (T);
Put_Line (" R1 reading...");
I := One_A_Time.Read;
Put_Time_Diff (T);
Put_Line (" ...R1 read" & Integer'Image (I));
delay 5.0;
-- try to read with R2
I := One_A_Time.Read;
Put_Time_Diff (T); Put_Line ("*** R1 exit ***");
end Reader1;
task body Reader2 is
I : Integer;
T : Time := Clock;
begin
Put_Time_Diff (T);
Put_Line (" R2 works for 2s");
delay 2.0;
Put_Time_Diff (T);
Put_Line (" R2 reading...");
I := One_A_Time.Read;
Put_Time_Diff (T);
Put_Line (" ...R2 read" & Integer'Image (I));
Put_Line ("*** R2 exit ***");
end Reader2;
T : Time := Clock;
begin
-- The main writes
Put_Time_Diff (T);
Put_Line (" ET writes 1...");
One_A_Time.Write (1);
Put_Time_Diff (T);
Put_Line (" ET has written 1");
end;
| 13025 | --
-- One writer, one reader at a time, using
-- protected object.
--
-- Output can be intermixed (can another
-- protected object be used to streamline output?)
--
-- Each task has its reference start time; shouldn't it be
-- the same for all? (Another protected object, again;
-- anyway the differences should be small)
--
-------------------
-- OUTPUT EXAMPLE
--
-- 0.000004000 R1 reading...
-- 0.000222000 OAT starts reading...
-- 0.000033000 0.000128000 ET writes 1...
-- R2 works for 2s
-- 2.000336000 R2 reading...
-- 3.000359000 OAT ended read
-- 3.000268000 3.000418000 OAT starts writing...
-- ...R1 read 0
-- 8.000543000 OAT ended writing...
-- 8.000542000 ET has written 1
-- 8.000588000 OAT starts reading...
-- 11.000725000 OAT ended read
-- 11.000623000 ...R2 read 1
-- *** R2 exit ***
-- 11.000794000 OAT starts reading...
-- 14.000952000 OAT ended read
-- 14.000848000*** R1 exit ***
--
-- R1 reads at 0, end reading at 3
-- ET starts writing at 0, but OAT is already reading,
-- so it really begins writing at 3, hence ending at 8
-- R2 starts reading at 2, and ends at 11
--
-- ..........1.
-- 0....5....0.
-- R1 RRR-----rrrRRR
-- R2 --rrrrrrRRR
-- ET wwwWWWWW____
--
-- When using a function, which isn't allowed to modify the data
-- of the protected object, <NAME> (Programming in Ada 2012) says:
-- "The implementation is consequently permitted to perform the
-- useful optimization of allowing multiple calls of functions
-- at the same time thus automatically solving the basic classic
-- readers and writers problem".
--
-- The results are consistent with the implementation NOT doing
-- anything like this, even if I've used a function for reading.
--
-- BUT, I am also using a delay, gnat warns me so
-- potentially blocking operation in protected operation
-- for both the function and the procedure. Anyway, could the
-- delay be the bottleneck? (The delay waits itself...?)
--
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
procedure Protect is
procedure Put_Time_Diff (D : in Time) is
T : Duration := Clock - D;
begin
Put (Duration'Image (T));
end Put_Time_Diff;
protected One_A_Time is
function Read return Integer;
-- Reading takes 3s
procedure Write (X : Integer);
-- Writing takes 5s
private
V : Integer := 0;
T : Time := Clock;
end One_A_Time;
protected body One_A_Time is
function Read return Integer is
begin
Put_Time_Diff (T); Put_Line (" OAT starts reading...");
delay 3.0;
Put_Time_Diff (T); Put_Line (" OAT ended read");
return V;
end Read;
procedure Write (X : Integer) is
begin
Put_Time_Diff (T); Put_Line (" OAT starts writing...");
delay 5.0;
V := X;
Put_Time_Diff (T); Put_Line (" OAT ended writing...");
end Write;
end One_A_Time;
task Reader1;
task Reader2;
task body Reader1 is
I : Integer;
T : Time := Clock;
begin
Put_Time_Diff (T);
Put_Line (" R1 reading...");
I := One_A_Time.Read;
Put_Time_Diff (T);
Put_Line (" ...R1 read" & Integer'Image (I));
delay 5.0;
-- try to read with R2
I := One_A_Time.Read;
Put_Time_Diff (T); Put_Line ("*** R1 exit ***");
end Reader1;
task body Reader2 is
I : Integer;
T : Time := Clock;
begin
Put_Time_Diff (T);
Put_Line (" R2 works for 2s");
delay 2.0;
Put_Time_Diff (T);
Put_Line (" R2 reading...");
I := One_A_Time.Read;
Put_Time_Diff (T);
Put_Line (" ...R2 read" & Integer'Image (I));
Put_Line ("*** R2 exit ***");
end Reader2;
T : Time := Clock;
begin
-- The main writes
Put_Time_Diff (T);
Put_Line (" ET writes 1...");
One_A_Time.Write (1);
Put_Time_Diff (T);
Put_Line (" ET has written 1");
end;
| true | --
-- One writer, one reader at a time, using
-- protected object.
--
-- Output can be intermixed (can another
-- protected object be used to streamline output?)
--
-- Each task has its reference start time; shouldn't it be
-- the same for all? (Another protected object, again;
-- anyway the differences should be small)
--
-------------------
-- OUTPUT EXAMPLE
--
-- 0.000004000 R1 reading...
-- 0.000222000 OAT starts reading...
-- 0.000033000 0.000128000 ET writes 1...
-- R2 works for 2s
-- 2.000336000 R2 reading...
-- 3.000359000 OAT ended read
-- 3.000268000 3.000418000 OAT starts writing...
-- ...R1 read 0
-- 8.000543000 OAT ended writing...
-- 8.000542000 ET has written 1
-- 8.000588000 OAT starts reading...
-- 11.000725000 OAT ended read
-- 11.000623000 ...R2 read 1
-- *** R2 exit ***
-- 11.000794000 OAT starts reading...
-- 14.000952000 OAT ended read
-- 14.000848000*** R1 exit ***
--
-- R1 reads at 0, end reading at 3
-- ET starts writing at 0, but OAT is already reading,
-- so it really begins writing at 3, hence ending at 8
-- R2 starts reading at 2, and ends at 11
--
-- ..........1.
-- 0....5....0.
-- R1 RRR-----rrrRRR
-- R2 --rrrrrrRRR
-- ET wwwWWWWW____
--
-- When using a function, which isn't allowed to modify the data
-- of the protected object, PI:NAME:<NAME>END_PI (Programming in Ada 2012) says:
-- "The implementation is consequently permitted to perform the
-- useful optimization of allowing multiple calls of functions
-- at the same time thus automatically solving the basic classic
-- readers and writers problem".
--
-- The results are consistent with the implementation NOT doing
-- anything like this, even if I've used a function for reading.
--
-- BUT, I am also using a delay, gnat warns me so
-- potentially blocking operation in protected operation
-- for both the function and the procedure. Anyway, could the
-- delay be the bottleneck? (The delay waits itself...?)
--
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
procedure Protect is
procedure Put_Time_Diff (D : in Time) is
T : Duration := Clock - D;
begin
Put (Duration'Image (T));
end Put_Time_Diff;
protected One_A_Time is
function Read return Integer;
-- Reading takes 3s
procedure Write (X : Integer);
-- Writing takes 5s
private
V : Integer := 0;
T : Time := Clock;
end One_A_Time;
protected body One_A_Time is
function Read return Integer is
begin
Put_Time_Diff (T); Put_Line (" OAT starts reading...");
delay 3.0;
Put_Time_Diff (T); Put_Line (" OAT ended read");
return V;
end Read;
procedure Write (X : Integer) is
begin
Put_Time_Diff (T); Put_Line (" OAT starts writing...");
delay 5.0;
V := X;
Put_Time_Diff (T); Put_Line (" OAT ended writing...");
end Write;
end One_A_Time;
task Reader1;
task Reader2;
task body Reader1 is
I : Integer;
T : Time := Clock;
begin
Put_Time_Diff (T);
Put_Line (" R1 reading...");
I := One_A_Time.Read;
Put_Time_Diff (T);
Put_Line (" ...R1 read" & Integer'Image (I));
delay 5.0;
-- try to read with R2
I := One_A_Time.Read;
Put_Time_Diff (T); Put_Line ("*** R1 exit ***");
end Reader1;
task body Reader2 is
I : Integer;
T : Time := Clock;
begin
Put_Time_Diff (T);
Put_Line (" R2 works for 2s");
delay 2.0;
Put_Time_Diff (T);
Put_Line (" R2 reading...");
I := One_A_Time.Read;
Put_Time_Diff (T);
Put_Line (" ...R2 read" & Integer'Image (I));
Put_Line ("*** R2 exit ***");
end Reader2;
T : Time := Clock;
begin
-- The main writes
Put_Time_Diff (T);
Put_Line (" ET writes 1...");
One_A_Time.Write (1);
Put_Time_Diff (T);
Put_Line (" ET has written 1");
end;
|
[
{
"context": "Identifier: BSD-3-Clause\n--\n-- Copyright (c) 2017 Eric Bruneton\n-- All rights reserved.\n--\n-- Redistribution an",
"end": 81,
"score": 0.9998577833175659,
"start": 68,
"tag": "NAME",
"value": "Eric Bruneton"
}
] | orka_plugin_atmosphere/src/orka-features-atmosphere.adb | onox/orka | 52 | -- SPDX-License-Identifier: BSD-3-Clause
--
-- Copyright (c) 2017 Eric Bruneton
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions
-- are met:
-- 1. Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- 3. Neither the name of the copyright holders nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
-- THE POSSIBILITY OF SUCH DAMAGE.
-- This package's role is to precompute the transmittance, scattering and
-- irradiance textures. The GLSL functions to precompute them are provided
-- in functions.frag, but they are not sufficient.
-- They must be used in fully functional shaders and programs, and these
-- programs must be called in the correct order, with the correct input and
-- output textures (via framebuffer objects), to precompute each scattering
-- order in sequence, as described in Algorithm 4.1 of our paper [1].
--
-- [1] https://hal.inria.fr/inria-00288758/en
with Ada.Characters.Latin_1;
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Strings.Unbounded;
with Ada.Unchecked_Conversion;
with GL.Blending;
with GL.Buffers;
with GL.Pixels;
with GL.Toggles;
with Orka.Features.Atmosphere.Constants;
with Orka.Rendering.Drawing;
with Orka.Rendering.Framebuffers;
with Orka.Rendering.Programs.Uniforms;
with Orka.Rendering.Textures;
with Orka.Types;
package body Orka.Features.Atmosphere is
package Framebuffers renames Orka.Rendering.Framebuffers;
package SU renames Ada.Strings.Unbounded;
K_Lambda_R : constant Double := 680.0;
K_Lambda_G : constant Double := 550.0;
K_Lambda_B : constant Double := 440.0;
function Convert (Bytes : Resources.Byte_Array) return String renames Resources.Convert;
use Orka.Features.Atmosphere.Constants;
function Create_Sampler return GL.Objects.Samplers.Sampler is
Result : GL.Objects.Samplers.Sampler;
use all type Textures.Wrapping_Mode;
use all type Textures.Minifying_Function;
begin
Result.Set_X_Wrapping (Clamp_To_Edge);
Result.Set_Y_Wrapping (Clamp_To_Edge);
Result.Set_Z_Wrapping (Clamp_To_Edge);
Result.Set_Minifying_Filter (Linear);
Result.Set_Magnifying_Filter (Linear);
return Result;
end Create_Sampler;
function Create_Texture (Width, Height : Size) return Textures.Texture is
Result : Textures.Texture (LE.Texture_2D);
begin
-- 16F precision for the transmittance gives artifacts
Result.Allocate_Storage (1, 1, GL.Pixels.RGBA32F, Width, Height, 1);
return Result;
end Create_Texture;
function Create_Texture
(Width, Height, Depth : Size;
Half_Precision : Boolean) return Textures.Texture
is
Result : Textures.Texture (LE.Texture_3D);
Internal_Format : constant GL.Pixels.Internal_Format
:= (if Half_Precision then GL.Pixels.RGBA16F else GL.Pixels.RGBA32F);
begin
Result.Allocate_Storage (1, 1, Internal_Format, Width, Height, Depth);
return Result;
end Create_Texture;
-----------------------------------------------------------------------------
type Enable_Blend_Array is array (GL.Buffers.Draw_Buffer_Index range <>) of Boolean;
procedure Draw_Quad (Blend : Enable_Blend_Array) is
begin
for Index in Blend'Range loop
if Blend (Index) then
GL.Toggles.Enable (GL.Toggles.Blend, Index);
end if;
end loop;
Orka.Rendering.Drawing.Draw (Triangles, 0, 3);
for Index in Blend'Range loop
GL.Toggles.Disable (GL.Toggles.Blend, Index);
end loop;
end Draw_Quad;
-----------------------------------------------------------------------------
-- Finally, we need a utility function to compute the value of the
-- conversion constants *_RADIANCE_TO_LUMINANCE, used in the shader
-- to convert the spectral results into luminance values. These are
-- the constants k_r, k_g, k_b described in Section 14.3 of
-- "A Qualitative and Quantitative Evaluation of 8 Clear Sky Models" [1].
-- Computing their value requires an integral of a function times a
-- CIE color matching function. Thus, we first need functions to
-- interpolate an arbitrary function (specified by some samples), and
-- a CIE color matching function (specified by tabulated values), at
-- an arbitrary wavelength. This is the purpose of the two functions
-- below.
--
-- [1] https://arxiv.org/pdf/1612.04336.pdf
function CIE_Color_Matching_Function_Table_Value
(Wavelength : Double;
Column : Size) return Double is
begin
if Wavelength <= K_Lambda_Min or Wavelength >= K_Lambda_Max then
return 0.0;
end if;
declare
U : Double := (Wavelength - K_Lambda_Min) / 5.0;
Row : constant Size := Int (Double'Floor (U));
pragma Assert (Row + 1 < 95);
pragma Assert (CIE_2_Deg_Color_Matching_Functions (4 * Row) <= Wavelength);
pragma Assert (CIE_2_Deg_Color_Matching_Functions (4 * (Row + 1)) >= Wavelength);
begin
U := U - Double (Row);
return CIE_2_Deg_Color_Matching_Functions (4 * Row + Column) * (1.0 - U) +
CIE_2_Deg_Color_Matching_Functions (4 * (Row + 1) + Column) * U;
end;
end CIE_Color_Matching_Function_Table_Value;
function Interpolate
(Wavelengths, Functions : Double_Vectors.Vector;
Wavelength : Double) return Double
is
pragma Assert (Wavelengths.Length = Functions.Length);
begin
if Wavelength < Wavelengths.First_Element then
return Functions.First_Element;
end if;
for Index in Wavelengths.First_Index .. Wavelengths.Last_Index - 1 loop
if Wavelength < Wavelengths (Index + 1) then
declare
U : constant Double := (Wavelength - Wavelengths (Index))
/ (Wavelengths (Index + 1) - Wavelengths (Index));
begin
return Functions (Index) * (1.0 - U) + Functions (Index + 1) * U;
end;
end if;
end loop;
return Functions.Last_Element;
end Interpolate;
-- We can then implement a utility function to compute the "spectral
-- radiance to luminance" conversion constants (see Section 14.3 in
-- "A Qualitative and Quantitative Evaluation of 8 Clear Sky Models" [1]
-- for their definitions).
--
-- [1] https://arxiv.org/pdf/1612.04336.pdf
procedure Compute_Spectral_Radiance_To_Luminance_Factors
(Wavelengths, Solar_Irradiance : Double_Vectors.Vector;
Lambda_Power : Double;
K_R, K_G, K_B : out Double) -- The returned constants are in lumen.nm / watt
is
package EF is new Ada.Numerics.Generic_Elementary_Functions (Double);
use EF;
Solar_R : constant Double := Interpolate (Wavelengths, Solar_Irradiance, K_Lambda_R);
Solar_G : constant Double := Interpolate (Wavelengths, Solar_Irradiance, K_Lambda_G);
Solar_B : constant Double := Interpolate (Wavelengths, Solar_Irradiance, K_Lambda_B);
D_Lambda : constant Double := 1.0;
Lambda : Double := K_Lambda_Min;
begin
K_R := 0.0;
K_G := 0.0;
K_B := 0.0;
while Lambda < K_Lambda_Max loop
declare
X_Bar : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 1);
Y_Bar : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 2);
Z_Bar : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 3);
R_Bar : constant Double
:= XYZ_To_SRGB (0) * X_Bar + XYZ_To_SRGB (1) * Y_Bar + XYZ_To_SRGB (2) * Z_Bar;
G_Bar : constant Double
:= XYZ_To_SRGB (3) * X_Bar + XYZ_To_SRGB (4) * Y_Bar + XYZ_To_SRGB (5) * Z_Bar;
B_Bar : constant Double
:= XYZ_To_SRGB (6) * X_Bar + XYZ_To_SRGB (7) * Y_Bar + XYZ_To_SRGB (8) * Z_Bar;
Irradiance : constant Double := Interpolate (Wavelengths, Solar_Irradiance, Lambda);
begin
K_R := K_R + R_Bar * Irradiance / Solar_R * (Lambda / K_Lambda_R) ** Lambda_Power;
K_G := K_G + G_Bar * Irradiance / Solar_G * (Lambda / K_Lambda_G) ** Lambda_Power;
K_B := K_B + B_Bar * Irradiance / Solar_B * (Lambda / K_Lambda_B) ** Lambda_Power;
end;
Lambda := Lambda + D_Lambda;
end loop;
K_R := K_R * Max_Luminous_Efficacy * D_Lambda;
K_G := K_G * Max_Luminous_Efficacy * D_Lambda;
K_B := K_B * Max_Luminous_Efficacy * D_Lambda;
end Compute_Spectral_Radiance_To_Luminance_Factors;
-- A function that creates a shader header containing our atmosphere computation
-- functions, specialized for the given atmosphere parameters and for the 3
-- wavelengths in Lambdas
function Shader_Header (Result : Model; Lambdas : Double_Array) return String is
package EF is new Ada.Numerics.Generic_Elementary_Functions (Double);
use Ada.Characters.Latin_1;
Data : not null access constant Model_Data renames Result.Data;
function To_String
(V : Double_Vectors.Vector;
Scale : Double) return String
is
R : constant Double := Interpolate (Data.Wavelengths, V, Lambdas (0)) * Scale;
G : constant Double := Interpolate (Data.Wavelengths, V, Lambdas (1)) * Scale;
B : constant Double := Interpolate (Data.Wavelengths, V, Lambdas (2)) * Scale;
begin
return "vec3(" & R'Image & "," & G'Image & "," & B'Image & ")";
end To_String;
function Density_Layer (Layer : Density_Profile_Layer) return String is
Width : constant Double := Layer.Width / Data.Length_Unit_In_Meters;
Scale : constant Double := Layer.Exp_Scale * Data.Length_Unit_In_Meters;
Linear_Term : constant Double := Layer.Linear_Term * Data.Length_Unit_In_Meters;
begin
return "DensityProfileLayer(" &
Width'Image & "," & Layer.Exp_Term'Image & "," &
Scale'Image & "," & Linear_Term'Image & "," &
Layer.Constant_Term'Image & ")";
end Density_Layer;
function Density_Profile (Layers : Density_Vectors.Vector) return String is
K_Layer_Count : constant := 2;
K_Layers : Density_Vectors.Vector := Layers.Copy;
Zero_Layer : Density_Profile_Layer;
Result : SU.Unbounded_String;
begin
while K_Layers.Length < K_Layer_Count loop
K_Layers.Prepend (Zero_Layer);
end loop;
SU.Append (Result, "DensityProfile(DensityProfileLayer[" &
Natural'Image (K_Layer_Count) & "](");
for Index in K_Layers.First_Index .. K_Layers.Last_Index - 1 loop
SU.Append (Result, Density_Layer (K_Layers (Index)) & ",");
end loop;
SU.Append (Result, Density_Layer (K_Layers.Last_Element) & "))");
return SU.To_String (Result);
end Density_Profile;
Definitions_GLSL : constant String
:= Convert (Resources.Byte_Array'(Result.Data_Definitions.Get));
Functions_GLSL : constant String
:= Convert (Resources.Byte_Array'(Result.Data_Functions.Get));
Bottom_Radius : constant Double := Data.Bottom_Radius / Data.Length_Unit_In_Meters;
Top_Radius : constant Double := Data.Top_Radius / Data.Length_Unit_In_Meters;
begin
return
"#version 420" & LF &
"#extension GL_ARB_fragment_layer_viewport : require" & LF &
"#define IN(x) const in x" & LF &
"#define OUT(x) out x" & LF &
"#define TEMPLATE(x)" & LF &
"#define TEMPLATE_ARGUMENT(x)" & LF &
"#define assert(x)" & LF &
"const int TRANSMITTANCE_TEXTURE_WIDTH = " &
Natural'Image (Transmittance_Texture_Width) & ";" & LF &
"const int TRANSMITTANCE_TEXTURE_HEIGHT = " &
Natural'Image (Transmittance_Texture_Height) & ";" & LF &
"const int SCATTERING_TEXTURE_R_SIZE = " &
Natural'Image (Scattering_Texture_R_Size) & ";" & LF &
"const int SCATTERING_TEXTURE_MU_SIZE = " &
Natural'Image (Scattering_Texture_Mu_Size) & ";" & LF &
"const int SCATTERING_TEXTURE_MU_S_SIZE = " &
Natural'Image (Scattering_Texture_Mu_S_Size) & ";" & LF &
"const int SCATTERING_TEXTURE_NU_SIZE = " &
Natural'Image (Scattering_Texture_Nu_Size) & ";" & LF &
"const int IRRADIANCE_TEXTURE_WIDTH = " &
Natural'Image (Irradiance_Texture_Width) & ";" & LF &
"const int IRRADIANCE_TEXTURE_HEIGHT = " &
Natural'Image (Irradiance_Texture_Height) & ";" & LF &
(if Data.Combine_Scattering_Textures then
"#define COMBINED_SCATTERING_TEXTURES" & LF
else "") &
Definitions_GLSL & LF &
"const AtmosphereParameters ATMOSPHERE = AtmosphereParameters(" & LF &
To_String (Data.Solar_Irradiance, 1.0) & "," & LF &
Data.Sun_Angular_Radius'Image & "," & LF &
Bottom_Radius'Image & "," & LF &
Top_Radius'Image & "," & LF &
Density_Profile (Data.Rayleigh_Density) & "," & LF &
To_String
(Data.Rayleigh_Scattering, Data.Length_Unit_In_Meters) & "," & LF &
Density_Profile (Data.Mie_Density) & "," & LF &
To_String
(Data.Mie_Scattering, Data.Length_Unit_In_Meters) & "," & LF &
To_String
(Data.Mie_Extinction, Data.Length_Unit_In_Meters) & "," & LF &
Data.Mie_Phase_Function_G'Image & "," & LF &
Density_Profile (Data.Absorption_Density) & "," & LF &
To_String
(Data.Absorption_Extinction, Data.Length_Unit_In_Meters) & "," & LF &
To_String (Data.Ground_Albedo, 1.0) & "," & LF &
EF.Cos (Data.Max_Sun_Zenith_Angle)'Image & ");" & LF &
"const vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE = vec3(" &
Result.Sky_K_R'Image & "," &
Result.Sky_K_G'Image & "," &
Result.Sky_K_B'Image & ");" & LF &
"const vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE = vec3(" &
Result.Sun_K_R'Image & "," &
Result.Sun_K_G'Image & "," &
Result.Sun_K_B'Image & ");" & LF &
Functions_GLSL & LF;
end Shader_Header;
-----------------------------------------------------------------------------
function Create_Model
(Data : not null access constant Model_Data;
Location : Resources.Locations.Location_Ptr) return Model
is
-- Compute the values for the SKY_RADIANCE_TO_LUMINANCE constant. In theory
-- this should be 1 in precomputed illuminance mode (because the precomputed
-- textures already contain illuminance values). In practice, however, storing
-- true illuminance values in half precision textures yields artefacts
-- (because the values are too large), so we store illuminance values divided
-- by MAX_LUMINOUS_EFFICACY instead. This is why, in precomputed illuminance
-- mode, we set SKY_RADIANCE_TO_LUMINANCE to MAX_LUMINOUS_EFFICACY.
Precompute_Illuminance : constant Boolean := Data.Num_Precomputed_Wavelengths > 3;
Power_Sky : constant Double := -3.0;
Power_Sun : constant Double := 0.0;
begin
return Result : Model (Data) do
if Precompute_Illuminance then
Result.Sky_K_R := Max_Luminous_Efficacy;
Result.Sky_K_G := Max_Luminous_Efficacy;
Result.Sky_K_B := Max_Luminous_Efficacy;
else
Compute_Spectral_Radiance_To_Luminance_Factors
(Data.Wavelengths, Data.Solar_Irradiance, Power_Sky,
Result.Sky_K_R, Result.Sky_K_G, Result.Sky_K_B);
end if;
-- Compute the values for the SUN_RADIANCE_TO_LUMINANCE constant
Compute_Spectral_Radiance_To_Luminance_Factors
(Data.Wavelengths, Data.Solar_Irradiance, Power_Sun,
Result.Sun_K_R, Result.Sun_K_G, Result.Sun_K_B);
Result.Data_Definitions := Location.Read_Data ("atmosphere/definitions.frag");
Result.Data_Functions := Location.Read_Data ("atmosphere/functions.frag");
Result.Location := Location;
end return;
end Create_Model;
-- The utility method is implemented with a simple numerical integration
-- of the given function, times the CIE color matching functions (with an
-- integration step of 1 nm), followed by a matrix multiplication
procedure Convert_Spectrum_To_Linear_SRGB (Data : Model_Data; R, G, B : out Double) is
D_Lambda : constant Double := 1.0;
Lambda : Double := K_Lambda_Min;
X, Y, Z : Double := 0.0;
begin
while Lambda < K_Lambda_Max loop
declare
Value : constant Double :=
Interpolate (Data.Wavelengths, Data.Solar_Irradiance, Lambda);
begin
X := X + CIE_Color_Matching_Function_Table_Value (Lambda, 1) * Value;
Y := Y + CIE_Color_Matching_Function_Table_Value (Lambda, 2) * Value;
Z := Z + CIE_Color_Matching_Function_Table_Value (Lambda, 3) * Value;
end;
Lambda := Lambda + D_Lambda;
end loop;
R := Max_Luminous_Efficacy *
(XYZ_To_SRGB (0) * X + XYZ_To_SRGB (1) * Y + XYZ_To_SRGB (2) * Z) * D_Lambda;
G := Max_Luminous_Efficacy *
(XYZ_To_SRGB (3) * X + XYZ_To_SRGB (4) * Y + XYZ_To_SRGB (5) * Z) * D_Lambda;
B := Max_Luminous_Efficacy *
(XYZ_To_SRGB (6) * X + XYZ_To_SRGB (7) * Y + XYZ_To_SRGB (8) * Z) * D_Lambda;
end Convert_Spectrum_To_Linear_SRGB;
-- Implementation of the precomputation algorithm described in
-- Algorithm 4.1 of [1]. Each step is explained by the inline
-- comments below.
--
-- [1] https://hal.inria.fr/inria-00288758/en
procedure Precompute
(Object : Model;
Result : Precomputed_Textures;
Delta_Irradiance_Texture, Delta_Rayleigh_Scattering_Texture,
Delta_Mie_Scattering_Texture, Delta_Scattering_Density_Texture,
Delta_Multiple_Scattering_Texture : Textures.Texture;
Lambdas : Double_Array;
Luminance_From_Radiance : Single_Array;
Blend : Boolean;
Num_Scattering_Orders : Natural)
is
LR : Single_Array renames Luminance_From_Radiance;
Luminance_From_Radiance_Mat3 : constant Orka.Types.Singles.Matrix4 :=
((LR (0), LR (1), LR (2), 0.0),
(LR (3), LR (4), LR (5), 0.0),
(LR (6), LR (7), LR (8), 0.0),
(0.0, 0.0, 0.0, 0.0));
use Orka.Rendering.Programs;
-- The precomputations require specific GLSL programs for each
-- precomputation step
Module_VS : constant Modules.Module
:= Modules.Create_Module (Object.Location, VS => "atmosphere/oversized-triangle.vert");
Module_GS : constant Modules.Module
:= Modules.Create_Module (Object.Location, GS => "atmosphere/layer.geom");
Header : constant String := Object.Shader_Header (Lambdas);
FS_Transmittance : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-transmittance.frag").Get));
FS_Direct_Irradiance : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-direct-irradiance.frag").Get));
FS_Indirect_Irradiance : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-indirect-irradiance.frag").Get));
FS_Single_Scattering : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-single-scattering.frag").Get));
FS_Multiple_Scattering : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-multiple-scattering.frag").Get));
FS_Scattering_Density : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-scattering-density.frag").Get));
Program_Transmittance : Program := Create_Program (Modules.Module_Array'
(Module_VS,
Modules.Create_Module_From_Sources (FS => Header & FS_Transmittance)));
Program_Direct_Irradiance : Program := Create_Program (Modules.Module_Array'
(Module_VS,
Modules.Create_Module_From_Sources (FS => Header & FS_Direct_Irradiance)));
Program_Indirect_Irradiance : Program := Create_Program (Modules.Module_Array'
(Module_VS,
Modules.Create_Module_From_Sources (FS => Header & FS_Indirect_Irradiance)));
Program_Single_Scattering : Program := Create_Program (Modules.Module_Array'
(Module_VS, Module_GS,
Modules.Create_Module_From_Sources (FS => Header & FS_Single_Scattering)));
Program_Multiple_Scattering : Program := Create_Program (Modules.Module_Array'
(Module_VS, Module_GS,
Modules.Create_Module_From_Sources (FS => Header & FS_Multiple_Scattering)));
Program_Scattering_Density : Program := Create_Program (Modules.Module_Array'
(Module_VS, Module_GS,
Modules.Create_Module_From_Sources (FS => Header & FS_Scattering_Density)));
-------------------------------------------------------------------------
FBO_Transmittance : Framebuffers.Framebuffer := Framebuffers.Create_Framebuffer
(Width => Constants.Transmittance_Texture_Width,
Height => Constants.Transmittance_Texture_Height);
FBO_Irradiance : Framebuffers.Framebuffer := Framebuffers.Create_Framebuffer
(Width => Constants.Irradiance_Texture_Width,
Height => Constants.Irradiance_Texture_Height);
FBO_Scattering : Framebuffers.Framebuffer := Framebuffers.Create_Framebuffer
(Width => Constants.Scattering_Texture_Width,
Height => Constants.Scattering_Texture_Height);
use all type GL.Blending.Equation;
use all type GL.Blending.Blend_Factor;
use all type Rendering.Textures.Indexed_Texture_Target;
use all type Framebuffers.Color_Attachment_Point;
begin
GL.Blending.Set_Blend_Equation ((Func_Add, Func_Add));
GL.Blending.Set_Blend_Func ((One, One, One, One));
Rendering.Textures.Bind (Result.Transmittance_Texture, Texture, 0);
-- transmittance_texture
Rendering.Textures.Bind (Delta_Rayleigh_Scattering_Texture, Texture, 1);
-- single_rayleigh_scattering_texture
Rendering.Textures.Bind (Delta_Mie_Scattering_Texture, Texture, 2);
-- single_mie_scattering_texture
Rendering.Textures.Bind (Delta_Multiple_Scattering_Texture, Texture, 3);
-- multiple_scattering_texture
Rendering.Textures.Bind (Delta_Irradiance_Texture, Texture, 4);
-- irradiance_texture
Rendering.Textures.Bind (Delta_Scattering_Density_Texture, Texture, 5);
-- scattering_density_texture
-- Compute the transmittance and store it in Transmittance_Texture
FBO_Transmittance.Use_Framebuffer;
FBO_Transmittance.Attach (Color_Attachment_0, Result.Transmittance_Texture);
FBO_Transmittance.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0));
Program_Transmittance.Use_Program;
Draw_Quad ((1 .. 0 => <>));
-------------------------------------------------------------------------
-- Compute the direct irradiance, store it in Delta_Irradiance_Texture and,
-- depending on 'blend', either initialize Irradiance_Texture with
-- zeros or leave it unchanged (we don't want the irradiance in
-- Irradiance_Texture, but only the irradiance from the sky
FBO_Irradiance.Use_Framebuffer;
FBO_Irradiance.Attach (Color_Attachment_0, Delta_Irradiance_Texture);
FBO_Irradiance.Attach (Color_Attachment_1, Result.Irradiance_Texture);
FBO_Irradiance.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0,
1 => GL.Buffers.Color_Attachment1));
Program_Direct_Irradiance.Use_Program;
Draw_Quad ((False, Blend));
-------------------------------------------------------------------------
-- Compute the rayleigh and mie single scattering, store them in
-- Delta_Rayleigh_Scattering_Texture and Delta_Mie_Scattering_Texture,
-- and either them or accumulate them in Scattering_Texture and
-- Optional_Single_Mie_Scattering_Texture
FBO_Scattering.Use_Framebuffer;
FBO_Scattering.Attach (Color_Attachment_0, Delta_Rayleigh_Scattering_Texture);
FBO_Scattering.Attach (Color_Attachment_1, Delta_Mie_Scattering_Texture);
FBO_Scattering.Attach (Color_Attachment_2, Result.Scattering_Texture);
if not Object.Data.Combine_Scattering_Textures then
FBO_Scattering.Attach (Color_Attachment_3,
Result.Optional_Single_Mie_Scattering_Texture);
FBO_Scattering.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0,
1 => GL.Buffers.Color_Attachment1,
2 => GL.Buffers.Color_Attachment2,
3 => GL.Buffers.Color_Attachment3));
else
FBO_Scattering.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0,
1 => GL.Buffers.Color_Attachment1,
2 => GL.Buffers.Color_Attachment2));
end if;
Program_Single_Scattering.Use_Program;
Program_Single_Scattering.Uniform ("luminance_from_radiance").Set_Matrix
(Luminance_From_Radiance_Mat3);
for Layer in 0 .. Int (Constants.Scattering_Texture_Depth - 1) loop
Program_Single_Scattering.Uniform ("layer").Set_Int (Layer);
Draw_Quad ((False, False, Blend, Blend));
end loop;
-------------------------------------------------------------------------
-- Compute the 2nd, 3rd and 4th order of scattering, in sequence
for Scattering_Order in 2 .. Int (Num_Scattering_Orders) loop
-- Compute the scattering density, and store it in
-- Delta_Scattering_Density_Texture
FBO_Scattering.Use_Framebuffer;
FBO_Scattering.Attach (Color_Attachment_0, Delta_Scattering_Density_Texture);
FBO_Scattering.Detach (Color_Attachment_1);
FBO_Scattering.Detach (Color_Attachment_2);
FBO_Scattering.Detach (Color_Attachment_3);
FBO_Scattering.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0));
Program_Scattering_Density.Use_Program;
Program_Scattering_Density.Uniform ("scattering_order").Set_Int (Scattering_Order);
for Layer in 0 .. Int (Constants.Scattering_Texture_Depth - 1) loop
Program_Scattering_Density.Uniform ("layer").Set_Int (Layer);
Draw_Quad ((1 .. 0 => <>));
end loop;
-- Compute the indirect irradiance, store it in Delta_Irradiance_Texture
-- and accumulate it in Irradiance_Texture
FBO_Irradiance.Use_Framebuffer;
FBO_Irradiance.Attach (Color_Attachment_0, Delta_Irradiance_Texture);
FBO_Irradiance.Attach (Color_Attachment_1, Result.Irradiance_Texture);
FBO_Irradiance.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0,
1 => GL.Buffers.Color_Attachment1));
Program_Indirect_Irradiance.Use_Program;
Program_Indirect_Irradiance.Uniform ("luminance_from_radiance").Set_Matrix
(Luminance_From_Radiance_Mat3);
Program_Indirect_Irradiance.Uniform ("scattering_order").Set_Int (Scattering_Order - 1);
Draw_Quad ((False, True));
-- Compute the multiple scattering, store it in
-- Delta_Multiple_Scattering_Texture, and accumulate it in
-- Scattering_Texture
FBO_Scattering.Use_Framebuffer;
FBO_Scattering.Attach (Color_Attachment_0, Delta_Multiple_Scattering_Texture);
FBO_Scattering.Attach (Color_Attachment_1, Result.Scattering_Texture);
FBO_Scattering.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0,
1 => GL.Buffers.Color_Attachment1));
Program_Multiple_Scattering.Use_Program;
Program_Multiple_Scattering.Uniform ("luminance_from_radiance").Set_Matrix
(Luminance_From_Radiance_Mat3);
for Layer in 0 .. Int (Constants.Scattering_Texture_Depth - 1) loop
Program_Multiple_Scattering.Uniform ("layer").Set_Int (Layer);
Draw_Quad ((False, True));
end loop;
end loop;
end Precompute;
-- Precomputes the atmosphere textures. It first allocates the
-- temporary resources it needs and then calls Precompute to do the
-- actual precomputations.
--
-- Note that there are two precomputation modes here, depending on whether we
-- want to store precomputed irradiance or illuminance values:
--
-- - In precomputed irradiance mode, we simply need to call
-- Precompute with the 3 wavelengths for which we want to precompute
-- irradiance, namely K_Lambda_R, K_Lambda_G,
-- K_Lambda_B (with the identity matrix for
-- Luminance_From_Radiance, since we don't want any conversion from
-- radiance to luminance)
--
-- - In precomputed illuminance mode, we need to precompute irradiance for
-- Num_Precomputed_Wavelengths, and then integrate the results,
-- multiplied with the 3 CIE xyz color matching functions and the XYZ to sRGB
-- matrix to get sRGB illuminance values.
--
-- A naive solution would be to allocate temporary textures for the
-- intermediate irradiance results, then perform the integration from irradiance
-- to illuminance and store the result in the final precomputed texture. In
-- pseudo-code (and assuming one wavelength per texture instead of 3):
--
-- create n temporary irradiance textures
-- for each wavelength lambda in the n wavelengths:
-- precompute irradiance at lambda into one of the temporary textures
-- initializes the final illuminance texture with zeros
-- for each wavelength lambda in the n wavelengths:
-- accumulate in the final illuminance texture the product of the
-- precomputed irradiance at lambda (read from the temporary textures)
-- with the value of the 3 sRGB color matching functions at lambda (i.e.
-- the product of the XYZ to sRGB matrix with the CIE xyz color matching
-- functions).
--
-- However, this be would waste GPU memory. Instead, we can avoid allocating
-- temporary irradiance textures, by merging the two above loops:
--
-- for each wavelength lambda in the n wavelengths:
-- accumulate in the final illuminance texture (or, for the first
-- iteration, set this texture to) the product of the precomputed
-- irradiance at lambda (computed on the fly) with the value of the 3
-- sRGB color matching functions at lambda.
--
-- This is the method we use below, with 3 wavelengths per iteration instead
-- of 1, using Precompute to compute 3 irradiances values per
-- iteration, and Luminance_From_Radiance to multiply 3 irradiances
-- with the values of the 3 sRGB color matching functions at 3 different
-- wavelengths (yielding a 3x3 matrix).
function Compute_Textures (Object : Model; Scattering_Orders : Natural := 4)
return Precomputed_Textures
is
-- The precomputations require temporary textures, in particular to store the
-- contribution of one scattering order, which is needed to compute the next
-- order of scattering (the final precomputed textures store the sum of all
-- the scattering orders)
Delta_Irradiance_Texture : constant Textures.Texture (LE.Texture_2D)
:= Create_Texture (Constants.Irradiance_Texture_Width,
Constants.Irradiance_Texture_Height);
Delta_Rayleigh_Scattering_Texture : constant Textures.Texture (LE.Texture_3D)
:= Create_Texture (Constants.Scattering_Texture_Width,
Constants.Scattering_Texture_Height,
Constants.Scattering_Texture_Depth,
Object.Data.Half_Precision);
Delta_Mie_Scattering_Texture : constant Textures.Texture (LE.Texture_3D)
:= Create_Texture (Constants.Scattering_Texture_Width,
Constants.Scattering_Texture_Height,
Constants.Scattering_Texture_Depth,
Object.Data.Half_Precision);
Delta_Scattering_Density_Texture : constant Textures.Texture (LE.Texture_3D)
:= Create_Texture (Constants.Scattering_Texture_Width,
Constants.Scattering_Texture_Height,
Constants.Scattering_Texture_Depth,
Object.Data.Half_Precision);
-- Delta_Multiple_Scattering_Texture is only needed to compute scattering
-- order 3 or more, while Delta_Rayleigh_Scattering_Texture and
-- Delta_Mie_Scattering_Texture are only needed to compute double scattering.
-- Therefore, to save memory, we can store Delta_Rayleigh_Scattering_Texture
-- and Delta_Multiple_Scattering_Texture in the same GPU texture.
Delta_Multiple_Scattering_Texture : constant Textures.Texture (LE.Texture_3D)
:= Delta_Rayleigh_Scattering_Texture;
-- Allocate the precomputed textures before precomputing them
Textures : Precomputed_Textures :=
(Sampler => Create_Sampler,
Combine_Scattering => Object.Data.Combine_Scattering_Textures,
Transmittance_Texture => Create_Texture
(Transmittance_Texture_Width, Transmittance_Texture_Height),
Irradiance_Texture => Create_Texture
(Irradiance_Texture_Width, Irradiance_Texture_Height),
Scattering_Texture => Create_Texture
(Scattering_Texture_Width, Scattering_Texture_Height, Scattering_Texture_Depth,
Object.Data.Half_Precision),
others => <>);
begin
Textures.Sampler.Bind (0);
Textures.Sampler.Bind (1);
Textures.Sampler.Bind (2);
Textures.Sampler.Bind (3);
if not Object.Data.Combine_Scattering_Textures then
Textures.Optional_Single_Mie_Scattering_Texture := Create_Texture
(Scattering_Texture_Width, Scattering_Texture_Height, Scattering_Texture_Depth,
Object.Data.Half_Precision);
end if;
if Object.Data.Num_Precomputed_Wavelengths <= 3 then
declare
Lambdas : constant Double_Array := (K_Lambda_R, K_Lambda_G, K_Lambda_B);
Luminance_From_Radiance : constant Single_Array
:= (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
begin
Object.Precompute
(Textures,
Delta_Irradiance_Texture, Delta_Rayleigh_Scattering_Texture,
Delta_Mie_Scattering_Texture, Delta_Scattering_Density_Texture,
Delta_Multiple_Scattering_Texture,
Lambdas, Luminance_From_Radiance,
Blend => False, Num_Scattering_Orders => Scattering_Orders);
end;
else
declare
Num_Iterations : constant UInt := (Object.Data.Num_Precomputed_Wavelengths + 2) / 3;
D_Lambda : constant Double
:= (K_Lambda_Max - K_Lambda_Min) / Double (3 * Num_Iterations);
begin
for I in 0 .. Num_Iterations - 1 loop
declare
Lambdas : constant Double_Array :=
(K_Lambda_Min + (3.0 * Double (I) + 0.5) * D_Lambda,
K_Lambda_Min + (3.0 * Double (I) + 1.5) * D_Lambda,
K_Lambda_Min + (3.0 * Double (I) + 2.5) * D_Lambda);
function Coeff (Lambda : Double; Component : Size) return Single is
-- Note that we don't include MAX_LUMINOUS_EFFICACY here, to avoid
-- artefacts due to too large values when using half precision on GPU.
-- We add this term back in atmosphere.frag, via
-- SKY_SPECTRAL_RADIANCE_TO_LUMINANCE (see also the comments in the
-- Model constructor).
X : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 1);
Y : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 2);
Z : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 3);
begin
return Single
((XYZ_To_SRGB (Component * 3 + 0) * X +
XYZ_To_SRGB (Component * 3 + 1) * Y +
XYZ_To_SRGB (Component * 3 + 2) * Z) * D_Lambda);
end Coeff;
Luminance_From_Radiance : constant Single_Array :=
(Coeff (Lambdas (0), 0), Coeff (Lambdas (0), 1), Coeff (Lambdas (0), 2),
Coeff (Lambdas (1), 0), Coeff (Lambdas (1), 1), Coeff (Lambdas (1), 2),
Coeff (Lambdas (2), 0), Coeff (Lambdas (2), 1), Coeff (Lambdas (2), 2));
begin
Object.Precompute
(Textures,
Delta_Irradiance_Texture, Delta_Rayleigh_Scattering_Texture,
Delta_Mie_Scattering_Texture, Delta_Scattering_Density_Texture,
Delta_Multiple_Scattering_Texture,
Lambdas, Luminance_From_Radiance,
Blend => I > 0, Num_Scattering_Orders => Scattering_Orders);
end;
end loop;
end;
-- After the above iterations, the transmittance texture contains the
-- transmittance for the 3 wavelengths used at the last iteration. But we
-- want the transmittance at kLambdaR, kLambdaG, kLambdaB instead, so we
-- must recompute it here for these 3 wavelengths:
declare
Lambdas : constant Double_Array := (K_Lambda_R, K_Lambda_G, K_Lambda_B);
use Orka.Rendering.Programs;
Header : constant String := Object.Shader_Header (Lambdas);
FS_Transmittance : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-transmittance.frag").Get));
Program_Transmittance : Program := Create_Program (Modules.Module_Array'
(Modules.Create_Module (Object.Location, VS => "oversized-triangle.vert"),
Modules.Create_Module_From_Sources (FS => Header & FS_Transmittance)));
FBO_Transmittance : Framebuffers.Framebuffer := Framebuffers.Create_Framebuffer
(Width => Constants.Transmittance_Texture_Width,
Height => Constants.Transmittance_Texture_Height);
begin
FBO_Transmittance.Use_Framebuffer;
FBO_Transmittance.Attach (Textures.Transmittance_Texture);
FBO_Transmittance.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0));
Program_Transmittance.Use_Program;
Draw_Quad ((1 .. 0 => <>));
end;
end if;
return Textures;
end Compute_Textures;
function Get_Shader (Object : Model) return Rendering.Programs.Modules.Module is
Precompute_Illuminance : constant Boolean := Object.Data.Num_Precomputed_Wavelengths > 3;
Atmosphere_Fragment_Shader : constant String := Convert
(Resources.Byte_Array'(Object.Location.Read_Data ("atmosphere/atmosphere.frag").Get));
use Ada.Characters.Latin_1;
-- Create and compile the fragment shader providing our API.
--
-- It defines an "ATMOSPHERE" constant containing the atmosphere
-- parameters (we use constants instead of uniforms to enable
-- constant folding and propagation optimizations in the GLSL compiler),
-- concatenated with functions.frag, and with Atmosphere_Fragment_Shader, to
-- create the fragment shader
Shader_Source : constant String
:= Object.Shader_Header ((K_Lambda_R, K_Lambda_G, K_Lambda_B)) &
(if Precompute_Illuminance then "" else "#define RADIANCE_API_ENABLED" & LF) &
Atmosphere_Fragment_Shader;
begin
return Rendering.Programs.Modules.Create_Module_From_Sources (FS => Shader_Source);
end Get_Shader;
procedure Bind_Textures (Object : Precomputed_Textures) is
use all type Rendering.Textures.Indexed_Texture_Target;
begin
Object.Sampler.Bind (0);
Object.Sampler.Bind (1);
Object.Sampler.Bind (2);
Object.Sampler.Bind (3);
Rendering.Textures.Bind (Object.Transmittance_Texture, Texture, 0);
Rendering.Textures.Bind (Object.Scattering_Texture, Texture, 1);
-- Only used by GetSunAndSkyIrradiance to compute radiance
-- reflected by the ground
Rendering.Textures.Bind (Object.Irradiance_Texture, Texture, 2);
if not Object.Combine_Scattering then
Rendering.Textures.Bind (Object.Optional_Single_Mie_Scattering_Texture, Texture, 3);
end if;
end Bind_Textures;
end Orka.Features.Atmosphere;
| 8557 | -- SPDX-License-Identifier: BSD-3-Clause
--
-- Copyright (c) 2017 <NAME>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions
-- are met:
-- 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 holders nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
-- THE POSSIBILITY OF SUCH DAMAGE.
-- This package's role is to precompute the transmittance, scattering and
-- irradiance textures. The GLSL functions to precompute them are provided
-- in functions.frag, but they are not sufficient.
-- They must be used in fully functional shaders and programs, and these
-- programs must be called in the correct order, with the correct input and
-- output textures (via framebuffer objects), to precompute each scattering
-- order in sequence, as described in Algorithm 4.1 of our paper [1].
--
-- [1] https://hal.inria.fr/inria-00288758/en
with Ada.Characters.Latin_1;
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Strings.Unbounded;
with Ada.Unchecked_Conversion;
with GL.Blending;
with GL.Buffers;
with GL.Pixels;
with GL.Toggles;
with Orka.Features.Atmosphere.Constants;
with Orka.Rendering.Drawing;
with Orka.Rendering.Framebuffers;
with Orka.Rendering.Programs.Uniforms;
with Orka.Rendering.Textures;
with Orka.Types;
package body Orka.Features.Atmosphere is
package Framebuffers renames Orka.Rendering.Framebuffers;
package SU renames Ada.Strings.Unbounded;
K_Lambda_R : constant Double := 680.0;
K_Lambda_G : constant Double := 550.0;
K_Lambda_B : constant Double := 440.0;
function Convert (Bytes : Resources.Byte_Array) return String renames Resources.Convert;
use Orka.Features.Atmosphere.Constants;
function Create_Sampler return GL.Objects.Samplers.Sampler is
Result : GL.Objects.Samplers.Sampler;
use all type Textures.Wrapping_Mode;
use all type Textures.Minifying_Function;
begin
Result.Set_X_Wrapping (Clamp_To_Edge);
Result.Set_Y_Wrapping (Clamp_To_Edge);
Result.Set_Z_Wrapping (Clamp_To_Edge);
Result.Set_Minifying_Filter (Linear);
Result.Set_Magnifying_Filter (Linear);
return Result;
end Create_Sampler;
function Create_Texture (Width, Height : Size) return Textures.Texture is
Result : Textures.Texture (LE.Texture_2D);
begin
-- 16F precision for the transmittance gives artifacts
Result.Allocate_Storage (1, 1, GL.Pixels.RGBA32F, Width, Height, 1);
return Result;
end Create_Texture;
function Create_Texture
(Width, Height, Depth : Size;
Half_Precision : Boolean) return Textures.Texture
is
Result : Textures.Texture (LE.Texture_3D);
Internal_Format : constant GL.Pixels.Internal_Format
:= (if Half_Precision then GL.Pixels.RGBA16F else GL.Pixels.RGBA32F);
begin
Result.Allocate_Storage (1, 1, Internal_Format, Width, Height, Depth);
return Result;
end Create_Texture;
-----------------------------------------------------------------------------
type Enable_Blend_Array is array (GL.Buffers.Draw_Buffer_Index range <>) of Boolean;
procedure Draw_Quad (Blend : Enable_Blend_Array) is
begin
for Index in Blend'Range loop
if Blend (Index) then
GL.Toggles.Enable (GL.Toggles.Blend, Index);
end if;
end loop;
Orka.Rendering.Drawing.Draw (Triangles, 0, 3);
for Index in Blend'Range loop
GL.Toggles.Disable (GL.Toggles.Blend, Index);
end loop;
end Draw_Quad;
-----------------------------------------------------------------------------
-- Finally, we need a utility function to compute the value of the
-- conversion constants *_RADIANCE_TO_LUMINANCE, used in the shader
-- to convert the spectral results into luminance values. These are
-- the constants k_r, k_g, k_b described in Section 14.3 of
-- "A Qualitative and Quantitative Evaluation of 8 Clear Sky Models" [1].
-- Computing their value requires an integral of a function times a
-- CIE color matching function. Thus, we first need functions to
-- interpolate an arbitrary function (specified by some samples), and
-- a CIE color matching function (specified by tabulated values), at
-- an arbitrary wavelength. This is the purpose of the two functions
-- below.
--
-- [1] https://arxiv.org/pdf/1612.04336.pdf
function CIE_Color_Matching_Function_Table_Value
(Wavelength : Double;
Column : Size) return Double is
begin
if Wavelength <= K_Lambda_Min or Wavelength >= K_Lambda_Max then
return 0.0;
end if;
declare
U : Double := (Wavelength - K_Lambda_Min) / 5.0;
Row : constant Size := Int (Double'Floor (U));
pragma Assert (Row + 1 < 95);
pragma Assert (CIE_2_Deg_Color_Matching_Functions (4 * Row) <= Wavelength);
pragma Assert (CIE_2_Deg_Color_Matching_Functions (4 * (Row + 1)) >= Wavelength);
begin
U := U - Double (Row);
return CIE_2_Deg_Color_Matching_Functions (4 * Row + Column) * (1.0 - U) +
CIE_2_Deg_Color_Matching_Functions (4 * (Row + 1) + Column) * U;
end;
end CIE_Color_Matching_Function_Table_Value;
function Interpolate
(Wavelengths, Functions : Double_Vectors.Vector;
Wavelength : Double) return Double
is
pragma Assert (Wavelengths.Length = Functions.Length);
begin
if Wavelength < Wavelengths.First_Element then
return Functions.First_Element;
end if;
for Index in Wavelengths.First_Index .. Wavelengths.Last_Index - 1 loop
if Wavelength < Wavelengths (Index + 1) then
declare
U : constant Double := (Wavelength - Wavelengths (Index))
/ (Wavelengths (Index + 1) - Wavelengths (Index));
begin
return Functions (Index) * (1.0 - U) + Functions (Index + 1) * U;
end;
end if;
end loop;
return Functions.Last_Element;
end Interpolate;
-- We can then implement a utility function to compute the "spectral
-- radiance to luminance" conversion constants (see Section 14.3 in
-- "A Qualitative and Quantitative Evaluation of 8 Clear Sky Models" [1]
-- for their definitions).
--
-- [1] https://arxiv.org/pdf/1612.04336.pdf
procedure Compute_Spectral_Radiance_To_Luminance_Factors
(Wavelengths, Solar_Irradiance : Double_Vectors.Vector;
Lambda_Power : Double;
K_R, K_G, K_B : out Double) -- The returned constants are in lumen.nm / watt
is
package EF is new Ada.Numerics.Generic_Elementary_Functions (Double);
use EF;
Solar_R : constant Double := Interpolate (Wavelengths, Solar_Irradiance, K_Lambda_R);
Solar_G : constant Double := Interpolate (Wavelengths, Solar_Irradiance, K_Lambda_G);
Solar_B : constant Double := Interpolate (Wavelengths, Solar_Irradiance, K_Lambda_B);
D_Lambda : constant Double := 1.0;
Lambda : Double := K_Lambda_Min;
begin
K_R := 0.0;
K_G := 0.0;
K_B := 0.0;
while Lambda < K_Lambda_Max loop
declare
X_Bar : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 1);
Y_Bar : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 2);
Z_Bar : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 3);
R_Bar : constant Double
:= XYZ_To_SRGB (0) * X_Bar + XYZ_To_SRGB (1) * Y_Bar + XYZ_To_SRGB (2) * Z_Bar;
G_Bar : constant Double
:= XYZ_To_SRGB (3) * X_Bar + XYZ_To_SRGB (4) * Y_Bar + XYZ_To_SRGB (5) * Z_Bar;
B_Bar : constant Double
:= XYZ_To_SRGB (6) * X_Bar + XYZ_To_SRGB (7) * Y_Bar + XYZ_To_SRGB (8) * Z_Bar;
Irradiance : constant Double := Interpolate (Wavelengths, Solar_Irradiance, Lambda);
begin
K_R := K_R + R_Bar * Irradiance / Solar_R * (Lambda / K_Lambda_R) ** Lambda_Power;
K_G := K_G + G_Bar * Irradiance / Solar_G * (Lambda / K_Lambda_G) ** Lambda_Power;
K_B := K_B + B_Bar * Irradiance / Solar_B * (Lambda / K_Lambda_B) ** Lambda_Power;
end;
Lambda := Lambda + D_Lambda;
end loop;
K_R := K_R * Max_Luminous_Efficacy * D_Lambda;
K_G := K_G * Max_Luminous_Efficacy * D_Lambda;
K_B := K_B * Max_Luminous_Efficacy * D_Lambda;
end Compute_Spectral_Radiance_To_Luminance_Factors;
-- A function that creates a shader header containing our atmosphere computation
-- functions, specialized for the given atmosphere parameters and for the 3
-- wavelengths in Lambdas
function Shader_Header (Result : Model; Lambdas : Double_Array) return String is
package EF is new Ada.Numerics.Generic_Elementary_Functions (Double);
use Ada.Characters.Latin_1;
Data : not null access constant Model_Data renames Result.Data;
function To_String
(V : Double_Vectors.Vector;
Scale : Double) return String
is
R : constant Double := Interpolate (Data.Wavelengths, V, Lambdas (0)) * Scale;
G : constant Double := Interpolate (Data.Wavelengths, V, Lambdas (1)) * Scale;
B : constant Double := Interpolate (Data.Wavelengths, V, Lambdas (2)) * Scale;
begin
return "vec3(" & R'Image & "," & G'Image & "," & B'Image & ")";
end To_String;
function Density_Layer (Layer : Density_Profile_Layer) return String is
Width : constant Double := Layer.Width / Data.Length_Unit_In_Meters;
Scale : constant Double := Layer.Exp_Scale * Data.Length_Unit_In_Meters;
Linear_Term : constant Double := Layer.Linear_Term * Data.Length_Unit_In_Meters;
begin
return "DensityProfileLayer(" &
Width'Image & "," & Layer.Exp_Term'Image & "," &
Scale'Image & "," & Linear_Term'Image & "," &
Layer.Constant_Term'Image & ")";
end Density_Layer;
function Density_Profile (Layers : Density_Vectors.Vector) return String is
K_Layer_Count : constant := 2;
K_Layers : Density_Vectors.Vector := Layers.Copy;
Zero_Layer : Density_Profile_Layer;
Result : SU.Unbounded_String;
begin
while K_Layers.Length < K_Layer_Count loop
K_Layers.Prepend (Zero_Layer);
end loop;
SU.Append (Result, "DensityProfile(DensityProfileLayer[" &
Natural'Image (K_Layer_Count) & "](");
for Index in K_Layers.First_Index .. K_Layers.Last_Index - 1 loop
SU.Append (Result, Density_Layer (K_Layers (Index)) & ",");
end loop;
SU.Append (Result, Density_Layer (K_Layers.Last_Element) & "))");
return SU.To_String (Result);
end Density_Profile;
Definitions_GLSL : constant String
:= Convert (Resources.Byte_Array'(Result.Data_Definitions.Get));
Functions_GLSL : constant String
:= Convert (Resources.Byte_Array'(Result.Data_Functions.Get));
Bottom_Radius : constant Double := Data.Bottom_Radius / Data.Length_Unit_In_Meters;
Top_Radius : constant Double := Data.Top_Radius / Data.Length_Unit_In_Meters;
begin
return
"#version 420" & LF &
"#extension GL_ARB_fragment_layer_viewport : require" & LF &
"#define IN(x) const in x" & LF &
"#define OUT(x) out x" & LF &
"#define TEMPLATE(x)" & LF &
"#define TEMPLATE_ARGUMENT(x)" & LF &
"#define assert(x)" & LF &
"const int TRANSMITTANCE_TEXTURE_WIDTH = " &
Natural'Image (Transmittance_Texture_Width) & ";" & LF &
"const int TRANSMITTANCE_TEXTURE_HEIGHT = " &
Natural'Image (Transmittance_Texture_Height) & ";" & LF &
"const int SCATTERING_TEXTURE_R_SIZE = " &
Natural'Image (Scattering_Texture_R_Size) & ";" & LF &
"const int SCATTERING_TEXTURE_MU_SIZE = " &
Natural'Image (Scattering_Texture_Mu_Size) & ";" & LF &
"const int SCATTERING_TEXTURE_MU_S_SIZE = " &
Natural'Image (Scattering_Texture_Mu_S_Size) & ";" & LF &
"const int SCATTERING_TEXTURE_NU_SIZE = " &
Natural'Image (Scattering_Texture_Nu_Size) & ";" & LF &
"const int IRRADIANCE_TEXTURE_WIDTH = " &
Natural'Image (Irradiance_Texture_Width) & ";" & LF &
"const int IRRADIANCE_TEXTURE_HEIGHT = " &
Natural'Image (Irradiance_Texture_Height) & ";" & LF &
(if Data.Combine_Scattering_Textures then
"#define COMBINED_SCATTERING_TEXTURES" & LF
else "") &
Definitions_GLSL & LF &
"const AtmosphereParameters ATMOSPHERE = AtmosphereParameters(" & LF &
To_String (Data.Solar_Irradiance, 1.0) & "," & LF &
Data.Sun_Angular_Radius'Image & "," & LF &
Bottom_Radius'Image & "," & LF &
Top_Radius'Image & "," & LF &
Density_Profile (Data.Rayleigh_Density) & "," & LF &
To_String
(Data.Rayleigh_Scattering, Data.Length_Unit_In_Meters) & "," & LF &
Density_Profile (Data.Mie_Density) & "," & LF &
To_String
(Data.Mie_Scattering, Data.Length_Unit_In_Meters) & "," & LF &
To_String
(Data.Mie_Extinction, Data.Length_Unit_In_Meters) & "," & LF &
Data.Mie_Phase_Function_G'Image & "," & LF &
Density_Profile (Data.Absorption_Density) & "," & LF &
To_String
(Data.Absorption_Extinction, Data.Length_Unit_In_Meters) & "," & LF &
To_String (Data.Ground_Albedo, 1.0) & "," & LF &
EF.Cos (Data.Max_Sun_Zenith_Angle)'Image & ");" & LF &
"const vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE = vec3(" &
Result.Sky_K_R'Image & "," &
Result.Sky_K_G'Image & "," &
Result.Sky_K_B'Image & ");" & LF &
"const vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE = vec3(" &
Result.Sun_K_R'Image & "," &
Result.Sun_K_G'Image & "," &
Result.Sun_K_B'Image & ");" & LF &
Functions_GLSL & LF;
end Shader_Header;
-----------------------------------------------------------------------------
function Create_Model
(Data : not null access constant Model_Data;
Location : Resources.Locations.Location_Ptr) return Model
is
-- Compute the values for the SKY_RADIANCE_TO_LUMINANCE constant. In theory
-- this should be 1 in precomputed illuminance mode (because the precomputed
-- textures already contain illuminance values). In practice, however, storing
-- true illuminance values in half precision textures yields artefacts
-- (because the values are too large), so we store illuminance values divided
-- by MAX_LUMINOUS_EFFICACY instead. This is why, in precomputed illuminance
-- mode, we set SKY_RADIANCE_TO_LUMINANCE to MAX_LUMINOUS_EFFICACY.
Precompute_Illuminance : constant Boolean := Data.Num_Precomputed_Wavelengths > 3;
Power_Sky : constant Double := -3.0;
Power_Sun : constant Double := 0.0;
begin
return Result : Model (Data) do
if Precompute_Illuminance then
Result.Sky_K_R := Max_Luminous_Efficacy;
Result.Sky_K_G := Max_Luminous_Efficacy;
Result.Sky_K_B := Max_Luminous_Efficacy;
else
Compute_Spectral_Radiance_To_Luminance_Factors
(Data.Wavelengths, Data.Solar_Irradiance, Power_Sky,
Result.Sky_K_R, Result.Sky_K_G, Result.Sky_K_B);
end if;
-- Compute the values for the SUN_RADIANCE_TO_LUMINANCE constant
Compute_Spectral_Radiance_To_Luminance_Factors
(Data.Wavelengths, Data.Solar_Irradiance, Power_Sun,
Result.Sun_K_R, Result.Sun_K_G, Result.Sun_K_B);
Result.Data_Definitions := Location.Read_Data ("atmosphere/definitions.frag");
Result.Data_Functions := Location.Read_Data ("atmosphere/functions.frag");
Result.Location := Location;
end return;
end Create_Model;
-- The utility method is implemented with a simple numerical integration
-- of the given function, times the CIE color matching functions (with an
-- integration step of 1 nm), followed by a matrix multiplication
procedure Convert_Spectrum_To_Linear_SRGB (Data : Model_Data; R, G, B : out Double) is
D_Lambda : constant Double := 1.0;
Lambda : Double := K_Lambda_Min;
X, Y, Z : Double := 0.0;
begin
while Lambda < K_Lambda_Max loop
declare
Value : constant Double :=
Interpolate (Data.Wavelengths, Data.Solar_Irradiance, Lambda);
begin
X := X + CIE_Color_Matching_Function_Table_Value (Lambda, 1) * Value;
Y := Y + CIE_Color_Matching_Function_Table_Value (Lambda, 2) * Value;
Z := Z + CIE_Color_Matching_Function_Table_Value (Lambda, 3) * Value;
end;
Lambda := Lambda + D_Lambda;
end loop;
R := Max_Luminous_Efficacy *
(XYZ_To_SRGB (0) * X + XYZ_To_SRGB (1) * Y + XYZ_To_SRGB (2) * Z) * D_Lambda;
G := Max_Luminous_Efficacy *
(XYZ_To_SRGB (3) * X + XYZ_To_SRGB (4) * Y + XYZ_To_SRGB (5) * Z) * D_Lambda;
B := Max_Luminous_Efficacy *
(XYZ_To_SRGB (6) * X + XYZ_To_SRGB (7) * Y + XYZ_To_SRGB (8) * Z) * D_Lambda;
end Convert_Spectrum_To_Linear_SRGB;
-- Implementation of the precomputation algorithm described in
-- Algorithm 4.1 of [1]. Each step is explained by the inline
-- comments below.
--
-- [1] https://hal.inria.fr/inria-00288758/en
procedure Precompute
(Object : Model;
Result : Precomputed_Textures;
Delta_Irradiance_Texture, Delta_Rayleigh_Scattering_Texture,
Delta_Mie_Scattering_Texture, Delta_Scattering_Density_Texture,
Delta_Multiple_Scattering_Texture : Textures.Texture;
Lambdas : Double_Array;
Luminance_From_Radiance : Single_Array;
Blend : Boolean;
Num_Scattering_Orders : Natural)
is
LR : Single_Array renames Luminance_From_Radiance;
Luminance_From_Radiance_Mat3 : constant Orka.Types.Singles.Matrix4 :=
((LR (0), LR (1), LR (2), 0.0),
(LR (3), LR (4), LR (5), 0.0),
(LR (6), LR (7), LR (8), 0.0),
(0.0, 0.0, 0.0, 0.0));
use Orka.Rendering.Programs;
-- The precomputations require specific GLSL programs for each
-- precomputation step
Module_VS : constant Modules.Module
:= Modules.Create_Module (Object.Location, VS => "atmosphere/oversized-triangle.vert");
Module_GS : constant Modules.Module
:= Modules.Create_Module (Object.Location, GS => "atmosphere/layer.geom");
Header : constant String := Object.Shader_Header (Lambdas);
FS_Transmittance : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-transmittance.frag").Get));
FS_Direct_Irradiance : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-direct-irradiance.frag").Get));
FS_Indirect_Irradiance : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-indirect-irradiance.frag").Get));
FS_Single_Scattering : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-single-scattering.frag").Get));
FS_Multiple_Scattering : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-multiple-scattering.frag").Get));
FS_Scattering_Density : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-scattering-density.frag").Get));
Program_Transmittance : Program := Create_Program (Modules.Module_Array'
(Module_VS,
Modules.Create_Module_From_Sources (FS => Header & FS_Transmittance)));
Program_Direct_Irradiance : Program := Create_Program (Modules.Module_Array'
(Module_VS,
Modules.Create_Module_From_Sources (FS => Header & FS_Direct_Irradiance)));
Program_Indirect_Irradiance : Program := Create_Program (Modules.Module_Array'
(Module_VS,
Modules.Create_Module_From_Sources (FS => Header & FS_Indirect_Irradiance)));
Program_Single_Scattering : Program := Create_Program (Modules.Module_Array'
(Module_VS, Module_GS,
Modules.Create_Module_From_Sources (FS => Header & FS_Single_Scattering)));
Program_Multiple_Scattering : Program := Create_Program (Modules.Module_Array'
(Module_VS, Module_GS,
Modules.Create_Module_From_Sources (FS => Header & FS_Multiple_Scattering)));
Program_Scattering_Density : Program := Create_Program (Modules.Module_Array'
(Module_VS, Module_GS,
Modules.Create_Module_From_Sources (FS => Header & FS_Scattering_Density)));
-------------------------------------------------------------------------
FBO_Transmittance : Framebuffers.Framebuffer := Framebuffers.Create_Framebuffer
(Width => Constants.Transmittance_Texture_Width,
Height => Constants.Transmittance_Texture_Height);
FBO_Irradiance : Framebuffers.Framebuffer := Framebuffers.Create_Framebuffer
(Width => Constants.Irradiance_Texture_Width,
Height => Constants.Irradiance_Texture_Height);
FBO_Scattering : Framebuffers.Framebuffer := Framebuffers.Create_Framebuffer
(Width => Constants.Scattering_Texture_Width,
Height => Constants.Scattering_Texture_Height);
use all type GL.Blending.Equation;
use all type GL.Blending.Blend_Factor;
use all type Rendering.Textures.Indexed_Texture_Target;
use all type Framebuffers.Color_Attachment_Point;
begin
GL.Blending.Set_Blend_Equation ((Func_Add, Func_Add));
GL.Blending.Set_Blend_Func ((One, One, One, One));
Rendering.Textures.Bind (Result.Transmittance_Texture, Texture, 0);
-- transmittance_texture
Rendering.Textures.Bind (Delta_Rayleigh_Scattering_Texture, Texture, 1);
-- single_rayleigh_scattering_texture
Rendering.Textures.Bind (Delta_Mie_Scattering_Texture, Texture, 2);
-- single_mie_scattering_texture
Rendering.Textures.Bind (Delta_Multiple_Scattering_Texture, Texture, 3);
-- multiple_scattering_texture
Rendering.Textures.Bind (Delta_Irradiance_Texture, Texture, 4);
-- irradiance_texture
Rendering.Textures.Bind (Delta_Scattering_Density_Texture, Texture, 5);
-- scattering_density_texture
-- Compute the transmittance and store it in Transmittance_Texture
FBO_Transmittance.Use_Framebuffer;
FBO_Transmittance.Attach (Color_Attachment_0, Result.Transmittance_Texture);
FBO_Transmittance.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0));
Program_Transmittance.Use_Program;
Draw_Quad ((1 .. 0 => <>));
-------------------------------------------------------------------------
-- Compute the direct irradiance, store it in Delta_Irradiance_Texture and,
-- depending on 'blend', either initialize Irradiance_Texture with
-- zeros or leave it unchanged (we don't want the irradiance in
-- Irradiance_Texture, but only the irradiance from the sky
FBO_Irradiance.Use_Framebuffer;
FBO_Irradiance.Attach (Color_Attachment_0, Delta_Irradiance_Texture);
FBO_Irradiance.Attach (Color_Attachment_1, Result.Irradiance_Texture);
FBO_Irradiance.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0,
1 => GL.Buffers.Color_Attachment1));
Program_Direct_Irradiance.Use_Program;
Draw_Quad ((False, Blend));
-------------------------------------------------------------------------
-- Compute the rayleigh and mie single scattering, store them in
-- Delta_Rayleigh_Scattering_Texture and Delta_Mie_Scattering_Texture,
-- and either them or accumulate them in Scattering_Texture and
-- Optional_Single_Mie_Scattering_Texture
FBO_Scattering.Use_Framebuffer;
FBO_Scattering.Attach (Color_Attachment_0, Delta_Rayleigh_Scattering_Texture);
FBO_Scattering.Attach (Color_Attachment_1, Delta_Mie_Scattering_Texture);
FBO_Scattering.Attach (Color_Attachment_2, Result.Scattering_Texture);
if not Object.Data.Combine_Scattering_Textures then
FBO_Scattering.Attach (Color_Attachment_3,
Result.Optional_Single_Mie_Scattering_Texture);
FBO_Scattering.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0,
1 => GL.Buffers.Color_Attachment1,
2 => GL.Buffers.Color_Attachment2,
3 => GL.Buffers.Color_Attachment3));
else
FBO_Scattering.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0,
1 => GL.Buffers.Color_Attachment1,
2 => GL.Buffers.Color_Attachment2));
end if;
Program_Single_Scattering.Use_Program;
Program_Single_Scattering.Uniform ("luminance_from_radiance").Set_Matrix
(Luminance_From_Radiance_Mat3);
for Layer in 0 .. Int (Constants.Scattering_Texture_Depth - 1) loop
Program_Single_Scattering.Uniform ("layer").Set_Int (Layer);
Draw_Quad ((False, False, Blend, Blend));
end loop;
-------------------------------------------------------------------------
-- Compute the 2nd, 3rd and 4th order of scattering, in sequence
for Scattering_Order in 2 .. Int (Num_Scattering_Orders) loop
-- Compute the scattering density, and store it in
-- Delta_Scattering_Density_Texture
FBO_Scattering.Use_Framebuffer;
FBO_Scattering.Attach (Color_Attachment_0, Delta_Scattering_Density_Texture);
FBO_Scattering.Detach (Color_Attachment_1);
FBO_Scattering.Detach (Color_Attachment_2);
FBO_Scattering.Detach (Color_Attachment_3);
FBO_Scattering.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0));
Program_Scattering_Density.Use_Program;
Program_Scattering_Density.Uniform ("scattering_order").Set_Int (Scattering_Order);
for Layer in 0 .. Int (Constants.Scattering_Texture_Depth - 1) loop
Program_Scattering_Density.Uniform ("layer").Set_Int (Layer);
Draw_Quad ((1 .. 0 => <>));
end loop;
-- Compute the indirect irradiance, store it in Delta_Irradiance_Texture
-- and accumulate it in Irradiance_Texture
FBO_Irradiance.Use_Framebuffer;
FBO_Irradiance.Attach (Color_Attachment_0, Delta_Irradiance_Texture);
FBO_Irradiance.Attach (Color_Attachment_1, Result.Irradiance_Texture);
FBO_Irradiance.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0,
1 => GL.Buffers.Color_Attachment1));
Program_Indirect_Irradiance.Use_Program;
Program_Indirect_Irradiance.Uniform ("luminance_from_radiance").Set_Matrix
(Luminance_From_Radiance_Mat3);
Program_Indirect_Irradiance.Uniform ("scattering_order").Set_Int (Scattering_Order - 1);
Draw_Quad ((False, True));
-- Compute the multiple scattering, store it in
-- Delta_Multiple_Scattering_Texture, and accumulate it in
-- Scattering_Texture
FBO_Scattering.Use_Framebuffer;
FBO_Scattering.Attach (Color_Attachment_0, Delta_Multiple_Scattering_Texture);
FBO_Scattering.Attach (Color_Attachment_1, Result.Scattering_Texture);
FBO_Scattering.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0,
1 => GL.Buffers.Color_Attachment1));
Program_Multiple_Scattering.Use_Program;
Program_Multiple_Scattering.Uniform ("luminance_from_radiance").Set_Matrix
(Luminance_From_Radiance_Mat3);
for Layer in 0 .. Int (Constants.Scattering_Texture_Depth - 1) loop
Program_Multiple_Scattering.Uniform ("layer").Set_Int (Layer);
Draw_Quad ((False, True));
end loop;
end loop;
end Precompute;
-- Precomputes the atmosphere textures. It first allocates the
-- temporary resources it needs and then calls Precompute to do the
-- actual precomputations.
--
-- Note that there are two precomputation modes here, depending on whether we
-- want to store precomputed irradiance or illuminance values:
--
-- - In precomputed irradiance mode, we simply need to call
-- Precompute with the 3 wavelengths for which we want to precompute
-- irradiance, namely K_Lambda_R, K_Lambda_G,
-- K_Lambda_B (with the identity matrix for
-- Luminance_From_Radiance, since we don't want any conversion from
-- radiance to luminance)
--
-- - In precomputed illuminance mode, we need to precompute irradiance for
-- Num_Precomputed_Wavelengths, and then integrate the results,
-- multiplied with the 3 CIE xyz color matching functions and the XYZ to sRGB
-- matrix to get sRGB illuminance values.
--
-- A naive solution would be to allocate temporary textures for the
-- intermediate irradiance results, then perform the integration from irradiance
-- to illuminance and store the result in the final precomputed texture. In
-- pseudo-code (and assuming one wavelength per texture instead of 3):
--
-- create n temporary irradiance textures
-- for each wavelength lambda in the n wavelengths:
-- precompute irradiance at lambda into one of the temporary textures
-- initializes the final illuminance texture with zeros
-- for each wavelength lambda in the n wavelengths:
-- accumulate in the final illuminance texture the product of the
-- precomputed irradiance at lambda (read from the temporary textures)
-- with the value of the 3 sRGB color matching functions at lambda (i.e.
-- the product of the XYZ to sRGB matrix with the CIE xyz color matching
-- functions).
--
-- However, this be would waste GPU memory. Instead, we can avoid allocating
-- temporary irradiance textures, by merging the two above loops:
--
-- for each wavelength lambda in the n wavelengths:
-- accumulate in the final illuminance texture (or, for the first
-- iteration, set this texture to) the product of the precomputed
-- irradiance at lambda (computed on the fly) with the value of the 3
-- sRGB color matching functions at lambda.
--
-- This is the method we use below, with 3 wavelengths per iteration instead
-- of 1, using Precompute to compute 3 irradiances values per
-- iteration, and Luminance_From_Radiance to multiply 3 irradiances
-- with the values of the 3 sRGB color matching functions at 3 different
-- wavelengths (yielding a 3x3 matrix).
function Compute_Textures (Object : Model; Scattering_Orders : Natural := 4)
return Precomputed_Textures
is
-- The precomputations require temporary textures, in particular to store the
-- contribution of one scattering order, which is needed to compute the next
-- order of scattering (the final precomputed textures store the sum of all
-- the scattering orders)
Delta_Irradiance_Texture : constant Textures.Texture (LE.Texture_2D)
:= Create_Texture (Constants.Irradiance_Texture_Width,
Constants.Irradiance_Texture_Height);
Delta_Rayleigh_Scattering_Texture : constant Textures.Texture (LE.Texture_3D)
:= Create_Texture (Constants.Scattering_Texture_Width,
Constants.Scattering_Texture_Height,
Constants.Scattering_Texture_Depth,
Object.Data.Half_Precision);
Delta_Mie_Scattering_Texture : constant Textures.Texture (LE.Texture_3D)
:= Create_Texture (Constants.Scattering_Texture_Width,
Constants.Scattering_Texture_Height,
Constants.Scattering_Texture_Depth,
Object.Data.Half_Precision);
Delta_Scattering_Density_Texture : constant Textures.Texture (LE.Texture_3D)
:= Create_Texture (Constants.Scattering_Texture_Width,
Constants.Scattering_Texture_Height,
Constants.Scattering_Texture_Depth,
Object.Data.Half_Precision);
-- Delta_Multiple_Scattering_Texture is only needed to compute scattering
-- order 3 or more, while Delta_Rayleigh_Scattering_Texture and
-- Delta_Mie_Scattering_Texture are only needed to compute double scattering.
-- Therefore, to save memory, we can store Delta_Rayleigh_Scattering_Texture
-- and Delta_Multiple_Scattering_Texture in the same GPU texture.
Delta_Multiple_Scattering_Texture : constant Textures.Texture (LE.Texture_3D)
:= Delta_Rayleigh_Scattering_Texture;
-- Allocate the precomputed textures before precomputing them
Textures : Precomputed_Textures :=
(Sampler => Create_Sampler,
Combine_Scattering => Object.Data.Combine_Scattering_Textures,
Transmittance_Texture => Create_Texture
(Transmittance_Texture_Width, Transmittance_Texture_Height),
Irradiance_Texture => Create_Texture
(Irradiance_Texture_Width, Irradiance_Texture_Height),
Scattering_Texture => Create_Texture
(Scattering_Texture_Width, Scattering_Texture_Height, Scattering_Texture_Depth,
Object.Data.Half_Precision),
others => <>);
begin
Textures.Sampler.Bind (0);
Textures.Sampler.Bind (1);
Textures.Sampler.Bind (2);
Textures.Sampler.Bind (3);
if not Object.Data.Combine_Scattering_Textures then
Textures.Optional_Single_Mie_Scattering_Texture := Create_Texture
(Scattering_Texture_Width, Scattering_Texture_Height, Scattering_Texture_Depth,
Object.Data.Half_Precision);
end if;
if Object.Data.Num_Precomputed_Wavelengths <= 3 then
declare
Lambdas : constant Double_Array := (K_Lambda_R, K_Lambda_G, K_Lambda_B);
Luminance_From_Radiance : constant Single_Array
:= (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
begin
Object.Precompute
(Textures,
Delta_Irradiance_Texture, Delta_Rayleigh_Scattering_Texture,
Delta_Mie_Scattering_Texture, Delta_Scattering_Density_Texture,
Delta_Multiple_Scattering_Texture,
Lambdas, Luminance_From_Radiance,
Blend => False, Num_Scattering_Orders => Scattering_Orders);
end;
else
declare
Num_Iterations : constant UInt := (Object.Data.Num_Precomputed_Wavelengths + 2) / 3;
D_Lambda : constant Double
:= (K_Lambda_Max - K_Lambda_Min) / Double (3 * Num_Iterations);
begin
for I in 0 .. Num_Iterations - 1 loop
declare
Lambdas : constant Double_Array :=
(K_Lambda_Min + (3.0 * Double (I) + 0.5) * D_Lambda,
K_Lambda_Min + (3.0 * Double (I) + 1.5) * D_Lambda,
K_Lambda_Min + (3.0 * Double (I) + 2.5) * D_Lambda);
function Coeff (Lambda : Double; Component : Size) return Single is
-- Note that we don't include MAX_LUMINOUS_EFFICACY here, to avoid
-- artefacts due to too large values when using half precision on GPU.
-- We add this term back in atmosphere.frag, via
-- SKY_SPECTRAL_RADIANCE_TO_LUMINANCE (see also the comments in the
-- Model constructor).
X : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 1);
Y : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 2);
Z : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 3);
begin
return Single
((XYZ_To_SRGB (Component * 3 + 0) * X +
XYZ_To_SRGB (Component * 3 + 1) * Y +
XYZ_To_SRGB (Component * 3 + 2) * Z) * D_Lambda);
end Coeff;
Luminance_From_Radiance : constant Single_Array :=
(Coeff (Lambdas (0), 0), Coeff (Lambdas (0), 1), Coeff (Lambdas (0), 2),
Coeff (Lambdas (1), 0), Coeff (Lambdas (1), 1), Coeff (Lambdas (1), 2),
Coeff (Lambdas (2), 0), Coeff (Lambdas (2), 1), Coeff (Lambdas (2), 2));
begin
Object.Precompute
(Textures,
Delta_Irradiance_Texture, Delta_Rayleigh_Scattering_Texture,
Delta_Mie_Scattering_Texture, Delta_Scattering_Density_Texture,
Delta_Multiple_Scattering_Texture,
Lambdas, Luminance_From_Radiance,
Blend => I > 0, Num_Scattering_Orders => Scattering_Orders);
end;
end loop;
end;
-- After the above iterations, the transmittance texture contains the
-- transmittance for the 3 wavelengths used at the last iteration. But we
-- want the transmittance at kLambdaR, kLambdaG, kLambdaB instead, so we
-- must recompute it here for these 3 wavelengths:
declare
Lambdas : constant Double_Array := (K_Lambda_R, K_Lambda_G, K_Lambda_B);
use Orka.Rendering.Programs;
Header : constant String := Object.Shader_Header (Lambdas);
FS_Transmittance : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-transmittance.frag").Get));
Program_Transmittance : Program := Create_Program (Modules.Module_Array'
(Modules.Create_Module (Object.Location, VS => "oversized-triangle.vert"),
Modules.Create_Module_From_Sources (FS => Header & FS_Transmittance)));
FBO_Transmittance : Framebuffers.Framebuffer := Framebuffers.Create_Framebuffer
(Width => Constants.Transmittance_Texture_Width,
Height => Constants.Transmittance_Texture_Height);
begin
FBO_Transmittance.Use_Framebuffer;
FBO_Transmittance.Attach (Textures.Transmittance_Texture);
FBO_Transmittance.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0));
Program_Transmittance.Use_Program;
Draw_Quad ((1 .. 0 => <>));
end;
end if;
return Textures;
end Compute_Textures;
function Get_Shader (Object : Model) return Rendering.Programs.Modules.Module is
Precompute_Illuminance : constant Boolean := Object.Data.Num_Precomputed_Wavelengths > 3;
Atmosphere_Fragment_Shader : constant String := Convert
(Resources.Byte_Array'(Object.Location.Read_Data ("atmosphere/atmosphere.frag").Get));
use Ada.Characters.Latin_1;
-- Create and compile the fragment shader providing our API.
--
-- It defines an "ATMOSPHERE" constant containing the atmosphere
-- parameters (we use constants instead of uniforms to enable
-- constant folding and propagation optimizations in the GLSL compiler),
-- concatenated with functions.frag, and with Atmosphere_Fragment_Shader, to
-- create the fragment shader
Shader_Source : constant String
:= Object.Shader_Header ((K_Lambda_R, K_Lambda_G, K_Lambda_B)) &
(if Precompute_Illuminance then "" else "#define RADIANCE_API_ENABLED" & LF) &
Atmosphere_Fragment_Shader;
begin
return Rendering.Programs.Modules.Create_Module_From_Sources (FS => Shader_Source);
end Get_Shader;
procedure Bind_Textures (Object : Precomputed_Textures) is
use all type Rendering.Textures.Indexed_Texture_Target;
begin
Object.Sampler.Bind (0);
Object.Sampler.Bind (1);
Object.Sampler.Bind (2);
Object.Sampler.Bind (3);
Rendering.Textures.Bind (Object.Transmittance_Texture, Texture, 0);
Rendering.Textures.Bind (Object.Scattering_Texture, Texture, 1);
-- Only used by GetSunAndSkyIrradiance to compute radiance
-- reflected by the ground
Rendering.Textures.Bind (Object.Irradiance_Texture, Texture, 2);
if not Object.Combine_Scattering then
Rendering.Textures.Bind (Object.Optional_Single_Mie_Scattering_Texture, Texture, 3);
end if;
end Bind_Textures;
end Orka.Features.Atmosphere;
| true | -- SPDX-License-Identifier: BSD-3-Clause
--
-- Copyright (c) 2017 PI:NAME:<NAME>END_PI
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions
-- are met:
-- 1. Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- 3. Neither the name of the copyright holders nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
-- THE POSSIBILITY OF SUCH DAMAGE.
-- This package's role is to precompute the transmittance, scattering and
-- irradiance textures. The GLSL functions to precompute them are provided
-- in functions.frag, but they are not sufficient.
-- They must be used in fully functional shaders and programs, and these
-- programs must be called in the correct order, with the correct input and
-- output textures (via framebuffer objects), to precompute each scattering
-- order in sequence, as described in Algorithm 4.1 of our paper [1].
--
-- [1] https://hal.inria.fr/inria-00288758/en
with Ada.Characters.Latin_1;
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Strings.Unbounded;
with Ada.Unchecked_Conversion;
with GL.Blending;
with GL.Buffers;
with GL.Pixels;
with GL.Toggles;
with Orka.Features.Atmosphere.Constants;
with Orka.Rendering.Drawing;
with Orka.Rendering.Framebuffers;
with Orka.Rendering.Programs.Uniforms;
with Orka.Rendering.Textures;
with Orka.Types;
package body Orka.Features.Atmosphere is
package Framebuffers renames Orka.Rendering.Framebuffers;
package SU renames Ada.Strings.Unbounded;
K_Lambda_R : constant Double := 680.0;
K_Lambda_G : constant Double := 550.0;
K_Lambda_B : constant Double := 440.0;
function Convert (Bytes : Resources.Byte_Array) return String renames Resources.Convert;
use Orka.Features.Atmosphere.Constants;
function Create_Sampler return GL.Objects.Samplers.Sampler is
Result : GL.Objects.Samplers.Sampler;
use all type Textures.Wrapping_Mode;
use all type Textures.Minifying_Function;
begin
Result.Set_X_Wrapping (Clamp_To_Edge);
Result.Set_Y_Wrapping (Clamp_To_Edge);
Result.Set_Z_Wrapping (Clamp_To_Edge);
Result.Set_Minifying_Filter (Linear);
Result.Set_Magnifying_Filter (Linear);
return Result;
end Create_Sampler;
function Create_Texture (Width, Height : Size) return Textures.Texture is
Result : Textures.Texture (LE.Texture_2D);
begin
-- 16F precision for the transmittance gives artifacts
Result.Allocate_Storage (1, 1, GL.Pixels.RGBA32F, Width, Height, 1);
return Result;
end Create_Texture;
function Create_Texture
(Width, Height, Depth : Size;
Half_Precision : Boolean) return Textures.Texture
is
Result : Textures.Texture (LE.Texture_3D);
Internal_Format : constant GL.Pixels.Internal_Format
:= (if Half_Precision then GL.Pixels.RGBA16F else GL.Pixels.RGBA32F);
begin
Result.Allocate_Storage (1, 1, Internal_Format, Width, Height, Depth);
return Result;
end Create_Texture;
-----------------------------------------------------------------------------
type Enable_Blend_Array is array (GL.Buffers.Draw_Buffer_Index range <>) of Boolean;
procedure Draw_Quad (Blend : Enable_Blend_Array) is
begin
for Index in Blend'Range loop
if Blend (Index) then
GL.Toggles.Enable (GL.Toggles.Blend, Index);
end if;
end loop;
Orka.Rendering.Drawing.Draw (Triangles, 0, 3);
for Index in Blend'Range loop
GL.Toggles.Disable (GL.Toggles.Blend, Index);
end loop;
end Draw_Quad;
-----------------------------------------------------------------------------
-- Finally, we need a utility function to compute the value of the
-- conversion constants *_RADIANCE_TO_LUMINANCE, used in the shader
-- to convert the spectral results into luminance values. These are
-- the constants k_r, k_g, k_b described in Section 14.3 of
-- "A Qualitative and Quantitative Evaluation of 8 Clear Sky Models" [1].
-- Computing their value requires an integral of a function times a
-- CIE color matching function. Thus, we first need functions to
-- interpolate an arbitrary function (specified by some samples), and
-- a CIE color matching function (specified by tabulated values), at
-- an arbitrary wavelength. This is the purpose of the two functions
-- below.
--
-- [1] https://arxiv.org/pdf/1612.04336.pdf
function CIE_Color_Matching_Function_Table_Value
(Wavelength : Double;
Column : Size) return Double is
begin
if Wavelength <= K_Lambda_Min or Wavelength >= K_Lambda_Max then
return 0.0;
end if;
declare
U : Double := (Wavelength - K_Lambda_Min) / 5.0;
Row : constant Size := Int (Double'Floor (U));
pragma Assert (Row + 1 < 95);
pragma Assert (CIE_2_Deg_Color_Matching_Functions (4 * Row) <= Wavelength);
pragma Assert (CIE_2_Deg_Color_Matching_Functions (4 * (Row + 1)) >= Wavelength);
begin
U := U - Double (Row);
return CIE_2_Deg_Color_Matching_Functions (4 * Row + Column) * (1.0 - U) +
CIE_2_Deg_Color_Matching_Functions (4 * (Row + 1) + Column) * U;
end;
end CIE_Color_Matching_Function_Table_Value;
function Interpolate
(Wavelengths, Functions : Double_Vectors.Vector;
Wavelength : Double) return Double
is
pragma Assert (Wavelengths.Length = Functions.Length);
begin
if Wavelength < Wavelengths.First_Element then
return Functions.First_Element;
end if;
for Index in Wavelengths.First_Index .. Wavelengths.Last_Index - 1 loop
if Wavelength < Wavelengths (Index + 1) then
declare
U : constant Double := (Wavelength - Wavelengths (Index))
/ (Wavelengths (Index + 1) - Wavelengths (Index));
begin
return Functions (Index) * (1.0 - U) + Functions (Index + 1) * U;
end;
end if;
end loop;
return Functions.Last_Element;
end Interpolate;
-- We can then implement a utility function to compute the "spectral
-- radiance to luminance" conversion constants (see Section 14.3 in
-- "A Qualitative and Quantitative Evaluation of 8 Clear Sky Models" [1]
-- for their definitions).
--
-- [1] https://arxiv.org/pdf/1612.04336.pdf
procedure Compute_Spectral_Radiance_To_Luminance_Factors
(Wavelengths, Solar_Irradiance : Double_Vectors.Vector;
Lambda_Power : Double;
K_R, K_G, K_B : out Double) -- The returned constants are in lumen.nm / watt
is
package EF is new Ada.Numerics.Generic_Elementary_Functions (Double);
use EF;
Solar_R : constant Double := Interpolate (Wavelengths, Solar_Irradiance, K_Lambda_R);
Solar_G : constant Double := Interpolate (Wavelengths, Solar_Irradiance, K_Lambda_G);
Solar_B : constant Double := Interpolate (Wavelengths, Solar_Irradiance, K_Lambda_B);
D_Lambda : constant Double := 1.0;
Lambda : Double := K_Lambda_Min;
begin
K_R := 0.0;
K_G := 0.0;
K_B := 0.0;
while Lambda < K_Lambda_Max loop
declare
X_Bar : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 1);
Y_Bar : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 2);
Z_Bar : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 3);
R_Bar : constant Double
:= XYZ_To_SRGB (0) * X_Bar + XYZ_To_SRGB (1) * Y_Bar + XYZ_To_SRGB (2) * Z_Bar;
G_Bar : constant Double
:= XYZ_To_SRGB (3) * X_Bar + XYZ_To_SRGB (4) * Y_Bar + XYZ_To_SRGB (5) * Z_Bar;
B_Bar : constant Double
:= XYZ_To_SRGB (6) * X_Bar + XYZ_To_SRGB (7) * Y_Bar + XYZ_To_SRGB (8) * Z_Bar;
Irradiance : constant Double := Interpolate (Wavelengths, Solar_Irradiance, Lambda);
begin
K_R := K_R + R_Bar * Irradiance / Solar_R * (Lambda / K_Lambda_R) ** Lambda_Power;
K_G := K_G + G_Bar * Irradiance / Solar_G * (Lambda / K_Lambda_G) ** Lambda_Power;
K_B := K_B + B_Bar * Irradiance / Solar_B * (Lambda / K_Lambda_B) ** Lambda_Power;
end;
Lambda := Lambda + D_Lambda;
end loop;
K_R := K_R * Max_Luminous_Efficacy * D_Lambda;
K_G := K_G * Max_Luminous_Efficacy * D_Lambda;
K_B := K_B * Max_Luminous_Efficacy * D_Lambda;
end Compute_Spectral_Radiance_To_Luminance_Factors;
-- A function that creates a shader header containing our atmosphere computation
-- functions, specialized for the given atmosphere parameters and for the 3
-- wavelengths in Lambdas
function Shader_Header (Result : Model; Lambdas : Double_Array) return String is
package EF is new Ada.Numerics.Generic_Elementary_Functions (Double);
use Ada.Characters.Latin_1;
Data : not null access constant Model_Data renames Result.Data;
function To_String
(V : Double_Vectors.Vector;
Scale : Double) return String
is
R : constant Double := Interpolate (Data.Wavelengths, V, Lambdas (0)) * Scale;
G : constant Double := Interpolate (Data.Wavelengths, V, Lambdas (1)) * Scale;
B : constant Double := Interpolate (Data.Wavelengths, V, Lambdas (2)) * Scale;
begin
return "vec3(" & R'Image & "," & G'Image & "," & B'Image & ")";
end To_String;
function Density_Layer (Layer : Density_Profile_Layer) return String is
Width : constant Double := Layer.Width / Data.Length_Unit_In_Meters;
Scale : constant Double := Layer.Exp_Scale * Data.Length_Unit_In_Meters;
Linear_Term : constant Double := Layer.Linear_Term * Data.Length_Unit_In_Meters;
begin
return "DensityProfileLayer(" &
Width'Image & "," & Layer.Exp_Term'Image & "," &
Scale'Image & "," & Linear_Term'Image & "," &
Layer.Constant_Term'Image & ")";
end Density_Layer;
function Density_Profile (Layers : Density_Vectors.Vector) return String is
K_Layer_Count : constant := 2;
K_Layers : Density_Vectors.Vector := Layers.Copy;
Zero_Layer : Density_Profile_Layer;
Result : SU.Unbounded_String;
begin
while K_Layers.Length < K_Layer_Count loop
K_Layers.Prepend (Zero_Layer);
end loop;
SU.Append (Result, "DensityProfile(DensityProfileLayer[" &
Natural'Image (K_Layer_Count) & "](");
for Index in K_Layers.First_Index .. K_Layers.Last_Index - 1 loop
SU.Append (Result, Density_Layer (K_Layers (Index)) & ",");
end loop;
SU.Append (Result, Density_Layer (K_Layers.Last_Element) & "))");
return SU.To_String (Result);
end Density_Profile;
Definitions_GLSL : constant String
:= Convert (Resources.Byte_Array'(Result.Data_Definitions.Get));
Functions_GLSL : constant String
:= Convert (Resources.Byte_Array'(Result.Data_Functions.Get));
Bottom_Radius : constant Double := Data.Bottom_Radius / Data.Length_Unit_In_Meters;
Top_Radius : constant Double := Data.Top_Radius / Data.Length_Unit_In_Meters;
begin
return
"#version 420" & LF &
"#extension GL_ARB_fragment_layer_viewport : require" & LF &
"#define IN(x) const in x" & LF &
"#define OUT(x) out x" & LF &
"#define TEMPLATE(x)" & LF &
"#define TEMPLATE_ARGUMENT(x)" & LF &
"#define assert(x)" & LF &
"const int TRANSMITTANCE_TEXTURE_WIDTH = " &
Natural'Image (Transmittance_Texture_Width) & ";" & LF &
"const int TRANSMITTANCE_TEXTURE_HEIGHT = " &
Natural'Image (Transmittance_Texture_Height) & ";" & LF &
"const int SCATTERING_TEXTURE_R_SIZE = " &
Natural'Image (Scattering_Texture_R_Size) & ";" & LF &
"const int SCATTERING_TEXTURE_MU_SIZE = " &
Natural'Image (Scattering_Texture_Mu_Size) & ";" & LF &
"const int SCATTERING_TEXTURE_MU_S_SIZE = " &
Natural'Image (Scattering_Texture_Mu_S_Size) & ";" & LF &
"const int SCATTERING_TEXTURE_NU_SIZE = " &
Natural'Image (Scattering_Texture_Nu_Size) & ";" & LF &
"const int IRRADIANCE_TEXTURE_WIDTH = " &
Natural'Image (Irradiance_Texture_Width) & ";" & LF &
"const int IRRADIANCE_TEXTURE_HEIGHT = " &
Natural'Image (Irradiance_Texture_Height) & ";" & LF &
(if Data.Combine_Scattering_Textures then
"#define COMBINED_SCATTERING_TEXTURES" & LF
else "") &
Definitions_GLSL & LF &
"const AtmosphereParameters ATMOSPHERE = AtmosphereParameters(" & LF &
To_String (Data.Solar_Irradiance, 1.0) & "," & LF &
Data.Sun_Angular_Radius'Image & "," & LF &
Bottom_Radius'Image & "," & LF &
Top_Radius'Image & "," & LF &
Density_Profile (Data.Rayleigh_Density) & "," & LF &
To_String
(Data.Rayleigh_Scattering, Data.Length_Unit_In_Meters) & "," & LF &
Density_Profile (Data.Mie_Density) & "," & LF &
To_String
(Data.Mie_Scattering, Data.Length_Unit_In_Meters) & "," & LF &
To_String
(Data.Mie_Extinction, Data.Length_Unit_In_Meters) & "," & LF &
Data.Mie_Phase_Function_G'Image & "," & LF &
Density_Profile (Data.Absorption_Density) & "," & LF &
To_String
(Data.Absorption_Extinction, Data.Length_Unit_In_Meters) & "," & LF &
To_String (Data.Ground_Albedo, 1.0) & "," & LF &
EF.Cos (Data.Max_Sun_Zenith_Angle)'Image & ");" & LF &
"const vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE = vec3(" &
Result.Sky_K_R'Image & "," &
Result.Sky_K_G'Image & "," &
Result.Sky_K_B'Image & ");" & LF &
"const vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE = vec3(" &
Result.Sun_K_R'Image & "," &
Result.Sun_K_G'Image & "," &
Result.Sun_K_B'Image & ");" & LF &
Functions_GLSL & LF;
end Shader_Header;
-----------------------------------------------------------------------------
function Create_Model
(Data : not null access constant Model_Data;
Location : Resources.Locations.Location_Ptr) return Model
is
-- Compute the values for the SKY_RADIANCE_TO_LUMINANCE constant. In theory
-- this should be 1 in precomputed illuminance mode (because the precomputed
-- textures already contain illuminance values). In practice, however, storing
-- true illuminance values in half precision textures yields artefacts
-- (because the values are too large), so we store illuminance values divided
-- by MAX_LUMINOUS_EFFICACY instead. This is why, in precomputed illuminance
-- mode, we set SKY_RADIANCE_TO_LUMINANCE to MAX_LUMINOUS_EFFICACY.
Precompute_Illuminance : constant Boolean := Data.Num_Precomputed_Wavelengths > 3;
Power_Sky : constant Double := -3.0;
Power_Sun : constant Double := 0.0;
begin
return Result : Model (Data) do
if Precompute_Illuminance then
Result.Sky_K_R := Max_Luminous_Efficacy;
Result.Sky_K_G := Max_Luminous_Efficacy;
Result.Sky_K_B := Max_Luminous_Efficacy;
else
Compute_Spectral_Radiance_To_Luminance_Factors
(Data.Wavelengths, Data.Solar_Irradiance, Power_Sky,
Result.Sky_K_R, Result.Sky_K_G, Result.Sky_K_B);
end if;
-- Compute the values for the SUN_RADIANCE_TO_LUMINANCE constant
Compute_Spectral_Radiance_To_Luminance_Factors
(Data.Wavelengths, Data.Solar_Irradiance, Power_Sun,
Result.Sun_K_R, Result.Sun_K_G, Result.Sun_K_B);
Result.Data_Definitions := Location.Read_Data ("atmosphere/definitions.frag");
Result.Data_Functions := Location.Read_Data ("atmosphere/functions.frag");
Result.Location := Location;
end return;
end Create_Model;
-- The utility method is implemented with a simple numerical integration
-- of the given function, times the CIE color matching functions (with an
-- integration step of 1 nm), followed by a matrix multiplication
procedure Convert_Spectrum_To_Linear_SRGB (Data : Model_Data; R, G, B : out Double) is
D_Lambda : constant Double := 1.0;
Lambda : Double := K_Lambda_Min;
X, Y, Z : Double := 0.0;
begin
while Lambda < K_Lambda_Max loop
declare
Value : constant Double :=
Interpolate (Data.Wavelengths, Data.Solar_Irradiance, Lambda);
begin
X := X + CIE_Color_Matching_Function_Table_Value (Lambda, 1) * Value;
Y := Y + CIE_Color_Matching_Function_Table_Value (Lambda, 2) * Value;
Z := Z + CIE_Color_Matching_Function_Table_Value (Lambda, 3) * Value;
end;
Lambda := Lambda + D_Lambda;
end loop;
R := Max_Luminous_Efficacy *
(XYZ_To_SRGB (0) * X + XYZ_To_SRGB (1) * Y + XYZ_To_SRGB (2) * Z) * D_Lambda;
G := Max_Luminous_Efficacy *
(XYZ_To_SRGB (3) * X + XYZ_To_SRGB (4) * Y + XYZ_To_SRGB (5) * Z) * D_Lambda;
B := Max_Luminous_Efficacy *
(XYZ_To_SRGB (6) * X + XYZ_To_SRGB (7) * Y + XYZ_To_SRGB (8) * Z) * D_Lambda;
end Convert_Spectrum_To_Linear_SRGB;
-- Implementation of the precomputation algorithm described in
-- Algorithm 4.1 of [1]. Each step is explained by the inline
-- comments below.
--
-- [1] https://hal.inria.fr/inria-00288758/en
procedure Precompute
(Object : Model;
Result : Precomputed_Textures;
Delta_Irradiance_Texture, Delta_Rayleigh_Scattering_Texture,
Delta_Mie_Scattering_Texture, Delta_Scattering_Density_Texture,
Delta_Multiple_Scattering_Texture : Textures.Texture;
Lambdas : Double_Array;
Luminance_From_Radiance : Single_Array;
Blend : Boolean;
Num_Scattering_Orders : Natural)
is
LR : Single_Array renames Luminance_From_Radiance;
Luminance_From_Radiance_Mat3 : constant Orka.Types.Singles.Matrix4 :=
((LR (0), LR (1), LR (2), 0.0),
(LR (3), LR (4), LR (5), 0.0),
(LR (6), LR (7), LR (8), 0.0),
(0.0, 0.0, 0.0, 0.0));
use Orka.Rendering.Programs;
-- The precomputations require specific GLSL programs for each
-- precomputation step
Module_VS : constant Modules.Module
:= Modules.Create_Module (Object.Location, VS => "atmosphere/oversized-triangle.vert");
Module_GS : constant Modules.Module
:= Modules.Create_Module (Object.Location, GS => "atmosphere/layer.geom");
Header : constant String := Object.Shader_Header (Lambdas);
FS_Transmittance : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-transmittance.frag").Get));
FS_Direct_Irradiance : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-direct-irradiance.frag").Get));
FS_Indirect_Irradiance : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-indirect-irradiance.frag").Get));
FS_Single_Scattering : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-single-scattering.frag").Get));
FS_Multiple_Scattering : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-multiple-scattering.frag").Get));
FS_Scattering_Density : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-scattering-density.frag").Get));
Program_Transmittance : Program := Create_Program (Modules.Module_Array'
(Module_VS,
Modules.Create_Module_From_Sources (FS => Header & FS_Transmittance)));
Program_Direct_Irradiance : Program := Create_Program (Modules.Module_Array'
(Module_VS,
Modules.Create_Module_From_Sources (FS => Header & FS_Direct_Irradiance)));
Program_Indirect_Irradiance : Program := Create_Program (Modules.Module_Array'
(Module_VS,
Modules.Create_Module_From_Sources (FS => Header & FS_Indirect_Irradiance)));
Program_Single_Scattering : Program := Create_Program (Modules.Module_Array'
(Module_VS, Module_GS,
Modules.Create_Module_From_Sources (FS => Header & FS_Single_Scattering)));
Program_Multiple_Scattering : Program := Create_Program (Modules.Module_Array'
(Module_VS, Module_GS,
Modules.Create_Module_From_Sources (FS => Header & FS_Multiple_Scattering)));
Program_Scattering_Density : Program := Create_Program (Modules.Module_Array'
(Module_VS, Module_GS,
Modules.Create_Module_From_Sources (FS => Header & FS_Scattering_Density)));
-------------------------------------------------------------------------
FBO_Transmittance : Framebuffers.Framebuffer := Framebuffers.Create_Framebuffer
(Width => Constants.Transmittance_Texture_Width,
Height => Constants.Transmittance_Texture_Height);
FBO_Irradiance : Framebuffers.Framebuffer := Framebuffers.Create_Framebuffer
(Width => Constants.Irradiance_Texture_Width,
Height => Constants.Irradiance_Texture_Height);
FBO_Scattering : Framebuffers.Framebuffer := Framebuffers.Create_Framebuffer
(Width => Constants.Scattering_Texture_Width,
Height => Constants.Scattering_Texture_Height);
use all type GL.Blending.Equation;
use all type GL.Blending.Blend_Factor;
use all type Rendering.Textures.Indexed_Texture_Target;
use all type Framebuffers.Color_Attachment_Point;
begin
GL.Blending.Set_Blend_Equation ((Func_Add, Func_Add));
GL.Blending.Set_Blend_Func ((One, One, One, One));
Rendering.Textures.Bind (Result.Transmittance_Texture, Texture, 0);
-- transmittance_texture
Rendering.Textures.Bind (Delta_Rayleigh_Scattering_Texture, Texture, 1);
-- single_rayleigh_scattering_texture
Rendering.Textures.Bind (Delta_Mie_Scattering_Texture, Texture, 2);
-- single_mie_scattering_texture
Rendering.Textures.Bind (Delta_Multiple_Scattering_Texture, Texture, 3);
-- multiple_scattering_texture
Rendering.Textures.Bind (Delta_Irradiance_Texture, Texture, 4);
-- irradiance_texture
Rendering.Textures.Bind (Delta_Scattering_Density_Texture, Texture, 5);
-- scattering_density_texture
-- Compute the transmittance and store it in Transmittance_Texture
FBO_Transmittance.Use_Framebuffer;
FBO_Transmittance.Attach (Color_Attachment_0, Result.Transmittance_Texture);
FBO_Transmittance.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0));
Program_Transmittance.Use_Program;
Draw_Quad ((1 .. 0 => <>));
-------------------------------------------------------------------------
-- Compute the direct irradiance, store it in Delta_Irradiance_Texture and,
-- depending on 'blend', either initialize Irradiance_Texture with
-- zeros or leave it unchanged (we don't want the irradiance in
-- Irradiance_Texture, but only the irradiance from the sky
FBO_Irradiance.Use_Framebuffer;
FBO_Irradiance.Attach (Color_Attachment_0, Delta_Irradiance_Texture);
FBO_Irradiance.Attach (Color_Attachment_1, Result.Irradiance_Texture);
FBO_Irradiance.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0,
1 => GL.Buffers.Color_Attachment1));
Program_Direct_Irradiance.Use_Program;
Draw_Quad ((False, Blend));
-------------------------------------------------------------------------
-- Compute the rayleigh and mie single scattering, store them in
-- Delta_Rayleigh_Scattering_Texture and Delta_Mie_Scattering_Texture,
-- and either them or accumulate them in Scattering_Texture and
-- Optional_Single_Mie_Scattering_Texture
FBO_Scattering.Use_Framebuffer;
FBO_Scattering.Attach (Color_Attachment_0, Delta_Rayleigh_Scattering_Texture);
FBO_Scattering.Attach (Color_Attachment_1, Delta_Mie_Scattering_Texture);
FBO_Scattering.Attach (Color_Attachment_2, Result.Scattering_Texture);
if not Object.Data.Combine_Scattering_Textures then
FBO_Scattering.Attach (Color_Attachment_3,
Result.Optional_Single_Mie_Scattering_Texture);
FBO_Scattering.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0,
1 => GL.Buffers.Color_Attachment1,
2 => GL.Buffers.Color_Attachment2,
3 => GL.Buffers.Color_Attachment3));
else
FBO_Scattering.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0,
1 => GL.Buffers.Color_Attachment1,
2 => GL.Buffers.Color_Attachment2));
end if;
Program_Single_Scattering.Use_Program;
Program_Single_Scattering.Uniform ("luminance_from_radiance").Set_Matrix
(Luminance_From_Radiance_Mat3);
for Layer in 0 .. Int (Constants.Scattering_Texture_Depth - 1) loop
Program_Single_Scattering.Uniform ("layer").Set_Int (Layer);
Draw_Quad ((False, False, Blend, Blend));
end loop;
-------------------------------------------------------------------------
-- Compute the 2nd, 3rd and 4th order of scattering, in sequence
for Scattering_Order in 2 .. Int (Num_Scattering_Orders) loop
-- Compute the scattering density, and store it in
-- Delta_Scattering_Density_Texture
FBO_Scattering.Use_Framebuffer;
FBO_Scattering.Attach (Color_Attachment_0, Delta_Scattering_Density_Texture);
FBO_Scattering.Detach (Color_Attachment_1);
FBO_Scattering.Detach (Color_Attachment_2);
FBO_Scattering.Detach (Color_Attachment_3);
FBO_Scattering.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0));
Program_Scattering_Density.Use_Program;
Program_Scattering_Density.Uniform ("scattering_order").Set_Int (Scattering_Order);
for Layer in 0 .. Int (Constants.Scattering_Texture_Depth - 1) loop
Program_Scattering_Density.Uniform ("layer").Set_Int (Layer);
Draw_Quad ((1 .. 0 => <>));
end loop;
-- Compute the indirect irradiance, store it in Delta_Irradiance_Texture
-- and accumulate it in Irradiance_Texture
FBO_Irradiance.Use_Framebuffer;
FBO_Irradiance.Attach (Color_Attachment_0, Delta_Irradiance_Texture);
FBO_Irradiance.Attach (Color_Attachment_1, Result.Irradiance_Texture);
FBO_Irradiance.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0,
1 => GL.Buffers.Color_Attachment1));
Program_Indirect_Irradiance.Use_Program;
Program_Indirect_Irradiance.Uniform ("luminance_from_radiance").Set_Matrix
(Luminance_From_Radiance_Mat3);
Program_Indirect_Irradiance.Uniform ("scattering_order").Set_Int (Scattering_Order - 1);
Draw_Quad ((False, True));
-- Compute the multiple scattering, store it in
-- Delta_Multiple_Scattering_Texture, and accumulate it in
-- Scattering_Texture
FBO_Scattering.Use_Framebuffer;
FBO_Scattering.Attach (Color_Attachment_0, Delta_Multiple_Scattering_Texture);
FBO_Scattering.Attach (Color_Attachment_1, Result.Scattering_Texture);
FBO_Scattering.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0,
1 => GL.Buffers.Color_Attachment1));
Program_Multiple_Scattering.Use_Program;
Program_Multiple_Scattering.Uniform ("luminance_from_radiance").Set_Matrix
(Luminance_From_Radiance_Mat3);
for Layer in 0 .. Int (Constants.Scattering_Texture_Depth - 1) loop
Program_Multiple_Scattering.Uniform ("layer").Set_Int (Layer);
Draw_Quad ((False, True));
end loop;
end loop;
end Precompute;
-- Precomputes the atmosphere textures. It first allocates the
-- temporary resources it needs and then calls Precompute to do the
-- actual precomputations.
--
-- Note that there are two precomputation modes here, depending on whether we
-- want to store precomputed irradiance or illuminance values:
--
-- - In precomputed irradiance mode, we simply need to call
-- Precompute with the 3 wavelengths for which we want to precompute
-- irradiance, namely K_Lambda_R, K_Lambda_G,
-- K_Lambda_B (with the identity matrix for
-- Luminance_From_Radiance, since we don't want any conversion from
-- radiance to luminance)
--
-- - In precomputed illuminance mode, we need to precompute irradiance for
-- Num_Precomputed_Wavelengths, and then integrate the results,
-- multiplied with the 3 CIE xyz color matching functions and the XYZ to sRGB
-- matrix to get sRGB illuminance values.
--
-- A naive solution would be to allocate temporary textures for the
-- intermediate irradiance results, then perform the integration from irradiance
-- to illuminance and store the result in the final precomputed texture. In
-- pseudo-code (and assuming one wavelength per texture instead of 3):
--
-- create n temporary irradiance textures
-- for each wavelength lambda in the n wavelengths:
-- precompute irradiance at lambda into one of the temporary textures
-- initializes the final illuminance texture with zeros
-- for each wavelength lambda in the n wavelengths:
-- accumulate in the final illuminance texture the product of the
-- precomputed irradiance at lambda (read from the temporary textures)
-- with the value of the 3 sRGB color matching functions at lambda (i.e.
-- the product of the XYZ to sRGB matrix with the CIE xyz color matching
-- functions).
--
-- However, this be would waste GPU memory. Instead, we can avoid allocating
-- temporary irradiance textures, by merging the two above loops:
--
-- for each wavelength lambda in the n wavelengths:
-- accumulate in the final illuminance texture (or, for the first
-- iteration, set this texture to) the product of the precomputed
-- irradiance at lambda (computed on the fly) with the value of the 3
-- sRGB color matching functions at lambda.
--
-- This is the method we use below, with 3 wavelengths per iteration instead
-- of 1, using Precompute to compute 3 irradiances values per
-- iteration, and Luminance_From_Radiance to multiply 3 irradiances
-- with the values of the 3 sRGB color matching functions at 3 different
-- wavelengths (yielding a 3x3 matrix).
function Compute_Textures (Object : Model; Scattering_Orders : Natural := 4)
return Precomputed_Textures
is
-- The precomputations require temporary textures, in particular to store the
-- contribution of one scattering order, which is needed to compute the next
-- order of scattering (the final precomputed textures store the sum of all
-- the scattering orders)
Delta_Irradiance_Texture : constant Textures.Texture (LE.Texture_2D)
:= Create_Texture (Constants.Irradiance_Texture_Width,
Constants.Irradiance_Texture_Height);
Delta_Rayleigh_Scattering_Texture : constant Textures.Texture (LE.Texture_3D)
:= Create_Texture (Constants.Scattering_Texture_Width,
Constants.Scattering_Texture_Height,
Constants.Scattering_Texture_Depth,
Object.Data.Half_Precision);
Delta_Mie_Scattering_Texture : constant Textures.Texture (LE.Texture_3D)
:= Create_Texture (Constants.Scattering_Texture_Width,
Constants.Scattering_Texture_Height,
Constants.Scattering_Texture_Depth,
Object.Data.Half_Precision);
Delta_Scattering_Density_Texture : constant Textures.Texture (LE.Texture_3D)
:= Create_Texture (Constants.Scattering_Texture_Width,
Constants.Scattering_Texture_Height,
Constants.Scattering_Texture_Depth,
Object.Data.Half_Precision);
-- Delta_Multiple_Scattering_Texture is only needed to compute scattering
-- order 3 or more, while Delta_Rayleigh_Scattering_Texture and
-- Delta_Mie_Scattering_Texture are only needed to compute double scattering.
-- Therefore, to save memory, we can store Delta_Rayleigh_Scattering_Texture
-- and Delta_Multiple_Scattering_Texture in the same GPU texture.
Delta_Multiple_Scattering_Texture : constant Textures.Texture (LE.Texture_3D)
:= Delta_Rayleigh_Scattering_Texture;
-- Allocate the precomputed textures before precomputing them
Textures : Precomputed_Textures :=
(Sampler => Create_Sampler,
Combine_Scattering => Object.Data.Combine_Scattering_Textures,
Transmittance_Texture => Create_Texture
(Transmittance_Texture_Width, Transmittance_Texture_Height),
Irradiance_Texture => Create_Texture
(Irradiance_Texture_Width, Irradiance_Texture_Height),
Scattering_Texture => Create_Texture
(Scattering_Texture_Width, Scattering_Texture_Height, Scattering_Texture_Depth,
Object.Data.Half_Precision),
others => <>);
begin
Textures.Sampler.Bind (0);
Textures.Sampler.Bind (1);
Textures.Sampler.Bind (2);
Textures.Sampler.Bind (3);
if not Object.Data.Combine_Scattering_Textures then
Textures.Optional_Single_Mie_Scattering_Texture := Create_Texture
(Scattering_Texture_Width, Scattering_Texture_Height, Scattering_Texture_Depth,
Object.Data.Half_Precision);
end if;
if Object.Data.Num_Precomputed_Wavelengths <= 3 then
declare
Lambdas : constant Double_Array := (K_Lambda_R, K_Lambda_G, K_Lambda_B);
Luminance_From_Radiance : constant Single_Array
:= (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
begin
Object.Precompute
(Textures,
Delta_Irradiance_Texture, Delta_Rayleigh_Scattering_Texture,
Delta_Mie_Scattering_Texture, Delta_Scattering_Density_Texture,
Delta_Multiple_Scattering_Texture,
Lambdas, Luminance_From_Radiance,
Blend => False, Num_Scattering_Orders => Scattering_Orders);
end;
else
declare
Num_Iterations : constant UInt := (Object.Data.Num_Precomputed_Wavelengths + 2) / 3;
D_Lambda : constant Double
:= (K_Lambda_Max - K_Lambda_Min) / Double (3 * Num_Iterations);
begin
for I in 0 .. Num_Iterations - 1 loop
declare
Lambdas : constant Double_Array :=
(K_Lambda_Min + (3.0 * Double (I) + 0.5) * D_Lambda,
K_Lambda_Min + (3.0 * Double (I) + 1.5) * D_Lambda,
K_Lambda_Min + (3.0 * Double (I) + 2.5) * D_Lambda);
function Coeff (Lambda : Double; Component : Size) return Single is
-- Note that we don't include MAX_LUMINOUS_EFFICACY here, to avoid
-- artefacts due to too large values when using half precision on GPU.
-- We add this term back in atmosphere.frag, via
-- SKY_SPECTRAL_RADIANCE_TO_LUMINANCE (see also the comments in the
-- Model constructor).
X : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 1);
Y : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 2);
Z : constant Double := CIE_Color_Matching_Function_Table_Value (Lambda, 3);
begin
return Single
((XYZ_To_SRGB (Component * 3 + 0) * X +
XYZ_To_SRGB (Component * 3 + 1) * Y +
XYZ_To_SRGB (Component * 3 + 2) * Z) * D_Lambda);
end Coeff;
Luminance_From_Radiance : constant Single_Array :=
(Coeff (Lambdas (0), 0), Coeff (Lambdas (0), 1), Coeff (Lambdas (0), 2),
Coeff (Lambdas (1), 0), Coeff (Lambdas (1), 1), Coeff (Lambdas (1), 2),
Coeff (Lambdas (2), 0), Coeff (Lambdas (2), 1), Coeff (Lambdas (2), 2));
begin
Object.Precompute
(Textures,
Delta_Irradiance_Texture, Delta_Rayleigh_Scattering_Texture,
Delta_Mie_Scattering_Texture, Delta_Scattering_Density_Texture,
Delta_Multiple_Scattering_Texture,
Lambdas, Luminance_From_Radiance,
Blend => I > 0, Num_Scattering_Orders => Scattering_Orders);
end;
end loop;
end;
-- After the above iterations, the transmittance texture contains the
-- transmittance for the 3 wavelengths used at the last iteration. But we
-- want the transmittance at kLambdaR, kLambdaG, kLambdaB instead, so we
-- must recompute it here for these 3 wavelengths:
declare
Lambdas : constant Double_Array := (K_Lambda_R, K_Lambda_G, K_Lambda_B);
use Orka.Rendering.Programs;
Header : constant String := Object.Shader_Header (Lambdas);
FS_Transmittance : constant String
:= Convert (Resources.Byte_Array'(Object.Location.Read_Data
("atmosphere/compute-transmittance.frag").Get));
Program_Transmittance : Program := Create_Program (Modules.Module_Array'
(Modules.Create_Module (Object.Location, VS => "oversized-triangle.vert"),
Modules.Create_Module_From_Sources (FS => Header & FS_Transmittance)));
FBO_Transmittance : Framebuffers.Framebuffer := Framebuffers.Create_Framebuffer
(Width => Constants.Transmittance_Texture_Width,
Height => Constants.Transmittance_Texture_Height);
begin
FBO_Transmittance.Use_Framebuffer;
FBO_Transmittance.Attach (Textures.Transmittance_Texture);
FBO_Transmittance.Set_Draw_Buffers
((0 => GL.Buffers.Color_Attachment0));
Program_Transmittance.Use_Program;
Draw_Quad ((1 .. 0 => <>));
end;
end if;
return Textures;
end Compute_Textures;
function Get_Shader (Object : Model) return Rendering.Programs.Modules.Module is
Precompute_Illuminance : constant Boolean := Object.Data.Num_Precomputed_Wavelengths > 3;
Atmosphere_Fragment_Shader : constant String := Convert
(Resources.Byte_Array'(Object.Location.Read_Data ("atmosphere/atmosphere.frag").Get));
use Ada.Characters.Latin_1;
-- Create and compile the fragment shader providing our API.
--
-- It defines an "ATMOSPHERE" constant containing the atmosphere
-- parameters (we use constants instead of uniforms to enable
-- constant folding and propagation optimizations in the GLSL compiler),
-- concatenated with functions.frag, and with Atmosphere_Fragment_Shader, to
-- create the fragment shader
Shader_Source : constant String
:= Object.Shader_Header ((K_Lambda_R, K_Lambda_G, K_Lambda_B)) &
(if Precompute_Illuminance then "" else "#define RADIANCE_API_ENABLED" & LF) &
Atmosphere_Fragment_Shader;
begin
return Rendering.Programs.Modules.Create_Module_From_Sources (FS => Shader_Source);
end Get_Shader;
procedure Bind_Textures (Object : Precomputed_Textures) is
use all type Rendering.Textures.Indexed_Texture_Target;
begin
Object.Sampler.Bind (0);
Object.Sampler.Bind (1);
Object.Sampler.Bind (2);
Object.Sampler.Bind (3);
Rendering.Textures.Bind (Object.Transmittance_Texture, Texture, 0);
Rendering.Textures.Bind (Object.Scattering_Texture, Texture, 1);
-- Only used by GetSunAndSkyIrradiance to compute radiance
-- reflected by the ground
Rendering.Textures.Bind (Object.Irradiance_Texture, Texture, 2);
if not Object.Combine_Scattering then
Rendering.Textures.Bind (Object.Optional_Single_Mie_Scattering_Texture, Texture, 3);
end if;
end Bind_Textures;
end Orka.Features.Atmosphere;
|
[
{
"context": " code by info - zip group, translated to pascal by Christian Ghisler\r\n -- based on unz51g.zip\r\n\r\n -- Free huffman ",
"end": 224,
"score": 0.9994726181030273,
"start": 207,
"tag": "NAME",
"value": "Christian Ghisler"
},
{
"context": "\r\n huft_incomplete := False; -- spotted by Tucker Taft, 19 - Aug - 2004\r\n return; -- complete\r\n ",
"end": 4763,
"score": 0.9998613595962524,
"start": 4752,
"tag": "NAME",
"value": "Tucker Taft"
}
] | Sources/Globe_3d/unzip/unzip-decompress-huffman.adb | ForYouEyesOnly/Space-Convoy | 1 | with Interfaces;
with Ada.Text_IO;
with Ada.Unchecked_Deallocation;
package body UnZip.Decompress.Huffman is
-- Note from Pascal source:
-- C code by info - zip group, translated to pascal by Christian Ghisler
-- based on unz51g.zip
-- Free huffman tables starting with table where t points to
procedure HufT_free (tl : in out p_Table_list) is
procedure Dispose is new
Ada.Unchecked_Deallocation (HufT_table, p_HufT_table);
procedure Dispose is new
Ada.Unchecked_Deallocation (Table_list, p_Table_list);
current : p_Table_list;
tcount : Natural; -- just a stat. Idea : replace table_list with an array
begin
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.Put ("[HufT_Free .. . ");
tcount := 0;
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
while tl /= null loop
Dispose (tl.all.table); -- destroy the Huffman table
current := tl;
tl := tl.all.next;
Dispose (current); -- destroy the current node
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
tcount := tcount + 1;
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
end loop;
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.Put_Line (Integer'Image (tcount) & " tables]");
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
end HufT_free;
-- Build huffman table from code lengths given by array b
procedure HufT_build (b : Length_array;
s : Integer;
d, e : Length_array;
tl : out p_Table_list;
m : in out Integer;
huft_incomplete : out Boolean)
is
use Interfaces;
b_max : constant := 16;
b_maxp1 : constant := b_max + 1;
-- bit length count table
count : array (0 .. b_maxp1) of Integer := (others => 0);
f : Integer; -- i repeats in table every f entries
g : Integer; -- max. code length
i, -- counter, current code
j : Integer; -- counter
kcc : Integer; -- number of bits in current code
c_idx, v_idx : Natural; -- array indices
current_table_ptr : p_HufT_table := null;
current_node_ptr : p_Table_list := null; -- curr. node for the curr. table
new_node_ptr : p_Table_list; -- new node for the new table
new_entry : HufT; -- table entry for structure assignment
u : array (0 .. b_max) of p_HufT_table; -- table stack
n_max : constant := 288;
-- values in order of bit length
v : array (0 .. n_max) of Integer := (others => 0);
el_v, el_v_m_s : Integer;
w : Natural := 0; -- bits before this table
offset, code_stack : array (0 .. b_maxp1) of Integer;
table_level : Integer := -1;
bits : array (Integer'(-1) .. b_maxp1) of Integer;
-- ^bits (table_level) = # bits in table of level table_level
y : Integer; -- number of dummy codes added
z : Natural := 0; -- number of entries in current table
el : Integer; -- length of eob code=code 256
no_copy_length_array : constant Boolean := d'Length = 0 or else e'Length = 0;
begin
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.Put ("[HufT_Build .. .");
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
tl := null;
if b'Length > 256 then -- set length of EOB code, if any
el := b (256);
else
el := b_max;
end if;
-- Generate counts for each bit length
for k in b'Range loop
if b (k) > b_max then
-- m := 0; -- GNAT 2005 doesn't like it (warning).
raise huft_error;
end if;
count (b (k)) := count (b (k)) + 1;
end loop;
if count (0) = b'Length then
m := 0;
huft_incomplete := False; -- spotted by Tucker Taft, 19 - Aug - 2004
return; -- complete
end if;
-- Find minimum and maximum length, bound m by those
j := 1;
while j <= b_max and then count (j) = 0 loop
j := j + 1;
end loop;
kcc := j;
if m < j then
m := j;
end if;
i := b_max;
while i > 0 and then count (i) = 0 loop
i := i - 1;
end loop;
g := i;
if m > i then
m := i;
end if;
-- Adjust last length count to fill out codes, if needed
y := Integer (Shift_Left (Unsigned_32'(1), j)); -- y := 2 ** j;
while j < i loop
y := y - count (j);
if y < 0 then
raise huft_error;
end if;
y := y * 2;
j := j + 1;
end loop;
y := y - count (i);
if y < 0 then
raise huft_error;
end if;
count (i) := count (i) + y;
-- Generate starting offsets into the value table for each length
offset (1) := 0;
j := 0;
for idx in 2 .. i loop
j := j + count (idx - 1);
offset (idx) := j;
end loop;
-- Make table of values in order of bit length
for idx in b'Range loop
j := b (idx);
if j /= 0 then
v (offset (j)) := idx - b'First;
offset (j) := offset (j) + 1;
end if;
end loop;
-- Generate huffman codes and for each, make the table entries
code_stack (0) := 0;
i := 0;
v_idx := v'First;
bits (-1) := 0;
-- go through the bit lengths (kcc already is bits in shortest code)
for k in kcc .. g loop
for am1 in reverse 0 .. count (k) - 1 loop -- a counts codes of length k
-- here i is the huffman code of length k bits for value v (v_idx)
while k > w + bits (table_level) loop
w := w + bits (table_level); -- Length of tables to this position
table_level := table_level + 1;
z := g - w; -- Compute min size table <= m bits
if z > m then
z := m;
end if;
j := k - w;
f := Integer (Shift_Left (Unsigned_32'(1), j)); -- f := 2 ** j;
if f > am1 + 2 then -- Try a k - w bit table
f := f - (am1 + 2);
c_idx := k;
loop -- Try smaller tables up to z bits
j := j + 1;
exit when j >= z;
f := f * 2;
c_idx := c_idx + 1;
exit when f - count (c_idx) <= 0;
f := f - count (c_idx);
end loop;
end if;
if w + j > el and then w < el then
j := el - w; -- Make EOB code end at table
end if;
if w = 0 then
j := m; -- Fix : main table always m bits!
end if;
z := Integer (Shift_Left (Unsigned_32'(1), j)); -- z := 2 ** j;
bits (table_level) := j;
-- Allocate and link new table
begin
current_table_ptr := new HufT_table (0 .. z);
new_node_ptr := new Table_list'(current_table_ptr, null);
exception
when Storage_Error =>
raise huft_out_of_memory;
end;
if current_node_ptr = null then -- first table
tl := new_node_ptr;
else
current_node_ptr.all.next := new_node_ptr; -- not my first .. .
end if;
current_node_ptr := new_node_ptr; -- always non - Null from there
u (table_level) := current_table_ptr;
-- Connect to last table, if there is one
if table_level > 0 then
code_stack (table_level) := i;
new_entry.bits := bits (table_level - 1);
new_entry.extra_bits := 16 + j;
new_entry.next_table := current_table_ptr;
j := Integer (
Shift_Right (Unsigned_32 (i) and
(Shift_Left (Unsigned_32'(1), w) - 1),
w - bits (table_level - 1))
);
-- Test against bad input!
if j > u (table_level - 1)'Last then
raise huft_error;
end if;
u (table_level - 1).all (j) := new_entry;
end if;
end loop;
-- Set up table entry in new_entry
new_entry.bits := k - w;
new_entry.next_table := null; -- Unused
if v_idx >= b'Length then
new_entry.extra_bits := invalid;
else
el_v := v (v_idx);
el_v_m_s := el_v - s;
if el_v_m_s < 0 then -- Simple code, raw value
if el_v < 256 then
new_entry.extra_bits := 16;
else
new_entry.extra_bits := 15;
end if;
new_entry.n := el_v;
else -- Non - simple - > lookup in lists
if no_copy_length_array then
raise huft_error;
end if;
new_entry.extra_bits := e (el_v_m_s);
new_entry.n := d (el_v_m_s);
end if;
v_idx := v_idx + 1;
end if;
-- fill code - like entries with new_entry
f := Integer (Shift_Left (Unsigned_32'(1), k - w));
-- i.e. f := 2 ** (k - w);
j := Integer (Shift_Right (Unsigned_32 (i), w));
while j < z loop
current_table_ptr.all (j) := new_entry;
j := j + f;
end loop;
-- backwards increment the k - bit code i
j := Integer (Shift_Left (Unsigned_32'(1), k - 1));
-- i.e. : j := 2 ** (k - 1)
while (Unsigned_32 (i) and Unsigned_32 (j)) /= 0 loop
i := Integer (Unsigned_32 (i) xor Unsigned_32 (j));
j := j / 2;
end loop;
i := Integer (Unsigned_32 (i) xor Unsigned_32 (j));
-- backup over finished tables
while
Integer (Unsigned_32 (i) and (Shift_Left (1, w) - 1)) /=
code_stack (table_level)
loop
table_level := table_level - 1;
w := w - bits (table_level); -- Size of previous table!
end loop;
end loop; -- am1
end loop; -- k
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.Put_Line ("finished]");
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
huft_incomplete := y /= 0 and then g /= 1;
exception
when others =>
HufT_free (tl);
raise;
end HufT_build;
end UnZip.Decompress.Huffman;
| 4653 | with Interfaces;
with Ada.Text_IO;
with Ada.Unchecked_Deallocation;
package body UnZip.Decompress.Huffman is
-- Note from Pascal source:
-- C code by info - zip group, translated to pascal by <NAME>
-- based on unz51g.zip
-- Free huffman tables starting with table where t points to
procedure HufT_free (tl : in out p_Table_list) is
procedure Dispose is new
Ada.Unchecked_Deallocation (HufT_table, p_HufT_table);
procedure Dispose is new
Ada.Unchecked_Deallocation (Table_list, p_Table_list);
current : p_Table_list;
tcount : Natural; -- just a stat. Idea : replace table_list with an array
begin
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.Put ("[HufT_Free .. . ");
tcount := 0;
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
while tl /= null loop
Dispose (tl.all.table); -- destroy the Huffman table
current := tl;
tl := tl.all.next;
Dispose (current); -- destroy the current node
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
tcount := tcount + 1;
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
end loop;
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.Put_Line (Integer'Image (tcount) & " tables]");
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
end HufT_free;
-- Build huffman table from code lengths given by array b
procedure HufT_build (b : Length_array;
s : Integer;
d, e : Length_array;
tl : out p_Table_list;
m : in out Integer;
huft_incomplete : out Boolean)
is
use Interfaces;
b_max : constant := 16;
b_maxp1 : constant := b_max + 1;
-- bit length count table
count : array (0 .. b_maxp1) of Integer := (others => 0);
f : Integer; -- i repeats in table every f entries
g : Integer; -- max. code length
i, -- counter, current code
j : Integer; -- counter
kcc : Integer; -- number of bits in current code
c_idx, v_idx : Natural; -- array indices
current_table_ptr : p_HufT_table := null;
current_node_ptr : p_Table_list := null; -- curr. node for the curr. table
new_node_ptr : p_Table_list; -- new node for the new table
new_entry : HufT; -- table entry for structure assignment
u : array (0 .. b_max) of p_HufT_table; -- table stack
n_max : constant := 288;
-- values in order of bit length
v : array (0 .. n_max) of Integer := (others => 0);
el_v, el_v_m_s : Integer;
w : Natural := 0; -- bits before this table
offset, code_stack : array (0 .. b_maxp1) of Integer;
table_level : Integer := -1;
bits : array (Integer'(-1) .. b_maxp1) of Integer;
-- ^bits (table_level) = # bits in table of level table_level
y : Integer; -- number of dummy codes added
z : Natural := 0; -- number of entries in current table
el : Integer; -- length of eob code=code 256
no_copy_length_array : constant Boolean := d'Length = 0 or else e'Length = 0;
begin
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.Put ("[HufT_Build .. .");
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
tl := null;
if b'Length > 256 then -- set length of EOB code, if any
el := b (256);
else
el := b_max;
end if;
-- Generate counts for each bit length
for k in b'Range loop
if b (k) > b_max then
-- m := 0; -- GNAT 2005 doesn't like it (warning).
raise huft_error;
end if;
count (b (k)) := count (b (k)) + 1;
end loop;
if count (0) = b'Length then
m := 0;
huft_incomplete := False; -- spotted by <NAME>, 19 - Aug - 2004
return; -- complete
end if;
-- Find minimum and maximum length, bound m by those
j := 1;
while j <= b_max and then count (j) = 0 loop
j := j + 1;
end loop;
kcc := j;
if m < j then
m := j;
end if;
i := b_max;
while i > 0 and then count (i) = 0 loop
i := i - 1;
end loop;
g := i;
if m > i then
m := i;
end if;
-- Adjust last length count to fill out codes, if needed
y := Integer (Shift_Left (Unsigned_32'(1), j)); -- y := 2 ** j;
while j < i loop
y := y - count (j);
if y < 0 then
raise huft_error;
end if;
y := y * 2;
j := j + 1;
end loop;
y := y - count (i);
if y < 0 then
raise huft_error;
end if;
count (i) := count (i) + y;
-- Generate starting offsets into the value table for each length
offset (1) := 0;
j := 0;
for idx in 2 .. i loop
j := j + count (idx - 1);
offset (idx) := j;
end loop;
-- Make table of values in order of bit length
for idx in b'Range loop
j := b (idx);
if j /= 0 then
v (offset (j)) := idx - b'First;
offset (j) := offset (j) + 1;
end if;
end loop;
-- Generate huffman codes and for each, make the table entries
code_stack (0) := 0;
i := 0;
v_idx := v'First;
bits (-1) := 0;
-- go through the bit lengths (kcc already is bits in shortest code)
for k in kcc .. g loop
for am1 in reverse 0 .. count (k) - 1 loop -- a counts codes of length k
-- here i is the huffman code of length k bits for value v (v_idx)
while k > w + bits (table_level) loop
w := w + bits (table_level); -- Length of tables to this position
table_level := table_level + 1;
z := g - w; -- Compute min size table <= m bits
if z > m then
z := m;
end if;
j := k - w;
f := Integer (Shift_Left (Unsigned_32'(1), j)); -- f := 2 ** j;
if f > am1 + 2 then -- Try a k - w bit table
f := f - (am1 + 2);
c_idx := k;
loop -- Try smaller tables up to z bits
j := j + 1;
exit when j >= z;
f := f * 2;
c_idx := c_idx + 1;
exit when f - count (c_idx) <= 0;
f := f - count (c_idx);
end loop;
end if;
if w + j > el and then w < el then
j := el - w; -- Make EOB code end at table
end if;
if w = 0 then
j := m; -- Fix : main table always m bits!
end if;
z := Integer (Shift_Left (Unsigned_32'(1), j)); -- z := 2 ** j;
bits (table_level) := j;
-- Allocate and link new table
begin
current_table_ptr := new HufT_table (0 .. z);
new_node_ptr := new Table_list'(current_table_ptr, null);
exception
when Storage_Error =>
raise huft_out_of_memory;
end;
if current_node_ptr = null then -- first table
tl := new_node_ptr;
else
current_node_ptr.all.next := new_node_ptr; -- not my first .. .
end if;
current_node_ptr := new_node_ptr; -- always non - Null from there
u (table_level) := current_table_ptr;
-- Connect to last table, if there is one
if table_level > 0 then
code_stack (table_level) := i;
new_entry.bits := bits (table_level - 1);
new_entry.extra_bits := 16 + j;
new_entry.next_table := current_table_ptr;
j := Integer (
Shift_Right (Unsigned_32 (i) and
(Shift_Left (Unsigned_32'(1), w) - 1),
w - bits (table_level - 1))
);
-- Test against bad input!
if j > u (table_level - 1)'Last then
raise huft_error;
end if;
u (table_level - 1).all (j) := new_entry;
end if;
end loop;
-- Set up table entry in new_entry
new_entry.bits := k - w;
new_entry.next_table := null; -- Unused
if v_idx >= b'Length then
new_entry.extra_bits := invalid;
else
el_v := v (v_idx);
el_v_m_s := el_v - s;
if el_v_m_s < 0 then -- Simple code, raw value
if el_v < 256 then
new_entry.extra_bits := 16;
else
new_entry.extra_bits := 15;
end if;
new_entry.n := el_v;
else -- Non - simple - > lookup in lists
if no_copy_length_array then
raise huft_error;
end if;
new_entry.extra_bits := e (el_v_m_s);
new_entry.n := d (el_v_m_s);
end if;
v_idx := v_idx + 1;
end if;
-- fill code - like entries with new_entry
f := Integer (Shift_Left (Unsigned_32'(1), k - w));
-- i.e. f := 2 ** (k - w);
j := Integer (Shift_Right (Unsigned_32 (i), w));
while j < z loop
current_table_ptr.all (j) := new_entry;
j := j + f;
end loop;
-- backwards increment the k - bit code i
j := Integer (Shift_Left (Unsigned_32'(1), k - 1));
-- i.e. : j := 2 ** (k - 1)
while (Unsigned_32 (i) and Unsigned_32 (j)) /= 0 loop
i := Integer (Unsigned_32 (i) xor Unsigned_32 (j));
j := j / 2;
end loop;
i := Integer (Unsigned_32 (i) xor Unsigned_32 (j));
-- backup over finished tables
while
Integer (Unsigned_32 (i) and (Shift_Left (1, w) - 1)) /=
code_stack (table_level)
loop
table_level := table_level - 1;
w := w - bits (table_level); -- Size of previous table!
end loop;
end loop; -- am1
end loop; -- k
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.Put_Line ("finished]");
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
huft_incomplete := y /= 0 and then g /= 1;
exception
when others =>
HufT_free (tl);
raise;
end HufT_build;
end UnZip.Decompress.Huffman;
| true | with Interfaces;
with Ada.Text_IO;
with Ada.Unchecked_Deallocation;
package body UnZip.Decompress.Huffman is
-- Note from Pascal source:
-- C code by info - zip group, translated to pascal by PI:NAME:<NAME>END_PI
-- based on unz51g.zip
-- Free huffman tables starting with table where t points to
procedure HufT_free (tl : in out p_Table_list) is
procedure Dispose is new
Ada.Unchecked_Deallocation (HufT_table, p_HufT_table);
procedure Dispose is new
Ada.Unchecked_Deallocation (Table_list, p_Table_list);
current : p_Table_list;
tcount : Natural; -- just a stat. Idea : replace table_list with an array
begin
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.Put ("[HufT_Free .. . ");
tcount := 0;
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
while tl /= null loop
Dispose (tl.all.table); -- destroy the Huffman table
current := tl;
tl := tl.all.next;
Dispose (current); -- destroy the current node
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
tcount := tcount + 1;
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
end loop;
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.Put_Line (Integer'Image (tcount) & " tables]");
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
end HufT_free;
-- Build huffman table from code lengths given by array b
procedure HufT_build (b : Length_array;
s : Integer;
d, e : Length_array;
tl : out p_Table_list;
m : in out Integer;
huft_incomplete : out Boolean)
is
use Interfaces;
b_max : constant := 16;
b_maxp1 : constant := b_max + 1;
-- bit length count table
count : array (0 .. b_maxp1) of Integer := (others => 0);
f : Integer; -- i repeats in table every f entries
g : Integer; -- max. code length
i, -- counter, current code
j : Integer; -- counter
kcc : Integer; -- number of bits in current code
c_idx, v_idx : Natural; -- array indices
current_table_ptr : p_HufT_table := null;
current_node_ptr : p_Table_list := null; -- curr. node for the curr. table
new_node_ptr : p_Table_list; -- new node for the new table
new_entry : HufT; -- table entry for structure assignment
u : array (0 .. b_max) of p_HufT_table; -- table stack
n_max : constant := 288;
-- values in order of bit length
v : array (0 .. n_max) of Integer := (others => 0);
el_v, el_v_m_s : Integer;
w : Natural := 0; -- bits before this table
offset, code_stack : array (0 .. b_maxp1) of Integer;
table_level : Integer := -1;
bits : array (Integer'(-1) .. b_maxp1) of Integer;
-- ^bits (table_level) = # bits in table of level table_level
y : Integer; -- number of dummy codes added
z : Natural := 0; -- number of entries in current table
el : Integer; -- length of eob code=code 256
no_copy_length_array : constant Boolean := d'Length = 0 or else e'Length = 0;
begin
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.Put ("[HufT_Build .. .");
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
tl := null;
if b'Length > 256 then -- set length of EOB code, if any
el := b (256);
else
el := b_max;
end if;
-- Generate counts for each bit length
for k in b'Range loop
if b (k) > b_max then
-- m := 0; -- GNAT 2005 doesn't like it (warning).
raise huft_error;
end if;
count (b (k)) := count (b (k)) + 1;
end loop;
if count (0) = b'Length then
m := 0;
huft_incomplete := False; -- spotted by PI:NAME:<NAME>END_PI, 19 - Aug - 2004
return; -- complete
end if;
-- Find minimum and maximum length, bound m by those
j := 1;
while j <= b_max and then count (j) = 0 loop
j := j + 1;
end loop;
kcc := j;
if m < j then
m := j;
end if;
i := b_max;
while i > 0 and then count (i) = 0 loop
i := i - 1;
end loop;
g := i;
if m > i then
m := i;
end if;
-- Adjust last length count to fill out codes, if needed
y := Integer (Shift_Left (Unsigned_32'(1), j)); -- y := 2 ** j;
while j < i loop
y := y - count (j);
if y < 0 then
raise huft_error;
end if;
y := y * 2;
j := j + 1;
end loop;
y := y - count (i);
if y < 0 then
raise huft_error;
end if;
count (i) := count (i) + y;
-- Generate starting offsets into the value table for each length
offset (1) := 0;
j := 0;
for idx in 2 .. i loop
j := j + count (idx - 1);
offset (idx) := j;
end loop;
-- Make table of values in order of bit length
for idx in b'Range loop
j := b (idx);
if j /= 0 then
v (offset (j)) := idx - b'First;
offset (j) := offset (j) + 1;
end if;
end loop;
-- Generate huffman codes and for each, make the table entries
code_stack (0) := 0;
i := 0;
v_idx := v'First;
bits (-1) := 0;
-- go through the bit lengths (kcc already is bits in shortest code)
for k in kcc .. g loop
for am1 in reverse 0 .. count (k) - 1 loop -- a counts codes of length k
-- here i is the huffman code of length k bits for value v (v_idx)
while k > w + bits (table_level) loop
w := w + bits (table_level); -- Length of tables to this position
table_level := table_level + 1;
z := g - w; -- Compute min size table <= m bits
if z > m then
z := m;
end if;
j := k - w;
f := Integer (Shift_Left (Unsigned_32'(1), j)); -- f := 2 ** j;
if f > am1 + 2 then -- Try a k - w bit table
f := f - (am1 + 2);
c_idx := k;
loop -- Try smaller tables up to z bits
j := j + 1;
exit when j >= z;
f := f * 2;
c_idx := c_idx + 1;
exit when f - count (c_idx) <= 0;
f := f - count (c_idx);
end loop;
end if;
if w + j > el and then w < el then
j := el - w; -- Make EOB code end at table
end if;
if w = 0 then
j := m; -- Fix : main table always m bits!
end if;
z := Integer (Shift_Left (Unsigned_32'(1), j)); -- z := 2 ** j;
bits (table_level) := j;
-- Allocate and link new table
begin
current_table_ptr := new HufT_table (0 .. z);
new_node_ptr := new Table_list'(current_table_ptr, null);
exception
when Storage_Error =>
raise huft_out_of_memory;
end;
if current_node_ptr = null then -- first table
tl := new_node_ptr;
else
current_node_ptr.all.next := new_node_ptr; -- not my first .. .
end if;
current_node_ptr := new_node_ptr; -- always non - Null from there
u (table_level) := current_table_ptr;
-- Connect to last table, if there is one
if table_level > 0 then
code_stack (table_level) := i;
new_entry.bits := bits (table_level - 1);
new_entry.extra_bits := 16 + j;
new_entry.next_table := current_table_ptr;
j := Integer (
Shift_Right (Unsigned_32 (i) and
(Shift_Left (Unsigned_32'(1), w) - 1),
w - bits (table_level - 1))
);
-- Test against bad input!
if j > u (table_level - 1)'Last then
raise huft_error;
end if;
u (table_level - 1).all (j) := new_entry;
end if;
end loop;
-- Set up table entry in new_entry
new_entry.bits := k - w;
new_entry.next_table := null; -- Unused
if v_idx >= b'Length then
new_entry.extra_bits := invalid;
else
el_v := v (v_idx);
el_v_m_s := el_v - s;
if el_v_m_s < 0 then -- Simple code, raw value
if el_v < 256 then
new_entry.extra_bits := 16;
else
new_entry.extra_bits := 15;
end if;
new_entry.n := el_v;
else -- Non - simple - > lookup in lists
if no_copy_length_array then
raise huft_error;
end if;
new_entry.extra_bits := e (el_v_m_s);
new_entry.n := d (el_v_m_s);
end if;
v_idx := v_idx + 1;
end if;
-- fill code - like entries with new_entry
f := Integer (Shift_Left (Unsigned_32'(1), k - w));
-- i.e. f := 2 ** (k - w);
j := Integer (Shift_Right (Unsigned_32 (i), w));
while j < z loop
current_table_ptr.all (j) := new_entry;
j := j + f;
end loop;
-- backwards increment the k - bit code i
j := Integer (Shift_Left (Unsigned_32'(1), k - 1));
-- i.e. : j := 2 ** (k - 1)
while (Unsigned_32 (i) and Unsigned_32 (j)) /= 0 loop
i := Integer (Unsigned_32 (i) xor Unsigned_32 (j));
j := j / 2;
end loop;
i := Integer (Unsigned_32 (i) xor Unsigned_32 (j));
-- backup over finished tables
while
Integer (Unsigned_32 (i) and (Shift_Left (1, w) - 1)) /=
code_stack (table_level)
loop
table_level := table_level - 1;
w := w - bits (table_level); -- Size of previous table!
end loop;
end loop; -- am1
end loop; -- k
if full_trace then
pragma Warnings (Off, "this code can never be executed and has been deleted");
Ada.Text_IO.Put_Line ("finished]");
pragma Warnings (On, "this code can never be executed and has been deleted");
end if;
huft_incomplete := y /= 0 and then g /= 1;
exception
when others =>
HufT_free (tl);
raise;
end HufT_build;
end UnZip.Decompress.Huffman;
|
[
{
"context": "or dynamo\n-- Copyright (C) 2011, 2017, 2018, 2019 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@g",
"end": 186,
"score": 0.9998795390129089,
"start": 171,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "1, 2017, 2018, 2019 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under",
"end": 217,
"score": 0.9998874664306641,
"start": 202,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "9 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under the Apache License, Versio",
"end": 244,
"score": 0.9999314546585083,
"start": 219,
"tag": "EMAIL",
"value": "Stephane.Carrez@gmail.com"
}
] | src/gen-commands-page.ads | My-Colaborations/dynamo | 15 | -----------------------------------------------------------------------
-- gen-commands-page -- Page creation command for dynamo
-- Copyright (C) 2011, 2017, 2018, 2019 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.
-----------------------------------------------------------------------
package Gen.Commands.Page is
-- ------------------------------
-- Page Creation Command
-- ------------------------------
-- This command adds a XHTML page to the web application.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Name : in String;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Page;
| 22099 | -----------------------------------------------------------------------
-- gen-commands-page -- Page creation command for dynamo
-- Copyright (C) 2011, 2017, 2018, 2019 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package Gen.Commands.Page is
-- ------------------------------
-- Page Creation Command
-- ------------------------------
-- This command adds a XHTML page to the web application.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Name : in String;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Page;
| true | -----------------------------------------------------------------------
-- gen-commands-page -- Page creation command for dynamo
-- Copyright (C) 2011, 2017, 2018, 2019 PI:NAME:<NAME>END_PI
-- Written by PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package Gen.Commands.Page is
-- ------------------------------
-- Page Creation Command
-- ------------------------------
-- This command adds a XHTML page to the web application.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Name : in String;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Page;
|
[
{
"context": " --\n-- Copyright © 2012-2015, Vadim Godunko <vgodunko@gmail.com> --\n-- All rig",
"end": 829,
"score": 0.9998899102210999,
"start": 816,
"tag": "NAME",
"value": "Vadim Godunko"
},
{
"context": " --\n-- Copyright © 2012-2015, Vadim Godunko <vgodunko@gmail.com> --\n-- All rights reserved. ",
"end": 849,
"score": 0.999931275844574,
"start": 831,
"tag": "EMAIL",
"value": "vgodunko@gmail.com"
}
] | source/league/ucd/matreshka-internals-unicode-ucd-core_0020.ads | svn2github/matreshka | 24 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_0020 is
pragma Preelaborate;
Group_0020 : aliased constant Core_Second_Stage
:= (16#00# .. 16#06# => -- 2000 .. 2006
(Space_Separator, Neutral,
Other, Other, Sp, Break_After,
(White_Space
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#07# => -- 2007
(Space_Separator, Neutral,
Other, Other, Sp, Glue,
(White_Space
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#08# .. 16#0A# => -- 2008 .. 200A
(Space_Separator, Neutral,
Other, Other, Sp, Break_After,
(White_Space
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#0B# => -- 200B
(Format, Neutral,
Control, Other, Format, ZW_Space,
(Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#0C# .. 16#0D# => -- 200C .. 200D
(Format, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Join_Control
| Other_Grapheme_Extend
| Case_Ignorable
| Default_Ignorable_Code_Point
| Grapheme_Extend
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#0E# .. 16#0F# => -- 200E .. 200F
(Format, Neutral,
Control, Format, Format, Combining_Mark,
(Bidi_Control
| Pattern_White_Space
| Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#10# => -- 2010
(Dash_Punctuation, Ambiguous,
Other, Other, Other, Break_After,
(Dash
| Hyphen
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#11# => -- 2011
(Dash_Punctuation, Neutral,
Other, Other, Other, Glue,
(Dash
| Hyphen
| Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#12# => -- 2012
(Dash_Punctuation, Neutral,
Other, Other, Other, Break_After,
(Dash
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#13# => -- 2013
(Dash_Punctuation, Ambiguous,
Other, Other, S_Continue, Break_After,
(Dash
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#14# => -- 2014
(Dash_Punctuation, Ambiguous,
Other, Other, S_Continue, Break_Both,
(Dash
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#15# => -- 2015
(Dash_Punctuation, Ambiguous,
Other, Other, Other, Ambiguous,
(Dash
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#16# => -- 2016
(Other_Punctuation, Ambiguous,
Other, Other, Other, Ambiguous,
(Other_Math
| Pattern_Syntax
| Grapheme_Base
| Math => True,
others => False)),
16#17# => -- 2017
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#18# => -- 2018
(Initial_Punctuation, Ambiguous,
Other, Mid_Num_Let, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Case_Ignorable
| Grapheme_Base => True,
others => False)),
16#19# => -- 2019
(Final_Punctuation, Ambiguous,
Other, Mid_Num_Let, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Case_Ignorable
| Grapheme_Base => True,
others => False)),
16#1A# => -- 201A
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#1B# => -- 201B
(Initial_Punctuation, Neutral,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#1C# => -- 201C
(Initial_Punctuation, Ambiguous,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#1D# => -- 201D
(Final_Punctuation, Ambiguous,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#1E# => -- 201E
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#1F# => -- 201F
(Initial_Punctuation, Neutral,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#20# .. 16#21# => -- 2020 .. 2021
(Other_Punctuation, Ambiguous,
Other, Other, Other, Ambiguous,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#22# => -- 2022
(Other_Punctuation, Ambiguous,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#23# => -- 2023
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#24# => -- 2024
(Other_Punctuation, Ambiguous,
Other, Mid_Num_Let, A_Term, Inseparable,
(Pattern_Syntax
| Case_Ignorable
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#25# .. 16#26# => -- 2025 .. 2026
(Other_Punctuation, Ambiguous,
Other, Other, Other, Inseparable,
(Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#27# => -- 2027
(Other_Punctuation, Ambiguous,
Other, Mid_Letter, Other, Break_After,
(Pattern_Syntax
| Case_Ignorable
| Grapheme_Base => True,
others => False)),
16#28# => -- 2028
(Line_Separator, Neutral,
Control, Newline, Sep, Mandatory_Break,
(Pattern_White_Space
| White_Space => True,
others => False)),
16#29# => -- 2029
(Paragraph_Separator, Neutral,
Control, Newline, Sep, Mandatory_Break,
(Pattern_White_Space
| White_Space => True,
others => False)),
16#2A# .. 16#2E# => -- 202A .. 202E
(Format, Neutral,
Control, Format, Format, Combining_Mark,
(Bidi_Control
| Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#2F# => -- 202F
(Space_Separator, Neutral,
Other, Other, Sp, Glue,
(White_Space
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#30# => -- 2030
(Other_Punctuation, Ambiguous,
Other, Other, Other, Postfix_Numeric,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#31# => -- 2031
(Other_Punctuation, Neutral,
Other, Other, Other, Postfix_Numeric,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#32# => -- 2032
(Other_Punctuation, Ambiguous,
Other, Other, Other, Postfix_Numeric,
(Other_Math
| Pattern_Syntax
| Grapheme_Base
| Math => True,
others => False)),
16#33# => -- 2033
(Other_Punctuation, Ambiguous,
Other, Other, Other, Postfix_Numeric,
(Other_Math
| Pattern_Syntax
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#34# => -- 2034
(Other_Punctuation, Neutral,
Other, Other, Other, Postfix_Numeric,
(Other_Math
| Pattern_Syntax
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#35# => -- 2035
(Other_Punctuation, Ambiguous,
Other, Other, Other, Postfix_Numeric,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#36# .. 16#37# => -- 2036 .. 2037
(Other_Punctuation, Neutral,
Other, Other, Other, Postfix_Numeric,
(Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#38# => -- 2038
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#39# => -- 2039
(Initial_Punctuation, Neutral,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#3A# => -- 203A
(Final_Punctuation, Neutral,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#3B# => -- 203B
(Other_Punctuation, Ambiguous,
Other, Other, Other, Ambiguous,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#3C# => -- 203C
(Other_Punctuation, Neutral,
Other, Other, S_Term, Nonstarter,
(Pattern_Syntax
| STerm
| Terminal_Punctuation
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#3D# => -- 203D
(Other_Punctuation, Neutral,
Other, Other, S_Term, Nonstarter,
(Pattern_Syntax
| STerm
| Terminal_Punctuation
| Grapheme_Base => True,
others => False)),
16#3E# => -- 203E
(Other_Punctuation, Ambiguous,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#3F# => -- 203F
(Connector_Punctuation, Neutral,
Other, Extend_Num_Let, Other, Alphabetic,
(Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#40# => -- 2040
(Connector_Punctuation, Neutral,
Other, Extend_Num_Let, Other, Alphabetic,
(Other_Math
| Grapheme_Base
| ID_Continue
| Math
| XID_Continue => True,
others => False)),
16#41# .. 16#43# => -- 2041 .. 2043
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#44# => -- 2044
(Math_Symbol, Neutral,
Other, Mid_Num, Other, Infix_Numeric,
(Pattern_Syntax
| Grapheme_Base
| Math => True,
others => False)),
16#45# => -- 2045
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#46# => -- 2046
(Close_Punctuation, Neutral,
Other, Other, Close, Close_Punctuation,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#47# .. 16#49# => -- 2047 .. 2049
(Other_Punctuation, Neutral,
Other, Other, S_Term, Nonstarter,
(Pattern_Syntax
| STerm
| Terminal_Punctuation
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#4A# .. 16#51# => -- 204A .. 2051
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#52# => -- 2052
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base
| Math => True,
others => False)),
16#53# => -- 2053
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Dash
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#54# => -- 2054
(Connector_Punctuation, Neutral,
Other, Extend_Num_Let, Other, Alphabetic,
(Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#55# => -- 2055
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#56# => -- 2056
(Other_Punctuation, Neutral,
Other, Other, Other, Break_After,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#57# => -- 2057
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#58# .. 16#5B# => -- 2058 .. 205B
(Other_Punctuation, Neutral,
Other, Other, Other, Break_After,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#5C# => -- 205C
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#5D# .. 16#5E# => -- 205D .. 205E
(Other_Punctuation, Neutral,
Other, Other, Other, Break_After,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#5F# => -- 205F
(Space_Separator, Neutral,
Other, Other, Sp, Break_After,
(White_Space
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#60# => -- 2060
(Format, Neutral,
Control, Format, Format, Word_Joiner,
(Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#61# .. 16#64# => -- 2061 .. 2064
(Format, Neutral,
Control, Format, Format, Alphabetic,
(Other_Math
| Case_Ignorable
| Default_Ignorable_Code_Point
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#65# => -- 2065
(Unassigned, Neutral,
Control, Other, Other, Unknown,
(Other_Default_Ignorable_Code_Point
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#66# .. 16#69# => -- 2066 .. 2069
(Format, Neutral,
Control, Format, Format, Combining_Mark,
(Bidi_Control
| Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#6A# .. 16#6F# => -- 206A .. 206F
(Format, Neutral,
Control, Format, Format, Combining_Mark,
(Deprecated
| Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#70# => -- 2070
(Other_Number, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#71# => -- 2071
(Modifier_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Lowercase
| Soft_Dotted
| Alphabetic
| Cased
| Case_Ignorable
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#72# .. 16#73# => -- 2072 .. 2073
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#74# => -- 2074
(Other_Number, Ambiguous,
Other, Other, Other, Ambiguous,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#75# .. 16#79# => -- 2075 .. 2079
(Other_Number, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7A# => -- 207A
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7B# => -- 207B
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Dash
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7C# => -- 207C
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7D# => -- 207D
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Other_Math
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7E# => -- 207E
(Close_Punctuation, Neutral,
Other, Other, Close, Close_Punctuation,
(Other_Math
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7F# => -- 207F
(Modifier_Letter, Ambiguous,
Other, A_Letter, Lower, Ambiguous,
(Other_Lowercase
| Alphabetic
| Cased
| Case_Ignorable
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#80# => -- 2080
(Other_Number, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#81# .. 16#84# => -- 2081 .. 2084
(Other_Number, Ambiguous,
Other, Other, Other, Ambiguous,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#85# .. 16#89# => -- 2085 .. 2089
(Other_Number, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8A# => -- 208A
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8B# => -- 208B
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Dash
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8C# => -- 208C
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8D# => -- 208D
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Other_Math
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8E# => -- 208E
(Close_Punctuation, Neutral,
Other, Other, Close, Close_Punctuation,
(Other_Math
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8F# => -- 208F
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#90# .. 16#9C# => -- 2090 .. 209C
(Modifier_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Lowercase
| Alphabetic
| Cased
| Case_Ignorable
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#9D# .. 16#9F# => -- 209D .. 209F
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#A7# => -- 20A7
(Currency_Symbol, Neutral,
Other, Other, Other, Postfix_Numeric,
(Grapheme_Base => True,
others => False)),
16#A8# => -- 20A8
(Currency_Symbol, Neutral,
Other, Other, Other, Prefix_Numeric,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#A9# => -- 20A9
(Currency_Symbol, Halfwidth,
Other, Other, Other, Prefix_Numeric,
(Grapheme_Base => True,
others => False)),
16#AC# => -- 20AC
(Currency_Symbol, Ambiguous,
Other, Other, Other, Prefix_Numeric,
(Grapheme_Base => True,
others => False)),
16#B6# => -- 20B6
(Currency_Symbol, Neutral,
Other, Other, Other, Postfix_Numeric,
(Grapheme_Base => True,
others => False)),
16#BB# => -- 20BB
(Currency_Symbol, Neutral,
Other, Other, Other, Postfix_Numeric,
(Grapheme_Base => True,
others => False)),
16#BE# .. 16#CF# => -- 20BE .. 20CF
(Unassigned, Neutral,
Other, Other, Other, Prefix_Numeric,
(others => False)),
16#D0# .. 16#DC# => -- 20D0 .. 20DC
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Math
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| Math
| XID_Continue => True,
others => False)),
16#DD# .. 16#E0# => -- 20DD .. 20E0
(Enclosing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Case_Ignorable
| Grapheme_Extend => True,
others => False)),
16#E1# => -- 20E1
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Math
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| Math
| XID_Continue => True,
others => False)),
16#E2# .. 16#E4# => -- 20E2 .. 20E4
(Enclosing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Case_Ignorable
| Grapheme_Extend => True,
others => False)),
16#E5# .. 16#E6# => -- 20E5 .. 20E6
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Math
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| Math
| XID_Continue => True,
others => False)),
16#E7# .. 16#EA# => -- 20E7 .. 20EA
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#EB# .. 16#EF# => -- 20EB .. 20EF
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Math
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| Math
| XID_Continue => True,
others => False)),
16#F0# => -- 20F0
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#F1# .. 16#FF# => -- 20F1 .. 20FF
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
others =>
(Currency_Symbol, Neutral,
Other, Other, Other, Prefix_Numeric,
(Grapheme_Base => True,
others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_0020;
| 18374 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_0020 is
pragma Preelaborate;
Group_0020 : aliased constant Core_Second_Stage
:= (16#00# .. 16#06# => -- 2000 .. 2006
(Space_Separator, Neutral,
Other, Other, Sp, Break_After,
(White_Space
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#07# => -- 2007
(Space_Separator, Neutral,
Other, Other, Sp, Glue,
(White_Space
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#08# .. 16#0A# => -- 2008 .. 200A
(Space_Separator, Neutral,
Other, Other, Sp, Break_After,
(White_Space
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#0B# => -- 200B
(Format, Neutral,
Control, Other, Format, ZW_Space,
(Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#0C# .. 16#0D# => -- 200C .. 200D
(Format, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Join_Control
| Other_Grapheme_Extend
| Case_Ignorable
| Default_Ignorable_Code_Point
| Grapheme_Extend
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#0E# .. 16#0F# => -- 200E .. 200F
(Format, Neutral,
Control, Format, Format, Combining_Mark,
(Bidi_Control
| Pattern_White_Space
| Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#10# => -- 2010
(Dash_Punctuation, Ambiguous,
Other, Other, Other, Break_After,
(Dash
| Hyphen
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#11# => -- 2011
(Dash_Punctuation, Neutral,
Other, Other, Other, Glue,
(Dash
| Hyphen
| Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#12# => -- 2012
(Dash_Punctuation, Neutral,
Other, Other, Other, Break_After,
(Dash
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#13# => -- 2013
(Dash_Punctuation, Ambiguous,
Other, Other, S_Continue, Break_After,
(Dash
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#14# => -- 2014
(Dash_Punctuation, Ambiguous,
Other, Other, S_Continue, Break_Both,
(Dash
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#15# => -- 2015
(Dash_Punctuation, Ambiguous,
Other, Other, Other, Ambiguous,
(Dash
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#16# => -- 2016
(Other_Punctuation, Ambiguous,
Other, Other, Other, Ambiguous,
(Other_Math
| Pattern_Syntax
| Grapheme_Base
| Math => True,
others => False)),
16#17# => -- 2017
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#18# => -- 2018
(Initial_Punctuation, Ambiguous,
Other, Mid_Num_Let, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Case_Ignorable
| Grapheme_Base => True,
others => False)),
16#19# => -- 2019
(Final_Punctuation, Ambiguous,
Other, Mid_Num_Let, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Case_Ignorable
| Grapheme_Base => True,
others => False)),
16#1A# => -- 201A
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#1B# => -- 201B
(Initial_Punctuation, Neutral,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#1C# => -- 201C
(Initial_Punctuation, Ambiguous,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#1D# => -- 201D
(Final_Punctuation, Ambiguous,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#1E# => -- 201E
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#1F# => -- 201F
(Initial_Punctuation, Neutral,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#20# .. 16#21# => -- 2020 .. 2021
(Other_Punctuation, Ambiguous,
Other, Other, Other, Ambiguous,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#22# => -- 2022
(Other_Punctuation, Ambiguous,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#23# => -- 2023
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#24# => -- 2024
(Other_Punctuation, Ambiguous,
Other, Mid_Num_Let, A_Term, Inseparable,
(Pattern_Syntax
| Case_Ignorable
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#25# .. 16#26# => -- 2025 .. 2026
(Other_Punctuation, Ambiguous,
Other, Other, Other, Inseparable,
(Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#27# => -- 2027
(Other_Punctuation, Ambiguous,
Other, Mid_Letter, Other, Break_After,
(Pattern_Syntax
| Case_Ignorable
| Grapheme_Base => True,
others => False)),
16#28# => -- 2028
(Line_Separator, Neutral,
Control, Newline, Sep, Mandatory_Break,
(Pattern_White_Space
| White_Space => True,
others => False)),
16#29# => -- 2029
(Paragraph_Separator, Neutral,
Control, Newline, Sep, Mandatory_Break,
(Pattern_White_Space
| White_Space => True,
others => False)),
16#2A# .. 16#2E# => -- 202A .. 202E
(Format, Neutral,
Control, Format, Format, Combining_Mark,
(Bidi_Control
| Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#2F# => -- 202F
(Space_Separator, Neutral,
Other, Other, Sp, Glue,
(White_Space
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#30# => -- 2030
(Other_Punctuation, Ambiguous,
Other, Other, Other, Postfix_Numeric,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#31# => -- 2031
(Other_Punctuation, Neutral,
Other, Other, Other, Postfix_Numeric,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#32# => -- 2032
(Other_Punctuation, Ambiguous,
Other, Other, Other, Postfix_Numeric,
(Other_Math
| Pattern_Syntax
| Grapheme_Base
| Math => True,
others => False)),
16#33# => -- 2033
(Other_Punctuation, Ambiguous,
Other, Other, Other, Postfix_Numeric,
(Other_Math
| Pattern_Syntax
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#34# => -- 2034
(Other_Punctuation, Neutral,
Other, Other, Other, Postfix_Numeric,
(Other_Math
| Pattern_Syntax
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#35# => -- 2035
(Other_Punctuation, Ambiguous,
Other, Other, Other, Postfix_Numeric,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#36# .. 16#37# => -- 2036 .. 2037
(Other_Punctuation, Neutral,
Other, Other, Other, Postfix_Numeric,
(Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#38# => -- 2038
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#39# => -- 2039
(Initial_Punctuation, Neutral,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#3A# => -- 203A
(Final_Punctuation, Neutral,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#3B# => -- 203B
(Other_Punctuation, Ambiguous,
Other, Other, Other, Ambiguous,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#3C# => -- 203C
(Other_Punctuation, Neutral,
Other, Other, S_Term, Nonstarter,
(Pattern_Syntax
| STerm
| Terminal_Punctuation
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#3D# => -- 203D
(Other_Punctuation, Neutral,
Other, Other, S_Term, Nonstarter,
(Pattern_Syntax
| STerm
| Terminal_Punctuation
| Grapheme_Base => True,
others => False)),
16#3E# => -- 203E
(Other_Punctuation, Ambiguous,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#3F# => -- 203F
(Connector_Punctuation, Neutral,
Other, Extend_Num_Let, Other, Alphabetic,
(Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#40# => -- 2040
(Connector_Punctuation, Neutral,
Other, Extend_Num_Let, Other, Alphabetic,
(Other_Math
| Grapheme_Base
| ID_Continue
| Math
| XID_Continue => True,
others => False)),
16#41# .. 16#43# => -- 2041 .. 2043
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#44# => -- 2044
(Math_Symbol, Neutral,
Other, Mid_Num, Other, Infix_Numeric,
(Pattern_Syntax
| Grapheme_Base
| Math => True,
others => False)),
16#45# => -- 2045
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#46# => -- 2046
(Close_Punctuation, Neutral,
Other, Other, Close, Close_Punctuation,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#47# .. 16#49# => -- 2047 .. 2049
(Other_Punctuation, Neutral,
Other, Other, S_Term, Nonstarter,
(Pattern_Syntax
| STerm
| Terminal_Punctuation
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#4A# .. 16#51# => -- 204A .. 2051
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#52# => -- 2052
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base
| Math => True,
others => False)),
16#53# => -- 2053
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Dash
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#54# => -- 2054
(Connector_Punctuation, Neutral,
Other, Extend_Num_Let, Other, Alphabetic,
(Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#55# => -- 2055
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#56# => -- 2056
(Other_Punctuation, Neutral,
Other, Other, Other, Break_After,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#57# => -- 2057
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#58# .. 16#5B# => -- 2058 .. 205B
(Other_Punctuation, Neutral,
Other, Other, Other, Break_After,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#5C# => -- 205C
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#5D# .. 16#5E# => -- 205D .. 205E
(Other_Punctuation, Neutral,
Other, Other, Other, Break_After,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#5F# => -- 205F
(Space_Separator, Neutral,
Other, Other, Sp, Break_After,
(White_Space
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#60# => -- 2060
(Format, Neutral,
Control, Format, Format, Word_Joiner,
(Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#61# .. 16#64# => -- 2061 .. 2064
(Format, Neutral,
Control, Format, Format, Alphabetic,
(Other_Math
| Case_Ignorable
| Default_Ignorable_Code_Point
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#65# => -- 2065
(Unassigned, Neutral,
Control, Other, Other, Unknown,
(Other_Default_Ignorable_Code_Point
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#66# .. 16#69# => -- 2066 .. 2069
(Format, Neutral,
Control, Format, Format, Combining_Mark,
(Bidi_Control
| Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#6A# .. 16#6F# => -- 206A .. 206F
(Format, Neutral,
Control, Format, Format, Combining_Mark,
(Deprecated
| Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#70# => -- 2070
(Other_Number, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#71# => -- 2071
(Modifier_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Lowercase
| Soft_Dotted
| Alphabetic
| Cased
| Case_Ignorable
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#72# .. 16#73# => -- 2072 .. 2073
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#74# => -- 2074
(Other_Number, Ambiguous,
Other, Other, Other, Ambiguous,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#75# .. 16#79# => -- 2075 .. 2079
(Other_Number, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7A# => -- 207A
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7B# => -- 207B
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Dash
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7C# => -- 207C
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7D# => -- 207D
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Other_Math
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7E# => -- 207E
(Close_Punctuation, Neutral,
Other, Other, Close, Close_Punctuation,
(Other_Math
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7F# => -- 207F
(Modifier_Letter, Ambiguous,
Other, A_Letter, Lower, Ambiguous,
(Other_Lowercase
| Alphabetic
| Cased
| Case_Ignorable
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#80# => -- 2080
(Other_Number, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#81# .. 16#84# => -- 2081 .. 2084
(Other_Number, Ambiguous,
Other, Other, Other, Ambiguous,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#85# .. 16#89# => -- 2085 .. 2089
(Other_Number, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8A# => -- 208A
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8B# => -- 208B
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Dash
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8C# => -- 208C
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8D# => -- 208D
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Other_Math
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8E# => -- 208E
(Close_Punctuation, Neutral,
Other, Other, Close, Close_Punctuation,
(Other_Math
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8F# => -- 208F
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#90# .. 16#9C# => -- 2090 .. 209C
(Modifier_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Lowercase
| Alphabetic
| Cased
| Case_Ignorable
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#9D# .. 16#9F# => -- 209D .. 209F
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#A7# => -- 20A7
(Currency_Symbol, Neutral,
Other, Other, Other, Postfix_Numeric,
(Grapheme_Base => True,
others => False)),
16#A8# => -- 20A8
(Currency_Symbol, Neutral,
Other, Other, Other, Prefix_Numeric,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#A9# => -- 20A9
(Currency_Symbol, Halfwidth,
Other, Other, Other, Prefix_Numeric,
(Grapheme_Base => True,
others => False)),
16#AC# => -- 20AC
(Currency_Symbol, Ambiguous,
Other, Other, Other, Prefix_Numeric,
(Grapheme_Base => True,
others => False)),
16#B6# => -- 20B6
(Currency_Symbol, Neutral,
Other, Other, Other, Postfix_Numeric,
(Grapheme_Base => True,
others => False)),
16#BB# => -- 20BB
(Currency_Symbol, Neutral,
Other, Other, Other, Postfix_Numeric,
(Grapheme_Base => True,
others => False)),
16#BE# .. 16#CF# => -- 20BE .. 20CF
(Unassigned, Neutral,
Other, Other, Other, Prefix_Numeric,
(others => False)),
16#D0# .. 16#DC# => -- 20D0 .. 20DC
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Math
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| Math
| XID_Continue => True,
others => False)),
16#DD# .. 16#E0# => -- 20DD .. 20E0
(Enclosing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Case_Ignorable
| Grapheme_Extend => True,
others => False)),
16#E1# => -- 20E1
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Math
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| Math
| XID_Continue => True,
others => False)),
16#E2# .. 16#E4# => -- 20E2 .. 20E4
(Enclosing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Case_Ignorable
| Grapheme_Extend => True,
others => False)),
16#E5# .. 16#E6# => -- 20E5 .. 20E6
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Math
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| Math
| XID_Continue => True,
others => False)),
16#E7# .. 16#EA# => -- 20E7 .. 20EA
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#EB# .. 16#EF# => -- 20EB .. 20EF
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Math
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| Math
| XID_Continue => True,
others => False)),
16#F0# => -- 20F0
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#F1# .. 16#FF# => -- 20F1 .. 20FF
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
others =>
(Currency_Symbol, Neutral,
Other, Other, Other, Prefix_Numeric,
(Grapheme_Base => True,
others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_0020;
| true | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_0020 is
pragma Preelaborate;
Group_0020 : aliased constant Core_Second_Stage
:= (16#00# .. 16#06# => -- 2000 .. 2006
(Space_Separator, Neutral,
Other, Other, Sp, Break_After,
(White_Space
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#07# => -- 2007
(Space_Separator, Neutral,
Other, Other, Sp, Glue,
(White_Space
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#08# .. 16#0A# => -- 2008 .. 200A
(Space_Separator, Neutral,
Other, Other, Sp, Break_After,
(White_Space
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#0B# => -- 200B
(Format, Neutral,
Control, Other, Format, ZW_Space,
(Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#0C# .. 16#0D# => -- 200C .. 200D
(Format, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Join_Control
| Other_Grapheme_Extend
| Case_Ignorable
| Default_Ignorable_Code_Point
| Grapheme_Extend
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#0E# .. 16#0F# => -- 200E .. 200F
(Format, Neutral,
Control, Format, Format, Combining_Mark,
(Bidi_Control
| Pattern_White_Space
| Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#10# => -- 2010
(Dash_Punctuation, Ambiguous,
Other, Other, Other, Break_After,
(Dash
| Hyphen
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#11# => -- 2011
(Dash_Punctuation, Neutral,
Other, Other, Other, Glue,
(Dash
| Hyphen
| Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#12# => -- 2012
(Dash_Punctuation, Neutral,
Other, Other, Other, Break_After,
(Dash
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#13# => -- 2013
(Dash_Punctuation, Ambiguous,
Other, Other, S_Continue, Break_After,
(Dash
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#14# => -- 2014
(Dash_Punctuation, Ambiguous,
Other, Other, S_Continue, Break_Both,
(Dash
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#15# => -- 2015
(Dash_Punctuation, Ambiguous,
Other, Other, Other, Ambiguous,
(Dash
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#16# => -- 2016
(Other_Punctuation, Ambiguous,
Other, Other, Other, Ambiguous,
(Other_Math
| Pattern_Syntax
| Grapheme_Base
| Math => True,
others => False)),
16#17# => -- 2017
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#18# => -- 2018
(Initial_Punctuation, Ambiguous,
Other, Mid_Num_Let, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Case_Ignorable
| Grapheme_Base => True,
others => False)),
16#19# => -- 2019
(Final_Punctuation, Ambiguous,
Other, Mid_Num_Let, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Case_Ignorable
| Grapheme_Base => True,
others => False)),
16#1A# => -- 201A
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#1B# => -- 201B
(Initial_Punctuation, Neutral,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#1C# => -- 201C
(Initial_Punctuation, Ambiguous,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#1D# => -- 201D
(Final_Punctuation, Ambiguous,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#1E# => -- 201E
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#1F# => -- 201F
(Initial_Punctuation, Neutral,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#20# .. 16#21# => -- 2020 .. 2021
(Other_Punctuation, Ambiguous,
Other, Other, Other, Ambiguous,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#22# => -- 2022
(Other_Punctuation, Ambiguous,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#23# => -- 2023
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#24# => -- 2024
(Other_Punctuation, Ambiguous,
Other, Mid_Num_Let, A_Term, Inseparable,
(Pattern_Syntax
| Case_Ignorable
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#25# .. 16#26# => -- 2025 .. 2026
(Other_Punctuation, Ambiguous,
Other, Other, Other, Inseparable,
(Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#27# => -- 2027
(Other_Punctuation, Ambiguous,
Other, Mid_Letter, Other, Break_After,
(Pattern_Syntax
| Case_Ignorable
| Grapheme_Base => True,
others => False)),
16#28# => -- 2028
(Line_Separator, Neutral,
Control, Newline, Sep, Mandatory_Break,
(Pattern_White_Space
| White_Space => True,
others => False)),
16#29# => -- 2029
(Paragraph_Separator, Neutral,
Control, Newline, Sep, Mandatory_Break,
(Pattern_White_Space
| White_Space => True,
others => False)),
16#2A# .. 16#2E# => -- 202A .. 202E
(Format, Neutral,
Control, Format, Format, Combining_Mark,
(Bidi_Control
| Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#2F# => -- 202F
(Space_Separator, Neutral,
Other, Other, Sp, Glue,
(White_Space
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#30# => -- 2030
(Other_Punctuation, Ambiguous,
Other, Other, Other, Postfix_Numeric,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#31# => -- 2031
(Other_Punctuation, Neutral,
Other, Other, Other, Postfix_Numeric,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#32# => -- 2032
(Other_Punctuation, Ambiguous,
Other, Other, Other, Postfix_Numeric,
(Other_Math
| Pattern_Syntax
| Grapheme_Base
| Math => True,
others => False)),
16#33# => -- 2033
(Other_Punctuation, Ambiguous,
Other, Other, Other, Postfix_Numeric,
(Other_Math
| Pattern_Syntax
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#34# => -- 2034
(Other_Punctuation, Neutral,
Other, Other, Other, Postfix_Numeric,
(Other_Math
| Pattern_Syntax
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#35# => -- 2035
(Other_Punctuation, Ambiguous,
Other, Other, Other, Postfix_Numeric,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#36# .. 16#37# => -- 2036 .. 2037
(Other_Punctuation, Neutral,
Other, Other, Other, Postfix_Numeric,
(Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#38# => -- 2038
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#39# => -- 2039
(Initial_Punctuation, Neutral,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#3A# => -- 203A
(Final_Punctuation, Neutral,
Other, Other, Close, Quotation,
(Pattern_Syntax
| Quotation_Mark
| Grapheme_Base => True,
others => False)),
16#3B# => -- 203B
(Other_Punctuation, Ambiguous,
Other, Other, Other, Ambiguous,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#3C# => -- 203C
(Other_Punctuation, Neutral,
Other, Other, S_Term, Nonstarter,
(Pattern_Syntax
| STerm
| Terminal_Punctuation
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#3D# => -- 203D
(Other_Punctuation, Neutral,
Other, Other, S_Term, Nonstarter,
(Pattern_Syntax
| STerm
| Terminal_Punctuation
| Grapheme_Base => True,
others => False)),
16#3E# => -- 203E
(Other_Punctuation, Ambiguous,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#3F# => -- 203F
(Connector_Punctuation, Neutral,
Other, Extend_Num_Let, Other, Alphabetic,
(Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#40# => -- 2040
(Connector_Punctuation, Neutral,
Other, Extend_Num_Let, Other, Alphabetic,
(Other_Math
| Grapheme_Base
| ID_Continue
| Math
| XID_Continue => True,
others => False)),
16#41# .. 16#43# => -- 2041 .. 2043
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#44# => -- 2044
(Math_Symbol, Neutral,
Other, Mid_Num, Other, Infix_Numeric,
(Pattern_Syntax
| Grapheme_Base
| Math => True,
others => False)),
16#45# => -- 2045
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#46# => -- 2046
(Close_Punctuation, Neutral,
Other, Other, Close, Close_Punctuation,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#47# .. 16#49# => -- 2047 .. 2049
(Other_Punctuation, Neutral,
Other, Other, S_Term, Nonstarter,
(Pattern_Syntax
| STerm
| Terminal_Punctuation
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#4A# .. 16#51# => -- 204A .. 2051
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#52# => -- 2052
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base
| Math => True,
others => False)),
16#53# => -- 2053
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Dash
| Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#54# => -- 2054
(Connector_Punctuation, Neutral,
Other, Extend_Num_Let, Other, Alphabetic,
(Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#55# => -- 2055
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#56# => -- 2056
(Other_Punctuation, Neutral,
Other, Other, Other, Break_After,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#57# => -- 2057
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#58# .. 16#5B# => -- 2058 .. 205B
(Other_Punctuation, Neutral,
Other, Other, Other, Break_After,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#5C# => -- 205C
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#5D# .. 16#5E# => -- 205D .. 205E
(Other_Punctuation, Neutral,
Other, Other, Other, Break_After,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)),
16#5F# => -- 205F
(Space_Separator, Neutral,
Other, Other, Sp, Break_After,
(White_Space
| Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#60# => -- 2060
(Format, Neutral,
Control, Format, Format, Word_Joiner,
(Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#61# .. 16#64# => -- 2061 .. 2064
(Format, Neutral,
Control, Format, Format, Alphabetic,
(Other_Math
| Case_Ignorable
| Default_Ignorable_Code_Point
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#65# => -- 2065
(Unassigned, Neutral,
Control, Other, Other, Unknown,
(Other_Default_Ignorable_Code_Point
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#66# .. 16#69# => -- 2066 .. 2069
(Format, Neutral,
Control, Format, Format, Combining_Mark,
(Bidi_Control
| Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#6A# .. 16#6F# => -- 206A .. 206F
(Format, Neutral,
Control, Format, Format, Combining_Mark,
(Deprecated
| Case_Ignorable
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#70# => -- 2070
(Other_Number, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#71# => -- 2071
(Modifier_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Lowercase
| Soft_Dotted
| Alphabetic
| Cased
| Case_Ignorable
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#72# .. 16#73# => -- 2072 .. 2073
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#74# => -- 2074
(Other_Number, Ambiguous,
Other, Other, Other, Ambiguous,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#75# .. 16#79# => -- 2075 .. 2079
(Other_Number, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7A# => -- 207A
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7B# => -- 207B
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Dash
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7C# => -- 207C
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7D# => -- 207D
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Other_Math
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7E# => -- 207E
(Close_Punctuation, Neutral,
Other, Other, Close, Close_Punctuation,
(Other_Math
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7F# => -- 207F
(Modifier_Letter, Ambiguous,
Other, A_Letter, Lower, Ambiguous,
(Other_Lowercase
| Alphabetic
| Cased
| Case_Ignorable
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#80# => -- 2080
(Other_Number, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#81# .. 16#84# => -- 2081 .. 2084
(Other_Number, Ambiguous,
Other, Other, Other, Ambiguous,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#85# .. 16#89# => -- 2085 .. 2089
(Other_Number, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8A# => -- 208A
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8B# => -- 208B
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Dash
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8C# => -- 208C
(Math_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8D# => -- 208D
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Other_Math
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8E# => -- 208E
(Close_Punctuation, Neutral,
Other, Other, Close, Close_Punctuation,
(Other_Math
| Grapheme_Base
| Math
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#8F# => -- 208F
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#90# .. 16#9C# => -- 2090 .. 209C
(Modifier_Letter, Neutral,
Other, A_Letter, Lower, Alphabetic,
(Other_Lowercase
| Alphabetic
| Cased
| Case_Ignorable
| Grapheme_Base
| ID_Continue
| ID_Start
| Lowercase
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#9D# .. 16#9F# => -- 209D .. 209F
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#A7# => -- 20A7
(Currency_Symbol, Neutral,
Other, Other, Other, Postfix_Numeric,
(Grapheme_Base => True,
others => False)),
16#A8# => -- 20A8
(Currency_Symbol, Neutral,
Other, Other, Other, Prefix_Numeric,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#A9# => -- 20A9
(Currency_Symbol, Halfwidth,
Other, Other, Other, Prefix_Numeric,
(Grapheme_Base => True,
others => False)),
16#AC# => -- 20AC
(Currency_Symbol, Ambiguous,
Other, Other, Other, Prefix_Numeric,
(Grapheme_Base => True,
others => False)),
16#B6# => -- 20B6
(Currency_Symbol, Neutral,
Other, Other, Other, Postfix_Numeric,
(Grapheme_Base => True,
others => False)),
16#BB# => -- 20BB
(Currency_Symbol, Neutral,
Other, Other, Other, Postfix_Numeric,
(Grapheme_Base => True,
others => False)),
16#BE# .. 16#CF# => -- 20BE .. 20CF
(Unassigned, Neutral,
Other, Other, Other, Prefix_Numeric,
(others => False)),
16#D0# .. 16#DC# => -- 20D0 .. 20DC
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Math
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| Math
| XID_Continue => True,
others => False)),
16#DD# .. 16#E0# => -- 20DD .. 20E0
(Enclosing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Case_Ignorable
| Grapheme_Extend => True,
others => False)),
16#E1# => -- 20E1
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Math
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| Math
| XID_Continue => True,
others => False)),
16#E2# .. 16#E4# => -- 20E2 .. 20E4
(Enclosing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Case_Ignorable
| Grapheme_Extend => True,
others => False)),
16#E5# .. 16#E6# => -- 20E5 .. 20E6
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Math
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| Math
| XID_Continue => True,
others => False)),
16#E7# .. 16#EA# => -- 20E7 .. 20EA
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#EB# .. 16#EF# => -- 20EB .. 20EF
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Math
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| Math
| XID_Continue => True,
others => False)),
16#F0# => -- 20F0
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#F1# .. 16#FF# => -- 20F1 .. 20FF
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
others =>
(Currency_Symbol, Neutral,
Other, Other, Other, Prefix_Numeric,
(Grapheme_Base => True,
others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_0020;
|
[
{
"context": "phRPC package.\n--\n-- Revision 0\n-- \n-- 2018/09/24, Maya Posch\n\npackage NymphClient is\n\n--\n\nend NymphClient;\n\n\n\n",
"end": 100,
"score": 0.9998645782470703,
"start": 90,
"tag": "NAME",
"value": "Maya Posch"
}
] | ada/src/nymph_client.ads | Watch-Later/NymphRPC | 52 | -- nymph.ada - Package file for the NymphRPC package.
--
-- Revision 0
--
-- 2018/09/24, Maya Posch
package NymphClient is
--
end NymphClient;
| 29248 | -- nymph.ada - Package file for the NymphRPC package.
--
-- Revision 0
--
-- 2018/09/24, <NAME>
package NymphClient is
--
end NymphClient;
| true | -- nymph.ada - Package file for the NymphRPC package.
--
-- Revision 0
--
-- 2018/09/24, PI:NAME:<NAME>END_PI
package NymphClient is
--
end NymphClient;
|
[
{
"context": ":51 grosch rel $\n\n-- $Log: StringM.mi,v $\n\n-- Ich, Doktor Josef Grosch, Informatiker, Sept. 1994\n\nwith StringM, Strings,",
"end": 111,
"score": 0.9995085000991821,
"start": 92,
"tag": "NAME",
"value": "Doktor Josef Grosch"
}
] | reuse/ada/stringmd.adb | cocolab8/cocktail | 0 | -- $Id: StringM.mi,v 1.5 1993/08/18 15:06:51 grosch rel $
-- $Log: StringM.mi,v $
-- Ich, Doktor Josef Grosch, Informatiker, Sept. 1994
with StringM, Strings, Text_Io;
use StringM, Strings, Text_Io;
procedure StringMD is
procedure do_it is
s : tString;
r : tStringRef;
begin
Put ("enter strings, one per line, - terminates"); New_Line;
loop
ReadS (Standard_Input, s);
r := PutString (s);
WriteString (Standard_Output, r); New_Line;
if Length (r) = 0 or else Element (s, 1) = '-' then exit; end if;
end loop;
New_Line;
WriteStringMemory;
end do_it;
begin
do_it;
InitStringMemory;
do_it;
end StringMD;
| 3751 | -- $Id: StringM.mi,v 1.5 1993/08/18 15:06:51 grosch rel $
-- $Log: StringM.mi,v $
-- Ich, <NAME>, Informatiker, Sept. 1994
with StringM, Strings, Text_Io;
use StringM, Strings, Text_Io;
procedure StringMD is
procedure do_it is
s : tString;
r : tStringRef;
begin
Put ("enter strings, one per line, - terminates"); New_Line;
loop
ReadS (Standard_Input, s);
r := PutString (s);
WriteString (Standard_Output, r); New_Line;
if Length (r) = 0 or else Element (s, 1) = '-' then exit; end if;
end loop;
New_Line;
WriteStringMemory;
end do_it;
begin
do_it;
InitStringMemory;
do_it;
end StringMD;
| true | -- $Id: StringM.mi,v 1.5 1993/08/18 15:06:51 grosch rel $
-- $Log: StringM.mi,v $
-- Ich, PI:NAME:<NAME>END_PI, Informatiker, Sept. 1994
with StringM, Strings, Text_Io;
use StringM, Strings, Text_Io;
procedure StringMD is
procedure do_it is
s : tString;
r : tStringRef;
begin
Put ("enter strings, one per line, - terminates"); New_Line;
loop
ReadS (Standard_Input, s);
r := PutString (s);
WriteString (Standard_Output, r); New_Line;
if Length (r) = 0 or else Element (s, 1) = '-' then exit; end if;
end loop;
New_Line;
WriteStringMemory;
end do_it;
begin
do_it;
InitStringMemory;
do_it;
end StringMD;
|
[
{
"context": "ies\n-- Copyright (C) 2010, 2011, 2016, 2018, 2020 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@g",
"end": 171,
"score": 0.9998787045478821,
"start": 156,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "1, 2016, 2018, 2020 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under",
"end": 202,
"score": 0.9998853802680969,
"start": 187,
"tag": "NAME",
"value": "Stephane Carrez"
},
{
"context": "0 Stephane Carrez\n-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)\n--\n-- Licensed under the Apache License, Versio",
"end": 229,
"score": 0.9999294281005859,
"start": 204,
"tag": "EMAIL",
"value": "Stephane.Carrez@gmail.com"
}
] | src/sys/streams/util-streams.adb | My-Colaborations/ada-util | 0 | -----------------------------------------------------------------------
-- util-streams -- Stream utilities
-- Copyright (C) 2010, 2011, 2016, 2018, 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 Interfaces;
package body Util.Streams is
use Ada.Streams;
subtype Offset is Ada.Streams.Stream_Element_Offset;
-- ------------------------------
-- Copy the input stream to the output stream until the end of the input stream
-- is reached.
-- ------------------------------
procedure Copy (From : in out Input_Stream'Class;
Into : in out Output_Stream'Class) is
Buffer : Stream_Element_Array (0 .. 4_096);
Last : Stream_Element_Offset;
begin
loop
From.Read (Buffer, Last);
if Last > Buffer'First then
Into.Write (Buffer (Buffer'First .. Last));
end if;
exit when Last < Buffer'Last;
end loop;
end Copy;
-- ------------------------------
-- Copy the stream array to the string.
-- The string must be large enough to hold the stream array
-- or a Constraint_Error exception is raised.
-- ------------------------------
procedure Copy (From : in Ada.Streams.Stream_Element_Array;
Into : in out String) is
Pos : Positive := Into'First;
begin
for I in From'Range loop
Into (Pos) := Character'Val (From (I));
Pos := Pos + 1;
end loop;
end Copy;
-- ------------------------------
-- Copy the string to the stream array.
-- The stream array must be large enough to hold the string
-- or a Constraint_Error exception is raised.
-- ------------------------------
procedure Copy (From : in String;
Into : in out Ada.Streams.Stream_Element_Array) is
Pos : Ada.Streams.Stream_Element_Offset := Into'First;
begin
for I in From'Range loop
Into (Pos) := Character'Pos (From (I));
Pos := Pos + 1;
end loop;
end Copy;
-- ------------------------------
-- Write a raw character on the stream.
-- ------------------------------
procedure Write (Stream : in out Output_Stream'Class;
Item : in Character) is
Buf : constant Ada.Streams.Stream_Element_Array (1 .. 1)
:= (1 => Ada.Streams.Stream_Element (Character'Pos (Item)));
begin
Stream.Write (Buf);
end Write;
-- ------------------------------
-- Write a wide character on the stream doing some conversion if necessary.
-- The default implementation translates the wide character to a UTF-8 sequence.
-- ------------------------------
procedure Write_Wide (Stream : in out Output_Stream'Class;
Item : in Wide_Wide_Character) is
use Interfaces;
Val : Unsigned_32;
Buf : Ada.Streams.Stream_Element_Array (1 .. 4);
begin
-- UTF-8 conversion
-- 7 U+0000 U+007F 1 0xxxxxxx
-- 11 U+0080 U+07FF 2 110xxxxx 10xxxxxx
-- 16 U+0800 U+FFFF 3 1110xxxx 10xxxxxx 10xxxxxx
-- 21 U+10000 U+1FFFFF 4 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
Val := Wide_Wide_Character'Pos (Item);
if Val <= 16#7f# then
Buf (1) := Ada.Streams.Stream_Element (Val);
Stream.Write (Buf (1 .. 1));
elsif Val <= 16#07FF# then
Buf (1) := Stream_Element (16#C0# or Shift_Right (Val, 6));
Buf (2) := Stream_Element (16#80# or (Val and 16#03F#));
Stream.Write (Buf (1 .. 2));
elsif Val <= 16#0FFFF# then
Buf (1) := Stream_Element (16#E0# or Shift_Right (Val, 12));
Val := Val and 16#0FFF#;
Buf (2) := Stream_Element (16#80# or Shift_Right (Val, 6));
Buf (3) := Stream_Element (16#80# or (Val and 16#03F#));
Stream.Write (Buf (1 .. 3));
else
Val := Val and 16#1FFFFF#;
Buf (1) := Stream_Element (16#F0# or Shift_Right (Val, 18));
Val := Val and 16#3FFFF#;
Buf (2) := Stream_Element (16#80# or Shift_Right (Val, 12));
Val := Val and 16#0FFF#;
Buf (3) := Stream_Element (16#80# or Shift_Right (Val, 6));
Buf (4) := Stream_Element (16#80# or (Val and 16#03F#));
Stream.Write (Buf (1 .. 4));
end if;
end Write_Wide;
procedure Write_Wide (Stream : in out Output_Stream'Class;
Item : in Wide_Wide_String) is
begin
for C of Item loop
Stream.Write_Wide (C);
end loop;
end Write_Wide;
-- ------------------------------
-- Write a raw string on the stream.
-- ------------------------------
procedure Write (Stream : in out Output_Stream'Class;
Item : in String) is
Buf : Ada.Streams.Stream_Element_Array (Offset (Item'First) .. Offset (Item'Last));
for Buf'Address use Item'Address;
begin
Stream.Write (Buf);
end Write;
end Util.Streams;
| 993 | -----------------------------------------------------------------------
-- util-streams -- Stream utilities
-- Copyright (C) 2010, 2011, 2016, 2018, 2020 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Interfaces;
package body Util.Streams is
use Ada.Streams;
subtype Offset is Ada.Streams.Stream_Element_Offset;
-- ------------------------------
-- Copy the input stream to the output stream until the end of the input stream
-- is reached.
-- ------------------------------
procedure Copy (From : in out Input_Stream'Class;
Into : in out Output_Stream'Class) is
Buffer : Stream_Element_Array (0 .. 4_096);
Last : Stream_Element_Offset;
begin
loop
From.Read (Buffer, Last);
if Last > Buffer'First then
Into.Write (Buffer (Buffer'First .. Last));
end if;
exit when Last < Buffer'Last;
end loop;
end Copy;
-- ------------------------------
-- Copy the stream array to the string.
-- The string must be large enough to hold the stream array
-- or a Constraint_Error exception is raised.
-- ------------------------------
procedure Copy (From : in Ada.Streams.Stream_Element_Array;
Into : in out String) is
Pos : Positive := Into'First;
begin
for I in From'Range loop
Into (Pos) := Character'Val (From (I));
Pos := Pos + 1;
end loop;
end Copy;
-- ------------------------------
-- Copy the string to the stream array.
-- The stream array must be large enough to hold the string
-- or a Constraint_Error exception is raised.
-- ------------------------------
procedure Copy (From : in String;
Into : in out Ada.Streams.Stream_Element_Array) is
Pos : Ada.Streams.Stream_Element_Offset := Into'First;
begin
for I in From'Range loop
Into (Pos) := Character'Pos (From (I));
Pos := Pos + 1;
end loop;
end Copy;
-- ------------------------------
-- Write a raw character on the stream.
-- ------------------------------
procedure Write (Stream : in out Output_Stream'Class;
Item : in Character) is
Buf : constant Ada.Streams.Stream_Element_Array (1 .. 1)
:= (1 => Ada.Streams.Stream_Element (Character'Pos (Item)));
begin
Stream.Write (Buf);
end Write;
-- ------------------------------
-- Write a wide character on the stream doing some conversion if necessary.
-- The default implementation translates the wide character to a UTF-8 sequence.
-- ------------------------------
procedure Write_Wide (Stream : in out Output_Stream'Class;
Item : in Wide_Wide_Character) is
use Interfaces;
Val : Unsigned_32;
Buf : Ada.Streams.Stream_Element_Array (1 .. 4);
begin
-- UTF-8 conversion
-- 7 U+0000 U+007F 1 0xxxxxxx
-- 11 U+0080 U+07FF 2 110xxxxx 10xxxxxx
-- 16 U+0800 U+FFFF 3 1110xxxx 10xxxxxx 10xxxxxx
-- 21 U+10000 U+1FFFFF 4 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
Val := Wide_Wide_Character'Pos (Item);
if Val <= 16#7f# then
Buf (1) := Ada.Streams.Stream_Element (Val);
Stream.Write (Buf (1 .. 1));
elsif Val <= 16#07FF# then
Buf (1) := Stream_Element (16#C0# or Shift_Right (Val, 6));
Buf (2) := Stream_Element (16#80# or (Val and 16#03F#));
Stream.Write (Buf (1 .. 2));
elsif Val <= 16#0FFFF# then
Buf (1) := Stream_Element (16#E0# or Shift_Right (Val, 12));
Val := Val and 16#0FFF#;
Buf (2) := Stream_Element (16#80# or Shift_Right (Val, 6));
Buf (3) := Stream_Element (16#80# or (Val and 16#03F#));
Stream.Write (Buf (1 .. 3));
else
Val := Val and 16#1FFFFF#;
Buf (1) := Stream_Element (16#F0# or Shift_Right (Val, 18));
Val := Val and 16#3FFFF#;
Buf (2) := Stream_Element (16#80# or Shift_Right (Val, 12));
Val := Val and 16#0FFF#;
Buf (3) := Stream_Element (16#80# or Shift_Right (Val, 6));
Buf (4) := Stream_Element (16#80# or (Val and 16#03F#));
Stream.Write (Buf (1 .. 4));
end if;
end Write_Wide;
procedure Write_Wide (Stream : in out Output_Stream'Class;
Item : in Wide_Wide_String) is
begin
for C of Item loop
Stream.Write_Wide (C);
end loop;
end Write_Wide;
-- ------------------------------
-- Write a raw string on the stream.
-- ------------------------------
procedure Write (Stream : in out Output_Stream'Class;
Item : in String) is
Buf : Ada.Streams.Stream_Element_Array (Offset (Item'First) .. Offset (Item'Last));
for Buf'Address use Item'Address;
begin
Stream.Write (Buf);
end Write;
end Util.Streams;
| true | -----------------------------------------------------------------------
-- util-streams -- Stream utilities
-- Copyright (C) 2010, 2011, 2016, 2018, 2020 PI:NAME:<NAME>END_PI
-- Written by PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI)
--
-- 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 Util.Streams is
use Ada.Streams;
subtype Offset is Ada.Streams.Stream_Element_Offset;
-- ------------------------------
-- Copy the input stream to the output stream until the end of the input stream
-- is reached.
-- ------------------------------
procedure Copy (From : in out Input_Stream'Class;
Into : in out Output_Stream'Class) is
Buffer : Stream_Element_Array (0 .. 4_096);
Last : Stream_Element_Offset;
begin
loop
From.Read (Buffer, Last);
if Last > Buffer'First then
Into.Write (Buffer (Buffer'First .. Last));
end if;
exit when Last < Buffer'Last;
end loop;
end Copy;
-- ------------------------------
-- Copy the stream array to the string.
-- The string must be large enough to hold the stream array
-- or a Constraint_Error exception is raised.
-- ------------------------------
procedure Copy (From : in Ada.Streams.Stream_Element_Array;
Into : in out String) is
Pos : Positive := Into'First;
begin
for I in From'Range loop
Into (Pos) := Character'Val (From (I));
Pos := Pos + 1;
end loop;
end Copy;
-- ------------------------------
-- Copy the string to the stream array.
-- The stream array must be large enough to hold the string
-- or a Constraint_Error exception is raised.
-- ------------------------------
procedure Copy (From : in String;
Into : in out Ada.Streams.Stream_Element_Array) is
Pos : Ada.Streams.Stream_Element_Offset := Into'First;
begin
for I in From'Range loop
Into (Pos) := Character'Pos (From (I));
Pos := Pos + 1;
end loop;
end Copy;
-- ------------------------------
-- Write a raw character on the stream.
-- ------------------------------
procedure Write (Stream : in out Output_Stream'Class;
Item : in Character) is
Buf : constant Ada.Streams.Stream_Element_Array (1 .. 1)
:= (1 => Ada.Streams.Stream_Element (Character'Pos (Item)));
begin
Stream.Write (Buf);
end Write;
-- ------------------------------
-- Write a wide character on the stream doing some conversion if necessary.
-- The default implementation translates the wide character to a UTF-8 sequence.
-- ------------------------------
procedure Write_Wide (Stream : in out Output_Stream'Class;
Item : in Wide_Wide_Character) is
use Interfaces;
Val : Unsigned_32;
Buf : Ada.Streams.Stream_Element_Array (1 .. 4);
begin
-- UTF-8 conversion
-- 7 U+0000 U+007F 1 0xxxxxxx
-- 11 U+0080 U+07FF 2 110xxxxx 10xxxxxx
-- 16 U+0800 U+FFFF 3 1110xxxx 10xxxxxx 10xxxxxx
-- 21 U+10000 U+1FFFFF 4 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
Val := Wide_Wide_Character'Pos (Item);
if Val <= 16#7f# then
Buf (1) := Ada.Streams.Stream_Element (Val);
Stream.Write (Buf (1 .. 1));
elsif Val <= 16#07FF# then
Buf (1) := Stream_Element (16#C0# or Shift_Right (Val, 6));
Buf (2) := Stream_Element (16#80# or (Val and 16#03F#));
Stream.Write (Buf (1 .. 2));
elsif Val <= 16#0FFFF# then
Buf (1) := Stream_Element (16#E0# or Shift_Right (Val, 12));
Val := Val and 16#0FFF#;
Buf (2) := Stream_Element (16#80# or Shift_Right (Val, 6));
Buf (3) := Stream_Element (16#80# or (Val and 16#03F#));
Stream.Write (Buf (1 .. 3));
else
Val := Val and 16#1FFFFF#;
Buf (1) := Stream_Element (16#F0# or Shift_Right (Val, 18));
Val := Val and 16#3FFFF#;
Buf (2) := Stream_Element (16#80# or Shift_Right (Val, 12));
Val := Val and 16#0FFF#;
Buf (3) := Stream_Element (16#80# or Shift_Right (Val, 6));
Buf (4) := Stream_Element (16#80# or (Val and 16#03F#));
Stream.Write (Buf (1 .. 4));
end if;
end Write_Wide;
procedure Write_Wide (Stream : in out Output_Stream'Class;
Item : in Wide_Wide_String) is
begin
for C of Item loop
Stream.Write_Wide (C);
end loop;
end Write_Wide;
-- ------------------------------
-- Write a raw string on the stream.
-- ------------------------------
procedure Write (Stream : in out Output_Stream'Class;
Item : in String) is
Buf : Ada.Streams.Stream_Element_Array (Offset (Item'First) .. Offset (Item'Last));
for Buf'Address use Item'Address;
begin
Stream.Write (Buf);
end Write;
end Util.Streams;
|
[
{
"context": " --\n-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --\n-- All rig",
"end": 829,
"score": 0.9998888373374939,
"start": 816,
"tag": "NAME",
"value": "Vadim Godunko"
},
{
"context": " --\n-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --\n-- All rights reserved. ",
"end": 849,
"score": 0.9999319314956665,
"start": 831,
"tag": "EMAIL",
"value": "vgodunko@gmail.com"
}
] | source/amf/uml/amf-internals-uml_element_imports.ads | svn2github/matreshka | 24 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, 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 AMF.Internals.UML_Elements;
with AMF.UML.Element_Imports;
with AMF.UML.Elements.Collections;
with AMF.UML.Namespaces;
with AMF.UML.Packageable_Elements;
with AMF.Visitors;
package AMF.Internals.UML_Element_Imports is
type UML_Element_Import_Proxy is
limited new AMF.Internals.UML_Elements.UML_Element_Proxy
and AMF.UML.Element_Imports.UML_Element_Import with null record;
overriding function Get_Alias
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.Optional_String;
-- Getter of ElementImport::alias.
--
-- Specifies the name that should be added to the namespace of the
-- importing package in lieu of the name of the imported packagable
-- element. The aliased name must not clash with any other member name in
-- the importing package. By default, no alias is used.
overriding procedure Set_Alias
(Self : not null access UML_Element_Import_Proxy;
To : AMF.Optional_String);
-- Setter of ElementImport::alias.
--
-- Specifies the name that should be added to the namespace of the
-- importing package in lieu of the name of the imported packagable
-- element. The aliased name must not clash with any other member name in
-- the importing package. By default, no alias is used.
overriding function Get_Imported_Element
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Packageable_Elements.UML_Packageable_Element_Access;
-- Getter of ElementImport::importedElement.
--
-- Specifies the PackageableElement whose name is to be added to a
-- Namespace.
overriding procedure Set_Imported_Element
(Self : not null access UML_Element_Import_Proxy;
To : AMF.UML.Packageable_Elements.UML_Packageable_Element_Access);
-- Setter of ElementImport::importedElement.
--
-- Specifies the PackageableElement whose name is to be added to a
-- Namespace.
overriding function Get_Importing_Namespace
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of ElementImport::importingNamespace.
--
-- Specifies the Namespace that imports a PackageableElement from another
-- Package.
overriding procedure Set_Importing_Namespace
(Self : not null access UML_Element_Import_Proxy;
To : AMF.UML.Namespaces.UML_Namespace_Access);
-- Setter of ElementImport::importingNamespace.
--
-- Specifies the Namespace that imports a PackageableElement from another
-- Package.
overriding function Get_Visibility
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.UML_Visibility_Kind;
-- Getter of ElementImport::visibility.
--
-- Specifies the visibility of the imported PackageableElement within the
-- importing Package. The default visibility is the same as that of the
-- imported element. If the imported element does not have a visibility,
-- it is possible to add visibility to the element import.
overriding procedure Set_Visibility
(Self : not null access UML_Element_Import_Proxy;
To : AMF.UML.UML_Visibility_Kind);
-- Setter of ElementImport::visibility.
--
-- Specifies the visibility of the imported PackageableElement within the
-- importing Package. The default visibility is the same as that of the
-- imported element. If the imported element does not have a visibility,
-- it is possible to add visibility to the element import.
overriding function Get_Source
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of DirectedRelationship::source.
--
-- Specifies the sources of the DirectedRelationship.
overriding function Get_Target
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of DirectedRelationship::target.
--
-- Specifies the targets of the DirectedRelationship.
overriding function Get_Related_Element
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of Relationship::relatedElement.
--
-- Specifies the elements related by the Relationship.
overriding function Get_Name
(Self : not null access constant UML_Element_Import_Proxy)
return League.Strings.Universal_String;
-- Operation ElementImport::getName.
--
-- The query getName() returns the name under which the imported
-- PackageableElement will be known in the importing namespace.
overriding procedure Enter_Element
(Self : not null access constant UML_Element_Import_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Element_Import_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Element_Import_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Element_Imports;
| 12765 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Elements;
with AMF.UML.Element_Imports;
with AMF.UML.Elements.Collections;
with AMF.UML.Namespaces;
with AMF.UML.Packageable_Elements;
with AMF.Visitors;
package AMF.Internals.UML_Element_Imports is
type UML_Element_Import_Proxy is
limited new AMF.Internals.UML_Elements.UML_Element_Proxy
and AMF.UML.Element_Imports.UML_Element_Import with null record;
overriding function Get_Alias
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.Optional_String;
-- Getter of ElementImport::alias.
--
-- Specifies the name that should be added to the namespace of the
-- importing package in lieu of the name of the imported packagable
-- element. The aliased name must not clash with any other member name in
-- the importing package. By default, no alias is used.
overriding procedure Set_Alias
(Self : not null access UML_Element_Import_Proxy;
To : AMF.Optional_String);
-- Setter of ElementImport::alias.
--
-- Specifies the name that should be added to the namespace of the
-- importing package in lieu of the name of the imported packagable
-- element. The aliased name must not clash with any other member name in
-- the importing package. By default, no alias is used.
overriding function Get_Imported_Element
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Packageable_Elements.UML_Packageable_Element_Access;
-- Getter of ElementImport::importedElement.
--
-- Specifies the PackageableElement whose name is to be added to a
-- Namespace.
overriding procedure Set_Imported_Element
(Self : not null access UML_Element_Import_Proxy;
To : AMF.UML.Packageable_Elements.UML_Packageable_Element_Access);
-- Setter of ElementImport::importedElement.
--
-- Specifies the PackageableElement whose name is to be added to a
-- Namespace.
overriding function Get_Importing_Namespace
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of ElementImport::importingNamespace.
--
-- Specifies the Namespace that imports a PackageableElement from another
-- Package.
overriding procedure Set_Importing_Namespace
(Self : not null access UML_Element_Import_Proxy;
To : AMF.UML.Namespaces.UML_Namespace_Access);
-- Setter of ElementImport::importingNamespace.
--
-- Specifies the Namespace that imports a PackageableElement from another
-- Package.
overriding function Get_Visibility
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.UML_Visibility_Kind;
-- Getter of ElementImport::visibility.
--
-- Specifies the visibility of the imported PackageableElement within the
-- importing Package. The default visibility is the same as that of the
-- imported element. If the imported element does not have a visibility,
-- it is possible to add visibility to the element import.
overriding procedure Set_Visibility
(Self : not null access UML_Element_Import_Proxy;
To : AMF.UML.UML_Visibility_Kind);
-- Setter of ElementImport::visibility.
--
-- Specifies the visibility of the imported PackageableElement within the
-- importing Package. The default visibility is the same as that of the
-- imported element. If the imported element does not have a visibility,
-- it is possible to add visibility to the element import.
overriding function Get_Source
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of DirectedRelationship::source.
--
-- Specifies the sources of the DirectedRelationship.
overriding function Get_Target
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of DirectedRelationship::target.
--
-- Specifies the targets of the DirectedRelationship.
overriding function Get_Related_Element
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of Relationship::relatedElement.
--
-- Specifies the elements related by the Relationship.
overriding function Get_Name
(Self : not null access constant UML_Element_Import_Proxy)
return League.Strings.Universal_String;
-- Operation ElementImport::getName.
--
-- The query getName() returns the name under which the imported
-- PackageableElement will be known in the importing namespace.
overriding procedure Enter_Element
(Self : not null access constant UML_Element_Import_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Element_Import_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Element_Import_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Element_Imports;
| true | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Elements;
with AMF.UML.Element_Imports;
with AMF.UML.Elements.Collections;
with AMF.UML.Namespaces;
with AMF.UML.Packageable_Elements;
with AMF.Visitors;
package AMF.Internals.UML_Element_Imports is
type UML_Element_Import_Proxy is
limited new AMF.Internals.UML_Elements.UML_Element_Proxy
and AMF.UML.Element_Imports.UML_Element_Import with null record;
overriding function Get_Alias
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.Optional_String;
-- Getter of ElementImport::alias.
--
-- Specifies the name that should be added to the namespace of the
-- importing package in lieu of the name of the imported packagable
-- element. The aliased name must not clash with any other member name in
-- the importing package. By default, no alias is used.
overriding procedure Set_Alias
(Self : not null access UML_Element_Import_Proxy;
To : AMF.Optional_String);
-- Setter of ElementImport::alias.
--
-- Specifies the name that should be added to the namespace of the
-- importing package in lieu of the name of the imported packagable
-- element. The aliased name must not clash with any other member name in
-- the importing package. By default, no alias is used.
overriding function Get_Imported_Element
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Packageable_Elements.UML_Packageable_Element_Access;
-- Getter of ElementImport::importedElement.
--
-- Specifies the PackageableElement whose name is to be added to a
-- Namespace.
overriding procedure Set_Imported_Element
(Self : not null access UML_Element_Import_Proxy;
To : AMF.UML.Packageable_Elements.UML_Packageable_Element_Access);
-- Setter of ElementImport::importedElement.
--
-- Specifies the PackageableElement whose name is to be added to a
-- Namespace.
overriding function Get_Importing_Namespace
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of ElementImport::importingNamespace.
--
-- Specifies the Namespace that imports a PackageableElement from another
-- Package.
overriding procedure Set_Importing_Namespace
(Self : not null access UML_Element_Import_Proxy;
To : AMF.UML.Namespaces.UML_Namespace_Access);
-- Setter of ElementImport::importingNamespace.
--
-- Specifies the Namespace that imports a PackageableElement from another
-- Package.
overriding function Get_Visibility
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.UML_Visibility_Kind;
-- Getter of ElementImport::visibility.
--
-- Specifies the visibility of the imported PackageableElement within the
-- importing Package. The default visibility is the same as that of the
-- imported element. If the imported element does not have a visibility,
-- it is possible to add visibility to the element import.
overriding procedure Set_Visibility
(Self : not null access UML_Element_Import_Proxy;
To : AMF.UML.UML_Visibility_Kind);
-- Setter of ElementImport::visibility.
--
-- Specifies the visibility of the imported PackageableElement within the
-- importing Package. The default visibility is the same as that of the
-- imported element. If the imported element does not have a visibility,
-- it is possible to add visibility to the element import.
overriding function Get_Source
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of DirectedRelationship::source.
--
-- Specifies the sources of the DirectedRelationship.
overriding function Get_Target
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of DirectedRelationship::target.
--
-- Specifies the targets of the DirectedRelationship.
overriding function Get_Related_Element
(Self : not null access constant UML_Element_Import_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- Getter of Relationship::relatedElement.
--
-- Specifies the elements related by the Relationship.
overriding function Get_Name
(Self : not null access constant UML_Element_Import_Proxy)
return League.Strings.Universal_String;
-- Operation ElementImport::getName.
--
-- The query getName() returns the name under which the imported
-- PackageableElement will be known in the importing namespace.
overriding procedure Enter_Element
(Self : not null access constant UML_Element_Import_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Element_Import_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Element_Import_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Element_Imports;
|