mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 18:39:30 +02:00
IDE: fixed duplicate code, break cycle lfmunitresource
git-svn-id: trunk@42895 -
This commit is contained in:
parent
0c1f11b7a5
commit
3b717ddda1
@ -40,12 +40,13 @@ type
|
||||
out LCLVersion: string;
|
||||
out MissingClasses: TStrings// e.g. MyFrame2:TMyFrame
|
||||
): TModalResult; virtual; abstract;
|
||||
|
||||
|
||||
end;
|
||||
TUnitResourcefileFormatClass = class of TUnitResourcefileFormat;
|
||||
TUnitResourcefileFormatArr = array of TUnitResourcefileFormatClass;
|
||||
|
||||
var
|
||||
LFMUnitResourceFileFormat: TUnitResourcefileFormatClass = nil;// set by IDE
|
||||
|
||||
procedure RegisterUnitResourcefileFormat(AResourceFileFormat: TUnitResourcefileFormatClass);
|
||||
function GetUnitResourcefileFormats: TUnitResourcefileFormatArr;
|
||||
|
||||
|
@ -43,8 +43,9 @@ uses
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, AvgLvlTree, BasicCodeTools, TypInfo, LCLProc, LResources,
|
||||
Forms, Controls, LCLMemManager, LCLIntf, Dialogs, PropEditUtils, PropEdits,
|
||||
IDEProcs, PackageDefs, BasePkgManager, UnitResources, lfmUnitResource;
|
||||
Forms, Controls, LCLMemManager, LCLIntf, Dialogs,
|
||||
PropEditUtils, PropEdits, UnitResources,
|
||||
IDEProcs, PackageDefs, BasePkgManager;
|
||||
|
||||
type
|
||||
//----------------------------------------------------------------------------
|
||||
@ -1148,7 +1149,7 @@ begin
|
||||
SubReader:=nil;
|
||||
DestroyDriver:=false;
|
||||
try
|
||||
CreateReader(BinStream,TLFMUnitResourcefileFormat,SubReader,DestroyDriver);
|
||||
CreateReader(BinStream,LFMUnitResourcefileFormat,SubReader,DestroyDriver);
|
||||
// The stream contains only the diff to the Ancestor instance,
|
||||
// => give it the Ancestor instance
|
||||
SubReader.Ancestor:=Ancestor;
|
||||
@ -1310,7 +1311,7 @@ begin
|
||||
try
|
||||
DestroyDriver:=false;
|
||||
InitReading;
|
||||
CreateReader(BinStream,TLFMUnitResourcefileFormat, Reader,DestroyDriver);
|
||||
CreateReader(BinStream,LFMUnitResourcefileFormat, Reader,DestroyDriver);
|
||||
{$IFDEF VerboseJITForms}
|
||||
debugln('[TJITComponentList.AddJITChildComponentFromStream] B');
|
||||
{$ENDIF}
|
||||
|
@ -138,107 +138,6 @@ end;
|
||||
|
||||
initialization
|
||||
RegisterUnitResourcefileFormat(TLFMUnitResourcefileFormat);
|
||||
end.
|
||||
|
||||
unit lfmUnitResource;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils,
|
||||
LCLMemManager,
|
||||
Forms,
|
||||
UnitResources;
|
||||
|
||||
type
|
||||
|
||||
{ TLFMUnitResourcefileFormat }
|
||||
|
||||
TLFMUnitResourcefileFormat = class(TUnitResourcefileFormat)
|
||||
public
|
||||
class function FindResourceDirective(Source: TObject): boolean; override;
|
||||
class function ResourceDirectiveFilename: string; override;
|
||||
class function GetUnitResourceFilename(AUnitFilenae: string): string; override;
|
||||
class procedure TextStreamToBinStream(ATxtStream, ABinStream: TExtMemoryStream); override;
|
||||
class procedure BinStreamToTextStream(ABinStream, ATextStream: TExtMemoryStream); override;
|
||||
class function GetClassNameFromStream(s: TStream; out IsInherited: Boolean): shortstring; override;
|
||||
class function CreateReader(s: TStream; var DestroyDriver: boolean): TReader; override;
|
||||
class function QuickCheckResourceBuffer(PascalBuffer, LFMBuffer: TObject; out
|
||||
LFMType, LFMComponentName, LFMClassName: string; out LCLVersion: string;
|
||||
out MissingClasses: TStrings): TModalResult; override;
|
||||
class function CreateWriter(s: TStream; var DestroyDriver: boolean): TWriter; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
LResources,
|
||||
CodeCache,
|
||||
CodeToolManager,
|
||||
CheckLFMDlg;
|
||||
|
||||
{ TLFMUnitResourcefileFormat }
|
||||
|
||||
class function TLFMUnitResourcefileFormat.FindResourceDirective(Source: TObject): boolean;
|
||||
var
|
||||
cb: TCodeBuffer;
|
||||
nx,ny,nt: integer;
|
||||
begin
|
||||
result := CodeToolBoss.FindResourceDirective(Source as TCodeBuffer,1,1,cb,nx,ny,nt, ResourceDirectiveFilename,false);
|
||||
end;
|
||||
|
||||
class function TLFMUnitResourcefileFormat.ResourceDirectiveFilename: string;
|
||||
begin
|
||||
result := '*.lfm';
|
||||
end;
|
||||
|
||||
class function TLFMUnitResourcefileFormat.GetUnitResourceFilename(
|
||||
AUnitFilenae: string): string;
|
||||
begin
|
||||
result := ChangeFileExt(AUnitFilenae,'.lfm');
|
||||
end;
|
||||
|
||||
class procedure TLFMUnitResourcefileFormat.TextStreamToBinStream(ATxtStream,
|
||||
ABinStream: TExtMemoryStream);
|
||||
begin
|
||||
LRSObjectTextToBinary(ATxtStream,ABinStream);
|
||||
end;
|
||||
|
||||
class procedure TLFMUnitResourcefileFormat.BinStreamToTextStream(ABinStream,
|
||||
ATextStream: TExtMemoryStream);
|
||||
begin
|
||||
LRSObjectBinaryToText(ABinStream,ATextStream);
|
||||
end;
|
||||
|
||||
class function TLFMUnitResourcefileFormat.GetClassNameFromStream(s: TStream;
|
||||
out IsInherited: Boolean): shortstring;
|
||||
begin
|
||||
result := GetClassNameFromLRSStream(s,IsInherited);
|
||||
end;
|
||||
|
||||
class function TLFMUnitResourcefileFormat.CreateReader(s: TStream;
|
||||
var DestroyDriver: boolean): TReader;
|
||||
begin
|
||||
result := CreateLRSReader(s,DestroyDriver);
|
||||
end;
|
||||
|
||||
class function TLFMUnitResourcefileFormat.QuickCheckResourceBuffer(PascalBuffer,
|
||||
LFMBuffer: TObject; out LFMType, LFMComponentName, LFMClassName: string; out
|
||||
LCLVersion: string; out MissingClasses: TStrings): TModalResult;
|
||||
begin
|
||||
result := QuickCheckLFMBuffer(PascalBuffer as TCodeBuffer, LFMBuffer as TCodeBuffer, LFMType, LFMComponentName, LFMClassName,
|
||||
LCLVersion, MissingClasses);
|
||||
end;
|
||||
|
||||
class function TLFMUnitResourcefileFormat.CreateWriter(s: TStream;
|
||||
var DestroyDriver: boolean): TWriter;
|
||||
begin
|
||||
result := CreateLRSWriter(s, DestroyDriver);
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterUnitResourcefileFormat(TLFMUnitResourcefileFormat);
|
||||
LFMUnitResourceFileFormat:=TLFMUnitResourcefileFormat;
|
||||
end.
|
||||
|
||||
|
@ -95,7 +95,7 @@ uses
|
||||
IDEContextHelpEdit, IDEHelpIntf, ExtendedTabControls, IDEHelpManager, CodeHelp, HelpOptions,
|
||||
// designer
|
||||
JITForms, ComponentPalette, ComponentList, CompPagesPopup,
|
||||
ObjInspExt, Designer, FormEditor, CustomFormEditor,
|
||||
ObjInspExt, Designer, FormEditor, CustomFormEditor, lfmUnitResource,
|
||||
ControlSelection, AnchorEditor, TabOrderDlg, MenuEditorForm,
|
||||
// LRT stuff
|
||||
Translations,
|
||||
|
@ -60,7 +60,7 @@ uses
|
||||
SynEdit,
|
||||
// IDE
|
||||
CompOptsModes, ProjectResources, LazConf, W32Manifest, ProjectIcon,
|
||||
LazarusIDEStrConsts, CompilerOptions, lfmUnitResource,
|
||||
LazarusIDEStrConsts, CompilerOptions,
|
||||
TransferMacros, EditorOptions, IDEProcs, RunParamsOpts, ProjectDefs,
|
||||
FileReferenceList, EditDefineTree, ModeMatrixOpts, PackageDefs, PackageSystem,
|
||||
IDEDialogs;
|
||||
@ -2380,7 +2380,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
FUnitResourceFileformat := TLFMUnitResourcefileFormat;
|
||||
FUnitResourceFileformat := LFMUnitResourcefileFormat;
|
||||
end;
|
||||
Result := FUnitResourceFileformat;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user