mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 00:09:26 +02:00
IDE: new package unit: use compiler options for mode directive
git-svn-id: trunk@23287 -
This commit is contained in:
parent
54c8997fd4
commit
77b42d4ccc
@ -569,6 +569,7 @@ type
|
||||
ResourceName: string): string; virtual;
|
||||
function GetImplementationSource(const Filename, SourceName,
|
||||
ResourceName: string): string; virtual;
|
||||
class function CompilerOptionsToUnitDirectives(CompOpts: TLazCompilerOptions): string;
|
||||
end;
|
||||
|
||||
|
||||
@ -1348,21 +1349,10 @@ begin
|
||||
end;
|
||||
|
||||
function TFileDescPascalUnit.GetUnitDirectives: string;
|
||||
var
|
||||
Project: TLazProject;
|
||||
SyntaxMode: String;
|
||||
begin
|
||||
Result:='{$mode objfpc}{$H+}';
|
||||
if Owner is TLazProject then begin
|
||||
Project:=TLazProject(Owner);
|
||||
SyntaxMode:=Project.LazCompilerOptions.SyntaxMode;
|
||||
if SyntaxMode<>'' then begin
|
||||
Result:='{$mode '+lowercase(SyntaxMode)+'}';
|
||||
if Project.LazCompilerOptions.UseAnsiStrings
|
||||
and (SysUtils.CompareText(SyntaxMode,'Delphi')<>0) then
|
||||
Result:=Result+'{$H+}';
|
||||
end;
|
||||
end;
|
||||
if Owner is TLazProject then
|
||||
Result:=CompilerOptionsToUnitDirectives(TLazProject(Owner).LazCompilerOptions);
|
||||
end;
|
||||
|
||||
function TFileDescPascalUnit.GetInterfaceUsesSection: string;
|
||||
@ -1382,6 +1372,22 @@ begin
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
class function TFileDescPascalUnit.CompilerOptionsToUnitDirectives(
|
||||
CompOpts: TLazCompilerOptions): string;
|
||||
var
|
||||
SyntaxMode: String;
|
||||
begin
|
||||
Result:='{$mode objfpc}{$H+}';
|
||||
if CompOpts=nil then exit;
|
||||
SyntaxMode:=CompOpts.SyntaxMode;
|
||||
if SyntaxMode<>'' then begin
|
||||
Result:='{$mode '+lowercase(SyntaxMode)+'}';
|
||||
if CompOpts.UseAnsiStrings
|
||||
and (SysUtils.CompareText(SyntaxMode,'Delphi')<>0) then
|
||||
Result:=Result+'{$H+}';
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TFileDescPascalUnitWithResource }
|
||||
|
||||
function TFileDescPascalUnitWithResource.GetResourceType: TLFMResourceType;
|
||||
|
@ -57,6 +57,7 @@ type
|
||||
);
|
||||
|
||||
TAddToPkgResult = class
|
||||
Pkg: TLazPackage;
|
||||
AddType: TAddToPkgType;
|
||||
Dependency: TPkgDependency;
|
||||
UnitFilename: string;
|
||||
@ -937,6 +938,7 @@ procedure TAddToPackageDlg.SetLazPackage(const AValue: TLazPackage);
|
||||
begin
|
||||
if FLazPackage=AValue then exit;
|
||||
FLazPackage:=AValue;
|
||||
Params.Pkg:=FLazPackage;
|
||||
UpdateAvailableAncestorTypes;
|
||||
UpdateAvailablePageNames;
|
||||
UpdateAvailableDependencyNames;
|
||||
|
@ -747,6 +747,7 @@ var
|
||||
LE: String;
|
||||
UsesLine: String;
|
||||
NewSource: String;
|
||||
UnitDirectives: String;
|
||||
begin
|
||||
Result:=mrCancel;
|
||||
// create sourcecode
|
||||
@ -755,10 +756,15 @@ begin
|
||||
if (System.Pos(Params.UsedUnitname,UsesLine)<1)
|
||||
and (Params.UsedUnitname<>'') then
|
||||
UsesLine:=UsesLine+', '+Params.UsedUnitname;
|
||||
UnitDirectives:='{$mode objfpc}{$H+}';
|
||||
if Params.Pkg<>nil then
|
||||
UnitDirectives:=TFileDescPascalUnit.CompilerOptionsToUnitDirectives(
|
||||
Params.Pkg.CompilerOptions);
|
||||
|
||||
NewSource:=
|
||||
'unit '+Params.Unit_Name+';'+LE
|
||||
+LE
|
||||
+'{$mode objfpc}{$H+}'+LE
|
||||
+UnitDirectives+LE
|
||||
+LE
|
||||
+'interface'+LE
|
||||
+LE
|
||||
@ -788,9 +794,14 @@ begin
|
||||
+LE
|
||||
+'end.'+LE;
|
||||
|
||||
Result:=MainIDE.DoNewEditorFile(FileDescriptorUnit,
|
||||
Params.UnitFilename,NewSource,
|
||||
[nfOpenInEditor,nfIsNotPartOfProject,nfSave,nfAddToRecent]);
|
||||
FileDescriptorUnit.Owner:=Params.Pkg;
|
||||
try
|
||||
Result:=MainIDE.DoNewEditorFile(FileDescriptorUnit,
|
||||
Params.UnitFilename,NewSource,
|
||||
[nfOpenInEditor,nfIsNotPartOfProject,nfSave,nfAddToRecent]);
|
||||
finally
|
||||
FileDescriptorUnit.Owner:=nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPkgManager.OnPackageEditorDeleteAmbiguousFiles(Sender: TObject;
|
||||
|
Loading…
Reference in New Issue
Block a user