Browse Source

fcl-db: base: change formal data type of AsInteger to Longint instead of Integer (in objpas mode it is same as Integer) to be Delphi compatible.
Change call chain GetAsInteger calls GetAsLongint to GetAsLongint calls GetAsInteger, because AsInteger is used often than GetAsLongint so we save one more call.

git-svn-id: trunk@24632 -

lacak 12 years ago
parent
commit
eeabb9403e
2 changed files with 56 additions and 56 deletions
  1. 23 23
      packages/fcl-db/src/base/db.pas
  2. 33 33
      packages/fcl-db/src/base/fields.inc

+ 23 - 23
packages/fcl-db/src/base/db.pas

@@ -330,7 +330,7 @@ type
     function GetAsDateTime: TDateTime; virtual;
     function GetAsFloat: Double; virtual;
     function GetAsLongint: Longint; virtual;
-    function GetAsInteger: Integer; virtual;
+    function GetAsInteger: Longint; virtual;
     function GetAsVariant: variant; virtual;
     function GetOldValue: variant; virtual;
     function GetAsString: string; virtual;
@@ -356,7 +356,7 @@ type
     procedure SetAsDateTime(AValue: TDateTime); virtual;
     procedure SetAsFloat(AValue: Double); virtual;
     procedure SetAsLongint(AValue: Longint); virtual;
-    procedure SetAsInteger(AValue: Integer); virtual;
+    procedure SetAsInteger(AValue: Longint); virtual;
     procedure SetAsLargeint(AValue: Largeint); virtual;
     procedure SetAsVariant(const AValue: variant); virtual;
     procedure SetAsString(const AValue: string); virtual;
@@ -392,7 +392,7 @@ type
     property AsFloat: Double read GetAsFloat write SetAsFloat;
     property AsLongint: Longint read GetAsLongint write SetAsLongint;
     property AsLargeInt: LargeInt read GetAsLargeInt write SetAsLargeInt;
-    property AsInteger: Integer read GetAsInteger write SetAsInteger;
+    property AsInteger: Longint read GetAsInteger write SetAsInteger;
     property AsString: string read GetAsString write SetAsString;
     property AsWideString: WideString read GetAsWideString write SetAsWideString;
     property AsVariant: variant read GetAsVariant write SetAsVariant;
@@ -458,7 +458,7 @@ type
     function GetAsBoolean: Boolean; override;
     function GetAsDateTime: TDateTime; override;
     function GetAsFloat: Double; override;
-    function GetAsLongint: Longint; override;
+    function GetAsInteger: Longint; override;
     function GetAsString: string; override;
     function GetAsVariant: variant; override;
     function GetDataSize: Integer; override;
@@ -468,7 +468,7 @@ type
     procedure SetAsBoolean(AValue: Boolean); override;
     procedure SetAsDateTime(AValue: TDateTime); override;
     procedure SetAsFloat(AValue: Double); override;
-    procedure SetAsLongint(AValue: Longint); override;
+    procedure SetAsInteger(AValue: Longint); override;
     procedure SetAsString(const AValue: string); override;
     procedure SetVarValue(const AValue: Variant); override;
   public
@@ -534,27 +534,27 @@ type
     FMinValue,
     FMaxValue,
     FMinRange,
-    FMAxRange  : Longint;
+    FMaxRange  : Longint;
     Procedure SetMinValue (AValue : longint);
     Procedure SetMaxValue (AValue : longint);
   protected
     function GetAsFloat: Double; override;
-    function GetAsLongint: Longint; override;
+    function GetAsInteger: Longint; override;
     function GetAsString: string; override;
     function GetAsVariant: variant; override;
     function GetDataSize: Integer; override;
     procedure GetText(var AText: string; ADisplayText: Boolean); override;
     function GetValue(var AValue: Longint): Boolean;
     procedure SetAsFloat(AValue: Double); override;
-    procedure SetAsLongint(AValue: Longint); override;
+    procedure SetAsInteger(AValue: Longint); override;
     procedure SetAsString(const AValue: string); override;
     procedure SetVarValue(const AValue: Variant); override;
     function GetAsLargeint: Largeint; override;
     procedure SetAsLargeint(AValue: Largeint); override;
   public
     constructor Create(AOwner: TComponent); override;
-    Function CheckRange(AValue : longint) : Boolean;
-    property Value: Longint read GetAsLongint write SetAsLongint;
+    Function CheckRange(AValue : Longint) : Boolean;
+    property Value: Longint read GetAsInteger write SetAsInteger;
   published
     property MaxValue: Longint read FMaxValue write SetMaxValue default 0;
     property MinValue: Longint read FMinValue write SetMinValue default 0;
@@ -573,7 +573,7 @@ type
     Procedure SetMaxValue (AValue : Largeint);
   protected
     function GetAsFloat: Double; override;
-    function GetAsLongint: Longint; override;
+    function GetAsInteger: Longint; override;
     function GetAsLargeint: Largeint; override;
     function GetAsString: string; override;
     function GetAsVariant: variant; override;
@@ -581,7 +581,7 @@ type
     procedure GetText(var AText: string; ADisplayText: Boolean); override;
     function GetValue(var AValue: Largeint): Boolean;
     procedure SetAsFloat(AValue: Double); override;
-    procedure SetAsLongint(AValue: Longint); override;
+    procedure SetAsInteger(AValue: Longint); override;
     procedure SetAsLargeint(AValue: Largeint); override;
     procedure SetAsString(const AValue: string); override;
     procedure SetVarValue(const AValue: Variant); override;
@@ -616,7 +616,7 @@ type
 
   TAutoIncField = class(TLongintField)
   Protected
-    Procedure SetAsLongInt(AValue : Longint); override;
+    procedure SetAsInteger(AValue: Longint); override;
   public
     constructor Create(AOwner: TComponent); override;
   end;
@@ -634,14 +634,14 @@ type
   protected
     function GetAsFloat: Double; override;
     function GetAsLargeInt: LargeInt; override;
-    function GetAsLongint: Longint; override;
+    function GetAsInteger: Longint; override;
     function GetAsVariant: variant; override;
     function GetAsString: string; override;
     function GetDataSize: Integer; override;
     procedure GetText(var theText: string; ADisplayText: Boolean); override;
     procedure SetAsFloat(AValue: Double); override;
     procedure SetAsLargeInt(AValue: LargeInt); override;
-    procedure SetAsLongint(AValue: Longint); override;
+    procedure SetAsInteger(AValue: Longint); override;
     procedure SetAsString(const AValue: string); override;
     procedure SetVarValue(const AValue: Variant); override;
   public
@@ -677,12 +677,12 @@ type
     function GetAsBoolean: Boolean; override;
     function GetAsString: string; override;
     function GetAsVariant: variant; override;
-    function GetAsLongint: Longint; override;
+    function GetAsInteger: Longint; override;
     function GetDataSize: Integer; override;
     function GetDefaultWidth: Longint; override;
     procedure SetAsBoolean(AValue: Boolean); override;
     procedure SetAsString(const AValue: string); override;
-    procedure SetAsLongint(AValue: Longint); override;
+    procedure SetAsInteger(AValue: Longint); override;
     procedure SetVarValue(const AValue: Variant); override;
   public
     constructor Create(AOwner: TComponent); override;
@@ -783,7 +783,7 @@ type
     function GetAsBCD: TBCD; override;
     function GetAsCurrency: Currency; override;
     function GetAsFloat: Double; override;
-    function GetAsLongint: Longint; override;
+    function GetAsInteger: Longint; override;
     function GetAsString: string; override;
     function GetValue(var AValue: Currency): Boolean;
     function GetAsVariant: variant; override;
@@ -792,7 +792,7 @@ type
     procedure GetText(var TheText: string; ADisplayText: Boolean); override;
     procedure SetAsBCD(const AValue: TBCD); override;
     procedure SetAsFloat(AValue: Double); override;
-    procedure SetAsLongint(AValue: Longint); override;
+    procedure SetAsInteger(AValue: Longint); override;
     procedure SetAsString(const AValue: string); override;
     procedure SetAsCurrency(AValue: Currency); override;
     procedure SetVarValue(const AValue: Variant); override;
@@ -826,7 +826,7 @@ type
     function GetAsCurrency: Currency; override;
     function GetAsFloat: Double; override;
     function GetAsLargeInt: LargeInt; override;
-    function GetAsLongint: Longint; override;
+    function GetAsInteger: Longint; override;
     function GetAsString: string; override;
     function GetAsVariant: variant; override;
     function GetDataSize: Integer; override;
@@ -835,7 +835,7 @@ type
     procedure SetAsBCD(const AValue: TBCD); override;
     procedure SetAsFloat(AValue: Double); override;
     procedure SetAsLargeInt(AValue: LargeInt); override;
-    procedure SetAsLongint(AValue: Longint); override;
+    procedure SetAsInteger(AValue: Longint); override;
     procedure SetAsString(const AValue: string); override;
     procedure SetAsCurrency(AValue: Currency); override;
     procedure SetVarValue(const AValue: Variant); override;
@@ -942,8 +942,8 @@ type
     function GetAsFloat: Double; override;
     procedure SetAsFloat(aValue: Double); override;
 
-    function GetAsLongint: Longint; override;
-    procedure SetAsLongint(aValue: Longint); override;
+    function GetAsInteger: Longint; override;
+    procedure SetAsInteger(AValue: Longint); override;
 
     function GetAsString: string; override;
     procedure SetAsString(const aValue: string); override;

+ 33 - 33
packages/fcl-db/src/base/fields.inc

@@ -448,22 +448,22 @@ end;
 function TField.GetAsLongint: Longint;
 
 begin
-  raise AccessError(SInteger);
+  Result:=GetAsInteger;
 end;
 
-function TField.GetAsVariant: Variant;
+function TField.GetAsInteger: Longint;
 
 begin
-  raise AccessError(SVariant);
+  raise AccessError(SInteger);
 end;
 
-
-function TField.GetAsInteger: Integer;
+function TField.GetAsVariant: Variant;
 
 begin
-  Result:=GetAsLongint;
+  raise AccessError(SVariant);
 end;
 
+
 function TField.GetAsString: string;
 
 begin
@@ -797,13 +797,13 @@ end;
 procedure TField.SetAsLongint(AValue: Longint);
 
 begin
-  Raise AccessError(SInteger);
+  SetAsInteger(AValue);
 end;
 
-procedure TField.SetAsInteger(AValue: Integer);
+procedure TField.SetAsInteger(AValue: Longint);
 
 begin
-  SetAsLongint(AValue);
+  raise AccessError(SInteger);
 end;
 
 procedure TField.SetAsLargeint(AValue: Largeint);
@@ -1055,7 +1055,7 @@ begin
   Result:=StrToFloat(GetAsString);
 end;
 
-function TStringField.GetAsLongint: Longint;
+function TStringField.GetAsInteger: Longint;
 
 begin
   Result:=StrToInt(GetAsString);
@@ -1159,7 +1159,7 @@ begin
   SetAsString(FloatToStr(AValue));
 end;
 
-procedure TStringField.SetAsLongint(AValue: Longint);
+procedure TStringField.SetAsInteger(AValue: Longint);
 
 begin
   SetAsString(intToStr(AValue));
@@ -1354,7 +1354,7 @@ end;
 
 procedure TNumericField.SetAsBoolean(AValue: Boolean);
 begin
-  SetAsLongint(ord(AValue));
+  SetAsInteger(ord(AValue));
 end;
 
 { ---------------------------------------------------------------------
@@ -1375,15 +1375,15 @@ end;
 function TLongintField.GetAsFloat: Double;
 
 begin
-  Result:=GetAsLongint;
+  Result:=GetAsInteger;
 end;
 
 function TLongintField.GetAsLargeint: Largeint;
 begin
-  Result:=GetAsLongint;
+  Result:=GetAsInteger;
 end;
 
-function TLongintField.GetAsLongint: Longint;
+function TLongintField.GetAsInteger: Longint;
 
 begin
   If Not GetValue(Result) then
@@ -1455,7 +1455,7 @@ end;
 procedure TLongintField.SetAsLargeint(AValue: Largeint);
 begin
   if (AValue>=FMinRange) and (AValue<=FMaxRange) then
-    SetAsLongint(AValue)
+    SetAsInteger(AValue)
   else
     RangeError(AValue,FMinRange,FMaxRange);
 end;
@@ -1463,10 +1463,10 @@ end;
 procedure TLongintField.SetAsFloat(AValue: Double);
 
 begin
-  SetAsLongint(Round(AValue));
+  SetAsInteger(Round(AValue));
 end;
 
-procedure TLongintField.SetAsLongint(AValue: Longint);
+procedure TLongintField.SetAsInteger(AValue: Longint);
 
 begin
   If CheckRange(AValue) then
@@ -1477,7 +1477,7 @@ end;
 
 procedure TLongintField.SetVarValue(const AValue: Variant);
 begin
-  SetAsLongint(AValue);
+  SetAsInteger(AValue);
 end;
 
 procedure TLongintField.SetAsString(const AValue: string);
@@ -1491,7 +1491,7 @@ begin
     begin
     Val(AValue,L,Code);
     If Code=0 then
-      SetAsLongint(L)
+      SetAsInteger(L)
     else
       DatabaseErrorFMT(SNotAnInteger,[AValue]);
     end;
@@ -1573,7 +1573,7 @@ begin
     Result:=Null;
 end;
 
-function TLargeintField.GetAsLongint: Longint;
+function TLargeintField.GetAsInteger: Longint;
 
 begin
   Result:=GetAsLargeint;
@@ -1641,7 +1641,7 @@ begin
     RangeError(AValue,FMinRange,FMaxRange);
 end;
 
-procedure TLargeintField.SetAsLongint(AValue: Longint);
+procedure TLargeintField.SetAsInteger(AValue: Longint);
 
 begin
   SetAsLargeint(AValue);
@@ -1752,7 +1752,7 @@ begin
   SetDataType(ftAutoInc);
 end;
 
-Procedure TAutoIncField.SetAsLongint(AValue : Longint);
+Procedure TAutoIncField.SetAsInteger(AValue: Longint);
 
 begin
   // Some databases allows insertion of explicit values into identity columns
@@ -1802,7 +1802,7 @@ begin
   Result:=Round(GetAsFloat);
 end;
 
-function TFloatField.GetAsLongint: Longint;
+function TFloatField.GetAsInteger: Longint;
 
 begin
   Result:=Round(GetAsFloat);
@@ -1874,7 +1874,7 @@ begin
   SetAsFloat(AValue);
 end;
 
-procedure TFloatField.SetAsLongint(AValue: Longint);
+procedure TFloatField.SetAsInteger(AValue: Longint);
 
 begin
   SetAsFloat(AValue);
@@ -1978,12 +1978,12 @@ begin
     Result:=Length(FDisplays[false,True]);
 end;
 
-function TBooleanField.GetAsLongint: Longint;
+function TBooleanField.GetAsInteger: Longint;
 begin
   Result := ord(GetAsBoolean);
 end;
 
-procedure TBooleanField.SetAsLongint(AValue: Longint);
+procedure TBooleanField.SetAsInteger(AValue: Longint);
 begin
   SetAsBoolean(AValue<>0);
 end;
@@ -2425,7 +2425,7 @@ begin
 end;
 
 
-function TBCDField.GetAsLongint: Longint;
+function TBCDField.GetAsInteger: Longint;
 
 begin
   result := round(GetAsCurrency);
@@ -2523,7 +2523,7 @@ begin
 end;
 
 
-procedure TBCDField.SetAsLongint(AValue: Longint);
+procedure TBCDField.SetAsInteger(AValue: Longint);
 
 begin
   SetAsCurrency(AValue);
@@ -2626,7 +2626,7 @@ begin
     Result := 0;
 end;
 
-function TFMTBCDField.GetAsLongint: Longint;
+function TFMTBCDField.GetAsInteger: Longint;
 begin
   Result := round(GetAsFloat);
 end;
@@ -2721,7 +2721,7 @@ begin
   SetAsBCD(IntegerToBCD(AValue));
 end;
 
-procedure TFMTBCDField.SetAsLongint(AValue: Longint);
+procedure TFMTBCDField.SetAsInteger(AValue: Longint);
 begin
   SetAsBCD(IntegerToBCD(AValue));
 end;
@@ -3102,7 +3102,7 @@ begin
   Result := GetAsVariant;
 end;
 
-function TVariantField.GetAsLongint: Longint;
+function TVariantField.GetAsInteger: Longint;
 begin
   Result := GetAsVariant;
 end;
@@ -3138,7 +3138,7 @@ begin
   SetVarValue(aValue);
 end;
 
-procedure TVariantField.SetAsLongint(aValue: Longint);
+procedure TVariantField.SetAsInteger(AValue: Longint);
 begin
   SetVarValue(aValue);
 end;