You've already forked lazarus-ccr
Added ability to gather all forward declarations into one file
* Check for implementation and set reserved words git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2345 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -38,7 +38,7 @@ uses
|
|||||||
Classes, SysUtils, strutils,
|
Classes, SysUtils, strutils,
|
||||||
idlParser;
|
idlParser;
|
||||||
|
|
||||||
procedure GeneratePascalSource(const AnIdlList: TIDLList; const PascalCode: tstrings;TypeConvList, CTypesList: TStrings; AlwaysAddPrefixToParam: boolean);
|
procedure GeneratePascalSource(const AnIdlList: TIDLList; const PascalCode: tstrings;TypeConvList, CTypesList: TStrings; AlwaysAddPrefixToParam: boolean; AForwardDeclList: TStrings = nil);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -91,12 +91,14 @@ begin
|
|||||||
case lowercase(AName) of
|
case lowercase(AName) of
|
||||||
'type': result := 'a'+AName;
|
'type': result := 'a'+AName;
|
||||||
'end' : result := 'an'+AName;
|
'end' : result := 'an'+AName;
|
||||||
|
'implementation' : result := 'an'+AName;
|
||||||
|
'set' : result := 'a'+AName;
|
||||||
else
|
else
|
||||||
result := AName;
|
result := AName;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure GeneratePascalSource(const AnIdlList: TIDLList; const PascalCode: tstrings;TypeConvList, CTypesList: TStrings; AlwaysAddPrefixToParam: boolean);
|
procedure GeneratePascalSource(const AnIdlList: TIDLList; const PascalCode: tstrings;TypeConvList, CTypesList: TStrings; AlwaysAddPrefixToParam: boolean; AForwardDeclList: TStrings = nil);
|
||||||
|
|
||||||
var
|
var
|
||||||
i,l,m: integer;
|
i,l,m: integer;
|
||||||
@ -183,6 +185,14 @@ begin
|
|||||||
s := LineEnding + s + LineEnding+' end;' + LineEnding
|
s := LineEnding + s + LineEnding+' end;' + LineEnding
|
||||||
else
|
else
|
||||||
s := s + ';';
|
s := s + ';';
|
||||||
|
|
||||||
|
if assigned(AForwardDeclList) and (anIDL.InterfaceType='') then
|
||||||
|
begin
|
||||||
|
if AForwardDeclList.Count=0 then
|
||||||
|
AForwardDeclList.Add('type');
|
||||||
|
AForwardDeclList.Add(s);
|
||||||
|
end
|
||||||
|
else
|
||||||
PascalCode.Add(s);
|
PascalCode.Add(s);
|
||||||
|
|
||||||
if consts<>'' then
|
if consts<>'' then
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<RunParams>
|
<RunParams>
|
||||||
<local>
|
<local>
|
||||||
<FormatVersion Value="1"/>
|
<FormatVersion Value="1"/>
|
||||||
<CommandLineParams Value="/home/CNOC/joost/svn/geckoport/xulrunner-sdk-10/idl/nsIPrompt.idl"/>
|
<CommandLineParams Value="/home/CNOC/joost/svn/geckoport/xulrunner-sdk-10/idl/nsIInterfaceRequestor.idl"/>
|
||||||
</local>
|
</local>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<Units Count="3">
|
<Units Count="3">
|
||||||
|
@ -24,7 +24,7 @@ type
|
|||||||
|
|
||||||
{ TIDLToPascal }
|
{ TIDLToPascal }
|
||||||
|
|
||||||
procedure HandleIDLFile(AFilename: string; AnOutput: TStrings; TypeConvList, CTypesList: TStrings; AlwaysAddPrefixToParam: boolean);
|
procedure HandleIDLFile(AFilename: string; AnOutput, ForwardOutput: TStrings; TypeConvList, CTypesList: TStrings; AlwaysAddPrefixToParam: boolean);
|
||||||
var
|
var
|
||||||
AnIDLList: TIDLList;
|
AnIDLList: TIDLList;
|
||||||
AnInput: TStrings;
|
AnInput: TStrings;
|
||||||
@ -35,7 +35,7 @@ begin
|
|||||||
AnIDLList := TIDLList.create;
|
AnIDLList := TIDLList.create;
|
||||||
try
|
try
|
||||||
ParseFile(AnIDLList, AnInput);
|
ParseFile(AnIDLList, AnInput);
|
||||||
GeneratePascalSource(AnIDLList,AnOutput,TypeConvList, CTypesList, AlwaysAddPrefixToParam);
|
GeneratePascalSource(AnIDLList,AnOutput,TypeConvList, CTypesList, AlwaysAddPrefixToParam, ForwardOutput);
|
||||||
finally
|
finally
|
||||||
AnIDLList.Free;
|
AnIDLList.Free;
|
||||||
end;
|
end;
|
||||||
@ -49,7 +49,7 @@ var
|
|||||||
ErrorMsg: String;
|
ErrorMsg: String;
|
||||||
i: integer;
|
i: integer;
|
||||||
filenames: TStrings;
|
filenames: TStrings;
|
||||||
output: TStrings;
|
output, forwardoutput: TStringList;
|
||||||
OutputToFile: boolean;
|
OutputToFile: boolean;
|
||||||
OutputFilename: string;
|
OutputFilename: string;
|
||||||
CTypes, TypeMapList: TStrings;
|
CTypes, TypeMapList: TStrings;
|
||||||
@ -61,7 +61,7 @@ begin
|
|||||||
TypeMapList := TStringList.Create;
|
TypeMapList := TStringList.Create;
|
||||||
try
|
try
|
||||||
// quick check parameters
|
// quick check parameters
|
||||||
ErrorMsg:=CheckOptions('hpo::c:m:',nil,nil,filenames);
|
ErrorMsg:=CheckOptions('hpo::c:m:f:',nil,nil,filenames);
|
||||||
if ErrorMsg<>'' then
|
if ErrorMsg<>'' then
|
||||||
begin
|
begin
|
||||||
ShowException(Exception.Create(ErrorMsg));
|
ShowException(Exception.Create(ErrorMsg));
|
||||||
@ -87,10 +87,21 @@ begin
|
|||||||
TypeMapList.LoadFromFile(GetOptionValue('m'));
|
TypeMapList.LoadFromFile(GetOptionValue('m'));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
OutputToFile := HasOption('o');
|
OutputToFile := HasOption('o');
|
||||||
OutputFilename := GetOptionValue('o');
|
OutputFilename := GetOptionValue('o');
|
||||||
AlwaysAddPrefixToParam := HasOption('p');
|
AlwaysAddPrefixToParam := HasOption('p');
|
||||||
|
|
||||||
|
if HasOption('f') then
|
||||||
|
begin
|
||||||
|
forwardoutput := TStringList.Create;
|
||||||
|
forwardoutput.CaseSensitive:=false;
|
||||||
|
forwardoutput.Sorted:=true;
|
||||||
|
forwardoutput.Duplicates:=dupIgnore;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
forwardoutput := nil;
|
||||||
|
|
||||||
output := TStringList.Create;
|
output := TStringList.Create;
|
||||||
try
|
try
|
||||||
for i := 0 to filenames.Count-1 do
|
for i := 0 to filenames.Count-1 do
|
||||||
@ -98,7 +109,7 @@ begin
|
|||||||
if OutputToFile and (OutputFilename='') then
|
if OutputToFile and (OutputFilename='') then
|
||||||
Output.Clear;
|
Output.Clear;
|
||||||
|
|
||||||
HandleIDLFile(filenames.Strings[i], output, TypeMapList, CTypes, AlwaysAddPrefixToParam);
|
HandleIDLFile(filenames.Strings[i], output, forwardoutput, TypeMapList, CTypes, AlwaysAddPrefixToParam);
|
||||||
|
|
||||||
if OutputToFile and (OutputFilename='') then
|
if OutputToFile and (OutputFilename='') then
|
||||||
output.SaveToFile(LowerCase(ExtractFileName(ChangeFileExt(filenames.Strings[i],'.inc'))));
|
output.SaveToFile(LowerCase(ExtractFileName(ChangeFileExt(filenames.Strings[i],'.inc'))));
|
||||||
@ -108,8 +119,12 @@ begin
|
|||||||
else if OutputFilename<>'' then
|
else if OutputFilename<>'' then
|
||||||
output.SaveToFile(OutputFilename);
|
output.SaveToFile(OutputFilename);
|
||||||
|
|
||||||
|
if assigned(forwardoutput) and (forwardoutput.Count<>0) then
|
||||||
|
forwardoutput.SaveToFile(GetOptionValue('f'));
|
||||||
|
|
||||||
finally
|
finally
|
||||||
output.Free;
|
output.Free;
|
||||||
|
forwardoutput.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
finally
|
finally
|
||||||
@ -150,6 +165,8 @@ begin
|
|||||||
writeln(' prefixed with ''c'' or ''cu'' (as used in the ctypes unit)');
|
writeln(' prefixed with ''c'' or ''cu'' (as used in the ctypes unit)');
|
||||||
writeln(' -m filename Read ''filename'' for a list of mappings between idl-type names');
|
writeln(' -m filename Read ''filename'' for a list of mappings between idl-type names');
|
||||||
writeln(' and their Pascal counterpart');
|
writeln(' and their Pascal counterpart');
|
||||||
|
writeln(' -f filename Place all forward declarations into one file called ''filename''');
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
Reference in New Issue
Block a user