You've already forked lazarus-ccr
updated, fixed ifndef usage
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@397 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -158,7 +158,7 @@ end;
|
|||||||
// returns define pas file name form Objective C name, like
|
// returns define pas file name form Objective C name, like
|
||||||
// NSApplication.h -> NSAPPLICATION_PAS_H
|
// NSApplication.h -> NSAPPLICATION_PAS_H
|
||||||
// SomePath/SomePath/SomeFileName.h -> SOMEFILENAME_PAS_H
|
// SomePath/SomePath/SomeFileName.h -> SOMEFILENAME_PAS_H
|
||||||
function GetIfDefFileName(const FileName: AnsiString): AnsiString;
|
function GetIfDefFileName(const FileName, DefExt: AnsiString): AnsiString;
|
||||||
var
|
var
|
||||||
i : integer;
|
i : integer;
|
||||||
s : AnsiString;
|
s : AnsiString;
|
||||||
@ -169,7 +169,7 @@ begin
|
|||||||
for i := 1 to length(Result) do
|
for i := 1 to length(Result) do
|
||||||
if Result[i] = '.' then
|
if Result[i] = '.' then
|
||||||
Result[i] := '_';
|
Result[i] := '_';
|
||||||
Result := Result + '_PAS_H';
|
Result := Result + '_PAS_'+DefExt;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// returns include pas file name form Objective C name, like
|
// returns include pas file name form Objective C name, like
|
||||||
@ -310,21 +310,20 @@ begin
|
|||||||
subs.Delete(i);
|
subs.Delete(i);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure BeginSection(const FileName, SectionName: AnsiString; st: TStrings);
|
procedure BeginSection(const SectionName: AnsiString; st: TStrings);
|
||||||
var
|
|
||||||
nm : AnsiString;
|
|
||||||
begin
|
begin
|
||||||
nm := GetIfDefFileName(FileName);
|
|
||||||
st.Add('{$ifdef '+SectionName+'}');
|
st.Add('{$ifdef '+SectionName+'}');
|
||||||
st.Add('{$ifndef '+nm+'}');
|
end;
|
||||||
st.Add('{$define '+nm+'}');
|
|
||||||
st.Add('');
|
procedure BeginExcludeSection(const DefineName: AnsiString; st: TStrings);
|
||||||
|
begin
|
||||||
|
st.Add('{$ifndef '+DefineName+'}');
|
||||||
|
st.Add('{$define '+DefineName+'}');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure EndSection(st: TStrings);
|
procedure EndSection(st: TStrings);
|
||||||
begin
|
begin
|
||||||
st.Add('{$endif}');
|
st.Add('{$endif}');
|
||||||
st.Add('{$endif}');
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// todo: remove Prefix param...
|
// todo: remove Prefix param...
|
||||||
@ -370,7 +369,7 @@ begin
|
|||||||
subs.Add('');
|
subs.Add('');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure WriteOutPrecompToHeader(Prec: TPrecompiler; st: TStrings);
|
procedure WriteOutPrecompInclude(Prec: TPrecompiler; st: TStrings);
|
||||||
var
|
var
|
||||||
dlph : AnsiString;
|
dlph : AnsiString;
|
||||||
begin
|
begin
|
||||||
@ -509,9 +508,11 @@ var
|
|||||||
const
|
const
|
||||||
SpacePrefix = ' ';
|
SpacePrefix = ' ';
|
||||||
begin
|
begin
|
||||||
BeginSection(hdr._FileName, 'HEADER', st);
|
BeginSection('HEADER', st);
|
||||||
|
BeginExcludeSection( GetIfDefFileName(hdr._FileName, 'H'), st);
|
||||||
subs := TStringList.Create;
|
subs := TStringList.Create;
|
||||||
consts := TStringList.Create;
|
consts := TStringList.Create;
|
||||||
|
|
||||||
try
|
try
|
||||||
for i := 0 to hdr.Items.Count - 1 do
|
for i := 0 to hdr.Items.Count - 1 do
|
||||||
if Assigned(hdr.Items[i]) then begin
|
if Assigned(hdr.Items[i]) then begin
|
||||||
@ -519,7 +520,7 @@ begin
|
|||||||
cl := TClassDef(hdr.Items[i]);
|
cl := TClassDef(hdr.Items[i]);
|
||||||
WriteOutClassToHeader(cl, subs, consts);
|
WriteOutClassToHeader(cl, subs, consts);
|
||||||
end else if (TObject(hdr.Items[i]) is TPrecompiler) then begin
|
end else if (TObject(hdr.Items[i]) is TPrecompiler) then begin
|
||||||
WriteOutPrecompToHeader(TPrecompiler(hdr.Items[i]), st);
|
WriteOutPrecompInclude(TPrecompiler(hdr.Items[i]), st);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -548,6 +549,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
finally
|
finally
|
||||||
|
EndSection(st);
|
||||||
EndSection(st);
|
EndSection(st);
|
||||||
subs.Free;
|
subs.Free;
|
||||||
consts.Free;
|
consts.Free;
|
||||||
@ -620,9 +622,14 @@ var
|
|||||||
s : AnsiString;
|
s : AnsiString;
|
||||||
subs : TStringList;
|
subs : TStringList;
|
||||||
begin
|
begin
|
||||||
BeginSection(hdr._FileName, 'CLASSES', st);
|
BeginSection('CLASSES', st);
|
||||||
|
BeginSection(GetIfDefFileName(hdr._FileName, 'C'), st);
|
||||||
subs := TStringList.Create;
|
subs := TStringList.Create;
|
||||||
try
|
try
|
||||||
|
for i := 0 to hdr.Items.Count - 1 do
|
||||||
|
if Assigned(hdr.Items[i]) then
|
||||||
|
WriteOutPrecompInclude(TPrecompiler(hdr.Items[i]), st);
|
||||||
|
|
||||||
for i := 0 to hdr.Items.Count - 1 do
|
for i := 0 to hdr.Items.Count - 1 do
|
||||||
if Assigned(hdr.Items[i]) and (TObject(hdr.Items[i]) is TClassDef) then begin
|
if Assigned(hdr.Items[i]) and (TObject(hdr.Items[i]) is TClassDef) then begin
|
||||||
WriteOutIfComment(hdr.Items, i - 1, ' ', subs);
|
WriteOutIfComment(hdr.Items, i - 1, ' ', subs);
|
||||||
@ -771,7 +778,7 @@ procedure WriteOutImplementationSection(hdr: TObjCHeader; st: TStrings);
|
|||||||
var
|
var
|
||||||
i : Integer;
|
i : Integer;
|
||||||
begin
|
begin
|
||||||
BeginSection(hdr._FileName, 'IMPLEMENTATION', st);
|
BeginSection('IMPLEMENTATION', st);
|
||||||
try
|
try
|
||||||
for i := 0 to hdr.Items.Count - 1 do
|
for i := 0 to hdr.Items.Count - 1 do
|
||||||
if Assigned(hdr.Items[i]) then begin
|
if Assigned(hdr.Items[i]) then begin
|
||||||
|
Reference in New Issue
Block a user