mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 03:39:40 +01:00 
			
		
		
		
	+ TInterfaceList implemented
git-svn-id: trunk@1453 -
This commit is contained in:
		
							parent
							
								
									4db863d076
								
							
						
					
					
						commit
						11336b091d
					
				@ -13,101 +13,211 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    constructor TInterfaceList.Create;
 | 
					    constructor TInterfaceList.Create;
 | 
				
			||||||
      begin
 | 
					      begin
 | 
				
			||||||
 | 
					        inherited create;
 | 
				
			||||||
 | 
					        FList:=TThreadList.Create;
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    destructor TInterfaceList.Destroy;
 | 
					    destructor TInterfaceList.Destroy;
 | 
				
			||||||
      begin
 | 
					      begin
 | 
				
			||||||
 | 
					        Clear;
 | 
				
			||||||
 | 
					        FList.Free;
 | 
				
			||||||
 | 
					        inherited Destroy;
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function TInterfaceList.Get(i : Integer) : IUnknown;
 | 
					    function TInterfaceList.Get(i : Integer) : IUnknown;
 | 
				
			||||||
      begin
 | 
					      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;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function TInterfaceList.GetCapacity : Integer;
 | 
					    function TInterfaceList.GetCapacity : Integer;
 | 
				
			||||||
      begin
 | 
					      begin
 | 
				
			||||||
 | 
					        FList.Locklist;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          result:=FList.FList.Capacity;
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					          FList.UnlockList;
 | 
				
			||||||
 | 
					        end;
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function TInterfaceList.GetCount : Integer;
 | 
					    function TInterfaceList.GetCount : Integer;
 | 
				
			||||||
      begin
 | 
					      begin
 | 
				
			||||||
 | 
					        FList.Locklist;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          result:=FList.FList.Count;
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					          FList.UnlockList;
 | 
				
			||||||
 | 
					        end;
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    procedure TInterfaceList.Put(i : Integer;item : IUnknown);
 | 
					    procedure TInterfaceList.Put(i : Integer;item : IUnknown);
 | 
				
			||||||
      begin
 | 
					      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;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    procedure TInterfaceList.SetCapacity(NewCapacity : Integer);
 | 
					    procedure TInterfaceList.SetCapacity(NewCapacity : Integer);
 | 
				
			||||||
      begin
 | 
					      begin
 | 
				
			||||||
 | 
					        FList.Locklist;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          FList.FList.Capacity:=NewCapacity;
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					          FList.UnlockList;
 | 
				
			||||||
 | 
					        end;
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    procedure TInterfaceList.SetCount(NewCount : Integer);
 | 
					    procedure TInterfaceList.SetCount(NewCount : Integer);
 | 
				
			||||||
      begin
 | 
					      begin
 | 
				
			||||||
 | 
					        FList.Locklist;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          FList.FList.Count:=NewCount;
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					          FList.UnlockList;
 | 
				
			||||||
 | 
					        end;
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    procedure TInterfaceList.Clear;
 | 
					    procedure TInterfaceList.Clear;
 | 
				
			||||||
 | 
					      var
 | 
				
			||||||
 | 
					        i : SizeInt;
 | 
				
			||||||
      begin
 | 
					      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;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    procedure TInterfaceList.Delete(index : Integer);
 | 
					    procedure TInterfaceList.Delete(index : Integer);
 | 
				
			||||||
      begin
 | 
					      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;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    procedure TInterfaceList.Exchange(index1,index2 : Integer);
 | 
					    procedure TInterfaceList.Exchange(index1,index2 : Integer);
 | 
				
			||||||
      begin
 | 
					      begin
 | 
				
			||||||
 | 
					        FList.Locklist;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          FList.FList.Exchange(index1,index2);
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					          FList.UnlockList;
 | 
				
			||||||
 | 
					        end;
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function TInterfaceList.First : IUnknown;
 | 
					    function TInterfaceList.First : IUnknown;
 | 
				
			||||||
      begin
 | 
					      begin
 | 
				
			||||||
 | 
					        result:=Get(0);
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function TInterfaceList.IndexOf(item : IUnknown) : Integer;
 | 
					    function TInterfaceList.IndexOf(item : IUnknown) : Integer;
 | 
				
			||||||
      begin
 | 
					      begin
 | 
				
			||||||
 | 
					        FList.Locklist;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          result:=FList.FList.IndexOf(Pointer(Item));
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					          FList.UnlockList;
 | 
				
			||||||
 | 
					        end;
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function TInterfaceList.Add(item : IUnknown) : Integer;
 | 
					    function TInterfaceList.Add(item : IUnknown) : Integer;
 | 
				
			||||||
      begin
 | 
					      begin
 | 
				
			||||||
 | 
					        FList.Locklist;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          result:=FList.FList.Add(nil);
 | 
				
			||||||
 | 
					          IUnknown(FList.FList.List^[result]):=item;
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					          FList.UnlockList;
 | 
				
			||||||
 | 
					        end;
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    procedure TInterfaceList.Insert(i : Integer;item : IUnknown);
 | 
					    procedure TInterfaceList.Insert(i : Integer;item : IUnknown);
 | 
				
			||||||
      begin
 | 
					      begin
 | 
				
			||||||
 | 
					        FList.Locklist;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          FList.FList.Insert(i,nil);
 | 
				
			||||||
 | 
					          IUnknown(FList.FList.List^[i]):=item;
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					          FList.UnlockList;
 | 
				
			||||||
 | 
					        end;
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function TInterfaceList.Last : IUnknown;
 | 
					    function TInterfaceList.Last : IUnknown;
 | 
				
			||||||
      begin
 | 
					      begin
 | 
				
			||||||
 | 
					        result:=Get(Count-1);
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function TInterfaceList.Remove(item : IUnknown): Integer;
 | 
					    function TInterfaceList.Remove(item : IUnknown): Integer;
 | 
				
			||||||
      begin
 | 
					      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;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    procedure TInterfaceList.Lock;
 | 
					    procedure TInterfaceList.Lock;
 | 
				
			||||||
      begin
 | 
					      begin
 | 
				
			||||||
 | 
					        FList.Locklist;
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    procedure TInterfaceList.Unlock;
 | 
					    procedure TInterfaceList.Unlock;
 | 
				
			||||||
      begin
 | 
					      begin
 | 
				
			||||||
 | 
					        FList.UnlockList;
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function TInterfaceList.Expand : TInterfaceList;
 | 
					    function TInterfaceList.Expand : TInterfaceList;
 | 
				
			||||||
      begin
 | 
					      begin
 | 
				
			||||||
 | 
					        FList.Locklist;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          FList.FList.Expand;
 | 
				
			||||||
 | 
					          result:=self;
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					          FList.UnlockList;
 | 
				
			||||||
 | 
					        end;
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user