mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 18:39:10 +02:00
MG: fixes for Delphi compataibility
git-svn-id: trunk@1492 -
This commit is contained in:
parent
ba01ab7df2
commit
e14d49fb6c
@ -1083,7 +1083,8 @@ writeln('TCodeCompletionCodeTool.CreateMissingProcBodies Gather existing method
|
|||||||
if (ProcCode='') then begin
|
if (ProcCode='') then begin
|
||||||
ANode:=ANodeExt.Node;
|
ANode:=ANodeExt.Node;
|
||||||
if (ANode<>nil) and (ANode.Desc=ctnProcedure) then begin
|
if (ANode<>nil) and (ANode.Desc=ctnProcedure) then begin
|
||||||
ProcCode:=ExtractProcHead(ANode,[phpWithStart,phpAddClassname,
|
ProcCode:=ExtractProcHead(ANode,[phpWithStart,
|
||||||
|
phpWithoutClassKeyword,phpAddClassname,
|
||||||
phpWithParameterNames,phpWithResultType,phpWithVarModifiers]);
|
phpWithParameterNames,phpWithResultType,phpWithVarModifiers]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1299,8 +1300,9 @@ writeln('TCodeCompletionCodeTool.CompleteCode Body not found -> create it ... ')
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// build nice proc
|
// build nice proc
|
||||||
ProcCode:=ExtractProcHead(ProcNode,[phpWithStart,phpWithVarModifiers,
|
ProcCode:=ExtractProcHead(ProcNode,[phpWithStart,phpWithoutClassKeyword,
|
||||||
phpWithParameterNames,phpWithResultType,phpWithComments]);
|
phpWithVarModifiers,phpWithParameterNames,phpWithResultType,
|
||||||
|
phpWithComments]);
|
||||||
if ProcCode='' then
|
if ProcCode='' then
|
||||||
RaiseException('unable to reparse proc node');
|
RaiseException('unable to reparse proc node');
|
||||||
ProcCode:=SourceChangeCache.BeautifyCodeOptions.BeautifyProc(ProcCode,
|
ProcCode:=SourceChangeCache.BeautifyCodeOptions.BeautifyProc(ProcCode,
|
||||||
|
@ -347,6 +347,7 @@ begin
|
|||||||
|
|
||||||
Add('TYPE',{$ifdef FPC}@{$endif}KeyWordFuncType);
|
Add('TYPE',{$ifdef FPC}@{$endif}KeyWordFuncType);
|
||||||
Add('VAR',{$ifdef FPC}@{$endif}KeyWordFuncVar);
|
Add('VAR',{$ifdef FPC}@{$endif}KeyWordFuncVar);
|
||||||
|
Add('THREADVAR',{$ifdef FPC}@{$endif}KeyWordFuncVar);
|
||||||
Add('CONST',{$ifdef FPC}@{$endif}KeyWordFuncConst);
|
Add('CONST',{$ifdef FPC}@{$endif}KeyWordFuncConst);
|
||||||
Add('RESOURCESTRING',{$ifdef FPC}@{$endif}KeyWordFuncResourceString);
|
Add('RESOURCESTRING',{$ifdef FPC}@{$endif}KeyWordFuncResourceString);
|
||||||
Add('LABEL',{$ifdef FPC}@{$endif}KeyWordFuncLabel);
|
Add('LABEL',{$ifdef FPC}@{$endif}KeyWordFuncLabel);
|
||||||
@ -2429,7 +2430,7 @@ function TPascalParserTool.KeyWordFuncTypeProc: boolean;
|
|||||||
function(ParmList):SimpleType of object;
|
function(ParmList):SimpleType of object;
|
||||||
procedure; cdecl; popstack; register; pascal; stdcall;
|
procedure; cdecl; popstack; register; pascal; stdcall;
|
||||||
}
|
}
|
||||||
var IsFunction, SemicolonFound: boolean;
|
var IsFunction, EqualFound: boolean;
|
||||||
begin
|
begin
|
||||||
IsFunction:=UpAtomIs('FUNCTION');
|
IsFunction:=UpAtomIs('FUNCTION');
|
||||||
CreateChildNode;
|
CreateChildNode;
|
||||||
@ -2460,18 +2461,19 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
if AtomIsChar(';') then begin
|
if AtomIsChar(';') then begin
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
SemicolonFound:=true;
|
EqualFound:=false;
|
||||||
end else begin
|
end else if AtomIsChar('=') then begin
|
||||||
SemicolonFound:=false;
|
EqualFound:=true;
|
||||||
end;
|
end;
|
||||||
|
if not EqualFound then begin
|
||||||
// read modifiers
|
// read modifiers
|
||||||
repeat
|
repeat
|
||||||
if not IsKeyWordProcedureTypeSpecifier.DoItUpperCase(UpperSrc,
|
if (not IsKeyWordProcedureTypeSpecifier.DoItUpperCase(UpperSrc,
|
||||||
CurPos.StartPos,CurPos.EndPos-CurPos.StartPos) then
|
CurPos.StartPos,CurPos.EndPos-CurPos.StartPos)) then
|
||||||
begin
|
begin
|
||||||
if not SemicolonFound then
|
|
||||||
RaiseException('; expected, but '+GetAtom+' found');
|
|
||||||
UndoReadNextAtom;
|
UndoReadNextAtom;
|
||||||
|
if (not AtomIsChar(';')) and (Scanner.CompilerMode<>cmDelphi) then
|
||||||
|
RaiseException('; expected, but '+GetAtom+' found');
|
||||||
break;
|
break;
|
||||||
end else begin
|
end else begin
|
||||||
if not ReadNextAtomIsChar(';') then begin
|
if not ReadNextAtomIsChar(';') then begin
|
||||||
@ -2486,13 +2488,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
UndoReadNextAtom;
|
UndoReadNextAtom;
|
||||||
end;
|
end;
|
||||||
end else begin
|
|
||||||
SemicolonFound:=true;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
until false;
|
until false;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
CurNode.EndPos:=CurPos.StartPos;
|
CurNode.EndPos:=CurPos.StartPos;
|
||||||
EndChildNode;
|
EndChildNode;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
@ -2560,8 +2561,6 @@ end;
|
|||||||
function TPascalParserTool.KeyWordFuncTypePointer: boolean;
|
function TPascalParserTool.KeyWordFuncTypePointer: boolean;
|
||||||
// '^Identfier'
|
// '^Identfier'
|
||||||
begin
|
begin
|
||||||
if not (LastAtomIs(0,'=') or LastAtomIs(0,':')) then
|
|
||||||
RaiseException('identifier expected, but ^ found');
|
|
||||||
CreateChildNode;
|
CreateChildNode;
|
||||||
CurNode.Desc:=ctnPointerType;
|
CurNode.Desc:=ctnPointerType;
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
|
@ -142,7 +142,7 @@ constructor TPicture.Create;
|
|||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
GetFileFormats;
|
GetFileFormats;
|
||||||
//GetClipboardFormats;
|
GetClipboardFormats;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TPicture.Destroy;
|
destructor TPicture.Destroy;
|
||||||
@ -180,12 +180,14 @@ end;
|
|||||||
|
|
||||||
function TPicture.GetPixmap: TPixmap;
|
function TPicture.GetPixmap: TPixmap;
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
ForceType(TPixmap);
|
||||||
|
Result := TPixmap(Graphic);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TPicture.GetIcon: TIcon;
|
function TPicture.GetIcon: TIcon;
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
ForceType(TIcon);
|
||||||
|
Result := TIcon(Graphic);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPicture.SetBitmap(Value: TBitmap);
|
procedure TPicture.SetBitmap(Value: TBitmap);
|
||||||
@ -225,7 +227,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Based on the extension of Filename, create the cooresponding TGraphic class
|
{ Based on the extension of Filename, create the corresponding TGraphic class
|
||||||
and call its LoadFromFile method. }
|
and call its LoadFromFile method. }
|
||||||
|
|
||||||
procedure TPicture.LoadFromFile(const Filename: string);
|
procedure TPicture.LoadFromFile(const Filename: string);
|
||||||
@ -233,20 +235,24 @@ var
|
|||||||
Ext: string;
|
Ext: string;
|
||||||
NewGraphic: TGraphic;
|
NewGraphic: TGraphic;
|
||||||
GraphicClass: TGraphicClass;
|
GraphicClass: TGraphicClass;
|
||||||
|
ok: boolean;
|
||||||
begin
|
begin
|
||||||
Ext := ExtractFileExt(Filename);
|
Ext := ExtractFileExt(Filename);
|
||||||
Delete(Ext, 1, 1);
|
System.Delete(Ext, 1, 1); // delete '.'
|
||||||
GraphicClass := GetFileFormats.FindExt(Ext);
|
GraphicClass := GetFileFormats.FindExt(Ext);
|
||||||
if GraphicClass = nil then
|
if GraphicClass = nil then
|
||||||
raise EInvalidGraphic.CreateFmt('Unknown picture extension', [Ext]);
|
raise EInvalidGraphic.CreateFmt('Unknown picture extension', [Ext]);
|
||||||
|
|
||||||
NewGraphic := GraphicClass.Create;
|
NewGraphic := GraphicClass.Create;
|
||||||
|
ok:=false;
|
||||||
try
|
try
|
||||||
NewGraphic.OnProgress := @Progress;
|
NewGraphic.OnProgress := @Progress;
|
||||||
NewGraphic.LoadFromFile(Filename);
|
NewGraphic.LoadFromFile(Filename);
|
||||||
except
|
ok:=true;
|
||||||
NewGraphic.Free;
|
finally
|
||||||
raise;
|
// this try..finally construction will in case of an exception
|
||||||
|
// not alter the error backtrace output
|
||||||
|
if not ok then NewGraphic.Free;
|
||||||
end;
|
end;
|
||||||
FGraphic.Free;
|
FGraphic.Free;
|
||||||
FGraphic := NewGraphic;
|
FGraphic := NewGraphic;
|
||||||
@ -260,8 +266,26 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPicture.LoadFromClipboardFormat(FormatID: TClipboardFormat);
|
procedure TPicture.LoadFromClipboardFormat(FormatID: TClipboardFormat);
|
||||||
|
var
|
||||||
|
NewGraphic: TGraphic;
|
||||||
|
GraphicClass: TGraphicClass;
|
||||||
begin
|
begin
|
||||||
|
GraphicClass := ClipboardFormats.FindFormat(FormatID);
|
||||||
|
if GraphicClass = nil then
|
||||||
|
InvalidGraphic(@SUnknownClipboardFormat);
|
||||||
|
|
||||||
|
NewGraphic := GraphicClass.Create;
|
||||||
|
try
|
||||||
|
NewGraphic.OnProgress := Progress;
|
||||||
|
NewGraphic.LoadFromClipboardFormat(AFormat, AData, APalette);
|
||||||
|
except
|
||||||
|
NewGraphic.Free;
|
||||||
|
raise;
|
||||||
|
end;
|
||||||
|
FGraphic.Free;
|
||||||
|
FGraphic := NewGraphic;
|
||||||
|
FGraphic.OnChange := Changed;
|
||||||
|
Changed(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPicture.SaveToClipboardFormat(FormatID: TClipboardFormat);
|
procedure TPicture.SaveToClipboardFormat(FormatID: TClipboardFormat);
|
||||||
|
Loading…
Reference in New Issue
Block a user