* pas2jni: fixed processing of int64 and boolean constants. Also fixes to correctly process whole System unit.

git-svn-id: trunk@24512 -
This commit is contained in:
yury 2013-05-15 15:34:10 +00:00
parent 10c1b11d15
commit 94197aade9
2 changed files with 31 additions and 8 deletions

View File

@ -402,7 +402,8 @@ var
BasicType:=btWideString
else
BasicType:=btString;
CurObjName:=s + 'string';
if not (IsSystemUnit and (CompareText(CurObjName, 'rawbytestring') = 0)) then
CurObjName:=s + 'string';
end
else
if jt = 'enum' then begin
@ -434,6 +435,8 @@ var
d.SymId:=it.Get('SymId', -1);
s:=it.Get('Visibility', '');
d.IsPrivate:=(s <> '') and (s <> 'public') and (s <> 'published');
if Copy(d.Name, 1, 1) = '$' then
d.IsPrivate:=True;
// Specific def attributes
case d.DefType of
@ -491,6 +494,9 @@ var
if it.Get('MethodPtr', False) then
ProcOpt:=ProcOpt + [poMethodPtr];
if IsSystemUnit and (ProcType = ptFunction) and (Name = 'int') then
Name:='Int';
_ReadDefs(d, it, 'Params');
end;
dtVar, dtField, dtParam:

View File

@ -618,11 +618,12 @@ begin
pi.JniName:=s;
pi.JniSignature:=GetProcSignature(d);
if AParent = nil then begin
// Checking duplicate name
// Checking duplicate name and duplicate params
ClassIdx:=FClasses.IndexOf(GetJavaClassName(d.Parent, ItemDef));
if ClassIdx >= 0 then begin
ci:=TClassInfo(FClasses.Objects[ClassIdx]);
j:=1;
ss:=Copy(pi.JniSignature, 1, Pos(')', pi.JniSignature));
repeat
err:=False;
for i:=0 to ci.Funcs.Count - 1 do
@ -632,7 +633,11 @@ begin
pi.JniName:=Format('%s_%d', [s, j]);
err:=True;
break;
end;
end
else
if (CompareText(Name, pi.Name) = 0) and (ss = Copy(JniSignature, 1, Pos(')', JniSignature))) then
// Duplicate params
exit;
until not err;
end;
@ -942,19 +947,31 @@ end;
procedure TWriter.WriteConst(d: TConstDef);
var
s: string;
s, v: string;
begin
if not d.IsUsed then
exit;
v:=d.Value;
if d.VarType = nil then begin
if Copy(d.Value, 1, 1) = '"' then
s:='String'
else
s:='double';
end
else
else begin
s:=DefToJavaType(d.VarType);
Fjs.WriteLn(Format('public static final %s %s = %s;', [s, d.Name, d.Value]));
if d.VarType.DefType = dtType then
case TTypeDef(d.VarType).BasicType of
btLongWord, btInt64:
v:=v + 'L';
btBoolean:
if v = '1' then
v:='true'
else
v:='false';
end;
end;
Fjs.WriteLn(Format('public static final %s %s = %s;', [s, d.Name, v]));
end;
procedure TWriter.WriteEnum(d: TDef);
@ -1479,12 +1496,12 @@ begin
Result:=Format('char(widechar(%s))', [Result]);
btWideChar:
Result:=Format('widechar(%s)', [Result]);
btEnum:
Result:=Format('%s(%s)', [d.Name, Result]);
btPointer:
Result:=Format('pointer(ptruint(%s))', [Result]);
btGuid:
Result:=Format('StringToGUID(ansistring(_StringFromJString(_env, %s)))', [Result]);
else
Result:=Format('%s(%s)', [d.Name, Result]);
end;
dtClass:
begin