Parcourir la source

* fixed some errors due to bug in fpc 3.1.1

master
Bergmann89 il y a 9 ans
Parent
révision
4fba9b2e02
2 fichiers modifiés avec 43 ajouts et 7 suppressions
  1. +39
    -3
      uutlGenerics.pas
  2. +4
    -4
      uutlMessageThread.pas

+ 39
- 3
uutlGenerics.pas Voir le fichier

@@ -208,6 +208,14 @@ type

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
EutlMap = class(Exception);
EutlMapKeyNotFound = class(EutlMap)
public
constructor Create;
end;
EutlMapKeyAlreadyExists = class(EutlMap)
public
constructor Create;
end;
generic TutlCustomMap<TKey, TValue> = class(TObject)
public type
IComparer = specialize IutlComparer<TKey>;
@@ -401,6 +409,10 @@ type
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
EutlEnumConvert = class(EConvertError)
public
constructor Create(const aValue, aExpectedType: String);
end;
generic TutlEnumHelper<T> = class(TObject)
private type
TValueArray = array of T;
@@ -609,6 +621,30 @@ begin
end;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//EutlEnumConvert///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor EutlEnumConvert.Create(const aValue, aExpectedType: String);
begin
inherited Create(Format('%s is not a %s', [aValue, aExpectedType]));
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//EutlMapKeyNotFound////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor EutlMapKeyNotFound.Create;
begin
inherited Create('key not found');
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//EutlMapKeyAlreadyExists///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor EutlMapKeyAlreadyExists.Create;
begin
inherited Create('key already exists');
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TutlEqualityComparer//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1352,7 +1388,7 @@ begin
kvp.Key := aKey;
kvp.Value := aValue;
if not fHashSet.Add(kvp) then
raise EutlMap.Create('key is already in list');
raise EutlMapKeyAlreadyExists.Create();
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1380,7 +1416,7 @@ var
begin
kvp.Key := aKey;
if not fHashSet.Remove(kvp) then
raise EutlMap.Create('key not found');
raise EutlMapKeyNotFound.Create;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1697,7 +1733,7 @@ end;
class function TutlEnumHelper.ToEnum(aStr: String): T;
begin
if not TryToEnum(aStr, result) then
raise EConvertError.CreateFmt('"%s" is an invalid %s',[aStr, PTypeInfo(TypeInfo(T))^.Name]);
raise EutlEnumConvert.Create(aStr, PTypeInfo(TypeInfo(T))^.Name);
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


+ 4
- 4
uutlMessageThread.pas Voir le fichier

@@ -21,8 +21,8 @@ type
private
fEvent: TSimpleEvent;
public
procedure Push(const aItem: T); override;
function Pop(out aItem: T): Boolean; override;
procedure Push(const aItem: TutlMessage); override;
function Pop(out aItem: TutlMessage): Boolean; override;

function WaitForMessages(const aWaitTime: Cardinal = INFINITE): Boolean;
function ProcessMessages(const aProgressCallback: TMessageProgressCallback): Boolean;
@@ -157,14 +157,14 @@ end;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TutlMessageThread.TMessageQueue///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TutlMessageThread.TMessageQueue.Push(const aItem: T);
procedure TutlMessageThread.TMessageQueue.Push(const aItem: TutlMessage);
begin
inherited Push(aItem);
fEvent.SetEvent;
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TutlMessageThread.TMessageQueue.Pop(out aItem: T): Boolean;
function TutlMessageThread.TMessageQueue.Pop(out aItem: TutlMessage): Boolean;
begin
result := inherited Pop(aItem);
if (Count <= 0) then


Chargement…
Annuler
Enregistrer