From f0c236b992e3f9750c5c4905b61e7683ba8ae199 Mon Sep 17 00:00:00 2001 From: marco Date: Sat, 27 Dec 2008 18:43:22 +0000 Subject: [PATCH] * Made overloading situation ifthen more Delphi compatible. Mantis #12662 All string variants now in one unit. git-svn-id: trunk@12442 - --- rtl/objpas/math.pp | 12 +++--------- rtl/objpas/strutils.pp | 10 +++++----- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/rtl/objpas/math.pp b/rtl/objpas/math.pp index 0d0359ce30..8fe57e75c9 100644 --- a/rtl/objpas/math.pp +++ b/rtl/objpas/math.pp @@ -510,10 +510,9 @@ function norm(const data : array of Extended) : float; function norm(const data : PExtended; Const N : Integer) : float; {$endif FPC_HAS_TYPE_EXTENDED} -function ifthen(val:boolean;const iftrue:integer; const iffalse:integer= 0) :integer; inline; -function ifthen(val:boolean;const iftrue:int64 ; const iffalse:int64 = 0) :int64; inline; -function ifthen(val:boolean;const iftrue:double ; const iffalse:double =0.0):double; inline; -function ifthen(val:boolean;const iftrue:String ; const iffalse:String ='') :String; inline; +function ifthen(val:boolean;const iftrue:integer; const iffalse:integer= 0) :integer; inline; overload; +function ifthen(val:boolean;const iftrue:int64 ; const iffalse:int64 = 0) :int64; inline; overload; +function ifthen(val:boolean;const iftrue:double ; const iffalse:double =0.0):double; inline; overload; function CompareValue ( const A, B : Integer) : TValueRelationship; inline; function CompareValue ( const A, B : Int64) : TValueRelationship; inline; @@ -2240,11 +2239,6 @@ begin if val then result:=iftrue else result:=iffalse; end; -function ifthen(val:boolean;const iftrue:String ; const iffalse:String ='') :String; inline; -begin - if val then result:=iftrue else result:=iffalse; -end; - // dilemma here. asm can do the two comparisons in one go? // but pascal is portable and can be i inline;ed. Ah well, we need purepascal's anyway: function CompareValue ( const A, B : Integer) : TValueRelationship; diff --git a/rtl/objpas/strutils.pp b/rtl/objpas/strutils.pp index 3e649aa8f9..e9285f6536 100644 --- a/rtl/objpas/strutils.pp +++ b/rtl/objpas/strutils.pp @@ -56,6 +56,7 @@ Function StuffString(const AText: string; AStart, ALength: Cardinal; const ASub Function RandomFrom(const AValues: array of string): string; overload; Function IfThen(AValue: Boolean; const ATrue: string; AFalse: string): string;inline; Function IfThen(AValue: Boolean; const ATrue: string): string;inline; // ; AFalse: string = '' +Function IfThen(AValue: Boolean; const ATrue: shortString ; const Afalse: shortString ='') :shortString; inline; { --------------------------------------------------------------------- VB emulations. @@ -395,8 +396,6 @@ begin result:=Avalues[random(High(AValues)+1)]; end; - - Function IfThen(AValue: Boolean; const ATrue: string; AFalse: string): string;inline; begin @@ -406,8 +405,6 @@ begin result:=afalse; end; - - Function IfThen(AValue: Boolean; const ATrue: string): string;inline; // ; AFalse: string = '' begin @@ -417,7 +414,10 @@ begin result:=''; end; - +Function IfThen(AValue:boolean;const ATrue:shortString ; const AFalse:shortString ='') :shortString; inline; +begin + if AValue then result:=ATrue else result:=AFalse; +end; { --------------------------------------------------------------------- VB emulations.