chelper: updates in the converter help file and default behaviour
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3970 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
b45156a654
commit
48490fd3c5
@ -18,20 +18,21 @@
|
|||||||
}
|
}
|
||||||
program cconvert;
|
program cconvert;
|
||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode delphi}{$H+}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
SysUtils,Classes,
|
SysUtils,Classes,
|
||||||
ctopasconvert, cparsertypes, cparserutils, cconvconfig, objcparsing,
|
ctopasconvert, cparsertypes, cparserutils, cconvconfig, objcparsing
|
||||||
commonsrcgen;
|
, cconvlog;
|
||||||
|
|
||||||
var
|
var
|
||||||
ConfigFile : AnsiString = '';
|
ConfigFile : AnsiString = '';
|
||||||
OutputFile : AnsiString = '';
|
OutputFile : AnsiString = '';
|
||||||
ConfigFileRO : Boolean = false;
|
ConfigFileRO : Boolean = false;
|
||||||
ParseAll : Boolean = false;
|
ParseAll : Boolean = true;
|
||||||
ShowCodeSize : Boolean = False; // show the size of code processed
|
ShowCodeSize : Boolean = False; // show the size of code processed
|
||||||
isPascalUnit : Boolean = False; // convert to pascal unit
|
isPascalUnit : Boolean = False; // convert to pascal unit
|
||||||
|
isPrintHelp : Boolean = False;
|
||||||
|
|
||||||
function StringFromFile(const FileName: AnsiString): AnsiString;
|
function StringFromFile(const FileName: AnsiString): AnsiString;
|
||||||
var
|
var
|
||||||
@ -56,8 +57,10 @@ var
|
|||||||
i : Integer;
|
i : Integer;
|
||||||
p : AnsiString;
|
p : AnsiString;
|
||||||
fn : AnsiString;
|
fn : AnsiString;
|
||||||
|
vrb : Boolean;
|
||||||
begin
|
begin
|
||||||
i:=1;
|
i:=1;
|
||||||
|
vrb:=false;
|
||||||
while i<=Paramcount do begin
|
while i<=Paramcount do begin
|
||||||
p:=AnsiLowerCase(ParamStr(i));
|
p:=AnsiLowerCase(ParamStr(i));
|
||||||
if p='-cfg' then begin
|
if p='-cfg' then begin
|
||||||
@ -73,19 +76,27 @@ begin
|
|||||||
end else if p='-o' then begin
|
end else if p='-o' then begin
|
||||||
inc(i);
|
inc(i);
|
||||||
OutputFile:=ParamStr(i);
|
OutputFile:=ParamStr(i);
|
||||||
end else if p='-all' then begin
|
end else if p='-first' then begin
|
||||||
ParseAll:=True
|
ParseAll:=false
|
||||||
end else if p='-pasunit' then
|
end else if p='-pasunit' then begin
|
||||||
isPascalUnit:=True;
|
isPascalUnit:=True;
|
||||||
|
end else if p='-verbose' then begin
|
||||||
|
vrb:=true;
|
||||||
|
// do not assign log now, wait until all params are done
|
||||||
|
end;
|
||||||
inc(i);
|
inc(i);
|
||||||
end;
|
end;
|
||||||
|
if vrb then
|
||||||
|
_log:=_stdOutLog;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure PrintHelp;
|
procedure PrintHelp;
|
||||||
begin
|
begin
|
||||||
writeln('cconvert - c to pascal convert utility');
|
writeln('cconvert 1.1 - c to pascal convert utility by Dmitry Boyarintsev');
|
||||||
|
writeln('usage:');
|
||||||
|
writeln(' cconvert [options] %header_filename%');
|
||||||
writeln('possible options:');
|
writeln('possible options:');
|
||||||
writeln(' -all - convert the whole header to pascal, instead of a first entity');
|
writeln(' -first - stops on the first first entity');
|
||||||
writeln(' -o filename - specify the output file. if not specified, outputs to stdout');
|
writeln(' -o filename - specify the output file. if not specified, outputs to stdout');
|
||||||
writeln(' -ro - prevent the configuration file from modifications (adding new types, etc)');
|
writeln(' -ro - prevent the configuration file from modifications (adding new types, etc)');
|
||||||
writeln(' -cfg filename - specifies the configuration file');
|
writeln(' -cfg filename - specifies the configuration file');
|
||||||
@ -93,6 +104,7 @@ begin
|
|||||||
writeln(' -showunparsed - writes out unprased entities by their classname (for debugging only)');
|
writeln(' -showunparsed - writes out unprased entities by their classname (for debugging only)');
|
||||||
writeln(' -codesize - show two numbers of the code processed (used by Chelper)');
|
writeln(' -codesize - show two numbers of the code processed (used by Chelper)');
|
||||||
writeln(' -pasunit - generates a pascal unit');
|
writeln(' -pasunit - generates a pascal unit');
|
||||||
|
//writeln(' -verbose - verbose output');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ReadParams(var InputFileName: String);
|
procedure ReadParams(var InputFileName: String);
|
||||||
@ -100,15 +112,19 @@ var
|
|||||||
i : integer;
|
i : integer;
|
||||||
s : string;
|
s : string;
|
||||||
begin
|
begin
|
||||||
for i:=1 to ParamCount do begin
|
if ParamCount=0 then
|
||||||
s:=LowerCase(ParamStr(i));
|
isPrintHelp:=true
|
||||||
if (s='-h') or (s='-help') or (s='-?') then begin
|
else begin
|
||||||
PrintHelp;
|
for i:=1 to ParamCount do begin
|
||||||
Halt;
|
s:=LowerCase(ParamStr(i));
|
||||||
end else if s='-showunparsed' then
|
if (s='-h') or (s='-help') or (s='-?') then begin
|
||||||
DoDebugEntities:=True;
|
isPrintHelp:=true;
|
||||||
|
Break;
|
||||||
|
end else if s='-showunparsed' then
|
||||||
|
DoDebugEntities:=True;
|
||||||
|
end;
|
||||||
|
InputFileName:=ParamStr(ParamCount);
|
||||||
end;
|
end;
|
||||||
InputFileName:=ParamStr(ParamCount);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -135,8 +151,12 @@ var
|
|||||||
err : TErrorInfo;
|
err : TErrorInfo;
|
||||||
fn : String;
|
fn : String;
|
||||||
begin
|
begin
|
||||||
if ParamCount=0 then Exit;
|
|
||||||
ReadParams(fn);
|
ReadParams(fn);
|
||||||
|
if isPrintHelp then begin
|
||||||
|
PrintHelp;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
if not FileExists(fn) then begin
|
if not FileExists(fn) then begin
|
||||||
writeln('file doesn''t exist: ', fn);
|
writeln('file doesn''t exist: ', fn);
|
||||||
Exit;
|
Exit;
|
||||||
@ -151,6 +171,7 @@ begin
|
|||||||
InitSettings(cfg);
|
InitSettings(cfg);
|
||||||
|
|
||||||
inps.LoadFromFile(ParamStr(ParamCount));
|
inps.LoadFromFile(ParamStr(ParamCount));
|
||||||
|
|
||||||
outs.Text:=ConvertCode(inps.Text, p, ParseAll, err, cfg);;
|
outs.Text:=ConvertCode(inps.Text, p, ParseAll, err, cfg);;
|
||||||
|
|
||||||
if ShowCodeSize then outs.Insert(0, Format('%d %d', [p.Y,p.X]));
|
if ShowCodeSize then outs.Insert(0, Format('%d %d', [p.Y,p.X]));
|
||||||
|
Loading…
Reference in New Issue
Block a user