text stringlengths 0 234 |
|---|
Self := null; |
return; |
end if; |
declare |
use Ada.Tags; |
the_String : constant String := String'Input (Stream); -- Read tag as string from stream. |
the_Tag : constant Tag := Descendant_Tag (the_String, Item'Tag); -- Convert to a tag. |
begin |
Self := View (AdaM.Factory.to_View (Id, the_Tag)); |
Function Definition: procedure register_Storer (the_Storer : access procedure) |
Function Body: is |
begin |
all_Storers.append (the_Storer); |
end register_Storer; |
procedure register_Restorer (the_Restorer : access procedure) |
is |
begin |
all_Restorers.append (the_Restorer); |
end register_Restorer; |
type to_View_function is access function (Id : in AdaM.Id) return Any_view; |
function Hash is new ada.Unchecked_Conversion (ada.Tags.Tag, ada.Containers.Hash_Type); |
use type ada.Tags.Tag; |
package tag_Maps_of_to_View_function is new ada.Containers.Hashed_Maps (Key_Type => ada.Tags.Tag, |
Element_Type => to_View_function, |
Hash => Hash, |
Equivalent_Keys => "="); |
tag_Map_of_to_View_function : tag_Maps_of_to_View_function.Map; |
procedure register_to_view_Function (the_Tag : in ada.Tags.Tag; |
the_Function : access function (Id : in AdaM.Id) return Any_view) |
is |
begin |
tag_Map_of_to_View_function.insert (the_Tag, the_Function); |
end register_to_view_Function; |
function to_View (Id : in AdaM.Id; Tag : in ada.Tags.Tag) return Any_view |
is |
use tag_Maps_of_to_View_function; |
the_Function : constant to_View_function := Element (tag_Map_of_to_View_function.Find (Tag)); |
begin |
return the_Function (Id); |
end to_View; |
-- Pools |
-- |
package body Pools |
is |
use Interfaces.C; |
-- Arrays and Pointers for our Pool. |
-- |
subtype item_Id is AdaM.Id range 1 .. AdaM.Id'Last; |
type Items is array (item_Id range <>) of aliased Item; |
type Addr is mod 2 ** System.Parameters.ptr_bits; |
function to_Addr is new Ada.Unchecked_Conversion (View, Addr); |
function to_Ptrdiff is new Ada.Unchecked_Conversion (Addr, Interfaces.C.ptrdiff_t); |
Elmt_Size : constant ptrdiff_t := (Items'Component_Size + System.Storage_Unit - 1) |
/ System.Storage_Unit; |
function "-" (Left : in View; |
Right : in View) return ptrdiff_t |
is |
begin |
if Left = null |
or else Right = null |
then |
raise constraint_Error; |
end if; |
return To_Ptrdiff (To_Addr (Left) - To_Addr (Right)) |
/ Elmt_Size; |
end "-"; |
-- The storage pool. |
-- |
Pool : Items (1 .. item_Id (max_Items)); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.