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,
|
||||
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
|
||||
|
||||
@ -91,12 +91,14 @@ begin
|
||||
case lowercase(AName) of
|
||||
'type': result := 'a'+AName;
|
||||
'end' : result := 'an'+AName;
|
||||
'implementation' : result := 'an'+AName;
|
||||
'set' : result := 'a'+AName;
|
||||
else
|
||||
result := AName;
|
||||
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
|
||||
i,l,m: integer;
|
||||
@ -183,7 +185,15 @@ begin
|
||||
s := LineEnding + s + LineEnding+' end;' + LineEnding
|
||||
else
|
||||
s := s + ';';
|
||||
PascalCode.Add(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);
|
||||
|
||||
if consts<>'' then
|
||||
begin
|
||||
|
@ -29,7 +29,7 @@
|
||||
<RunParams>
|
||||
<local>
|
||||
<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>
|
||||
</RunParams>
|
||||
<Units Count="3">
|
||||
|
@ -24,7 +24,7 @@ type
|
||||
|
||||
{ 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
|
||||
AnIDLList: TIDLList;
|
||||
AnInput: TStrings;
|
||||
@ -35,7 +35,7 @@ begin
|
||||
AnIDLList := TIDLList.create;
|
||||
try
|
||||
ParseFile(AnIDLList, AnInput);
|
||||
GeneratePascalSource(AnIDLList,AnOutput,TypeConvList, CTypesList, AlwaysAddPrefixToParam);
|
||||
GeneratePascalSource(AnIDLList,AnOutput,TypeConvList, CTypesList, AlwaysAddPrefixToParam, ForwardOutput);
|
||||
finally
|
||||
AnIDLList.Free;
|
||||
end;
|
||||
@ -49,7 +49,7 @@ var
|
||||
ErrorMsg: String;
|
||||
i: integer;
|
||||
filenames: TStrings;
|
||||
output: TStrings;
|
||||
output, forwardoutput: TStringList;
|
||||
OutputToFile: boolean;
|
||||
OutputFilename: string;
|
||||
CTypes, TypeMapList: TStrings;
|
||||
@ -61,7 +61,7 @@ begin
|
||||
TypeMapList := TStringList.Create;
|
||||
try
|
||||
// quick check parameters
|
||||
ErrorMsg:=CheckOptions('hpo::c:m:',nil,nil,filenames);
|
||||
ErrorMsg:=CheckOptions('hpo::c:m:f:',nil,nil,filenames);
|
||||
if ErrorMsg<>'' then
|
||||
begin
|
||||
ShowException(Exception.Create(ErrorMsg));
|
||||
@ -87,10 +87,21 @@ begin
|
||||
TypeMapList.LoadFromFile(GetOptionValue('m'));
|
||||
end;
|
||||
|
||||
|
||||
OutputToFile := HasOption('o');
|
||||
OutputFilename := GetOptionValue('o');
|
||||
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;
|
||||
try
|
||||
for i := 0 to filenames.Count-1 do
|
||||
@ -98,7 +109,7 @@ begin
|
||||
if OutputToFile and (OutputFilename='') then
|
||||
Output.Clear;
|
||||
|
||||
HandleIDLFile(filenames.Strings[i], output, TypeMapList, CTypes, AlwaysAddPrefixToParam);
|
||||
HandleIDLFile(filenames.Strings[i], output, forwardoutput, TypeMapList, CTypes, AlwaysAddPrefixToParam);
|
||||
|
||||
if OutputToFile and (OutputFilename='') then
|
||||
output.SaveToFile(LowerCase(ExtractFileName(ChangeFileExt(filenames.Strings[i],'.inc'))));
|
||||
@ -108,8 +119,12 @@ begin
|
||||
else if OutputFilename<>'' then
|
||||
output.SaveToFile(OutputFilename);
|
||||
|
||||
if assigned(forwardoutput) and (forwardoutput.Count<>0) then
|
||||
forwardoutput.SaveToFile(GetOptionValue('f'));
|
||||
|
||||
finally
|
||||
output.Free;
|
||||
forwardoutput.Free;
|
||||
end;
|
||||
|
||||
finally
|
||||
@ -150,6 +165,8 @@ begin
|
||||
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(' and their Pascal counterpart');
|
||||
writeln(' -f filename Place all forward declarations into one file called ''filename''');
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
|
Reference in New Issue
Block a user