Changeset 101 for Generics


Ignore:
Timestamp:
Dec 23, 2010, 9:50:33 AM (14 years ago)
Author:
george
Message:
  • Fixed: String type is reference counter thus have to be properly cleared in similar fashion to objects. Problem is caused by use of System.Move procedure where instance of strings are not reference count decremented. Introduced generic class TGListString which is used for common TListString class.
Location:
Generics/TemplateGenerics
Files:
4 added
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • Generics/TemplateGenerics/Generic/GenericList.inc

    r91 r101  
    2626    procedure AddArray(Values: array of TGListItem);
    2727    procedure AddList(List: TGList);
    28     procedure Assign(List: TGList);
     28    procedure Assign(Source: TGList); virtual;
    2929    procedure Clear; virtual;
    3030    procedure Contract;
     
    126126end;
    127127
    128 procedure TGList.Assign(List: TGList);
     128procedure TGList.Assign(Source: TGList);
    129129var
    130130  I: Integer;
    131131begin
    132   Count := List.Count;
     132  Count := Source.Count;
    133133  I := 0;
    134134  while I < Count do begin
    135     Items[I] := List[I];
     135    Items[I] := Source[I];
    136136    I := I + 1;
    137137  end;
  • Generics/TemplateGenerics/Specialized/SpecializedList.pas

    r92 r101  
    5252
    5353// TListString<Integer, string>
    54 {$DEFINE TGListIndex := Integer}
    55 {$DEFINE TGListItem := string}
    56 {$DEFINE TGList := TListString}
    57 {$DEFINE TGListSortCompare := TListStringSortCompare}
    58 {$DEFINE TGListToStringConverter := TListStringToStringConverter}
    59 {$DEFINE TGListFromStringConverter := TListStringFromStringConverter}
    60 {$DEFINE INTERFACE}
    61 {$I 'GenericList.inc'}
     54{$DEFINE TGListStringIndex := Integer}
     55{$DEFINE TGListStringItem := string}
     56{$DEFINE TGListString := TListString}
     57{$DEFINE TGListStringSortCompare := TListStringSortCompare}
     58{$DEFINE TGListStringToStringConverter := TListStringToStringConverter}
     59{$DEFINE TGListStringFromStringConverter := TListStringFromStringConverter}
     60{$DEFINE INTERFACE}
     61{$I 'GenericListString.inc'}
    6262
    6363// TListByte<Integer, Byte>
     
    8080{$DEFINE INTERFACE}
    8181{$I 'GenericList.inc'}
     82
     83// TListObject<Integer, TObject>
     84{$DEFINE TGListObjectIndex := Integer}
     85{$DEFINE TGListObjectItem := TObject}
     86{$DEFINE TGListObjectList := TObjectListListObject}
     87{$DEFINE TGListObject := TListObject}
     88{$DEFINE TGListObjectSortCompare := TObjectListSortCompareObject}
     89{$DEFINE TGListObjectToStringConverter := TObjectListToStringConverterObject}
     90{$DEFINE TGListObjectFromStringConverter := TObjectListFromStringConverterObject}
     91{$DEFINE INTERFACE}
     92{$I 'GenericListObject.inc'}
     93
    8294
    8395{ TListChar }
     
    140152
    141153// TListString<Integer, string>
    142 {$DEFINE TGListIndex := Integer}
    143 {$DEFINE TGListItem := string}
    144 {$DEFINE TGList := TListString}
    145 {$DEFINE TGListSortCompare := TListStringSortCompare}
    146 {$DEFINE TGListToStringConverter := TListStringToStringConverter}
    147 {$DEFINE TGListFromStringConverter := TListStringFromStringConverter}
    148 {$DEFINE IMPLEMENTATION}
    149 {$I 'GenericList.inc'}
     154{$DEFINE TGListStringIndex := Integer}
     155{$DEFINE TGListStringItem := string}
     156{$DEFINE TGListString := TListString}
     157{$DEFINE TGListStringSortCompare := TListStringSortCompare}
     158{$DEFINE TGListStringToStringConverter := TListStringToStringConverter}
     159{$DEFINE TGListStringFromStringConverter := TListStringFromStringConverter}
     160{$DEFINE IMPLEMENTATION}
     161{$I 'GenericListString.inc'}
    150162
    151163// TListByte<Integer, Byte>
     
    169181{$I 'GenericList.inc'}
    170182
     183// TListObject<Integer, TObject>
     184{$DEFINE TGListObjectIndex := Integer}
     185{$DEFINE TGListObjectItem := TObject}
     186{$DEFINE TGListObjectList := TObjectListListObject}
     187{$DEFINE TGListObject := TListObject}
     188{$DEFINE TGListObjectSortCompare := TObjectListSortCompareObject}
     189{$DEFINE TGListObjectToStringConverter := TObjectListToStringConverterObject}
     190{$DEFINE TGListObjectFromStringConverter := TObjectListFromStringConverterObject}
     191{$DEFINE IMPLEMENTATION}
     192{$I 'GenericListObject.inc'}
     193
     194
    171195
    172196function StrToStr(Value: string): string;
  • Generics/TemplateGenerics/TemplateGenerics.lpk

    r91 r101  
    3333      </Item3>
    3434      <Item4>
    35         <Filename Value="Generic\GenericObjectList.inc"/>
     35        <Filename Value="Generic\GenericListObject.inc"/>
    3636        <Type Value="Include"/>
    3737      </Item4>
     
    8181      </Item15>
    8282      <Item16>
    83         <Filename Value="Specialized\SpecializedObjectList.pas"/>
    84         <UnitName Value="SpecializedObjectList"/>
     83        <Filename Value="Generic\GenericListString.inc"/>
    8584      </Item16>
    8685    </Files>
  • Generics/TemplateGenerics/TemplateGenerics.pas

    r91 r101  
    99uses
    1010    SpecializedList, SpecializedDictionary, SpecializedStack, SpecializedTree,
    11   SpecializedQueue, SpecializedSet, SpecializedObjectList, LazarusPackageIntf;
     11  SpecializedQueue, SpecializedSet, LazarusPackageIntf;
    1212
    1313implementation
Note: See TracChangeset for help on using the changeset viewer.