1------------------------------------------------------------------------------ 2-- -- 3-- GNAT RUN-TIME COMPONENTS -- 4-- -- 5-- G N A T . T A B L E -- 6-- -- 7-- S p e c -- 8-- -- 9-- Copyright (C) 1998-2018, AdaCore -- 10-- -- 11-- GNAT is free software; you can redistribute it and/or modify it under -- 12-- terms of the GNU General Public License as published by the Free Soft- -- 13-- ware Foundation; either version 3, or (at your option) any later ver- -- 14-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- 15-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- 16-- or FITNESS FOR A PARTICULAR PURPOSE. -- 17-- -- 18-- As a special exception under Section 7 of GPL version 3, you are granted -- 19-- additional permissions described in the GCC Runtime Library Exception, -- 20-- version 3.1, as published by the Free Software Foundation. -- 21-- -- 22-- You should have received a copy of the GNU General Public License and -- 23-- a copy of the GCC Runtime Library Exception along with this program; -- 24-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- 25-- <http://www.gnu.org/licenses/>. -- 26-- -- 27-- GNAT was originally developed by the GNAT team at New York University. -- 28-- Extensive contributions were provided by Ada Core Technologies Inc. -- 29-- -- 30------------------------------------------------------------------------------ 31 32-- This package provides a singleton version of GNAT.Dynamic_Tables 33-- (g-dyntab.ads). See that package for documentation. This package just 34-- declares a single instance of GNAT.Dynamic_Tables.Instance, and provides 35-- wrappers for all the subprograms, passing that single instance. 36 37-- Note that these three interfaces should remain synchronized to keep as much 38-- coherency as possible among these related units: 39-- 40-- GNAT.Dynamic_Tables 41-- GNAT.Table 42-- Table (the compiler unit) 43 44with GNAT.Dynamic_Tables; 45 46generic 47 type Table_Component_Type is private; 48 type Table_Index_Type is range <>; 49 50 Table_Low_Bound : Table_Index_Type := Table_Index_Type'First; 51 Table_Initial : Positive := 8; 52 Table_Increment : Natural := 100; 53 Table_Name : String := ""; -- for debugging printouts 54 pragma Unreferenced (Table_Name); 55 Release_Threshold : Natural := 0; 56 57package GNAT.Table is 58 pragma Elaborate_Body; 59 60 package Tab is new GNAT.Dynamic_Tables 61 (Table_Component_Type, 62 Table_Index_Type, 63 Table_Low_Bound, 64 Table_Initial, 65 Table_Increment, 66 Release_Threshold); 67 68 subtype Valid_Table_Index_Type is Tab.Valid_Table_Index_Type; 69 subtype Table_Last_Type is Tab.Table_Last_Type; 70 subtype Table_Type is Tab.Table_Type; 71 function "=" (X, Y : Table_Type) return Boolean renames Tab."="; 72 73 subtype Table_Ptr is Tab.Table_Ptr; 74 75 The_Instance : Tab.Instance; 76 Table : Table_Ptr renames The_Instance.Table; 77 Locked : Boolean renames The_Instance.Locked; 78 79 function Is_Empty return Boolean; 80 81 procedure Init; 82 pragma Inline (Init); 83 procedure Free; 84 pragma Inline (Free); 85 86 function First return Table_Index_Type; 87 pragma Inline (First); 88 89 function Last return Table_Last_Type; 90 pragma Inline (Last); 91 92 procedure Release; 93 pragma Inline (Release); 94 95 procedure Set_Last (New_Val : Table_Last_Type); 96 pragma Inline (Set_Last); 97 98 procedure Increment_Last; 99 pragma Inline (Increment_Last); 100 101 procedure Decrement_Last; 102 pragma Inline (Decrement_Last); 103 104 procedure Append (New_Val : Table_Component_Type); 105 pragma Inline (Append); 106 107 procedure Append_All (New_Vals : Table_Type); 108 pragma Inline (Append_All); 109 110 procedure Set_Item 111 (Index : Valid_Table_Index_Type; 112 Item : Table_Component_Type); 113 pragma Inline (Set_Item); 114 115 subtype Saved_Table is Tab.Instance; 116 -- Type used for Save/Restore subprograms 117 118 function Save return Saved_Table; 119 pragma Inline (Save); 120 -- Resets table to empty, but saves old contents of table in returned 121 -- value, for possible later restoration by a call to Restore. 122 123 procedure Restore (T : in out Saved_Table); 124 pragma Inline (Restore); 125 -- Given a Saved_Table value returned by a prior call to Save, restores 126 -- the table to the state it was in at the time of the Save call. 127 128 procedure Allocate (Num : Integer := 1); 129 function Allocate (Num : Integer := 1) return Valid_Table_Index_Type; 130 pragma Inline (Allocate); 131 -- Adds Num to Last. The function version also returns the old value of 132 -- Last + 1. Note that this function has the possible side effect of 133 -- reallocating the table. This means that a reference X.Table (X.Allocate) 134 -- is incorrect, since the call to X.Allocate may modify the results of 135 -- calling X.Table. 136 137 generic 138 with procedure Action 139 (Index : Valid_Table_Index_Type; 140 Item : Table_Component_Type; 141 Quit : in out Boolean) is <>; 142 procedure For_Each; 143 pragma Inline (For_Each); 144 145 generic 146 with function Lt (Comp1, Comp2 : Table_Component_Type) return Boolean; 147 procedure Sort_Table; 148 pragma Inline (Sort_Table); 149 150end GNAT.Table; 151