|
From: <wp...@us...> - 2009-08-10 21:21:26
|
Revision: 819
http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=819&view=rev
Author: wp2udk
Date: 2009-08-10 21:21:19 +0000 (Mon, 10 Aug 2009)
Log Message:
-----------
Removal of several warnings:
- InstantCharInSet introduced: Should be used every time you need to check against sets of enumerated types.
- GetPropName introduced: Should be used every time you need to access PropInfo^.Name.
- Minor warnings are also removed
These code changes have only been tested against D2009.
Modified Paths:
--------------
trunk/Source/Core/InstantClasses.pas
trunk/Source/Core/InstantCode.pas
trunk/Source/Core/InstantCommand.pas
trunk/Source/Core/InstantExplorer.pas
trunk/Source/Core/InstantMetadata.pas
trunk/Source/Core/InstantPersistence.pas
trunk/Source/Core/InstantPresentation.pas
trunk/Source/Core/InstantRtti.pas
trunk/Source/Core/InstantTextFiler.pas
trunk/Source/Core/InstantUtils.pas
trunk/Source/Design/InstantCommandEditor.pas
Modified: trunk/Source/Core/InstantClasses.pas
===================================================================
--- trunk/Source/Core/InstantClasses.pas 2009-08-06 20:58:27 UTC (rev 818)
+++ trunk/Source/Core/InstantClasses.pas 2009-08-10 21:21:19 UTC (rev 819)
@@ -25,7 +25,7 @@
*
* Contributor(s):
* Carlo Barazzetta, Adrea Petrelli, Marco Cant\xF9, Nando Dessena, Uberto Barbini,
- * Riceball Lee
+ * Riceball Lee, Brian Andersen
*
* ***** END LICENSE BLOCK ***** *)
@@ -50,7 +50,12 @@
InstantBufferSize = 4096;
type
+{$IFDEF D12+}
+ TChars = set of AnsiChar; // Avoid WideChar reduced to byte warning
+{$ELSE}
TChars = set of Char;
+{$ENDIF}
+
{$IFDEF LINUX}
TDate = type TDateTime;
TTime = type TDateTime;
@@ -1411,7 +1416,7 @@
for I := 1 to Length(Data) do
begin
C := Data[I];
- if C in [#34, #38, #39, #60, #62] then
+ if InstantCharInSet(C, [#34, #38, #39, #60, #62]) then
begin
case C of
#34:
@@ -1659,7 +1664,7 @@
procedure TInstantXMLProcessor.SkipBlanks;
begin
- while PeekChar in [#1..#32] do
+ while InstantCharInSet(PeekChar, [#1..#32]) do
ReadChar;
end;
Modified: trunk/Source/Core/InstantCode.pas
===================================================================
--- trunk/Source/Core/InstantCode.pas 2009-08-06 20:58:27 UTC (rev 818)
+++ trunk/Source/Core/InstantCode.pas 2009-08-10 21:21:19 UTC (rev 819)
@@ -25,7 +25,7 @@
*
* Contributor(s):
* Carlo Barazzetta, Adrea Petrelli, Nando Dessena, Steven Mitchell,
- * Uberto Barbini, Joao Morais, Riceball Lee
+ * Uberto Barbini, Joao Morais, Riceball Lee, Brian Andersen
*
* ***** END LICENSE BLOCK ***** *)
@@ -2689,7 +2689,7 @@
begin
Name := Reader.ReadToken;
Reader.SkipSpace;
- Result := Reader.ReadChar in [':', ','];
+ Result := InstantCharInSet(Reader.ReadChar, [':', ',']);
end;
procedure TInstantCodeSymbol.InternalRead(Reader: TInstantCodeReader);
@@ -3933,14 +3933,14 @@
if Copy(Result, i, 1) = 's' then
begin
If (i > 3) and (Copy(Result, i - 2, 3) = 'ies') and
- not (Result[i - 3] in Vowels) then
+ not (InstantCharInSet(Result[i - 3], Vowels)) then
begin
Result := Copy(Result, 1, i - 3) + 'y';
end
else If (i > 3) and (Copy(Result, i - 1, 2) = 'es') and
- (Result[i - 2] in SpChars) then
+ (InstantCharInSet(Result[i - 2], SpChars)) then
begin
- if (Result[i - 2] = 'h') and not (Result[i - 3] in ['c', 's']) then
+ if (Result[i - 2] = 'h') and not (InstantCharInSet(Result[i - 3], ['c', 's'])) then
begin
//not ch or sh
Result := Copy(Result, 1, i - 1);
@@ -5761,7 +5761,7 @@
Reader.SkipSpace;
Reader.ReadToken;
Reader.SkipSpace;
- Result := Reader.NextChar in [':', '='];
+ Result := InstantCharInSet(Reader.NextChar, [':', '=']);
finally
Reader.Position := SavePos;
end;
@@ -8690,7 +8690,7 @@
if FCode^[I] = #10 then
begin
Inc(I);
- while FCode^[I] in [' ', #9] do
+ while InstantCharInSet(FCode^[I], [' ', #9]) do
begin
Result := Result + FCode^[I];
Inc(I);
Modified: trunk/Source/Core/InstantCommand.pas
===================================================================
--- trunk/Source/Core/InstantCommand.pas 2009-08-06 20:58:27 UTC (rev 818)
+++ trunk/Source/Core/InstantCommand.pas 2009-08-10 21:21:19 UTC (rev 819)
@@ -24,7 +24,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- * Nando Dessena, Andrea Magni
+ * Nando Dessena, Andrea Magni, Brian Andersen
*
* ***** END LICENSE BLOCK ***** *)
@@ -1121,7 +1121,7 @@
begin
Token := Reader.ReadToken;
Result := IsConstantToken(Token) or InstantIsNumeric(Token) or
- ((Length(Token) > 0) and (Token[1] in ['"', '''', '[']));
+ ((Length(Token) > 0) and (InstantCharInSet(Token[1], ['"', '''', '['])));
end;
procedure TInstantIQLConstant.InternalClear;
Modified: trunk/Source/Core/InstantExplorer.pas
===================================================================
--- trunk/Source/Core/InstantExplorer.pas 2009-08-06 20:58:27 UTC (rev 818)
+++ trunk/Source/Core/InstantExplorer.pas 2009-08-10 21:21:19 UTC (rev 819)
@@ -25,7 +25,7 @@
*
* Contributor(s):
* Carlo Barazzetta, Adrea Petrelli, Nando Dessena, Steven Mitchell,
- * Joao Morais
+ * Joao Morais, Brian Andersen
*
* ***** END LICENSE BLOCK ***** *)
@@ -561,7 +561,7 @@
Width := AParent.Width - Left - 8;
Anchors := [akLeft, akTop, akRight];
Parent := AParent;
- DataField := PropInfo.Name;
+ DataField := InstantGetPropName(PropInfo);
DataSource := ADataSource;
if not Assigned(PropInfo.SetProc) then
begin
@@ -574,7 +574,7 @@
Left := 8;
Top := ATop + 3;
Parent := AParent;
- Caption := PropInfo.Name;
+ Caption := InstantGetPropName(PropInfo);
FocusControl := Edit;
end;
Inc(ATop, Edit.Height);
Modified: trunk/Source/Core/InstantMetadata.pas
===================================================================
--- trunk/Source/Core/InstantMetadata.pas 2009-08-06 20:58:27 UTC (rev 818)
+++ trunk/Source/Core/InstantMetadata.pas 2009-08-10 21:21:19 UTC (rev 819)
@@ -26,7 +26,7 @@
* Contributor(s):
* Carlo Barazzetta, Andrea Petrelli, Nando Dessena, Steven Mitchell,
* Joao Morais, Cesar Coll, Uberto Barbini, David Taylor, Hanedi Salas,
- * Riceball Lee, David Moorhouse
+ * Riceball Lee, David Moorhouse, Brian Andersen
*
* ***** END LICENSE BLOCK ***** *)
@@ -67,7 +67,7 @@
protected
function InternalEquals(const Other: TInstantMetadata): Boolean; virtual;
public
- function Equals(const Other: TInstantMetadata): Boolean;
+ function Equals(const Other: TInstantMetadata): Boolean; {$IFDEF D12+} reintroduce; {$ENDIF} overload;
property Collection: TInstantMetadatas read GetCollection
write SetCollection;
end;
Modified: trunk/Source/Core/InstantPersistence.pas
===================================================================
--- trunk/Source/Core/InstantPersistence.pas 2009-08-06 20:58:27 UTC (rev 818)
+++ trunk/Source/Core/InstantPersistence.pas 2009-08-10 21:21:19 UTC (rev 819)
@@ -26,7 +26,7 @@
* Contributor(s):
* Carlo Barazzetta, Andrea Petrelli, Nando Dessena, Steven Mitchell,
* Joao Morais, Cesar Coll, Uberto Barbini, David Taylor, Hanedi Salas,
- * Riceball Lee, David Moorhouse
+ * Riceball Lee, David Moorhouse, Brian Andersen
*
* ***** END LICENSE BLOCK ***** *)
@@ -129,8 +129,8 @@
function Dereference(Connector: TInstantConnector = nil;
AOwnsInstance: Boolean = True; Retry: Boolean = False): TInstantObject;
procedure DestroyInstance;
- function Equals(const AObjectClassName, AObjectId: string): Boolean; overload;
- function Equals(AObject: TInstantObject): Boolean; overload;
+ function Equals(const AObjectClassName, AObjectId: string): Boolean; {$IFDEF D12+}reintroduce;{$ENDIF} overload;
+ function Equals(AObject: TInstantObject): Boolean; {$IFDEF D12+}reintroduce;{$ENDIF} overload;
function HasInstance: Boolean;
function HasReference: Boolean;
function IsBroken: Boolean;
@@ -1622,7 +1622,7 @@
begin
Result := True;
for I := 0 to Pred(BufferLength div SizeOf(Char)) do
- if (ValidChars <> []) and not (Buffer[I] in ValidChars + [#8, #10, #13]) then
+ if (ValidChars <> []) and not (InstantCharInSet(Buffer[I], ValidChars + [#8, #10, #13])) then
begin
Result := False;
InvalidChar := Buffer[I];
Modified: trunk/Source/Core/InstantPresentation.pas
===================================================================
--- trunk/Source/Core/InstantPresentation.pas 2009-08-06 20:58:27 UTC (rev 818)
+++ trunk/Source/Core/InstantPresentation.pas 2009-08-10 21:21:19 UTC (rev 819)
@@ -25,7 +25,7 @@
*
* Contributor(s):
* Carlo Barazzetta, Andrea Petrelli, Nando Dessena, Joao Morais,
- * Steven Mitchell
+ * Steven Mitchell, Brian Andersen
*
* ***** END LICENSE BLOCK ***** *)
@@ -1006,13 +1006,13 @@
Items.AddObject(Prefix + Names[I], Pointer(PropInfo));
if Traverse then
begin
- Path := AClass.ClassName + '.' + PropInfo.Name;
+ Path := AClass.ClassName + '.' + InstantGetPropName(PropInfo);
if Circular or (Paths.IndexOf(Path) = -1) then
begin
PathIndex := Paths.Add(Path);
try
TypeData := GetTypeData(PropInfo.PropType^);
- AddProperties(Prefix + PropInfo.Name + '.', TypeData.ClassType,
+ AddProperties(Prefix + InstantGetPropName(PropInfo) + '.', TypeData.ClassType,
Items, Paths);
finally
Paths.Delete(PathIndex);
@@ -2037,12 +2037,12 @@
Relation: string;
Index: Integer;
begin
- Relation := AClass.ClassName + '.' + PropInfo.Name;
- if BreakThorough(Prefix + PropInfo.Name) then
+ Relation := AClass.ClassName + '.' + InstantGetPropName(PropInfo);
+ if BreakThorough(Prefix + InstantGetPropName(PropInfo)) then
Exit;
if (Relations.IndexOf(Relation) = -1) or
- IncludeField(Prefix + '.' + PropInfo.Name, False) then
+ IncludeField(Prefix + '.' + InstantGetPropName(PropInfo), False) then
begin
Relations.Add(Relation);
try
@@ -2256,7 +2256,7 @@
Result := nil;
if not Assigned(PropInfo) then
Exit;
- FieldName := Prefix + PropInfo^.Name;
+ FieldName := Prefix + InstantGetPropName(PropInfo);
FieldSize := 0;
FieldAttribs := [];
TypeKind := PropInfo^.PropType^^.Kind;
Modified: trunk/Source/Core/InstantRtti.pas
===================================================================
--- trunk/Source/Core/InstantRtti.pas 2009-08-06 20:58:27 UTC (rev 818)
+++ trunk/Source/Core/InstantRtti.pas 2009-08-10 21:21:19 UTC (rev 819)
@@ -24,7 +24,8 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- * Carlo Barazzetta, Adrea Petrelli, Uberto Barbini, Nando Dessena
+ * Carlo Barazzetta, Adrea Petrelli, Uberto Barbini, Nando Dessena,
+ * Brian Andersen
*
* ***** END LICENSE BLOCK ***** *)
@@ -77,6 +78,7 @@
procedure InstantSetProperty(AObject: TObject; PropPath: string; Value: Variant);
function InstantIsDefaultPropertyValue(Instance: TObject;
PropInfo: PPropInfo): Boolean;
+function InstantGetPropName(PropInfo: PPropInfo): string;
implementation
@@ -134,18 +136,18 @@
Value := 1;
end;
{$ENDIF}
- SetPropValue(AObject, PropInfo^.Name, Value);
+ SetPropValue(AObject, InstantGetPropName(PropInfo), Value);
end;
tkSet:
if VarToStr(Value) = '' then
- SetPropValue(AObject, PropInfo^.Name, '[]')
+ SetPropValue(AObject, InstantGetPropName(PropInfo), '[]')
else
- SetPropValue(AObject, PropInfo^.Name, Value);
+ SetPropValue(AObject, InstantGetPropName(PropInfo), Value);
else
- SetPropValue(AObject, PropInfo^.Name, Value);
+ SetPropValue(AObject, InstantGetPropName(PropInfo), Value);
end;
end;
- Result := GetPropValue(AObject, PropInfo^.Name);
+ Result := GetPropValue(AObject, InstantGetPropName(PropInfo));
end else
Result := Null;
end else
@@ -294,6 +296,15 @@
end;
end;
+function InstantGetPropName(PropInfo: PPropInfo): string;
+begin
+{$IFNDEF D12+}
+ Result := PropInfo^.Name;
+{$ELSE}
+ Result := GetPropName(PropInfo);
+{$ENDIF}
+end;
+
{ TInstantProperties }
constructor TInstantProperties.Create(AInstance: TObject);
@@ -363,7 +374,7 @@
function TInstantProperties.GetNames(Index: Integer): string;
begin
- Result := PropInfos[Index]^.Name;
+ Result := InstantGetPropName(PropInfos[Index]);
end;
function TInstantProperties.GetPropInfos(Index: Integer): PPropInfo;
Modified: trunk/Source/Core/InstantTextFiler.pas
===================================================================
--- trunk/Source/Core/InstantTextFiler.pas 2009-08-06 20:58:27 UTC (rev 818)
+++ trunk/Source/Core/InstantTextFiler.pas 2009-08-10 21:21:19 UTC (rev 819)
@@ -24,7 +24,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- * Carlo Barazzetta, Adrea Petrelli, Nando Dessena
+ * Carlo Barazzetta, Adrea Petrelli, Nando Dessena, Brian Andersen
*
* ***** END LICENSE BLOCK ***** *)
@@ -236,7 +236,7 @@
function TInstantTextFiler.IsSpace(Ch: Char): Boolean;
begin
- Result := Ch in [' ', #9, #10, #13];
+ Result := InstantCharInSet(Ch, [' ', #9, #10, #13]);
end;
function TInstantTextFiler.IsText(Ch: Char): Boolean;
@@ -244,7 +244,7 @@
Result := ((Ch >= 'a') and (Ch <= 'z'))
or ((Ch >= 'A') and (Ch <= 'Z'))
or ((Ch >= '0') and (Ch <= '9'))
- or (Ch in ['#', '_']);
+ or (InstantCharInSet(Ch, ['#', '_']));
end;
procedure TInstantTextFiler.Reset;
@@ -325,7 +325,7 @@
function TInstantTextReader.IsStringDelimiter(Ch: Char): Boolean;
begin
- Result := ConstAware and (Ch in ['''', '"']);
+ Result := ConstAware and (InstantCharInSet(Ch, ['''', '"']));
end;
function TInstantTextReader.NextChar: Char;
Modified: trunk/Source/Core/InstantUtils.pas
===================================================================
--- trunk/Source/Core/InstantUtils.pas 2009-08-06 20:58:27 UTC (rev 818)
+++ trunk/Source/Core/InstantUtils.pas 2009-08-10 21:21:19 UTC (rev 819)
@@ -24,7 +24,8 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- * Carlo Barazzetta, Adrea Petrelli, Nando Dessena, Uberto Barbini
+ * Carlo Barazzetta, Adrea Petrelli, Nando Dessena, Uberto Barbini,
+ * Brian Andersen
*
* ***** END LICENSE BLOCK ***** *)
@@ -39,7 +40,7 @@
interface
uses
- Classes, InstantClasses;
+ Classes, InstantClasses, SysUtils;
type
TInstantCompareOption = (coCaseInsensitive, coPartial);
@@ -93,6 +94,10 @@
function TimeOf(const AValue: TDateTime): TDateTime;
{$ENDIF}
+function InstantCharInSet(C: AnsiChar; const CharSet: TSysCharSet): Boolean; overload;
+function InstantCharInSet(C: WideChar; const CharSet: TSysCharSet): Boolean; overload;
+
+
implementation
uses
@@ -102,8 +107,7 @@
{$IFDEF FPC}
InstantFpcUtils,
{$ENDIF}
- {$IFDEF D6+}Variants,{$ENDIF} InstantConsts, InstantRtti,
- SysUtils;
+ {$IFDEF D6+}Variants,{$ENDIF} InstantConsts, InstantRtti;
function InstantCharSetToStr(C: TChars): string;
var
@@ -112,7 +116,7 @@
begin
Result := '';
for I := 0 to 255 do
- if Chr(I) in C then
+ if InstantCharInSet(Chr(I), C) then
S := S + Chr(I);
I := 1;
L := Length(S);
@@ -570,7 +574,7 @@
I: Integer;
begin
I := Pos;
- while (I <= Length(Str)) and not (Str[I] in Delimiters) do
+ while (I <= Length(Str)) and not (InstantCharInSet(Str[I], Delimiters)) do
Inc(I);
Result := Copy(Str, Pos, I - Pos);
if I <= Length(Str) then
@@ -637,4 +641,22 @@
end;
{$ENDIF}
+function InstantCharInSet(C: AnsiChar; const CharSet: TSysCharSet): Boolean;
+begin
+{$IFNDEF D12+}
+ Result := C in CharSet;
+{$ELSE}
+ Result := CharInSet(C, CharSet);
+{$ENDIF}
+end;
+
+function InstantCharInSet(C: WideChar; const CharSet: TSysCharSet): Boolean;
+begin
+{$IFNDEF D12+}
+ Result := (C < #$0100) and (AnsiChar(C) in CharSet);
+{$ELSE}
+ Result := CharInSet(C, CharSet);
+{$ENDIF}
+end;
+
end.
Modified: trunk/Source/Design/InstantCommandEditor.pas
===================================================================
--- trunk/Source/Design/InstantCommandEditor.pas 2009-08-06 20:58:27 UTC (rev 818)
+++ trunk/Source/Design/InstantCommandEditor.pas 2009-08-10 21:21:19 UTC (rev 819)
@@ -24,7 +24,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- * Carlo Barazzetta, Adrea Petrelli, Nando Dessena
+ * Carlo Barazzetta, Adrea Petrelli, Nando Dessena, Brian Andersen
*
* ***** END LICENSE BLOCK ***** *)
@@ -114,7 +114,8 @@
implementation
uses
- InstantPersistence, InstantPresentation, InstantMetadata, InstantTypes;
+ InstantPersistence, InstantPresentation, InstantMetadata, InstantTypes,
+ InstantUtils;
{$R *.dfm}
@@ -177,7 +178,7 @@
function IsSpace(Ch: Char): Boolean;
begin
- Result := Ch in [' ', #9, #10, #13];
+ Result := InstantCharInSet(Ch, [' ', #9, #10, #13]);
end;
var
|