From b47c43d38a0a8b1dff4486e6acd51b84a0b61230 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Fri, 15 Mar 2019 22:11:15 +0100 Subject: [PATCH] move TPoint operator to common unit --- src/u_common.pas | 28 ++++++++++++++++++++++++++++ src/u_dlang.pas | 30 +----------------------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/u_common.pas b/src/u_common.pas index cc566024..3dd6d9a3 100644 --- a/src/u_common.pas +++ b/src/u_common.pas @@ -328,6 +328,14 @@ type // Converts the delta between two calls to GetTickCount64 to a string indicating a duration. function formatTicksAsDuration(ticks: UInt64): string; + (** + * Compares two TPoints. + *) + operator = (lhs: TPoint; rhs: TPoint): boolean; + operator > (lhs: TPoint; rhs: TPoint): boolean; + operator < (lhs: TPoint; rhs: TPoint): boolean; + operator <= (lhs: TPoint; rhs: TPoint): boolean; + var // additional directories to find background tools additionalPath: string; @@ -337,6 +345,26 @@ var implementation +operator = (lhs: TPoint; rhs: TPoint): boolean; +begin + exit((lhs.y = rhs.y) and (lhs.x = rhs.x)); +end; + +operator > (lhs: TPoint; rhs: TPoint): boolean; +begin + exit((lhs.y > rhs.y) or ((lhs.y = rhs.y) and (lhs.x > rhs.x))); +end; + +operator < (lhs: TPoint; rhs: TPoint): boolean; +begin + exit(rhs > lhs); +end; + +operator <= (lhs: TPoint; rhs: TPoint): boolean; +begin + exit((lhs = rhs) or (lhs < rhs)); +end; + function GetIconScaledSize: TIconScaledSize; var h : integer; diff --git a/src/u_dlang.pas b/src/u_dlang.pas index 69c2e653..957cd5bc 100644 --- a/src/u_dlang.pas +++ b/src/u_dlang.pas @@ -5,7 +5,7 @@ unit u_dlang; interface uses - Classes, SysUtils, u_dlangutils, u_dlangmaps; + Classes, SysUtils, u_common, u_dlangutils, u_dlangmaps; type @@ -153,37 +153,9 @@ procedure getImports(list: TLexTokenList; imports: TStrings); *) function getIndexOfTokenLeftTo(tokens: TLexTokenList; caretPos: TPoint): integer; -(** - * Compares two TPoints. - *) -operator = (lhs: TPoint; rhs: TPoint): boolean; -operator > (lhs: TPoint; rhs: TPoint): boolean; -operator < (lhs: TPoint; rhs: TPoint): boolean; -operator <= (lhs: TPoint; rhs: TPoint): boolean; - implementation {$REGION TReaderHead -----------------------------------------------------------} -operator = (lhs: TPoint; rhs: TPoint): boolean; -begin - exit((lhs.y = rhs.y) and (lhs.x = rhs.x)); -end; - -operator > (lhs: TPoint; rhs: TPoint): boolean; -begin - exit((lhs.y > rhs.y) or ((lhs.y = rhs.y) and (lhs.x > rhs.x))); -end; - -operator < (lhs: TPoint; rhs: TPoint): boolean; -begin - exit(rhs > lhs); -end; - -operator <= (lhs: TPoint; rhs: TPoint): boolean; -begin - exit((lhs = rhs) or (lhs < rhs)); -end; - constructor TReaderHead.Create(const text: PChar; const colAndLine: TPoint); begin setReader(text, colAndLine);