You've already forked lazarus-ccr
objective-c, type parsing improved, expressions parsing improved, bad pascal generated code bug fixed
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@407 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -1,23 +1,59 @@
|
|||||||
{
|
{
|
||||||
ObjCParserUtils.pas
|
ObjCParserUtils.pas
|
||||||
|
|
||||||
Copyright (C) 2008 Dmitry 'Skalogryz' Boyarintsev
|
Copyright (C) 2008 Dmitry 'Skalogryz' Boyarintsev
|
||||||
|
converting obj-c header to pascal (delphi compatible) unit
|
||||||
converting obj-c to objfpc unit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo: a lot of things =)
|
unit ObjCParserUtils;
|
||||||
|
|
||||||
unit ObjCParserUtils;
|
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
{$ifdef fpc}{$mode delphi}{$H+}{$endif}
|
||||||
{$ifdef fpc}{$mode delphi}{$H+}{$endif fpc}
|
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, ObjCParserTypes;
|
Classes, SysUtils, ObjCParserTypes;
|
||||||
|
|
||||||
|
type
|
||||||
|
{ TConvertSettings }
|
||||||
|
//todo: hash table
|
||||||
|
TReplace = class(TObject)
|
||||||
|
Src : AnsiString;
|
||||||
|
Dst : AnsiString;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TReplaceItem = class(TObject)
|
||||||
|
ReplaceStr : AnsiString;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TReplaceList = class(TObject)
|
||||||
|
private
|
||||||
|
fItems : TStringList;
|
||||||
|
protected
|
||||||
|
function GetReplace(const ARepl: AnsiString): AnsiString;
|
||||||
|
procedure SetReplace(const ARepl, AValue: AnsiString);
|
||||||
|
|
||||||
|
function GetCaseSense: Boolean;
|
||||||
|
procedure SetCaseSense(AValue: Boolean);
|
||||||
|
public
|
||||||
|
constructor Create;
|
||||||
|
destructor Destroy; override;
|
||||||
|
property Replace[const s: AnsiString]: AnsiString read GetReplace write SetReplace; default;
|
||||||
|
property CaseSensetive: Boolean read GetCaseSense write SetCaseSense;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TConvertSettings = class(TObject)
|
||||||
|
public
|
||||||
|
IgnoreIncludes : TStringList;
|
||||||
|
DefineReplace : TReplaceList;
|
||||||
|
TypeDefReplace : TReplaceList; // replaces for C types
|
||||||
|
constructor Create;
|
||||||
|
destructor Destroy; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
ConvertSettings : TConvertSettings;
|
||||||
|
|
||||||
procedure WriteOutIncludeFile(hdr: TObjCHeader; st: TStrings);
|
procedure WriteOutIncludeFile(hdr: TObjCHeader; st: TStrings);
|
||||||
|
procedure WriteOutMainFramework(hdr: TObjCHeader; st: TStrings);
|
||||||
|
|
||||||
function ObjCToDelphiType(const objcType: AnsiString; isPointer: Boolean): AnsiString;
|
function ObjCToDelphiType(const objcType: AnsiString; isPointer: Boolean): AnsiString;
|
||||||
|
|
||||||
@ -66,9 +102,6 @@ begin
|
|||||||
'w': Result := (ls = 'while') or (ls = 'with');
|
'w': Result := (ls = 'while') or (ls = 'with');
|
||||||
'x': Result := (ls = 'xor');
|
'x': Result := (ls = 'xor');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetMethodResultType(const m: TClassMethodDef): AnsiString;
|
function GetMethodResultType(const m: TClassMethodDef): AnsiString;
|
||||||
@ -137,6 +170,7 @@ end;
|
|||||||
function ObjCToDelphiType(const objcType: AnsiString; isPointer: Boolean): AnsiString;
|
function ObjCToDelphiType(const objcType: AnsiString; isPointer: Boolean): AnsiString;
|
||||||
var
|
var
|
||||||
l : AnsiString;
|
l : AnsiString;
|
||||||
|
r : AnsiString;
|
||||||
begin
|
begin
|
||||||
Result := objcType;
|
Result := objcType;
|
||||||
l := AnsiLowerCase(objcType);
|
l := AnsiLowerCase(objcType);
|
||||||
@ -164,6 +198,11 @@ begin
|
|||||||
'f':
|
'f':
|
||||||
if l = 'float' then Result := 'Single';
|
if l = 'float' then Result := 'Single';
|
||||||
end;
|
end;
|
||||||
|
if Result = objcType then begin
|
||||||
|
r := ConvertSettings.TypeDefReplace[objcType];
|
||||||
|
if r <> '' then Result := r;
|
||||||
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -252,13 +291,27 @@ end;
|
|||||||
// MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 -> MAC_OS_X_VERSION_10_3
|
// MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 -> MAC_OS_X_VERSION_10_3
|
||||||
// any other #ifdef excpresions would be passed "as is" even if are incorrect
|
// any other #ifdef excpresions would be passed "as is" even if are incorrect
|
||||||
// for pascal
|
// for pascal
|
||||||
function PrecompileIfDefToPascal(const prm: AnsiString): AnsiString;
|
function PrecompileIfDefToPascal(const prm: AnsiString; var isDef: Boolean): AnsiString;
|
||||||
var
|
var
|
||||||
i : Integer;
|
i : Integer;
|
||||||
const
|
vs : AnsiString;
|
||||||
VerExclude = 'MAC_OS_X_VERSION_MAX_ALLOWED >=';
|
|
||||||
begin
|
begin
|
||||||
|
i := 1;
|
||||||
|
ScanWhile(prm, i, [#32, #9]);
|
||||||
|
if prm[i] = '!' then begin
|
||||||
|
isDef := false;
|
||||||
|
inc(i);
|
||||||
|
ScanWhile(prm, i, [#32, #9]);
|
||||||
|
end else
|
||||||
|
isDef :=true;
|
||||||
|
vs := Copy(prm, i, length(prm) - i + 1);
|
||||||
|
|
||||||
// really slow... and... don't like this anyway!
|
// really slow... and... don't like this anyway!
|
||||||
|
vs := ConvertSettings.DefineReplace[vs];
|
||||||
|
if vs <> ''
|
||||||
|
then Result := vs
|
||||||
|
else Result := prm;
|
||||||
|
{ for i := 0 to ConvertSettings.DefineReplace.C
|
||||||
Result := prm;
|
Result := prm;
|
||||||
i := Pos(VerExclude, prm);
|
i := Pos(VerExclude, prm);
|
||||||
if i > 0 then begin
|
if i > 0 then begin
|
||||||
@ -266,7 +319,7 @@ begin
|
|||||||
while (i <= length(Result)) and (Result[i] = ' ') do inc(i);
|
while (i <= length(Result)) and (Result[i] = ' ') do inc(i);
|
||||||
if i <= length(Result) then
|
if i <= length(Result) then
|
||||||
Result := Copy(prm, i, length(Result) - i + 1);
|
Result := Copy(prm, i, length(Result) - i + 1);
|
||||||
end;
|
end;}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// converts TProcpmiler entity to pascal entity
|
// converts TProcpmiler entity to pascal entity
|
||||||
@ -277,13 +330,22 @@ end;
|
|||||||
function WriteOutPrecompToPascal(Prec: TPrecompiler): AnsiString;
|
function WriteOutPrecompToPascal(Prec: TPrecompiler): AnsiString;
|
||||||
var
|
var
|
||||||
dir : AnsiString;
|
dir : AnsiString;
|
||||||
|
prm : AnsiString;
|
||||||
|
isdef : Boolean;
|
||||||
|
const
|
||||||
|
isdefConst : array [Boolean] of AnsiString = ('ifndef', 'ifdef');
|
||||||
begin
|
begin
|
||||||
dir := AnsiLowerCase(Prec._Directive);
|
dir := AnsiLowerCase(Prec._Directive);
|
||||||
if (dir = '#import') or (dir = '#include') then
|
if (dir = '#import') or (dir = '#include') then begin
|
||||||
Result := Format('{$include %s}', [GetIncludeFile(Prec._Params)])
|
|
||||||
else if (dir = '#if') then
|
prm := GetIncludeFile(Prec._Params);
|
||||||
Result := Format('{$ifdef %s}', [PrecompileIfDefToPascal(Prec._Params)])
|
if (prm <> ' .inc') and (ConvertSettings.IgnoreIncludes.IndexOf(prm) < 0) then
|
||||||
else if (dir = '#else') then
|
Result := Format('{$include %s}', [prm]);
|
||||||
|
|
||||||
|
end else if (dir = '#if') then begin
|
||||||
|
prm := PrecompileIfDefToPascal(Prec._Params, isdef);
|
||||||
|
Result := Format('{$%s %s}', [isdefConst[isdef], prm]);
|
||||||
|
end else if (dir = '#else') then
|
||||||
Result := '{$else}'
|
Result := '{$else}'
|
||||||
else if (dir = '#endif') then
|
else if (dir = '#endif') then
|
||||||
Result := '{$endif}';
|
Result := '{$endif}';
|
||||||
@ -385,7 +447,7 @@ var
|
|||||||
begin
|
begin
|
||||||
ppas := WriteOutPrecompToPascal(prec);
|
ppas := WriteOutPrecompToPascal(prec);
|
||||||
isend := IsSubStr('{$endif', ppas, 1);
|
isend := IsSubStr('{$endif', ppas, 1);
|
||||||
if isend or IsSubStr('{$ifdef', ppas, 1) or IsSubStr('{$else', ppas, 1) then
|
if isend or IsSubStr('{$ifndef', ppas, 1) or IsSubStr('{$ifdef', ppas, 1) or IsSubStr('{$else', ppas, 1) then
|
||||||
subs.Add(Prefix + ppas);
|
subs.Add(Prefix + ppas);
|
||||||
if isend then ClearEmptyPrecompile(subs);
|
if isend then ClearEmptyPrecompile(subs);
|
||||||
end;
|
end;
|
||||||
@ -399,20 +461,20 @@ var
|
|||||||
mtd : TClassMethodDef;
|
mtd : TClassMethodDef;
|
||||||
obj : TObject;
|
obj : TObject;
|
||||||
begin
|
begin
|
||||||
if conststr.IndexOf(cl._ClassName) < 0 then begin
|
// if conststr.IndexOf(cl._ClassName) < 0 then begin
|
||||||
conststr.Add(cl._ClassName);
|
// conststr.Add(cl._ClassName);
|
||||||
s := Format(' Str_%s = '#39'%s'#39';', [cl._ClassName, cl._ClassName]);
|
s := Format(' Str%s_%s = '#39'%s'#39';', [cl._ClassName, cl._ClassName, cl._ClassName]);
|
||||||
subs.Add(s);
|
subs.Add(s);
|
||||||
end;
|
// end;
|
||||||
for i := 0 to cl.Items.Count - 1 do begin
|
for i := 0 to cl.Items.Count - 1 do begin
|
||||||
obj := TObject(cl.Items[i]);
|
obj := TObject(cl.Items[i]);
|
||||||
if obj is TClassMethodDef then begin
|
if obj is TClassMethodDef then begin
|
||||||
mtd := TClassMethodDef(cl.Items[i]);
|
mtd := TClassMethodDef(cl.Items[i]);
|
||||||
if conststr.IndexOf(mtd._Name) < 0 then begin
|
// if conststr.IndexOf(mtd._Name) < 0 then begin
|
||||||
conststr.Add(mtd._Name);
|
// conststr.Add(mtd._Name);
|
||||||
ss := Format(' Str_%s = '#39'%s'#39';', [mtd._Name, mtd._Name]);
|
ss := Format(' Str%s_%s = '#39'%s'#39';', [cl._ClassName, mtd._Name, mtd._Name]);
|
||||||
subs.add(ss);
|
subs.add(ss);
|
||||||
end;
|
// end;
|
||||||
end else if obj is TPrecompiler then begin
|
end else if obj is TPrecompiler then begin
|
||||||
WriteOutIfDefPrecompiler(TPrecompiler(obj), ' ', subs);
|
WriteOutIfDefPrecompiler(TPrecompiler(obj), ' ', subs);
|
||||||
end;
|
end;
|
||||||
@ -451,7 +513,8 @@ var
|
|||||||
dlph : AnsiString;
|
dlph : AnsiString;
|
||||||
begin
|
begin
|
||||||
dlph := WriteOutPrecompToPascal(Prec);
|
dlph := WriteOutPrecompToPascal(Prec);
|
||||||
if IsSubStr('{$include', dlph, 1) then st.Add(dlph);
|
if IsSubStr('{$include', dlph, 1) then
|
||||||
|
st.Add(dlph);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetPascalEnumValue(const Name, Param: AnsiString): AnsiString;
|
function GetPascalEnumValue(const Name, Param: AnsiString): AnsiString;
|
||||||
@ -481,6 +544,10 @@ begin
|
|||||||
//todo: improve! check at h2pas
|
//todo: improve! check at h2pas
|
||||||
Result := ReplaceStr('<<', 'shl', vl);
|
Result := ReplaceStr('<<', 'shl', vl);
|
||||||
Result := ReplaceStr('>>', 'shr', Result);
|
Result := ReplaceStr('>>', 'shr', Result);
|
||||||
|
Result := ReplaceStr('||', 'or', Result);
|
||||||
|
Result := ReplaceStr('|', 'or', Result);
|
||||||
|
Result := ReplaceStr('&&', 'and', Result);
|
||||||
|
Result := ReplaceStr('&', 'and', Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure WriteOutEnumValues(enm: TEnumTypeDef; const Prefix: AnsiString; st: TStrings);
|
procedure WriteOutEnumValues(enm: TEnumTypeDef; const Prefix: AnsiString; st: TStrings);
|
||||||
@ -559,20 +626,70 @@ end;
|
|||||||
|
|
||||||
procedure WriteOutEnumToHeader(enm: TEnumTypeDef; st: TStrings);
|
procedure WriteOutEnumToHeader(enm: TEnumTypeDef; st: TStrings);
|
||||||
var
|
var
|
||||||
// i : Integer;
|
i : Integer;
|
||||||
s : AnsiString;
|
// ent : TEnumValue;
|
||||||
|
obj : TObject;
|
||||||
|
pre : TEnumValue;
|
||||||
|
vl : TEnumValue;
|
||||||
|
vls : AnsiString;
|
||||||
|
vli : Integer;
|
||||||
begin
|
begin
|
||||||
if enm._Name = '' then s := EvaluateEnumName(enm)
|
if enm._Name = '' then begin
|
||||||
else s := enm._Name;
|
// unnamed enums are written out as constants
|
||||||
st.Add(Format(' %s = (', [s] ));
|
pre := nil;
|
||||||
WriteOutEnumValues(enm, ' ', st );
|
st.Add('const');
|
||||||
st.Add(' );');
|
vli := 1;
|
||||||
st.Add('');
|
for i := 0 to enm.Items.Count - 1 do begin
|
||||||
|
obj := TObject(enm.Items[i]);
|
||||||
|
if obj is TEnumValue then begin
|
||||||
|
vl := TEnumValue(obj);
|
||||||
|
if vl._Value = '' then begin
|
||||||
|
if not Assigned(pre) then begin
|
||||||
|
vls := '0';
|
||||||
|
pre := vl;
|
||||||
|
end else begin
|
||||||
|
vls := pre._Name + ' + ' + IntToStr(vli);
|
||||||
|
inc(vli);
|
||||||
|
end;
|
||||||
|
end else begin
|
||||||
|
vls := vl._Value;
|
||||||
|
vli := 1;
|
||||||
|
pre := vl;
|
||||||
|
end;
|
||||||
|
st.Add(Format(' %s = %s;', [vl._Name, GetPascalConstValue(vls)]));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
st.Add('');
|
||||||
|
//st.Add('type');
|
||||||
|
end else begin
|
||||||
|
st.Add('type');
|
||||||
|
// named enums are written out as delphi enumerations
|
||||||
|
st.Add(Format(' %s = (', [enm._Name] ));
|
||||||
|
WriteOutEnumValues(enm, ' ', st );
|
||||||
|
st.Add(' );');
|
||||||
|
st.Add('');
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure WriteOutTypeDefToHeader(typedef: TTypeNameDef; const Prefix: AnsiString; subs: TStrings);
|
procedure WriteOutTypeDefToHeader(typedef: TTypeNameDef; const Prefix: AnsiString; subs: TStrings);
|
||||||
|
var
|
||||||
|
vs : AnsiString;
|
||||||
|
tmp : AnsiString;
|
||||||
begin
|
begin
|
||||||
subs.Add( Prefix + Format('%s = %s;', [typedef._TypeName, typedef._Inherited]));
|
vs := ConvertSettings.TypeDefReplace[typedef._Inherited];
|
||||||
|
if vs = '' then vs := typedef._Inherited;
|
||||||
|
if not Assigned(typedef._Type) or (typedef._Type is TTypeDef) then begin
|
||||||
|
subs.Add('type');
|
||||||
|
subs.Add(Prefix + Format('%s = %s;', [typedef._TypeName, vs]))
|
||||||
|
end else begin
|
||||||
|
if typedef._Type is TEnumTypeDef then begin
|
||||||
|
tmp := TEnumTypeDef(typedef._Type)._Name;
|
||||||
|
TEnumTypeDef(typedef._Type)._Name := typedef._TypeName;
|
||||||
|
WriteOutEnumToHeader(TEnumTypeDef(typedef._Type), subs);
|
||||||
|
TEnumTypeDef(typedef._Type)._Name := tmp;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
subs.Add('');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure WriteOutHeaderSection(hdr: TObjCHeader; st: TStrings);
|
procedure WriteOutHeaderSection(hdr: TObjCHeader; st: TStrings);
|
||||||
@ -593,10 +710,12 @@ begin
|
|||||||
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
|
||||||
|
|
||||||
if (TObject(hdr.Items[i]) is TClassDef) then begin
|
if (TObject(hdr.Items[i]) is TClassDef) then 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
|
||||||
|
WriteOutIfDefPrecompiler(TPrecompiler(hdr.Items[i]), SpacePrefix, st);
|
||||||
WriteOutPrecompInclude(TPrecompiler(hdr.Items[i]), st);
|
WriteOutPrecompInclude(TPrecompiler(hdr.Items[i]), st);
|
||||||
WriteOutPrecompDefine(TPrecompiler(hdr.Items[i]), ' ', subs);
|
WriteOutPrecompDefine(TPrecompiler(hdr.Items[i]), ' ', subs);
|
||||||
end;
|
end;
|
||||||
@ -607,7 +726,7 @@ begin
|
|||||||
st.AddStrings(subs);
|
st.AddStrings(subs);
|
||||||
subs.Clear;
|
subs.Clear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
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
|
||||||
if (TObject(hdr.Items[i]) is TEnumTypeDef) then begin
|
if (TObject(hdr.Items[i]) is TEnumTypeDef) then begin
|
||||||
@ -617,11 +736,12 @@ begin
|
|||||||
WriteOutIfDefPrecompiler(TPrecompiler(hdr.Items[i]), SpacePrefix, st);
|
WriteOutIfDefPrecompiler(TPrecompiler(hdr.Items[i]), SpacePrefix, st);
|
||||||
end else if (TObject(hdr.Items[i]) is TTypeNameDef) then begin
|
end else if (TObject(hdr.Items[i]) is TTypeNameDef) then begin
|
||||||
WriteOutTypeDefToHeader(TTypeNameDef(hdr.Items[i]), SpacePrefix, subs);
|
WriteOutTypeDefToHeader(TTypeNameDef(hdr.Items[i]), SpacePrefix, subs);
|
||||||
end;
|
end else if (TObject(hdr.Items[i]) is TSkip) then
|
||||||
|
subs.Add('//'+ TSkip(hdr.Items[i])._Skip);
|
||||||
end; {of if}
|
end; {of if}
|
||||||
|
|
||||||
if subs.Count > 0 then begin
|
if subs.Count > 0 then begin
|
||||||
st.Add('type');
|
//if subs[0] <> 'const' then st.Add('type');
|
||||||
st.AddStrings(subs);
|
st.AddStrings(subs);
|
||||||
subs.Clear;
|
subs.Clear;
|
||||||
end;
|
end;
|
||||||
@ -701,7 +821,9 @@ var
|
|||||||
subs : TStringList;
|
subs : TStringList;
|
||||||
begin
|
begin
|
||||||
BeginSection('CLASSES', st);
|
BeginSection('CLASSES', st);
|
||||||
BeginSection(GetIfDefFileName(hdr._FileName, 'C'), st);
|
//BeginSection(GetIfDefFileName(hdr._FileName, 'C'), st);
|
||||||
|
BeginExcludeSection( GetIfDefFileName(hdr._FileName, 'C'), st);
|
||||||
|
|
||||||
subs := TStringList.Create;
|
subs := TStringList.Create;
|
||||||
try
|
try
|
||||||
for i := 0 to hdr.Items.Count - 1 do
|
for i := 0 to hdr.Items.Count - 1 do
|
||||||
@ -709,9 +831,13 @@ begin
|
|||||||
WriteOutPrecompInclude(TPrecompiler(hdr.Items[i]), st);
|
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]) then begin
|
||||||
WriteOutIfComment(hdr.Items, i - 1, ' ', subs);
|
if TObject(hdr.Items[i]) is TPrecompiler then
|
||||||
WriteOutClassToClasses(TClassDef(hdr.Items[i]), subs);
|
WriteOutIfDefPrecompiler(TPrecompiler(hdr.Items[i]), ' ', subs)
|
||||||
|
else if (TObject(hdr.Items[i]) is TClassDef) then begin
|
||||||
|
WriteOutIfComment(hdr.Items, i - 1, ' ', subs);
|
||||||
|
WriteOutClassToClasses(TClassDef(hdr.Items[i]), subs);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if subs.Count > 0 then begin
|
if subs.Count > 0 then begin
|
||||||
@ -720,6 +846,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
finally
|
finally
|
||||||
|
EndSection(st);
|
||||||
EndSection(st);
|
EndSection(st);
|
||||||
subs.Free;
|
subs.Free;
|
||||||
end;
|
end;
|
||||||
@ -745,12 +872,16 @@ procedure ObjCMethodToProcType(mtd: TClassMethodDef; var typeName: AnsiString; s
|
|||||||
var
|
var
|
||||||
// i : integer;
|
// i : integer;
|
||||||
s : AnsiString;
|
s : AnsiString;
|
||||||
|
ms : AnsiString;
|
||||||
begin
|
begin
|
||||||
typeName := MtdPrefix + mtd._Name + MtdPostFix;
|
typeName := MtdPrefix + mtd._Name + MtdPostFix;
|
||||||
subs.Add('type');
|
subs.Add('type');
|
||||||
// function GetProcFuncHead(const FuncName, OfClass, Params, ResType, FuncDest: AnsiString): AnsiString;
|
// function GetProcFuncHead(const FuncName, OfClass, Params, ResType, FuncDest: AnsiString): AnsiString;
|
||||||
s := typeName + ' = ' + GetProcFuncHead('', '', 'param1: objc.id; param2: SEL; ' + GetMethodParams(mtd), GetMethodResultType(mtd), '' );
|
ms := GetMethodParams(mtd);
|
||||||
subs.Add(' ' + s + ' cdecl;');
|
if ms = '' then ms := 'param1: objc.id; param2: SEL'
|
||||||
|
else ms := 'param1: objc.id; param2: SEL' + ';' + ms;
|
||||||
|
s := Format(' %s = %s cdecl;',[typeName, GetProcFuncHead('', '', ms, GetMethodResultType(mtd), '' )]);
|
||||||
|
subs.Add(s);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetParamsNames(mtd: TClassMethodDef): AnsiString;
|
function GetParamsNames(mtd: TClassMethodDef): AnsiString;
|
||||||
@ -774,52 +905,93 @@ begin
|
|||||||
// Result := Copy(Result, 1, length(Result) - 2);
|
// Result := Copy(Result, 1, length(Result) - 2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
// procedure writes out constructor entity to the implementation section
|
||||||
|
// with the followind structure
|
||||||
|
// assignes object's ClassID usinng GetClass method
|
||||||
|
// creates ObjC object calling objc_method Alloc
|
||||||
|
// adds procedure type and variable of objC init??? method, to wrap obj_SendMsg
|
||||||
|
// initialize ObjC object structure calling init??? method
|
||||||
|
|
||||||
|
procedure WriteOutConstructorMethod(mtd: TClassMethodDef; subs: TStrings);
|
||||||
|
var
|
||||||
|
typeName : AnsiString;
|
||||||
|
cl : TClassDef;
|
||||||
|
begin
|
||||||
|
cl := TClassDef(mtd.Owner);
|
||||||
|
ObjCMethodToProcType(mtd, typeName, subs);
|
||||||
|
subs.Add('var');
|
||||||
|
subs.Add(
|
||||||
|
Format(' vmethod: %s;', [typeName]));
|
||||||
|
subs.Add('begin');
|
||||||
|
subs.Add(' ClassID := getClass();');
|
||||||
|
subs.Add(' allocbuf := objc_msgSend(ClassID, sel_registerName(PChar(Str_alloc)), []);');
|
||||||
|
subs.Add(
|
||||||
|
Format(' vmethod := %s(@objc_msgSend);', [typeName]));
|
||||||
|
subs.Add(
|
||||||
|
Format(' Handle := vmethod(allocbuf, sel_registerName(PChar(Str%s_%s)), %s);', [cl._ClassName, mtd._Name, GetParamsNames(mtd)]));
|
||||||
|
subs.Add('end;');
|
||||||
|
end;
|
||||||
|
|
||||||
|
// writes out a method to implementation section
|
||||||
|
procedure WriteOutMethod(mtd: TClassMethodDef; subs: TStrings);
|
||||||
|
var
|
||||||
|
s : AnsiString;
|
||||||
|
typeName : AnsiString;
|
||||||
|
cl : TClassDef;
|
||||||
|
begin
|
||||||
|
cl := TClassDef(mtd.Owner);
|
||||||
|
s := Format('vmethod(Handle, sel_registerName(PChar(Str%s_%s)), %s)', [cl._ClassName, mtd._Name, GetParamsNames(mtd)]);
|
||||||
|
if ObjCToDelphiType(mtd.GetResultType._Name, mtd.GetResultType._IsPointer) <> '' then
|
||||||
|
s := 'Result := ' + s;
|
||||||
|
ObjCMethodToProcType(mtd, typeName, subs);
|
||||||
|
subs.Add('var');
|
||||||
|
subs.Add(
|
||||||
|
Format(' vmethod: %s;', [typeName]));
|
||||||
|
subs.Add('begin');
|
||||||
|
subs.Add(
|
||||||
|
Format(' vmethod := %s(@objc_msgSend);', [typeName]));
|
||||||
|
subs.Add(
|
||||||
|
Format(' %s;', [s]));
|
||||||
|
subs.Add('end;');
|
||||||
|
end;
|
||||||
|
|
||||||
|
// writes out a method to implementation section, that has no params
|
||||||
|
procedure WriteOutMethodNoParams(mtd: TClassMethodDef; subs: TStrings);
|
||||||
|
var
|
||||||
|
s : AnsiString;
|
||||||
|
res : AnsiString;
|
||||||
|
cl : TClassDef;
|
||||||
|
begin
|
||||||
|
cl := TClassDef(mtd.owner);
|
||||||
|
s := Format('objc_msgSend(Handle, sel_registerName(PChar(Str%s_%s)), [])', [cl._ClassName, mtd._Name]);
|
||||||
|
res := GetMethodResultType(mtd);
|
||||||
|
if res <> '' then begin
|
||||||
|
if res = 'objc.id' then s := 'Result := ' +s
|
||||||
|
else s := 'Result := '+res+'('+s+')'
|
||||||
|
end;
|
||||||
|
|
||||||
|
subs.Add('begin');
|
||||||
|
subs.Add(Format(' %s;', [s]));
|
||||||
|
subs.Add('end;');
|
||||||
|
end;
|
||||||
|
|
||||||
procedure WriteOutMethodToImplementation(mtd: TClassMethodDef; subs: TStrings);
|
procedure WriteOutMethodToImplementation(mtd: TClassMethodDef; subs: TStrings);
|
||||||
var
|
var
|
||||||
cl : TClassDef;
|
cl : TClassDef;
|
||||||
res : Ansistring;
|
|
||||||
sp : AnsiString;
|
|
||||||
s : AnsiString;
|
|
||||||
// isConsts : Boolean;
|
|
||||||
typeName : AnsiString;
|
typeName : AnsiString;
|
||||||
begin
|
begin
|
||||||
typeName := '';
|
typeName := '';
|
||||||
if not Assigned(mtd.Owner) or (not (TObject(mtd.Owner) is TClassDef)) then Exit; // method cannot be without owning class
|
if not Assigned(mtd.Owner) or (not (TObject(mtd.Owner) is TClassDef)) then Exit; // method cannot be without owning class
|
||||||
cl := TClassDef(mtd.Owner);
|
cl := TClassDef(mtd.Owner);
|
||||||
|
|
||||||
subs.Add(GetMethodStr(cl, mtd, true));
|
subs.Add(GetMethodStr(cl, mtd, true));//writes out method header, like function NsType.NsName(params): Result
|
||||||
|
if IsMethodConstructor(cl, mtd) then
|
||||||
if IsMethodConstructor(cl, mtd) then begin
|
WriteOutConstructorMethod(mtd, subs)
|
||||||
subs.Add('begin');
|
else if not isAnyParam(mtd) then
|
||||||
subs.Add(' //todo: constructors are not implemented, yet');
|
WriteOutMethodNoParams(mtd, subs)
|
||||||
subs.Add('end;');
|
else
|
||||||
end else if not isAnyParam(mtd) then begin
|
WriteOutMethod(mtd, subs);
|
||||||
subs.Add('begin');
|
|
||||||
try
|
|
||||||
sp := Format('objc_msgSend(Handle, sel_registerName(PChar(Str_%s)), [])', [mtd._Name]);
|
|
||||||
res := GetMethodResultType(mtd);
|
|
||||||
|
|
||||||
if res <> '' then begin
|
|
||||||
if res = 'objc.id' then sp := 'Result := ' +sp
|
|
||||||
else sp := 'Result := '+res+'('+sp+')'
|
|
||||||
end;
|
|
||||||
subs.Add(' ' + sp+';');
|
|
||||||
finally
|
|
||||||
subs.Add('end;');
|
|
||||||
end;
|
|
||||||
end else begin
|
|
||||||
ObjCMethodToProcType(mtd, typeName, subs);
|
|
||||||
subs.Add('var');
|
|
||||||
subs.Add(Format(' vmethod: %s;', [typeName]));
|
|
||||||
subs.Add('begin');
|
|
||||||
subs.Add(Format(' vmethod := %s(@objc_msgSend);', [typeName]));
|
|
||||||
s := Format('vmethod(Handle, sel_registerName(PChar(Str_%s)), %s)', [mtd._Name, GetParamsNames(mtd)]);
|
|
||||||
if ObjCToDelphiType(mtd.GetResultType._Name, mtd.GetResultType._IsPointer) <> '' then
|
|
||||||
s := 'Result := ' + s;
|
|
||||||
s := s + ';';
|
|
||||||
subs.Add(' ' + s);
|
|
||||||
subs.Add('end;');
|
|
||||||
end;
|
|
||||||
subs.Add('');
|
subs.Add('');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -839,8 +1011,9 @@ begin
|
|||||||
subs.Add('');
|
subs.Add('');
|
||||||
subs.Add(GetProcFuncHead('getClass', cl._ClassName, '', 'objc.id'));
|
subs.Add(GetProcFuncHead('getClass', cl._ClassName, '', 'objc.id'));
|
||||||
subs.Add('begin');
|
subs.Add('begin');
|
||||||
subs.Add(' Result := objc_getClass(Str_'+cl._ClassName+');');
|
subs.Add(
|
||||||
subs.Add('end');
|
Format(' Result := objc_getClass(Str%s_%s);', [cl._ClassName, cl._ClassName]));
|
||||||
|
subs.Add('end;');
|
||||||
subs.Add('');
|
subs.Add('');
|
||||||
|
|
||||||
for i := 0 to cl.Items.Count - 1 do begin
|
for i := 0 to cl.Items.Count - 1 do begin
|
||||||
@ -880,16 +1053,19 @@ begin
|
|||||||
Result := false;
|
Result := false;
|
||||||
EnumIdx := TypeDefIdx - 1;
|
EnumIdx := TypeDefIdx - 1;
|
||||||
if (EnumIdx < 0) or (EnumIdx >= items.Count) then Exit;
|
if (EnumIdx < 0) or (EnumIdx >= items.Count) then Exit;
|
||||||
|
|
||||||
if (TObject(items.Items[TypeDefIdx]) is TTypeNameDef) and
|
if (TObject(items.Items[TypeDefIdx]) is TTypeNameDef) and
|
||||||
(TObject(items.Items[EnumIdx]) is TEnumTypeDef) then begin
|
(TObject(items.Items[EnumIdx]) is TEnumTypeDef) then begin
|
||||||
typedef := TTypeNameDef(items.Items[TypeDefIdx]);
|
typedef := TTypeNameDef(items.Items[TypeDefIdx]);
|
||||||
enumdef := TEnumTypeDef(items.Items[EnumIdx]);
|
enumdef := TEnumTypeDef(items.Items[EnumIdx]);
|
||||||
end else
|
end else
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
if typedef._Inherited = AppleInherit then enumdef._Name := typedef._TypeName;
|
if typedef._Inherited = AppleInherit then begin
|
||||||
Result := true;
|
enumdef._Name := typedef._TypeName;
|
||||||
|
Result := true;
|
||||||
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -972,4 +1148,243 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure WriteOutMainFramework(hdr: TObjCHeader; st: TStrings);
|
||||||
|
//var
|
||||||
|
// i : integer;
|
||||||
|
// nm : AnsiString;
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TConvertSettings }
|
||||||
|
|
||||||
|
constructor TConvertSettings.Create;
|
||||||
|
begin
|
||||||
|
IgnoreIncludes := TStringList.Create;
|
||||||
|
IgnoreIncludes.CaseSensitive := false;
|
||||||
|
DefineReplace := TReplaceList.Create;
|
||||||
|
TypeDefReplace := TReplaceList.Create; // replaces for default types
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TConvertSettings.Destroy;
|
||||||
|
begin
|
||||||
|
IgnoreIncludes.Free;
|
||||||
|
TypeDefReplace.Free;
|
||||||
|
DefineReplace.Free;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure InitConvertSettings;
|
||||||
|
begin
|
||||||
|
with ConvertSettings.IgnoreIncludes do begin
|
||||||
|
// must not be $included, because they are used
|
||||||
|
Add('NSObjCRuntime.inc');
|
||||||
|
Add('NSObject.inc');
|
||||||
|
Add('Foundation.inc');
|
||||||
|
|
||||||
|
Add('NSZone.inc');
|
||||||
|
Add('NSAppleEventDescriptor.inc');
|
||||||
|
Add('NSAppleEventManager.inc');
|
||||||
|
Add('NSAppleScript.inc');
|
||||||
|
Add('NSArchiver.inc');
|
||||||
|
Add('NSArray.inc');
|
||||||
|
Add('NSAttributedString.inc');
|
||||||
|
Add('NSAutoreleasePool.inc');
|
||||||
|
Add('NSBundle.inc');
|
||||||
|
Add('NSByteOrder.inc');
|
||||||
|
Add('NSCalendar.inc');
|
||||||
|
Add('NSCalendarDate.inc');
|
||||||
|
Add('NSCharacterSet.inc');
|
||||||
|
Add('NSClassDescription.inc');
|
||||||
|
Add('NSCoder.inc');
|
||||||
|
Add('NSComparisonPredicate.inc');
|
||||||
|
Add('NSCompoundPredicate.inc');
|
||||||
|
Add('NSConnection.inc');
|
||||||
|
Add('NSData.inc');
|
||||||
|
Add('NSDate.inc');
|
||||||
|
Add('NSDateFormatter.inc');
|
||||||
|
Add('NSDebug.inc');
|
||||||
|
Add('NSDecimal.inc');
|
||||||
|
Add('NSDecimalNumber.inc');
|
||||||
|
Add('NSDictionary.inc');
|
||||||
|
Add('NSDistantObject.inc');
|
||||||
|
Add('NSDistributedLock.inc');
|
||||||
|
Add('NSDistributedNotificationCenter.inc');
|
||||||
|
Add('NSEnumerator.inc');
|
||||||
|
Add('NSError.inc');
|
||||||
|
Add('NSException.inc');
|
||||||
|
Add('NSExpression.inc');
|
||||||
|
Add('NSFileHandle.inc');
|
||||||
|
Add('NSFileManager.inc');
|
||||||
|
Add('NSFormatter.hinc');
|
||||||
|
Add('NSGarbageCollector.inc');
|
||||||
|
Add('NSGeometry.inc');
|
||||||
|
Add('NSHashTable.inc');
|
||||||
|
Add('NSHFSFileTypes.inc');
|
||||||
|
Add('NSHost.inc');
|
||||||
|
Add('NSHTTPCookie.inc');
|
||||||
|
Add('NSHTTPCookieStorage.inc');
|
||||||
|
Add('NSIndexPath.inc');
|
||||||
|
Add('NSIndexSet.inc');
|
||||||
|
Add('NSInvocation.inc');
|
||||||
|
Add('NSJavaSetup.inc');
|
||||||
|
Add('NSKeyedArchiver.inc');
|
||||||
|
Add('NSKeyValueCoding.inc');
|
||||||
|
Add('NSKeyValueObserving.inc');
|
||||||
|
Add('NSLocale.inc');
|
||||||
|
Add('NSLock.inc');
|
||||||
|
Add('NSMapTable.inc');
|
||||||
|
Add('NSMetadata.inc');
|
||||||
|
Add('NSMethodSignature.inc');
|
||||||
|
Add('NSNetServices.inc');
|
||||||
|
Add('NSNotification.inc');
|
||||||
|
Add('NSNotificationQueue.inc');
|
||||||
|
Add('NSNull.inc');
|
||||||
|
Add('NSNumberFormatter.inc');
|
||||||
|
Add('NSObjectScripting.inc');
|
||||||
|
Add('NSOperation.inc');
|
||||||
|
Add('NSPathUtilities.inc');
|
||||||
|
Add('NSPointerArray.inc');
|
||||||
|
Add('NSPointerFunctions.inc');
|
||||||
|
Add('NSPort.inc');
|
||||||
|
Add('NSPortCoder.inc');
|
||||||
|
Add('NSPortMessage.inc');
|
||||||
|
Add('NSPortNameServer.inc');
|
||||||
|
Add('NSPredicate.inc');
|
||||||
|
Add('NSProcessInfo.inc');
|
||||||
|
Add('NSPropertyList.inc');
|
||||||
|
Add('NSProtocolChecker.inc');
|
||||||
|
Add('NSProxy.inc');
|
||||||
|
Add('NSRange.inc');
|
||||||
|
Add('NSRunLoop.inc');
|
||||||
|
Add('NSScanner.inc');
|
||||||
|
Add('NSScriptClassDescription.inc');
|
||||||
|
Add('NSScriptCoercionHandler.inc');
|
||||||
|
Add('NSScriptCommand.inc');
|
||||||
|
Add('NSScriptCommandDescription.inc');
|
||||||
|
Add('NSScriptExecutionContext.inc');
|
||||||
|
Add('NSScriptKeyValueCoding.inc');
|
||||||
|
Add('NSScriptObjectSpecifiers.inc');
|
||||||
|
Add('NSScriptStandardSuiteCommands.inc');
|
||||||
|
Add('NSScriptSuiteRegistry.inc');
|
||||||
|
Add('NSScriptWhoseTests.inc');
|
||||||
|
Add('NSSet.inc');
|
||||||
|
Add('NSSortDescriptor.inc');
|
||||||
|
Add('NSSpellServer.inc');
|
||||||
|
Add('NSStream.inc');
|
||||||
|
Add('NSString.inc');
|
||||||
|
Add('NSTask.inc');
|
||||||
|
Add('NSThread.inc');
|
||||||
|
Add('NSTimer.inc');
|
||||||
|
Add('NSTimeZone.inc');
|
||||||
|
Add('NSUndoManager.inc');
|
||||||
|
Add('NSURL.inc');
|
||||||
|
Add('NSURLAuthenticationChallenge.inc');
|
||||||
|
Add('NSURLCache.inc');
|
||||||
|
Add('NSURLConnection.inc');
|
||||||
|
Add('NSURLCredential.inc');
|
||||||
|
Add('NSURLCredentialStorage.inc');
|
||||||
|
Add('NSURLDownload.inc');
|
||||||
|
Add('NSURLError.inc');
|
||||||
|
Add('NSURLHandle.inc');
|
||||||
|
Add('NSURLProtectionSpace.inc');
|
||||||
|
Add('NSURLProtocol.inc');
|
||||||
|
Add('NSURLRequest.inc');
|
||||||
|
Add('NSURLResponse.inc');
|
||||||
|
Add('NSUserDefaults.inc');
|
||||||
|
Add('NSValue.inc');
|
||||||
|
Add('NSValueTransformer.inc');
|
||||||
|
Add('NSXMLDocument.inc');
|
||||||
|
Add('NSXMLDTD.inc');
|
||||||
|
Add('NSXMLDTDNode.inc');
|
||||||
|
Add('NSXMLElement.inc');
|
||||||
|
Add('NSXMLNode.inc');
|
||||||
|
Add('NSXMLNodeOptions.inc');
|
||||||
|
Add('NSXMLParser.inc');
|
||||||
|
// temporary
|
||||||
|
Add('ApplicationServices.inc');
|
||||||
|
Add('IOLLEvent.inc');
|
||||||
|
Add('Limits.inc');
|
||||||
|
Add('AvailabilityMacros.inc');
|
||||||
|
Add('CCImage.inc');
|
||||||
|
Add('NSStringEncoding.inc');
|
||||||
|
Add('NSGlyph.inc');
|
||||||
|
Add('CFDate.inc');
|
||||||
|
Add('CFRunLoop.inc');
|
||||||
|
Add('gl.inc');
|
||||||
|
Add('UTF32Char.inc');
|
||||||
|
Add('CoreFoundation.inc');
|
||||||
|
Add('NSFetchRequest.inc');
|
||||||
|
Add('NSAttributeDescription.inc');
|
||||||
|
end;
|
||||||
|
with ConvertSettings do begin
|
||||||
|
DefineReplace['MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2'] := 'MAC_OS_X_VERSION_10_2';
|
||||||
|
DefineReplace['MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3'] := 'MAC_OS_X_VERSION_10_3';
|
||||||
|
DefineReplace['MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4'] := 'MAC_OS_X_VERSION_10_4';
|
||||||
|
DefineReplace['MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5'] := 'MAC_OS_X_VERSION_10_5';
|
||||||
|
DefineReplace['__LP64__'] := 'LP64';
|
||||||
|
TypeDefReplace['uint32_t'] := 'LongWord';
|
||||||
|
TypeDefReplace['uint8_t'] := 'byte';
|
||||||
|
TypeDefReplace['NSUInteger'] := 'LongWord';
|
||||||
|
end;
|
||||||
|
//????
|
||||||
|
// Values['MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2'] := 'MAC_OS_X_VERSION_10_2';
|
||||||
|
// Values['MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3'] := 'MAC_OS_X_VERSION_10_3';
|
||||||
|
// Values['MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4'] := 'MAC_OS_X_VERSION_10_4';
|
||||||
|
// Values['MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5'] := 'MAC_OS_X_VERSION_10_5';
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TReplaceList }
|
||||||
|
|
||||||
|
constructor TReplaceList.Create;
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
fItems := TStringList.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TReplaceList.Destroy;
|
||||||
|
begin
|
||||||
|
fItems.Free;
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TReplaceList.GetCaseSense: Boolean;
|
||||||
|
begin
|
||||||
|
Result := fItems.CaseSensitive;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TReplaceList.SetCaseSense(AValue: Boolean);
|
||||||
|
begin
|
||||||
|
fITems.CaseSensitive := AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TReplaceList.GetReplace(const ARepl: AnsiString): AnsiString;
|
||||||
|
var
|
||||||
|
i : integer;
|
||||||
|
begin
|
||||||
|
i := fItems.IndexOf(ARepl);
|
||||||
|
if i < 0 then Result := ''
|
||||||
|
else Result := TReplaceItem(fItems.Objects[i]).ReplaceStr;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TReplaceList.SetReplace(const ARepl, AValue: AnsiString);
|
||||||
|
var
|
||||||
|
i : integer;
|
||||||
|
it : TReplaceItem;
|
||||||
|
begin
|
||||||
|
i := fItems.IndexOf(ARepl);
|
||||||
|
if i < 0 then begin
|
||||||
|
it := TReplaceItem.Create;
|
||||||
|
it.ReplaceStr := AValue;
|
||||||
|
fItems.AddObject(Arepl, it);
|
||||||
|
end else
|
||||||
|
TReplaceItem(fItems.Objects[i]).ReplaceStr := AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
ConvertSettings := TConvertSettings.Create;
|
||||||
|
InitConvertSettings;
|
||||||
|
|
||||||
|
finalization
|
||||||
|
ConvertSettings.Free;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
<MainUnitHasCreateFormStatements Value="False"/>
|
<MainUnitHasCreateFormStatements Value="False"/>
|
||||||
<MainUnitHasTitleStatement Value="False"/>
|
<MainUnitHasTitleStatement Value="False"/>
|
||||||
</Flags>
|
</Flags>
|
||||||
<SessionStorage Value="InProjectDir"/>
|
|
||||||
<MainUnit Value="0"/>
|
<MainUnit Value="0"/>
|
||||||
<IconPath Value="./"/>
|
<IconPath Value="./"/>
|
||||||
<TargetFileExt Value=".exe"/>
|
<TargetFileExt Value=".exe"/>
|
||||||
<UseAppBundle Value="False"/>
|
<UseAppBundle Value="False"/>
|
||||||
|
<ActiveEditorIndexAtStart Value="3"/>
|
||||||
</General>
|
</General>
|
||||||
<VersionInfo>
|
<VersionInfo>
|
||||||
<ProjectVersion Value=""/>
|
<ProjectVersion Value=""/>
|
||||||
@ -30,22 +30,248 @@
|
|||||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||||
</local>
|
</local>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<Units Count="3">
|
<Units Count="31">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="objcparser.pas"/>
|
<Filename Value="objcparser.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="Project1"/>
|
<UnitName Value="Project1"/>
|
||||||
|
<CursorPos X="18" Y="20"/>
|
||||||
|
<TopLine Value="1"/>
|
||||||
|
<EditorIndex Value="0"/>
|
||||||
|
<UsageCount Value="69"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
</Unit0>
|
</Unit0>
|
||||||
<Unit1>
|
<Unit1>
|
||||||
|
<Filename Value="ObjCParserUtils.pas"/>
|
||||||
|
<UnitName Value="ObjCParserUtils"/>
|
||||||
|
<CursorPos X="1" Y="10"/>
|
||||||
|
<TopLine Value="1"/>
|
||||||
|
<EditorIndex Value="4"/>
|
||||||
|
<UsageCount Value="33"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit1>
|
||||||
|
<Unit2>
|
||||||
|
<Filename Value="ObjCParserTypes.pas"/>
|
||||||
|
<UnitName Value="ObjCParserTypes"/>
|
||||||
|
<CursorPos X="1" Y="266"/>
|
||||||
|
<TopLine Value="253"/>
|
||||||
|
<EditorIndex Value="3"/>
|
||||||
|
<UsageCount Value="33"/>
|
||||||
|
<Bookmarks Count="1">
|
||||||
|
<Item0 X="1" Y="589" ID="0"/>
|
||||||
|
</Bookmarks>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit2>
|
||||||
|
<Unit3>
|
||||||
|
<Filename Value="../foundation/foundation.pas"/>
|
||||||
|
<UnitName Value="foundation"/>
|
||||||
|
<CursorPos X="28" Y="10"/>
|
||||||
|
<TopLine Value="1"/>
|
||||||
|
<UsageCount Value="8"/>
|
||||||
|
</Unit3>
|
||||||
|
<Unit4>
|
||||||
|
<Filename Value="../appkit/AppKit.inc"/>
|
||||||
|
<CursorPos X="18" Y="156"/>
|
||||||
|
<TopLine Value="156"/>
|
||||||
|
<UsageCount Value="11"/>
|
||||||
|
</Unit4>
|
||||||
|
<Unit5>
|
||||||
|
<Filename Value="../../objc/objc.pas"/>
|
||||||
|
<UnitName Value="objc"/>
|
||||||
|
<CursorPos X="32" Y="38"/>
|
||||||
|
<TopLine Value="36"/>
|
||||||
|
<UsageCount Value="12"/>
|
||||||
|
</Unit5>
|
||||||
|
<Unit6>
|
||||||
|
<Filename Value="../../objc/objc-api.inc"/>
|
||||||
|
<CursorPos X="106" Y="9"/>
|
||||||
|
<TopLine Value="8"/>
|
||||||
|
<UsageCount Value="8"/>
|
||||||
|
</Unit6>
|
||||||
|
<Unit7>
|
||||||
|
<Filename Value="../appkit/NSActionCell.inc"/>
|
||||||
|
<CursorPos X="49" Y="34"/>
|
||||||
|
<TopLine Value="13"/>
|
||||||
|
<UsageCount Value="8"/>
|
||||||
|
</Unit7>
|
||||||
|
<Unit8>
|
||||||
|
<Filename Value="../appkit/NSCell.inc"/>
|
||||||
|
<CursorPos X="1" Y="48"/>
|
||||||
|
<TopLine Value="42"/>
|
||||||
|
<UsageCount Value="8"/>
|
||||||
|
</Unit8>
|
||||||
|
<Unit9>
|
||||||
|
<Filename Value="../foundation/NSGeometry.inc"/>
|
||||||
|
<CursorPos X="1" Y="46"/>
|
||||||
|
<TopLine Value="26"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit9>
|
||||||
|
<Unit10>
|
||||||
|
<Filename Value="../foundation/NSObject.inc"/>
|
||||||
|
<CursorPos X="37" Y="302"/>
|
||||||
|
<TopLine Value="302"/>
|
||||||
|
<UsageCount Value="13"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit10>
|
||||||
|
<Unit11>
|
||||||
<Filename Value="pascodeutils.pas"/>
|
<Filename Value="pascodeutils.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="pascodeutils"/>
|
<UnitName Value="pascodeutils"/>
|
||||||
</Unit1>
|
<CursorPos X="1" Y="13"/>
|
||||||
<Unit2>
|
<TopLine Value="1"/>
|
||||||
|
<UsageCount Value="66"/>
|
||||||
|
</Unit11>
|
||||||
|
<Unit12>
|
||||||
|
<Filename Value="../appkit/NSWindow.inc"/>
|
||||||
|
<CursorPos X="37" Y="302"/>
|
||||||
|
<TopLine Value="302"/>
|
||||||
|
<UsageCount Value="15"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit12>
|
||||||
|
<Unit13>
|
||||||
|
<Filename Value="test.inc"/>
|
||||||
|
<CursorPos X="9" Y="18"/>
|
||||||
|
<TopLine Value="1"/>
|
||||||
|
<UsageCount Value="9"/>
|
||||||
|
</Unit13>
|
||||||
|
<Unit14>
|
||||||
|
<Filename Value="NSWindow.h"/>
|
||||||
|
<CursorPos X="35" Y="194"/>
|
||||||
|
<TopLine Value="172"/>
|
||||||
|
<UsageCount Value="24"/>
|
||||||
|
<SyntaxHighlighter Value="C++"/>
|
||||||
|
</Unit14>
|
||||||
|
<Unit15>
|
||||||
|
<Filename Value="../../objc/objc-runtime.inc"/>
|
||||||
|
<CursorPos X="1" Y="127"/>
|
||||||
|
<TopLine Value="127"/>
|
||||||
|
<UsageCount Value="12"/>
|
||||||
|
</Unit15>
|
||||||
|
<Unit16>
|
||||||
|
<Filename Value="headers/NSScreen.h"/>
|
||||||
|
<CursorPos X="1" Y="9"/>
|
||||||
|
<TopLine Value="1"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
<SyntaxHighlighter Value="C++"/>
|
||||||
|
</Unit16>
|
||||||
|
<Unit17>
|
||||||
|
<Filename Value="../foundation/NSAutoreleasePool.inc"/>
|
||||||
|
<CursorPos X="16" Y="12"/>
|
||||||
|
<TopLine Value="12"/>
|
||||||
|
<UsageCount Value="9"/>
|
||||||
|
</Unit17>
|
||||||
|
<Unit18>
|
||||||
|
<Filename Value="../appkit/NSButton.inc"/>
|
||||||
|
<CursorPos X="23" Y="15"/>
|
||||||
|
<TopLine Value="12"/>
|
||||||
|
<UsageCount Value="9"/>
|
||||||
|
</Unit18>
|
||||||
|
<Unit19>
|
||||||
|
<Filename Value="../appkit/NSControl.inc"/>
|
||||||
|
<CursorPos X="21" Y="151"/>
|
||||||
|
<TopLine Value="139"/>
|
||||||
|
<UsageCount Value="13"/>
|
||||||
|
</Unit19>
|
||||||
|
<Unit20>
|
||||||
|
<Filename Value="headers/NSButton.h"/>
|
||||||
|
<CursorPos X="1" Y="23"/>
|
||||||
|
<TopLine Value="4"/>
|
||||||
|
<UsageCount Value="9"/>
|
||||||
|
<SyntaxHighlighter Value="C++"/>
|
||||||
|
</Unit20>
|
||||||
|
<Unit21>
|
||||||
|
<Filename Value="NSWindow.inc"/>
|
||||||
|
<CursorPos X="51" Y="447"/>
|
||||||
|
<TopLine Value="442"/>
|
||||||
|
<UsageCount Value="19"/>
|
||||||
|
</Unit21>
|
||||||
|
<Unit22>
|
||||||
<Filename Value="NSWindow2.h"/>
|
<Filename Value="NSWindow2.h"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
</Unit2>
|
<CursorPos X="44" Y="16"/>
|
||||||
|
<TopLine Value="11"/>
|
||||||
|
<UsageCount Value="47"/>
|
||||||
|
<SyntaxHighlighter Value="C++"/>
|
||||||
|
</Unit22>
|
||||||
|
<Unit23>
|
||||||
|
<Filename Value="../uikit/UIKit.h"/>
|
||||||
|
<CursorPos X="1" Y="31"/>
|
||||||
|
<TopLine Value="1"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
<SyntaxHighlighter Value="C++"/>
|
||||||
|
</Unit23>
|
||||||
|
<Unit24>
|
||||||
|
<Filename Value="../appkit/NSAlert.inc"/>
|
||||||
|
<CursorPos X="1" Y="61"/>
|
||||||
|
<TopLine Value="38"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit24>
|
||||||
|
<Unit25>
|
||||||
|
<Filename Value="../appkit/NSPanel.inc"/>
|
||||||
|
<CursorPos X="1" Y="34"/>
|
||||||
|
<TopLine Value="11"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit25>
|
||||||
|
<Unit26>
|
||||||
|
<Filename Value="../appkit/NSView.inc"/>
|
||||||
|
<CursorPos X="5" Y="136"/>
|
||||||
|
<TopLine Value="121"/>
|
||||||
|
<UsageCount Value="13"/>
|
||||||
|
</Unit26>
|
||||||
|
<Unit27>
|
||||||
|
<Filename Value="headersMacOS/NSWindow.inc"/>
|
||||||
|
<CursorPos X="37" Y="302"/>
|
||||||
|
<TopLine Value="302"/>
|
||||||
|
<UsageCount Value="12"/>
|
||||||
|
</Unit27>
|
||||||
|
<Unit28>
|
||||||
|
<Filename Value="../appkit/appkit.pas"/>
|
||||||
|
<UnitName Value="appkit"/>
|
||||||
|
<CursorPos X="1" Y="7"/>
|
||||||
|
<TopLine Value="1"/>
|
||||||
|
<UsageCount Value="11"/>
|
||||||
|
</Unit28>
|
||||||
|
<Unit29>
|
||||||
|
<Filename Value="NSFontPanelUnit.pas"/>
|
||||||
|
<UnitName Value="NSFontPanelUnit"/>
|
||||||
|
<CursorPos X="25" Y="93"/>
|
||||||
|
<TopLine Value="79"/>
|
||||||
|
<EditorIndex Value="1"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit29>
|
||||||
|
<Unit30>
|
||||||
|
<Filename Value="objc.pas"/>
|
||||||
|
<UnitName Value="objc"/>
|
||||||
|
<CursorPos X="10" Y="19"/>
|
||||||
|
<TopLine Value="5"/>
|
||||||
|
<EditorIndex Value="2"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit30>
|
||||||
</Units>
|
</Units>
|
||||||
|
<JumpHistory Count="5" HistoryIndex="4">
|
||||||
|
<Position1>
|
||||||
|
<Filename Value="NSFontPanelUnit.pas"/>
|
||||||
|
<Caret Line="1" Column="1" TopLine="1"/>
|
||||||
|
</Position1>
|
||||||
|
<Position2>
|
||||||
|
<Filename Value="NSFontPanelUnit.pas"/>
|
||||||
|
<Caret Line="92" Column="75" TopLine="79"/>
|
||||||
|
</Position2>
|
||||||
|
<Position3>
|
||||||
|
<Filename Value="NSFontPanelUnit.pas"/>
|
||||||
|
<Caret Line="1" Column="1" TopLine="1"/>
|
||||||
|
</Position3>
|
||||||
|
<Position4>
|
||||||
|
<Filename Value="NSFontPanelUnit.pas"/>
|
||||||
|
<Caret Line="93" Column="25" TopLine="79"/>
|
||||||
|
</Position4>
|
||||||
|
<Position5>
|
||||||
|
<Filename Value="objcparser.pas"/>
|
||||||
|
<Caret Line="199" Column="34" TopLine="193"/>
|
||||||
|
</Position5>
|
||||||
|
</JumpHistory>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
<Version Value="5"/>
|
<Version Value="5"/>
|
||||||
@ -59,4 +285,16 @@
|
|||||||
<CompilerPath Value="$(CompPath)"/>
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
</Other>
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
|
<Debugging>
|
||||||
|
<BreakPoints Count="2">
|
||||||
|
<Item1>
|
||||||
|
<Source Value="C:/Games/CodeTest2/Sources/examples/codecompletion.lpr"/>
|
||||||
|
<Line Value="47"/>
|
||||||
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<Source Value="../../LazTest4/consolethreads.pas"/>
|
||||||
|
<Line Value="18"/>
|
||||||
|
</Item2>
|
||||||
|
</BreakPoints>
|
||||||
|
</Debugging>
|
||||||
</CONFIG>
|
</CONFIG>
|
||||||
|
@ -14,13 +14,15 @@ program Project1;
|
|||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, ObjCParserUtils, ObjCParserTypes;
|
Classes,
|
||||||
|
SysUtils,
|
||||||
|
ObjCParserUtils,
|
||||||
|
ObjCParserTypes;
|
||||||
|
|
||||||
type
|
type
|
||||||
// this object is used only for precomile directives handling
|
// this object is used only for precomile directives handling
|
||||||
|
|
||||||
{ TPrecompileHandler }
|
{ TPrecompileHandler }
|
||||||
|
|
||||||
TPrecompileHandler = class(TObject)
|
TPrecompileHandler = class(TObject)
|
||||||
public
|
public
|
||||||
hdr : TObjCHeader;
|
hdr : TObjCHeader;
|
||||||
@ -28,7 +30,7 @@ type
|
|||||||
procedure OnComment(Sender: TObject; const Comment: AnsiString);
|
procedure OnComment(Sender: TObject; const Comment: AnsiString);
|
||||||
constructor Create(AHeader: TObjCHeader);
|
constructor Create(AHeader: TObjCHeader);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPrecompileHandler.OnPrecompile(Sender: TObject);
|
procedure TPrecompileHandler.OnPrecompile(Sender: TObject);
|
||||||
var
|
var
|
||||||
parser : TTextParser;
|
parser : TTextParser;
|
||||||
@ -83,15 +85,19 @@ begin
|
|||||||
hdr := AHeader;
|
hdr := AHeader;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ReadAndParseFile(const FileName: AnsiString; outdata: TStrings);
|
function ReadAndParseFile(const FileName: AnsiString; outdata: TStrings; var Err: AnsiString): Boolean;
|
||||||
var
|
var
|
||||||
hdr : TObjCHeader;
|
hdr : TObjCHeader;
|
||||||
parser : TTextParser;
|
parser : TTextParser;
|
||||||
prec : TPrecompileHandler ;
|
prec : TPrecompileHandler ;
|
||||||
s : AnsiString;
|
s : AnsiString;
|
||||||
|
i, cnt : integer;
|
||||||
begin
|
begin
|
||||||
if not FileExists(FileName) then
|
Result :=false;
|
||||||
|
if not FileExists(FileName) then begin
|
||||||
|
Err := 'File not found: ' + FileName;
|
||||||
Exit;
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
s := StrFromFile(FileName);
|
s := StrFromFile(FileName);
|
||||||
hdr := TObjCHeader.Create;
|
hdr := TObjCHeader.Create;
|
||||||
@ -106,7 +112,21 @@ begin
|
|||||||
parser.OnPrecompile := prec.OnPrecompile;
|
parser.OnPrecompile := prec.OnPrecompile;
|
||||||
parser.OnComment := prec.OnComment;
|
parser.OnComment := prec.OnComment;
|
||||||
hdr._FileName := ExtractFileName(FileName);
|
hdr._FileName := ExtractFileName(FileName);
|
||||||
hdr.Parse(parser);
|
Result := hdr.Parse(parser);
|
||||||
|
if not Result then begin
|
||||||
|
if parser.Errors.Count > 0 then Err := parser.Errors[0]
|
||||||
|
else Err := 'undesribed error';
|
||||||
|
|
||||||
|
Err := Err + #13#10;
|
||||||
|
cnt := 120;
|
||||||
|
i := parser.Index - cnt;
|
||||||
|
if i <= 0 then begin
|
||||||
|
i := 1;
|
||||||
|
cnt := parser.Index;
|
||||||
|
end;
|
||||||
|
Err := Err + Copy(parser.Buf, i, cnt);
|
||||||
|
end;
|
||||||
|
|
||||||
except
|
except
|
||||||
end;
|
end;
|
||||||
WriteOutIncludeFile(hdr, outdata);
|
WriteOutIncludeFile(hdr, outdata);
|
||||||
@ -128,14 +148,17 @@ var
|
|||||||
incs : AnsiString;
|
incs : AnsiString;
|
||||||
st : TStringList;
|
st : TStringList;
|
||||||
f : Text;
|
f : Text;
|
||||||
|
err : AnsiString;
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
writeln('would you like to parse of local files .h to inc?');
|
writeln('would you like to parse all current directory files .h to inc?');
|
||||||
readln(ch);
|
readln(ch);
|
||||||
if (ch <> 'Y') and (ch <> 'y') then begin
|
if (ch <> 'Y') and (ch <> 'y') then begin
|
||||||
writeln('as you wish, bye!');
|
writeln('as you wish, bye!');
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
pth := IncludeTrailingPathDelimiter( GetCurrentDir);
|
pth := IncludeTrailingPathDelimiter( GetCurrentDir);
|
||||||
writeln('looking for .h files in ', pth);
|
writeln('looking for .h files in ', pth);
|
||||||
res := FindFirst(pth + '*.h', -1, srch);
|
res := FindFirst(pth + '*.h', -1, srch);
|
||||||
@ -146,20 +169,23 @@ begin
|
|||||||
write('found: ', srch.Name);
|
write('found: ', srch.Name);
|
||||||
write(' parsing...');
|
write(' parsing...');
|
||||||
//writeln('parsing: ', pth+srch.Name);
|
//writeln('parsing: ', pth+srch.Name);
|
||||||
ReadAndParseFile(pth+srch.Name, st);
|
if ReadAndParseFile(pth+srch.Name, st, err) then begin
|
||||||
write(' parsed ');
|
write(' parsed ');
|
||||||
incs := pth + Copy(srch.Name,1, length(srch.Name) - length(ExtractFileExt(srch.Name)));
|
incs := pth + Copy(srch.Name,1, length(srch.Name) - length(ExtractFileExt(srch.Name)));
|
||||||
incs := incs + '.inc';
|
incs := incs + '.inc';
|
||||||
//writeln(incs);
|
//writeln(incs);
|
||||||
assignfile(f, incs); rewrite(f);
|
assignfile(f, incs); rewrite(f);
|
||||||
try
|
try
|
||||||
for i := 0 to st.Count - 1 do
|
for i := 0 to st.Count - 1 do
|
||||||
writeln(f, st[i]);
|
writeln(f, st[i]);
|
||||||
finally
|
finally
|
||||||
closefile(f);
|
closefile(f);
|
||||||
|
end;
|
||||||
|
st.Clear;
|
||||||
|
writeln(' converted!');
|
||||||
|
end else begin
|
||||||
|
writeln('Error: ', err);
|
||||||
end;
|
end;
|
||||||
st.Clear;
|
|
||||||
writeln(' converted!');
|
|
||||||
until FindNext(srch) <> 0;
|
until FindNext(srch) <> 0;
|
||||||
|
|
||||||
finally
|
finally
|
||||||
@ -167,8 +193,6 @@ begin
|
|||||||
st.Free;
|
st.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -176,6 +200,7 @@ var
|
|||||||
inpf : AnsiString;
|
inpf : AnsiString;
|
||||||
st : TStrings;
|
st : TStrings;
|
||||||
i : integer;
|
i : integer;
|
||||||
|
err : AnsiString;
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
inpf := ParamStr(1);
|
inpf := ParamStr(1);
|
||||||
@ -186,9 +211,11 @@ begin
|
|||||||
|
|
||||||
st := TStringList.Create;
|
st := TStringList.Create;
|
||||||
try
|
try
|
||||||
ReadAndParseFile(inpf, st);
|
if not ReadAndParseFile(inpf, st, err) then
|
||||||
for i := 0 to st.Count - 1 do
|
writeln('Error: ', err)
|
||||||
writeln(st[i]);
|
else
|
||||||
|
for i := 0 to st.Count - 1 do
|
||||||
|
writeln(st[i]);
|
||||||
except
|
except
|
||||||
end;
|
end;
|
||||||
st.Free;
|
st.Free;
|
||||||
|
Reference in New Issue
Block a user