소스 검색

* fixed some errors due to bug in fpc 3.1.1

master
Bergmann89 11 년 전
부모
커밋
4fba9b2e02
2개의 변경된 파일43개의 추가작업 그리고 7개의 파일을 삭제
  1. +39
    -3
      uutlGenerics.pas
  2. +4
    -4
      uutlMessageThread.pas

+ 39
- 3
uutlGenerics.pas 파일 보기

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


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


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
EutlEnumConvert = class(EConvertError)
public
constructor Create(const aValue, aExpectedType: String);
end;
generic TutlEnumHelper<T> = class(TObject) generic TutlEnumHelper<T> = class(TObject)
private type private type
TValueArray = array of T; TValueArray = array of T;
@@ -609,6 +621,30 @@ begin
end; end;
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////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TutlEqualityComparer//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1352,7 +1388,7 @@ begin
kvp.Key := aKey; kvp.Key := aKey;
kvp.Value := aValue; kvp.Value := aValue;
if not fHashSet.Add(kvp) then if not fHashSet.Add(kvp) then
raise EutlMap.Create('key is already in list');
raise EutlMapKeyAlreadyExists.Create();
end; end;


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


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1697,7 +1733,7 @@ end;
class function TutlEnumHelper.ToEnum(aStr: String): T; class function TutlEnumHelper.ToEnum(aStr: String): T;
begin begin
if not TryToEnum(aStr, result) then 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; end;


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


+ 4
- 4
uutlMessageThread.pas 파일 보기

@@ -21,8 +21,8 @@ type
private private
fEvent: TSimpleEvent; fEvent: TSimpleEvent;
public 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 WaitForMessages(const aWaitTime: Cardinal = INFINITE): Boolean;
function ProcessMessages(const aProgressCallback: TMessageProgressCallback): Boolean; function ProcessMessages(const aProgressCallback: TMessageProgressCallback): Boolean;
@@ -157,14 +157,14 @@ end;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TutlMessageThread.TMessageQueue/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TutlMessageThread.TMessageQueue///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TutlMessageThread.TMessageQueue.Push(const aItem: T);
procedure TutlMessageThread.TMessageQueue.Push(const aItem: TutlMessage);
begin begin
inherited Push(aItem); inherited Push(aItem);
fEvent.SetEvent; fEvent.SetEvent;
end; end;


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


불러오는 중...
취소
저장