IDE: add const for string parameters in resource handling classes

git-svn-id: trunk@52402 -
This commit is contained in:
blikblum 2016-05-28 14:42:39 +00:00
parent b2605a63b4
commit 0f8dcb2831
6 changed files with 54 additions and 44 deletions

View File

@ -31,8 +31,8 @@ type
procedure DoAfterBuild({%H-}AResources: TAbstractProjectResources; {%H-}AReason: TCompileReason; {%H-}SaveToTestDir: boolean); virtual;
procedure DoBeforeBuild({%H-}AResources: TAbstractProjectResources; {%H-}AReason: TCompileReason; {%H-}SaveToTestDir: boolean); virtual;
function UpdateResources(AResources: TAbstractProjectResources; const MainFilename: string): Boolean; virtual; abstract;
procedure WriteToProjectFile(AConfig: {TXMLConfig}TObject; Path: String); virtual; abstract;
procedure ReadFromProjectFile(AConfig: {TXMLConfig}TObject; Path: String); virtual; abstract;
procedure WriteToProjectFile(AConfig: {TXMLConfig}TObject; const Path: String); virtual; abstract;
procedure ReadFromProjectFile(AConfig: {TXMLConfig}TObject; const Path: String); virtual; abstract;
property Modified: boolean read FModified write SetModified;
property OnModified: TNotifyEvent read FOnModified write FOnModified;

View File

@ -63,8 +63,8 @@ type
function UpdateResources(AResources: TAbstractProjectResources;
const MainFilename: string): Boolean; override;
procedure WriteToProjectFile(AConfig: {TXMLConfig}TObject; Path: String); override;
procedure ReadFromProjectFile(AConfig: {TXMLConfig}TObject; Path: String); override;
procedure WriteToProjectFile(AConfig: {TXMLConfig}TObject; const Path: String); override;
procedure ReadFromProjectFile(AConfig: {TXMLConfig}TObject; const Path: String); override;
function SaveIconFile: Boolean;
@ -164,12 +164,12 @@ begin
AResources.AddSystemResource(ARes);
end;
procedure TProjectIcon.WriteToProjectFile(AConfig: TObject; Path: String);
procedure TProjectIcon.WriteToProjectFile(AConfig: TObject; const Path: String);
begin
TXMLConfig(AConfig).SetDeleteValue(Path+'General/Icon/Value', BoolToStr(IsEmpty), BoolToStr(true));
end;
procedure TProjectIcon.ReadFromProjectFile(AConfig: TObject; Path: String);
procedure TProjectIcon.ReadFromProjectFile(AConfig: TObject; const Path: String);
begin
with TXMLConfig(AConfig) do
begin

View File

@ -100,15 +100,15 @@ type
procedure Clear;
function Regenerate(const MainFileName: String;
UpdateSource, PerformSave: boolean;
SaveToTestDir: string): Boolean;
const SaveToTestDir: string): Boolean;
function RenameDirectives(const CurFileName, NewFileName: String): Boolean;
procedure DeleteResourceBuffers;
function HasSystemResources: Boolean;
function HasLazarusResources: Boolean;
procedure WriteToProjectFile(AConfig: TXMLConfig; Path: String);
procedure ReadFromProjectFile(AConfig: TXMLConfig; Path: String; ReadAll: Boolean);
procedure WriteToProjectFile(AConfig: TXMLConfig; const Path: String);
procedure ReadFromProjectFile(AConfig: TXMLConfig; const Path: String; ReadAll: Boolean);
property Modified: Boolean read FModified write SetModified;
property OnModified: TNotifyEvent read FOnModified write FOnModified;
@ -506,8 +506,8 @@ begin
FMessages.Clear;
end;
function TProjectResources.Regenerate(const MainFileName: String;
UpdateSource, PerformSave: boolean; SaveToTestDir: string): Boolean;
function TProjectResources.Regenerate(const MainFileName: String; UpdateSource,
PerformSave: boolean; const SaveToTestDir: string): Boolean;
begin
//DebugLn(['TProjectResources.Regenerate MainFilename=',MainFilename,' UpdateSource=',UpdateSource,' PerformSave=',PerformSave]);
//DumpStack;
@ -558,7 +558,8 @@ begin
Result := FLazarusResources.Count > 0;
end;
procedure TProjectResources.WriteToProjectFile(AConfig: TXMLConfig; Path: String);
procedure TProjectResources.WriteToProjectFile(AConfig: TXMLConfig;
const Path: String);
var
i: integer;
begin
@ -567,7 +568,8 @@ begin
FResources[i].WriteToProjectFile(AConfig, Path);
end;
procedure TProjectResources.ReadFromProjectFile(AConfig: TXMLConfig; Path: String; ReadAll: Boolean);
procedure TProjectResources.ReadFromProjectFile(AConfig: TXMLConfig;
const Path: String; ReadAll: Boolean);
var
i: integer;
begin

View File

@ -57,10 +57,10 @@ type
FileName: String;
ResType: TUserResourceType;
ResName: String;
procedure ReadFromProjectFile(AConfig: TXMLConfig; Path: String);
procedure WriteToProjectFile(AConfig: TXMLConfig; Path: String);
function CreateResource(ProjectDirectory: String): TAbstractResource;
function GetRealFileName(ProjectDirectory: String): String;
procedure ReadFromProjectFile(AConfig: TXMLConfig; const Path: String);
procedure WriteToProjectFile(AConfig: TXMLConfig; const Path: String);
function CreateResource(const ProjectDirectory: String): TAbstractResource;
function GetRealFileName(const ProjectDirectory: String): String;
end;
{ TResourceList }
@ -72,7 +72,7 @@ type
procedure Notify(Ptr: Pointer; Action: TListNotification); override;
public
function AddItem: PResourceItem;
procedure AddResource(FileName: String; ResType: TUserResourceType; ResName: String);
procedure AddResource(const FileName: String; ResType: TUserResourceType; const ResName: String);
property Items[AIndex: Integer]: PResourceItem read GetItem; default;
end;
@ -87,8 +87,8 @@ type
function UpdateResources(AResources: TAbstractProjectResources;
const MainFilename: string): Boolean; override;
procedure WriteToProjectFile(AConfig: {TXMLConfig}TObject; Path: String); override;
procedure ReadFromProjectFile(AConfig: {TXMLConfig}TObject; Path: String); override;
procedure WriteToProjectFile(AConfig: {TXMLConfig}TObject; const Path: String); override;
procedure ReadFromProjectFile(AConfig: {TXMLConfig}TObject; const Path: String); override;
property List: TResourceList read FList;
end;
@ -101,11 +101,11 @@ const
{ rtRCData } 'RCDATA'
);
function StrToResourceType(AStr: String): TUserResourceType;
function StrToResourceType(const AStr: String): TUserResourceType;
implementation
function StrToResourceType(AStr: String): TUserResourceType;
function StrToResourceType(const AStr: String): TUserResourceType;
begin
case AStr of
'ICON': Result := rtIcon;
@ -119,21 +119,23 @@ end;
{ TResourceItem }
procedure TResourceItem.ReadFromProjectFile(AConfig: TXMLConfig; Path: String);
procedure TResourceItem.ReadFromProjectFile(AConfig: TXMLConfig;
const Path: String);
begin
FileName := AConfig.GetValue(Path + 'FileName', '');
ResType := StrToResourceType(AConfig.GetValue(Path + 'Type', ''));
ResName := AConfig.GetValue(Path + 'ResourceName', '');
end;
procedure TResourceItem.WriteToProjectFile(AConfig: TXMLConfig; Path: String);
procedure TResourceItem.WriteToProjectFile(AConfig: TXMLConfig;
const Path: String);
begin
AConfig.SetValue(Path + 'FileName', FileName);
AConfig.SetValue(Path + 'Type', ResourceTypeToStr[ResType]);
AConfig.SetValue(Path + 'ResourceName', ResName);
end;
function TResourceItem.CreateResource(ProjectDirectory: String): TAbstractResource;
function TResourceItem.CreateResource(const ProjectDirectory: String): TAbstractResource;
var
Stream: TFileStream;
TypeDesc, NameDesc: TResourceDesc;
@ -188,7 +190,7 @@ begin
AddIDEMessage(mluError,Format(lisFileNotFound2, [Filename]));
end;
function TResourceItem.GetRealFileName(ProjectDirectory: String): String;
function TResourceItem.GetRealFileName(const ProjectDirectory: String): String;
begin
Result := FileName;
if not IDEMacros.SubstituteMacros(Result) then
@ -219,8 +221,8 @@ begin
Add(Result);
end;
procedure TResourceList.AddResource(FileName: String; ResType: TUserResourceType;
ResName: String);
procedure TResourceList.AddResource(const FileName: String;
ResType: TUserResourceType; const ResName: String);
var
Data: PResourceItem;
begin
@ -246,7 +248,8 @@ begin
end;
end;
procedure TProjectUserResources.WriteToProjectFile(AConfig: TObject; Path: String);
procedure TProjectUserResources.WriteToProjectFile(AConfig: TObject;
const Path: String);
var
I: Integer;
begin
@ -255,7 +258,8 @@ begin
List[I]^.WriteToProjectFile(TXMLConfig(AConfig), Path + 'General/Resources/Resource_' + IntToStr(I) + '/')
end;
procedure TProjectUserResources.ReadFromProjectFile(AConfig: TObject; Path: String);
procedure TProjectUserResources.ReadFromProjectFile(AConfig: TObject;
const Path: String);
var
I, Count: Integer;
begin

View File

@ -63,8 +63,8 @@ type
public
constructor Create; override;
function UpdateResources(AResources: TAbstractProjectResources; const {%H-}MainFilename: string): Boolean; override;
procedure WriteToProjectFile(AConfig: {TXMLConfig}TObject; Path: String); override;
procedure ReadFromProjectFile(AConfig: {TXMLConfig}TObject; Path: String); override;
procedure WriteToProjectFile(AConfig: {TXMLConfig}TObject; const Path: String); override;
procedure ReadFromProjectFile(AConfig: {TXMLConfig}TObject; const Path: String); override;
property UseManifest: boolean read FUseManifest write SetUseManifest;
property DpiAware: boolean read FIsDpiaAware write SetDpiAware;
@ -183,7 +183,8 @@ begin
end;
end;
procedure TProjectXPManifest.WriteToProjectFile(AConfig: TObject; Path: String);
procedure TProjectXPManifest.WriteToProjectFile(AConfig: TObject;
const Path: String);
begin
TXMLConfig(AConfig).SetDeleteValue(Path+'General/UseXPManifest/Value', UseManifest, False);
TXMLConfig(AConfig).SetDeleteValue(Path+'General/XPManifest/DpiAware/Value', DpiAware, False);
@ -191,7 +192,8 @@ begin
TXMLConfig(AConfig).SetDeleteValue(Path+'General/XPManifest/UIAccess/Value', UIAccess, False);
end;
procedure TProjectXPManifest.ReadFromProjectFile(AConfig: TObject; Path: String);
procedure TProjectXPManifest.ReadFromProjectFile(AConfig: TObject;
const Path: String);
begin
UseManifest := TXMLConfig(AConfig).GetValue(Path+'General/UseXPManifest/Value', False);
DpiAware := TXMLConfig(AConfig).GetValue(Path+'General/XPManifest/DpiAware/Value', False);

View File

@ -51,8 +51,8 @@ type
TProjectVersionStringTable = class(TVersionStringTable)
private
FOnModified: TNotifyEvent;
function GetValues(Key: string): string;
procedure SetValues(Key: string; const AValue: string);
function GetValues(const Key: string): string;
procedure SetValues(const Key: string; const AValue: string);
protected
procedure DoModified;
function KeyToIndex(const aKey: String): Integer;
@ -115,8 +115,8 @@ type
AReason: TCompileReason; {%H-}SaveToTestDir: boolean); override;
function UpdateResources(AResources: TAbstractProjectResources;
const {%H-}MainFilename: string): boolean; override;
procedure WriteToProjectFile(AConfig: {TXMLConfig}TObject; Path: string); override;
procedure ReadFromProjectFile(AConfig: {TXMLConfig}TObject; Path: string); override;
procedure WriteToProjectFile(AConfig: {TXMLConfig}TObject; const Path: string); override;
procedure ReadFromProjectFile(AConfig: {TXMLConfig}TObject; const Path: string); override;
property UseVersionInfo: boolean read FUseVersionInfo write SetUseVersionInfo;
property AutoIncrementBuild: boolean read FAutoIncrementBuild write SetAutoIncrementBuild;
@ -422,7 +422,8 @@ begin
end;
end;
procedure TProjectVersionInfo.WriteToProjectFile(AConfig: TObject; Path: string);
procedure TProjectVersionInfo.WriteToProjectFile(AConfig: TObject;
const Path: string);
var
i: integer;
Key: string;
@ -460,7 +461,8 @@ begin
end;
end;
procedure TProjectVersionInfo.ReadFromProjectFile(AConfig: TObject; Path: string);
procedure TProjectVersionInfo.ReadFromProjectFile(AConfig: TObject;
const Path: string);
var
i: integer;
Node: TDomNode;
@ -681,7 +683,7 @@ end;
{ TProjectVersionStringTable }
function TProjectVersionStringTable.GetValues(Key: string): string;
function TProjectVersionStringTable.GetValues(const Key: string): string;
var
idx: Integer;
begin
@ -692,7 +694,8 @@ begin
Result := ValuesByIndex[idx];
end;
procedure TProjectVersionStringTable.SetValues(Key: string; const AValue: string);
procedure TProjectVersionStringTable.SetValues(const Key: string;
const AValue: string);
var
idx: Integer;
begin
@ -722,8 +725,7 @@ begin
// - SpecialBuild
end;
function TProjectVersionStringTable.Equals(aTable: TProjectVersionStringTable
): boolean;
function TProjectVersionStringTable.Equals(aTable: TProjectVersionStringTable): boolean;
var
i: Integer;
begin