mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 12:49:20 +02:00
* pas2jni: Fixed memory leaks.
git-svn-id: trunk@32744 -
This commit is contained in:
parent
e3d2980c98
commit
95f933049a
@ -67,15 +67,17 @@ begin
|
||||
Result.Text:=r;
|
||||
end;
|
||||
|
||||
procedure ParseCmdLine;
|
||||
function ParseCmdLine: boolean;
|
||||
var
|
||||
i: integer;
|
||||
s, ss: string;
|
||||
sl: TStringList;
|
||||
begin
|
||||
Result:=False;
|
||||
if ParamCount = 0 then begin
|
||||
ShowUsage;
|
||||
Halt(1);
|
||||
ErrorCode:=1;
|
||||
exit;
|
||||
end;
|
||||
for i:=1 to Paramcount do begin
|
||||
s:=ParamStr(i);
|
||||
@ -151,12 +153,13 @@ begin
|
||||
'?', 'H':
|
||||
begin
|
||||
ShowUsage;
|
||||
Halt(0);
|
||||
exit;
|
||||
end;
|
||||
else
|
||||
begin
|
||||
writeln('Illegal parameter: -', s);
|
||||
Halt(1);
|
||||
ErrorCode:=1;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end
|
||||
@ -170,20 +173,21 @@ begin
|
||||
w.Units.Add(ExtractFileName(s));
|
||||
end;
|
||||
end;
|
||||
Result:=True;
|
||||
end;
|
||||
|
||||
begin
|
||||
try
|
||||
w:=TWriter.Create;
|
||||
try
|
||||
ParseCmdLine;
|
||||
w.ProcessUnits;
|
||||
if ParseCmdLine then
|
||||
w.ProcessUnits;
|
||||
finally
|
||||
w.Free;
|
||||
end;
|
||||
except
|
||||
writeln(Exception(ExceptObject).Message);
|
||||
Halt(2);
|
||||
ErrorCode:=2;
|
||||
end;
|
||||
end.
|
||||
|
||||
|
@ -59,7 +59,7 @@ var
|
||||
|
||||
implementation
|
||||
|
||||
uses process, pipes, fpjson, jsonparser;
|
||||
uses process, pipes, fpjson, jsonparser, jsonscanner;
|
||||
|
||||
const
|
||||
OnExceptionProcName = 'JNI_OnException';
|
||||
@ -119,7 +119,7 @@ constructor TPPUParser.Create(const ASearchPath: string);
|
||||
begin
|
||||
SearchPath:=TStringList.Create;
|
||||
AddSearchPath(ASearchPath);
|
||||
Units:=TDef.Create(nil, dtNone);
|
||||
Units:=TDef.Create;
|
||||
end;
|
||||
|
||||
destructor TPPUParser.Destroy;
|
||||
@ -188,7 +188,6 @@ end;
|
||||
function TPPUParser.InternalParse(const AUnitName: string): TUnitDef;
|
||||
var
|
||||
junit: TJSONObject;
|
||||
jp: TJSONParser;
|
||||
deref: array of TUnitDef;
|
||||
CurUnit: TUnitDef;
|
||||
IsSystemUnit: boolean;
|
||||
@ -550,6 +549,8 @@ var
|
||||
i, j: integer;
|
||||
s: string;
|
||||
chkres: TCheckItemResult;
|
||||
jp: TJSONParser;
|
||||
jdata: TJSONData;
|
||||
begin
|
||||
Result:=nil;
|
||||
for i:=0 to Units.Count - 1 do
|
||||
@ -569,11 +570,12 @@ begin
|
||||
|
||||
s:=ReadUnit(AUnitName);
|
||||
try
|
||||
junit:=nil;
|
||||
jdata:=nil;
|
||||
try
|
||||
jp:=TJSONParser.Create(s);
|
||||
jp:=TJSONParser.Create(s, [joUTF8]);
|
||||
try
|
||||
junit:=TJSONObject(jp.Parse.Items[0]);
|
||||
jdata:=jp.Parse;
|
||||
junit:=TJSONObject(jdata.Items[0]);
|
||||
finally
|
||||
jp.Free;
|
||||
end;
|
||||
@ -591,6 +593,9 @@ begin
|
||||
Result.OS:=Copy(Result.OS, 1, Length(Result.OS) - j - 1);
|
||||
Result.IntfCRC:=junit.Strings['InterfaceCRC'];
|
||||
|
||||
if IsSystemUnit then
|
||||
Result.IsUsed:=True;
|
||||
|
||||
if not FDefaultSearchPathAdded then begin
|
||||
FDefaultSearchPathAdded:=True;
|
||||
AddDefaultSearchPath(AnsiLowerCase(Result.CPU), AnsiLowerCase(Result.OS));
|
||||
@ -631,7 +636,7 @@ begin
|
||||
end;
|
||||
SetLength(Result.UsedUnits, j);
|
||||
finally
|
||||
junit.Free;
|
||||
jdata.Free;
|
||||
end;
|
||||
except
|
||||
if CurObjName <> '' then
|
||||
|
Loading…
Reference in New Issue
Block a user