android-sdk: Fixes some bugs in the string read/write and in the object read/write

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1788 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat
2011-08-08 16:03:47 +00:00
parent 36b5c94eb9
commit 2c47f0a180
5 changed files with 74 additions and 16 deletions

View File

@ -57,10 +57,11 @@
<ComponentName Value="Form1"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="mainform"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="0"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="34" Y="38"/>
<TopLine Value="6"/>
<CursorPos X="87" Y="47"/>
<UsageCount Value="34"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
@ -119,8 +120,8 @@
<UnitName Value="android_sdk_bindings_gen"/>
<EditorIndex Value="2"/>
<WindowIndex Value="0"/>
<TopLine Value="388"/>
<CursorPos X="114" Y="402"/>
<TopLine Value="762"/>
<CursorPos X="1" Y="798"/>
<UsageCount Value="34"/>
<Loaded Value="True"/>
</Unit8>
@ -198,11 +199,10 @@
</Unit17>
<Unit18>
<Filename Value="sdk_level_7/android_all.txt"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="4"/>
<WindowIndex Value="0"/>
<TopLine Value="38"/>
<CursorPos X="9" Y="46"/>
<TopLine Value="46"/>
<CursorPos X="42" Y="63"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
<DefaultSyntaxHighlighter Value="None"/>
@ -220,13 +220,13 @@
<EditorIndex Value="3"/>
<WindowIndex Value="0"/>
<TopLine Value="365"/>
<CursorPos X="63" Y="381"/>
<CursorPos X="38" Y="381"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
<DefaultSyntaxHighlighter Value="Java"/>
</Unit20>
</Units>
<JumpHistory Count="21" HistoryIndex="20">
<JumpHistory Count="28" HistoryIndex="27">
<Position1>
<Filename Value="android_sdk_bindings_gen.pas"/>
<Caret Line="641" Column="54" TopLine="637"/>
@ -311,6 +311,34 @@
<Filename Value="android_sdk_bindings_gen.pas"/>
<Caret Line="171" Column="31" TopLine="134"/>
</Position21>
<Position22>
<Filename Value="android_sdk_bindings_gen.pas"/>
<Caret Line="385" Column="1" TopLine="370"/>
</Position22>
<Position23>
<Filename Value="android_sdk_bindings_gen.pas"/>
<Caret Line="325" Column="22" TopLine="309"/>
</Position23>
<Position24>
<Filename Value="android_sdk_bindings_gen.pas"/>
<Caret Line="727" Column="32" TopLine="722"/>
</Position24>
<Position25>
<Filename Value="mainform.pas"/>
<Caret Line="38" Column="34" TopLine="1"/>
</Position25>
<Position26>
<Filename Value="mainform.pas"/>
<Caret Line="40" Column="32" TopLine="2"/>
</Position26>
<Position27>
<Filename Value="mainform.pas"/>
<Caret Line="48" Column="62" TopLine="2"/>
</Position27>
<Position28>
<Filename Value="mainform.pas"/>
<Caret Line="49" Column="15" TopLine="5"/>
</Position28>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>

View File

@ -322,6 +322,8 @@ var
lJavaParamVar, lJavaParams, lJavaParamSelf: string;
// For adding the var for string params
HasStringParam: Boolean = False;
StringParamCount: Integer = 0;
i: Integer;
begin
if ASourceLine = '' then Exit;
@ -377,13 +379,15 @@ begin
// Pascal parameter sending
if lParamTypePas = 'string' then
begin
FPasOutputImpl.Add(Format(' lString := TString.Create(%s);', [lParamName]));
FPasOutputImpl.Add(' vAndroidPipesComm.SendInt(lString.Index); // text');
FPasOutputImpl.Add(' lString.Free;');
HasStringParam := True;
Inc(StringParamCount);
FPasOutputImpl.Insert(FPasOutputImplCurLine+1, Format(' lString_%d := TString.Create(%s);', [StringParamCount, lParamName]));
FPasOutputImpl.Add(Format(' vAndroidPipesComm.SendInt(lString_%d.Index); // text', [StringParamCount]));
end
else
FPasOutputImpl.Add(' vAndroidPipesComm.SendInt(Integer(' + lParamName + '));');
else if IsBasicJavaType(lParamType) then
FPasOutputImpl.Add(' vAndroidPipesComm.SendInt(Integer(' + lParamName + '));')
else // for objects
FPasOutputImpl.Add(' vAndroidPipesComm.SendInt(Integer(' + lParamName + '.Index));');
// Java parameter reading
lJavaParamVar := Format('l%s_%d', [ConvertPointToUnderline(lParamType), lParamNum]);
@ -420,7 +424,11 @@ begin
if HasStringParam then
begin
FPasOutputImpl.Insert(FPasOutputImplCurLine+1, 'var');
FPasOutputImpl.Insert(FPasOutputImplCurLine+2, ' lString: TString;');
for i := 1 to StringParamCount do
begin
FPasOutputImpl.Insert(FPasOutputImplCurLine+1+i, Format(' lString_%d: TString;', [i]));
FPasOutputImpl.Add(Format(' lString_%d.Free;', [i]));
end;
end;
FPasOutputImpl.Add('end;');
FPasOutputImpl.Add('');
@ -718,6 +726,8 @@ begin
if AType = 'boolean' then Exit('lBool')
else if AType = 'int' then Exit('lInt')
else if AType = 'float' then Exit('lFloat')
else if AType = 'CharSequence' then
Result := Format('(%s) MyJavaLang.LangElements.get(lInt)', [AType])
else Result := Format('(%s) ViewElements.get(lInt)', [AType]);
end;

View File

@ -44,4 +44,13 @@ object Form1: TForm1
OnClick = Button1Click
TabOrder = 1
end
object Button2: TButton
Left = 17
Height = 25
Top = 160
Width = 155
Caption = 'Copy to the LCL'
OnClick = Button2Click
TabOrder = 2
end
end

View File

@ -14,10 +14,12 @@ type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
editInputPath: TDirectoryEdit;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ private declarations }
public
@ -38,5 +40,14 @@ begin
AndroidSDKBindingsGen.GenerateAllBindings(editInputPath.Text, editInputPath.Text, editInputPath.Text);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
lSourcePath, lDestPath: String;
begin
lSourcePath := IncludeTrailingPathDelimiter(editInputPath.Text) + 'android_all.pas';
lDestPath := '/home/felipe/Programas/lazarus/lcl/interfaces/android/android_all.pas';
FileUtil.CopyFile(lSourcePath, lDestPath);
end;
end.

View File

@ -47,7 +47,7 @@ method void addView(View child, ViewGroup.LayoutParams params);
[LinearLayout] ViewGroup
constructor Create(Activity);
procedure setOrientation(int orientation);
method void setOrientation(int orientation);
const HORIZONTAL = 0;
const VERTICAL = 1;