vss_24.0.0_b4d0be7c/source/text/implementation/vss-implementation-referrers.ads

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
--
--  Copyright (C) 2022-2023, AdaCore
--
--  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--

with Ada.Finalization;

with VSS.Implementation.Strings;
limited with VSS.Strings;

package VSS.Implementation.Referrers is

   pragma Preelaborate;

   type Virtual_String_Access is access all VSS.Strings.Virtual_String'Class;

   type Magic_String_Base is tagged;

   type Magic_String_Access is access all Magic_String_Base'Class;

   ------------------
   -- Referal_Base --
   ------------------

   type Referal_Base is tagged;

   type Referal_Access is access all Referal_Base'Class;

   type Referal_Base is abstract new Ada.Finalization.Controlled with record
      Owner    : Magic_String_Access;
      Next     : Referal_Access;
      Previous : Referal_Access;
   end record;

   procedure Connect
     (Self  : in out Referal_Base'Class;
      Owner : not null Magic_String_Access);
   --  Connect referal to string object

   procedure Disconnect (Self  : in out Referal_Base'Class);
   --  Disconnect referel from string object

   procedure Invalidate (Self : in out Referal_Base) is abstract;

   procedure String_Modified
     (Self     : in out Referal_Base;
      Start    : VSS.Implementation.Strings.Cursor;
      Removed  : VSS.Implementation.Strings.Cursor_Offset;
      Inserted : VSS.Implementation.Strings.Cursor_Offset) is abstract;
   --  Called when referenced string object has been modified. Start is the
   --  position of the first character of the operation, it is state before
   --  modification operation, thus negative UTF* offset is not valid.
   --  Removed and Inserted parameters are sizes of the removed and inserted
   --  segments. All their members are valid.

   overriding procedure Adjust (Self : in out Referal_Base);
   --  Connect new object to the string object.

   overriding procedure Finalize (Self : in out Referal_Base);
   --  Invalidate referal state and disconnect from the string object.

   function Get_Owner
     (Self : Referal_Base'Class) return Virtual_String_Access
        with Inline;
   --  Return owner as access to Virtual_String object.

   --------------------------
   -- Referal_Limited_Base --
   --------------------------

   type Referal_Limited_Base is tagged;

   type Referal_Limited_Access is access all Referal_Limited_Base'Class;

   type Referal_Limited_Base is
     abstract limited new Ada.Finalization.Limited_Controlled with record
      Owner    : Magic_String_Access;
      Next     : Referal_Limited_Access;
      Previous : Referal_Limited_Access;
   end record;

   procedure Connect
     (Self  : in out Referal_Limited_Base'Class;
      Owner : not null Magic_String_Access);
   --  Connect referal to string object

   procedure Disconnect (Self  : in out Referal_Limited_Base'Class);
   --  Disconnect referel from string object

   procedure Reconnect
     (Self  : in out Referal_Limited_Base'Class;
      Owner : Magic_String_Access);
   --  Reconnect referel to another string object. New owner may be null, in
   --  such case referel is disconnected from the old string object only.

   procedure Invalidate (Self : in out Referal_Limited_Base) is abstract;
   --  Invalidate state of the object. It should not call Disconnect, but
   --  reset state to invalid.

   procedure String_Modified
     (Self     : in out Referal_Limited_Base;
      Start    : VSS.Implementation.Strings.Cursor;
      Removed  : VSS.Implementation.Strings.Cursor_Offset;
      Inserted : VSS.Implementation.Strings.Cursor_Offset) is abstract;
   --  Called when referenced string object has been modified. Start is the
   --  position of the first character of the operation, it is state before
   --  modification operation, thus negative UTF* offset is not valid.
   --  Removed and Inserted parameters are sizes of the removed and inserted
   --  segments. All their members are valid.

   function Get_Owner
     (Self : Referal_Limited_Base'Class) return Virtual_String_Access
        with Inline;
   --  Return owner as access to Virtual_String object.

   overriding procedure Finalize (Self : in out Referal_Limited_Base);
   --  Invalidate referal state and disconnect from the string object.

   procedure Connect
     (Self  : in out Referal_Limited_Base'Class;
      Owner : aliased VSS.Strings.Virtual_String'Class);
   --  Connect referal to string object

   -----------------------
   -- Magic_String_Base --
   -----------------------

   type Magic_String_Base is
     abstract new Ada.Finalization.Controlled with record
      Limited_Head : Referal_Limited_Access;
      Limited_Tail : Referal_Limited_Access;
      Head         : Referal_Access;
      Tail         : Referal_Access;
   end record;

   --  overriding procedure Adjust (Self : in out Magic_String_Base);

   overriding procedure Finalize (Self : in out Magic_String_Base);

   procedure Notify_String_Modified
     (Self     : in out Magic_String_Base'Class;
      From     : VSS.Implementation.Strings.Cursor;
      Removed  : VSS.Implementation.Strings.Cursor_Offset;
      Inserted : VSS.Implementation.Strings.Cursor_Offset);
   --  Do notification about modification of the string. If some notification
   --  handler raises exception it is stored, and notification continued.
   --  First stored exception will be reraised before exit, thus call to this
   --  subprogram should be done at the end of the body of the caller
   --  subprogram or exception handling added to the caller subprogram.

end VSS.Implementation.Referrers;