mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 08:59:32 +02:00
CodeTools example AddFpprofCalls: show help if no filename is given. Fix memory leak.
git-svn-id: branches/fixes_1_8@56305 -
This commit is contained in:
parent
c1961125f0
commit
2dd75ec29d
@ -64,6 +64,43 @@ var
|
||||
FromPos: objpas.Integer;
|
||||
ToPos: objpas.Integer;
|
||||
|
||||
procedure ShowHelp;
|
||||
begin
|
||||
writeln('addfpprofcalls');
|
||||
writeln;
|
||||
writeln('List function signatures, or add or remove fpprofiler calls to selected functions.');
|
||||
writeln;
|
||||
writeln('Usage: <options> <unit file name> <function signature> <function signature> ...');
|
||||
writeln(' -h : write this help');
|
||||
writeln(' -r : remove calls instead of list');
|
||||
writeln(' -a : add calls instead of list');
|
||||
writeln;
|
||||
writeln('Example');
|
||||
writeln(' List all function signatures of unit1.pas');
|
||||
writeln(' ',ParamStrUTF8(0),' unit1.pas');
|
||||
writeln(' Add fpprofiler calls to TForm.Button1Click:');
|
||||
writeln(' ',ParamStrUTF8(0),' -a unit1.pas TForm1.Button1Click(:TObject)');
|
||||
writeln(' Remove fpprofiler calls from TForm.Button1Click:');
|
||||
writeln(' ',ParamStrUTF8(0),' -r unit1.pas TForm1.Button1Click(:TObject)');
|
||||
writeln;
|
||||
writeln('Before:');
|
||||
writeln('=======');
|
||||
writeln('procedure TMainForm.Button1Clicked(...)');
|
||||
writeln('begin');
|
||||
writeln(' // do something here');
|
||||
writeln('end;');
|
||||
writeln;
|
||||
writeln('After:');
|
||||
writeln('======');
|
||||
writeln('procedure TMainForm.Button1Clicked(...)');
|
||||
writeln('begin');
|
||||
writeln(' SendMethodEnter(''TMainForm.Button1Clicked'');');
|
||||
writeln(' // do something here');
|
||||
writeln(' SendMethodExit(''TMainForm.Button1Clicked'');');
|
||||
writeln('end;');
|
||||
writeln;
|
||||
end;
|
||||
|
||||
procedure RemoveCall;
|
||||
begin
|
||||
FromPos:=Tool.CurPos.StartPos;
|
||||
@ -98,39 +135,8 @@ begin
|
||||
for i:=1 to ParamCount do begin
|
||||
Param:=ParamStrUTF8(i);
|
||||
if (Param='-h') or (Param='-?') then begin
|
||||
writeln('addfpprofcalls');
|
||||
writeln;
|
||||
writeln('List function signatures, or add or remove fpprofiler calls to selected functions.');
|
||||
writeln;
|
||||
writeln('Usage: <options> <unit file name> <function signature> <function signature> ...');
|
||||
writeln(' -h : write this help');
|
||||
writeln(' -r : remove calls instead of list');
|
||||
writeln(' -a : add calls instead of list');
|
||||
writeln;
|
||||
writeln('Example');
|
||||
writeln(' List all function signatures of unit1.pas');
|
||||
writeln(' ',ParamStrUTF8(0),' unit1.pas');
|
||||
writeln(' Add fpprofiler calls to TForm.Button1Click:');
|
||||
writeln(' ',ParamStrUTF8(0),' -a unit1.pas TForm1.Button1Click(:TObject)');
|
||||
writeln(' Remove fpprofiler calls from TForm.Button1Click:');
|
||||
writeln(' ',ParamStrUTF8(0),' -r unit1.pas TForm1.Button1Click(:TObject)');
|
||||
writeln;
|
||||
writeln('Before:');
|
||||
writeln('=======');
|
||||
writeln('procedure TMainForm.Button1Clicked(...)');
|
||||
writeln('begin');
|
||||
writeln(' // do something here');
|
||||
writeln('end;');
|
||||
writeln;
|
||||
writeln('After:');
|
||||
writeln('======');
|
||||
writeln('procedure TMainForm.Button1Clicked(...)');
|
||||
writeln('begin');
|
||||
writeln(' SendMethodEnter(''TMainForm.Button1Clicked'');');
|
||||
writeln(' // do something here');
|
||||
writeln(' SendMethodExit(''TMainForm.Button1Clicked'');');
|
||||
writeln('end;');
|
||||
Halt;
|
||||
ShowHelp;
|
||||
exit;
|
||||
end else if Param='-r' then
|
||||
Mode:=mRemove
|
||||
else if Param='-a' then
|
||||
@ -146,6 +152,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
if Filename='' then begin
|
||||
ShowHelp;
|
||||
exit;
|
||||
end;
|
||||
|
||||
// load the file
|
||||
Code:=CodeToolBoss.LoadFile(Filename,false,false);
|
||||
if Code=nil then
|
||||
|
Loading…
Reference in New Issue
Block a user