11
{ TMethodList - array of TMethod }
17
function GetItems(Index: integer): TMethod;
18
procedure SetItems(Index: integer; const AValue: TMethod);
20
destructor Destroy; override;
21
function Count: integer;
22
function NextDownIndex(var Index: integer): boolean;
23
function IndexOf(const AMethod: TMethod): integer;
24
procedure Delete(Index: integer);
25
procedure Remove(const AMethod: TMethod);
26
procedure Add(const AMethod: TMethod);
27
procedure Add(const AMethod: TMethod; AsLast: boolean);
28
procedure Insert(Index: integer; const AMethod: TMethod);
29
procedure Move(OldIndex, NewIndex: integer);
30
procedure RemoveAllMethodsOfObject(const AnObject: TObject);
31
procedure CallNotifyEvents(Sender: TObject);
33
property Items[Index: integer]: TMethod read GetItems write SetItems; default;
40
function TMethodList.GetItems(Index: integer): TMethod;
42
Result:=FItems[Index];
45
procedure TMethodList.SetItems(Index: integer; const AValue: TMethod);
47
FItems[Index]:=AValue;
50
destructor TMethodList.Destroy;
56
function TMethodList.Count: integer;
64
function TMethodList.NextDownIndex(var Index: integer): boolean;
66
if Self<>nil then begin
68
if (Index>=FCount) then
75
function TMethodList.IndexOf(const AMethod: TMethod): integer;
77
if Self<>nil then begin
79
while Result>=0 do begin
80
if (FItems[Result].Code=AMethod.Code)
81
and (FItems[Result].Data=AMethod.Data) then exit;
88
procedure TMethodList.Delete(Index: integer);
92
System.Move(FItems[Index+1],FItems[Index],(FCount-Index)*SizeOf(TMethod));
93
ReAllocMem(FItems,FCount*SizeOf(TMethod));
96
procedure TMethodList.Remove(const AMethod: TMethod);
100
if Self<>nil then begin
102
if i>=0 then Delete(i);
106
procedure TMethodList.Add(const AMethod: TMethod);
109
ReAllocMem(FItems,FCount*SizeOf(TMethod));
110
FItems[FCount-1]:=AMethod;
113
procedure TMethodList.Add(const AMethod: TMethod; AsLast: boolean);
121
procedure TMethodList.Insert(Index: integer; const AMethod: TMethod);
124
ReAllocMem(FItems,FCount*SizeOf(TMethod));
126
System.Move(FItems[Index],FItems[Index+1],(FCount-Index-1)*SizeOf(TMethod));
127
FItems[Index]:=AMethod;
130
procedure TMethodList.Move(OldIndex, NewIndex: integer);
132
MovingMethod: TMethod;
134
if OldIndex=NewIndex then exit;
135
MovingMethod:=FItems[OldIndex];
136
if OldIndex>NewIndex then
137
System.Move(FItems[NewIndex],FItems[NewIndex+1],
138
SizeOf(TMethod)*(OldIndex-NewIndex))
140
System.Move(FItems[NewIndex+1],FItems[NewIndex],
141
SizeOf(TMethod)*(NewIndex-OldIndex));
142
FItems[NewIndex]:=MovingMethod;
145
procedure TMethodList.RemoveAllMethodsOfObject(const AnObject: TObject);
149
if Self=nil then exit;
152
if TObject(FItems[i].Data)=AnObject then Delete(i);
157
procedure TMethodList.CallNotifyEvents(Sender: TObject);
162
while NextDownIndex(i) do
163
TNotifyEvent(Items[i])(Sender);