blob: 6b6363671b1c6192e1356d0462a9587bf5f4fa11 (
plain)
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
{
This file is part of the Free Component Library (FCL)
Copyright (c) 2002 by the Free Pascal development team
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
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.
**********************************************************************}
{ TInerfaceListEnumerator }
constructor TInterfaceListEnumerator.Create(AList: TInterfaceList);
begin
inherited create;
FList:=AList;
FPosition:=-1;
end;
function TInterfaceListEnumerator.GetCurrent: IUnknown;
begin
Result:=FList[FPosition];
end;
function TInterfaceListEnumerator.MoveNext: Boolean;
begin
Inc(FPosition);
Result:=FPosition<FList.Count;
end;
{ TInterfaceList }
constructor TInterfaceList.Create;
begin
inherited create;
FList:=TThreadList.Create;
end;
destructor TInterfaceList.Destroy;
begin
Clear;
FList.Free;
inherited Destroy;
end;
function TInterfaceList.Get(i : Integer) : IUnknown;
begin
FList.Locklist;
try
if (i<0) or (i>=FList.FList.Count) then
FList.FList.Error(SListIndexError,i);
result:=IUnknown(FList.FList.List^[i]);
finally
FList.UnlockList;
end;
end;
function TInterfaceList.GetCapacity : Integer;
begin
FList.Locklist;
try
result:=FList.FList.Capacity;
finally
FList.UnlockList;
end;
end;
function TInterfaceList.GetCount : Integer;
begin
FList.Locklist;
try
result:=FList.FList.Count;
finally
FList.UnlockList;
end;
end;
procedure TInterfaceList.Put(i : Integer;item : IUnknown);
begin
FList.Locklist;
try
if (i<0) or (i>=FList.FList.Count) then
FList.FList.Error(SListIndexError,i);
IUnknown(FList.FList.List^[i]):=item;
finally
FList.UnlockList;
end;
end;
procedure TInterfaceList.SetCapacity(NewCapacity : Integer);
begin
FList.Locklist;
try
FList.FList.Capacity:=NewCapacity;
finally
FList.UnlockList;
end;
end;
procedure TInterfaceList.SetCount(NewCount : Integer);
begin
FList.Locklist;
try
FList.FList.Count:=NewCount;
finally
FList.UnlockList;
end;
end;
procedure TInterfaceList.Clear;
var
i : SizeInt;
begin
FList.Locklist;
try
for i:=0 to FList.FList.Count-1 do
IUnknown(FList.FList.List^[i]):=nil;
FList.Clear;
finally
FList.UnlockList;
end;
end;
procedure TInterfaceList.Delete(index : Integer);
begin
FList.Locklist;
try
if (index<0) or (index>=FList.FList.Count) then
FList.FList.Error(SListIndexError,index);
IUnknown(FList.FList.List^[index]):=nil;
FList.FList.Delete(index);
finally
FList.UnlockList;
end;
end;
procedure TInterfaceList.Exchange(index1,index2 : Integer);
begin
FList.Locklist;
try
FList.FList.Exchange(index1,index2);
finally
FList.UnlockList;
end;
end;
function TInterfaceList.First : IUnknown;
begin
result:=Get(0);
end;
function TInterfaceList.GetEnumerator: TInterfaceListEnumerator;
begin
result:=TInterfaceListEnumerator.Create(Self)
end;
function TInterfaceList.IndexOf(item : IUnknown) : Integer;
begin
FList.Locklist;
try
result:=FList.FList.IndexOf(Pointer(Item));
finally
FList.UnlockList;
end;
end;
function TInterfaceList.Add(item : IUnknown) : Integer;
begin
FList.Locklist;
try
result:=FList.FList.Add(nil);
IUnknown(FList.FList.List^[result]):=item;
finally
FList.UnlockList;
end;
end;
procedure TInterfaceList.Insert(i : Integer;item : IUnknown);
begin
FList.Locklist;
try
FList.FList.Insert(i,nil);
IUnknown(FList.FList.List^[i]):=item;
finally
FList.UnlockList;
end;
end;
function TInterfaceList.Last : IUnknown;
begin
result:=Get(Count-1);
end;
function TInterfaceList.Remove(item : IUnknown): Integer;
begin
FList.Locklist;
try
result:=FList.FList.IndexOf(item);
if result>=0 then
begin
IUnknown(FList.FList.List^[result]):=nil;
FList.FList.Delete(result);
end;
finally
FList.UnlockList;
end;
end;
procedure TInterfaceList.Lock;
begin
FList.Locklist;
end;
procedure TInterfaceList.Unlock;
begin
FList.UnlockList;
end;
function TInterfaceList.Expand : TInterfaceList;
begin
FList.Locklist;
try
FList.FList.Expand;
result:=self;
finally
FList.UnlockList;
end;
end;
|