Android-SDK: Finishes fixing all compilation errors from generated Pascal and Java
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1785 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
4e6ea3a726
commit
0a80e54a1d
@ -39,7 +39,7 @@
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="18">
|
||||
<Units Count="20">
|
||||
<Unit0>
|
||||
<Filename Value="android_bindings_generator.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -48,7 +48,7 @@
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="1"/>
|
||||
<CursorPos X="15" Y="14"/>
|
||||
<UsageCount Value="32"/>
|
||||
<UsageCount Value="34"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
@ -61,7 +61,7 @@
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="1"/>
|
||||
<CursorPos X="34" Y="38"/>
|
||||
<UsageCount Value="32"/>
|
||||
<UsageCount Value="34"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
</Unit1>
|
||||
@ -117,12 +117,11 @@
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="android_sdk_bindings_gen"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="150"/>
|
||||
<CursorPos X="54" Y="169"/>
|
||||
<UsageCount Value="32"/>
|
||||
<TopLine Value="501"/>
|
||||
<CursorPos X="5" Y="517"/>
|
||||
<UsageCount Value="34"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
@ -160,22 +159,20 @@
|
||||
<Unit13>
|
||||
<Filename Value="../../../p-tools/systeminfo4android/androidpipescomm.pas"/>
|
||||
<UnitName Value="androidpipescomm"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="127"/>
|
||||
<CursorPos X="17" Y="161"/>
|
||||
<UsageCount Value="11"/>
|
||||
<UsageCount Value="13"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit13>
|
||||
<Unit14>
|
||||
<Filename Value="sdk_level_7/android_all.pas"/>
|
||||
<UnitName Value="android_all"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="1"/>
|
||||
<CursorPos X="82" Y="15"/>
|
||||
<UsageCount Value="11"/>
|
||||
<Loaded Value="True"/>
|
||||
<CursorPos X="1" Y="1"/>
|
||||
<UsageCount Value="12"/>
|
||||
</Unit14>
|
||||
<Unit15>
|
||||
<Filename Value="../../../p-tools/systeminfo4android/javalang.pas"/>
|
||||
@ -195,132 +192,157 @@
|
||||
</Unit16>
|
||||
<Unit17>
|
||||
<Filename Value="sdk_level_7/AndroidAll.java"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="251"/>
|
||||
<CursorPos X="48" Y="251"/>
|
||||
<UsageCount Value="10"/>
|
||||
<TopLine Value="441"/>
|
||||
<CursorPos X="16" Y="441"/>
|
||||
<UsageCount Value="12"/>
|
||||
<Loaded Value="True"/>
|
||||
<DefaultSyntaxHighlighter Value="Java"/>
|
||||
</Unit17>
|
||||
<Unit18>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="50"/>
|
||||
<CursorPos X="13" Y="55"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
<DefaultSyntaxHighlighter Value="None"/>
|
||||
</Unit18>
|
||||
<Unit19>
|
||||
<Filename Value="../../../lazarus/lcl/graphics.pp"/>
|
||||
<UnitName Value="Graphics"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="501"/>
|
||||
<CursorPos X="54" Y="525"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit19>
|
||||
</Units>
|
||||
<JumpHistory Count="29" HistoryIndex="28">
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="438" Column="51" TopLine="433"/>
|
||||
<Caret Line="641" Column="54" TopLine="637"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="403" Column="65" TopLine="379"/>
|
||||
<Caret Line="641" Column="8" TopLine="617"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="391" Column="22" TopLine="379"/>
|
||||
<Caret Line="22" Column="27" TopLine="1"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="sdk_level_7/android_all.pas"/>
|
||||
<Caret Line="363" Column="24" TopLine="333"/>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="60" Column="17" TopLine="31"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="122" Column="21" TopLine="97"/>
|
||||
<Caret Line="110" Column="18" TopLine="103"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="138" Column="4" TopLine="98"/>
|
||||
<Caret Line="375" Column="33" TopLine="343"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="432" Column="91" TopLine="386"/>
|
||||
<Caret Line="22" Column="29" TopLine="1"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="416" Column="64" TopLine="392"/>
|
||||
<Caret Line="23" Column="15" TopLine="1"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="../../../p-tools/systeminfo4android/androidpipescomm.pas"/>
|
||||
<Caret Line="161" Column="17" TopLine="127"/>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="106" Column="72" TopLine="106"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="38" Column="34" TopLine="1"/>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="212" Column="35" TopLine="184"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="532" Column="35" TopLine="515"/>
|
||||
<Caret Line="375" Column="65" TopLine="351"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="293" Column="3" TopLine="287"/>
|
||||
<Caret Line="374" Column="50" TopLine="351"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="439" Column="1" TopLine="393"/>
|
||||
<Caret Line="36" Column="19" TopLine="3"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="448" Column="1" TopLine="414"/>
|
||||
<Caret Line="689" Column="24" TopLine="664"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="399" Column="77" TopLine="384"/>
|
||||
<Caret Line="375" Column="1" TopLine="352"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="478" Column="23" TopLine="451"/>
|
||||
<Filename Value="sdk_level_7/AndroidAll.java"/>
|
||||
<Caret Line="248" Column="22" TopLine="214"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="460" Column="27" TopLine="430"/>
|
||||
<Filename Value="sdk_level_7/AndroidAll.java"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="462" Column="97" TopLine="438"/>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="6" Column="43" TopLine="1"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="27" Column="30" TopLine="1"/>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="33" Column="24" TopLine="1"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="604" Column="42" TopLine="569"/>
|
||||
<Caret Line="40" Column="18" TopLine="3"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="602" Column="1" TopLine="577"/>
|
||||
<Caret Line="713" Column="13" TopLine="689"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="601" Column="55" TopLine="577"/>
|
||||
<Filename Value="sdk_level_7/AndroidAll.java"/>
|
||||
<Caret Line="156" Column="27" TopLine="131"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="389" Column="1" TopLine="356"/>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="23" Column="34" TopLine="1"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="25" Column="15" TopLine="12"/>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="54" Column="13" TopLine="14"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="302" Column="31" TopLine="289"/>
|
||||
<Caret Line="41" Column="53" TopLine="3"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="399" Column="67" TopLine="367"/>
|
||||
<Caret Line="677" Column="1" TopLine="673"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="641" Column="54" TopLine="637"/>
|
||||
<Caret Line="153" Column="40" TopLine="134"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="sdk_level_7/android_all.pas"/>
|
||||
<Caret Line="459" Column="85" TopLine="442"/>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="171" Column="31" TopLine="134"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="641" Column="8" TopLine="617"/>
|
||||
<Filename Value="sdk_level_7/AndroidAll.java"/>
|
||||
<Caret Line="417" Column="1" TopLine="403"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="../../../lazarus/lcl/graphics.pp"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
@ -19,6 +19,8 @@ type
|
||||
FJavaOutputIDs, FJavaOutputMethods: TStringList;
|
||||
FClassName, FClassNamePas: string; // Class name of the class currently being parsed
|
||||
FClassNum, FMethodNum: Integer;
|
||||
procedure GeneratePascalFile(ASourceFile: string; ADest: TStringList);
|
||||
procedure GenerateJavaFile(ASourceFile: string; ADest: TStringList);
|
||||
procedure ProcessModelFile(ASourceFile, APasOutputFile, AJavaOutputFile: string);
|
||||
procedure ProcessModelLine(ASourceLine: string);
|
||||
procedure ProcessModelClass(ASourceLine: string);
|
||||
@ -31,8 +33,12 @@ type
|
||||
function PassByReference(ABaseName: string): Boolean;
|
||||
function GetJavaResultFunction(AReturnType: string): string;
|
||||
function GetJavaTypeReader(AType: string): string;
|
||||
function GetJavaTypeLocalVar(AType: string): string;
|
||||
function GetJavaTypeConverter(AType: string): string;
|
||||
function GetIDString(AMethodName: string): string;
|
||||
procedure AddOutputIDs(AIDString: string);
|
||||
function ConvertPointToUnderline(AStr: string): string;
|
||||
function IsBasicJavaType(AStr: string): Boolean;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
@ -46,6 +52,144 @@ implementation
|
||||
|
||||
{ TAndroidSDKBindingsGen }
|
||||
|
||||
procedure TAndroidSDKBindingsGen.GeneratePascalFile(ASourceFile: string; ADest: TStringList);
|
||||
begin
|
||||
ADest.Add(Format('unit %s;', [ChangeFileExt(ExtractFileName(ASourceFile), '')]));
|
||||
ADest.Add('');
|
||||
ADest.Add('interface');
|
||||
ADest.Add('');
|
||||
ADest.Add('uses javalang, androidpipescomm;');
|
||||
ADest.Add('');
|
||||
ADest.Add('type');
|
||||
ADest.Add('');
|
||||
ADest.Add(' { Forward declaration of classes }');
|
||||
ADest.Add('');
|
||||
ADest.AddStrings(FPasOutputClassesForward);
|
||||
ADest.Add('');
|
||||
ADest.Add(' { Types }');
|
||||
ADest.Add('');
|
||||
ADest.AddStrings(FPasOutputTypes);
|
||||
ADest.Add('');
|
||||
ADest.Add(' { Classes }');
|
||||
ADest.Add('');
|
||||
ADest.AddStrings(FPasOutputClasses);
|
||||
ADest.Add(' end;');
|
||||
ADest.Add('');
|
||||
ADest.Add('function HandleMessage(AFirstInt: Integer): Boolean;');
|
||||
ADest.Add('');
|
||||
ADest.Add('implementation');
|
||||
ADest.Add('');
|
||||
ADest.Add('const');
|
||||
ADest.Add(' { Constants }');
|
||||
ADest.Add('');
|
||||
ADest.AddStrings(FPasOutputConsts);
|
||||
ADest.Add('');
|
||||
ADest.Add(' { IDs }');
|
||||
ADest.Add('');
|
||||
ADest.AddStrings(FPasOutputIDs);
|
||||
ADest.Add('');
|
||||
ADest.Add('{ Implementation of Classes }');
|
||||
ADest.Add('');
|
||||
ADest.AddStrings(FPasOutputImpl);
|
||||
ADest.Add('');
|
||||
ADest.Add('{ Message Handling }');
|
||||
ADest.Add('');
|
||||
ADest.Add('function HandleMessage(AFirstInt: Integer): Boolean;');
|
||||
ADest.Add('var');
|
||||
ADest.Add(' lInt: Integer;');
|
||||
ADest.Add(' lPascalPointer: PtrInt = -1;');
|
||||
ADest.Add('begin');
|
||||
ADest.Add(' case AFirstInt of');
|
||||
ADest.AddStrings(FPasOutputMessages);
|
||||
ADest.Add(' end;');
|
||||
ADest.Add('end;');
|
||||
ADest.Add('');
|
||||
ADest.Add('end.');
|
||||
end;
|
||||
|
||||
procedure TAndroidSDKBindingsGen.GenerateJavaFile(ASourceFile: string; ADest: TStringList);
|
||||
begin
|
||||
ADest.Add('package com.pascal.androidlcl;');
|
||||
ADest.Add('');
|
||||
ADest.Add('import android.app.*;');
|
||||
ADest.Add('import android.view.*;');
|
||||
ADest.Add('import android.os.*;');
|
||||
ADest.Add('import android.util.*;');
|
||||
ADest.Add('import android.content.*;');
|
||||
ADest.Add('import android.view.*;');
|
||||
ADest.Add('import android.widget.*;');
|
||||
ADest.Add('import java.util.*;');
|
||||
ADest.Add('import java.lang.*;');
|
||||
ADest.Add('');
|
||||
ADest.Add('public class AndroidAll');
|
||||
ADest.Add('{');
|
||||
ADest.Add(' // info from other classes');
|
||||
ADest.Add(' Activity activity;');
|
||||
ADest.Add(' AndroidPipesComm MyAndroidPipesComm;');
|
||||
ADest.Add(' JavaLang MyJavaLang;');
|
||||
ADest.Add(' // lists of variables');
|
||||
ADest.Add(' ArrayList ViewElements;');
|
||||
ADest.Add('');
|
||||
ADest.Add(' public AndroidAll(AndroidPipesComm AAndroidPipesComm, Activity AActivity, JavaLang AJavaLang)');
|
||||
ADest.Add(' {');
|
||||
ADest.Add(' activity = AActivity;');
|
||||
ADest.Add(' MyAndroidPipesComm = AAndroidPipesComm;');
|
||||
ADest.Add(' MyJavaLang = AJavaLang;');
|
||||
ADest.Add(' ViewElements = new ArrayList();');
|
||||
ADest.Add(' }');
|
||||
ADest.Add('');
|
||||
ADest.Add(' public void DebugOut(String Str)');
|
||||
ADest.Add(' {');
|
||||
ADest.Add(' MyAndroidPipesComm.DebugOut(Str);');
|
||||
ADest.Add(' }');
|
||||
ADest.Add('');
|
||||
ADest.AddStrings(FJavaOutputIDs);
|
||||
ADest.Add('');
|
||||
ADest.Add(' public boolean ProcessCommand(int Buffer)');
|
||||
ADest.Add(' {');
|
||||
ADest.Add(' //DebugOut("AndroidUI.ProcessCommand Command=" + java.lang.Integer.toHexString(Buffer));');
|
||||
ADest.Add(' // basic types');
|
||||
ADest.Add(' int lInt, lIndex, lPascalPointer;');
|
||||
ADest.Add(' boolean lBool;');
|
||||
ADest.Add(' float lFloat;');
|
||||
ADest.Add(' // Self params');
|
||||
ADest.Add(' View param_self_View;');
|
||||
ADest.Add(' ViewGroup param_self_ViewGroup;');
|
||||
ADest.Add(' TextView param_self_TextView;');
|
||||
ADest.Add(' Button param_self_Button;');
|
||||
ADest.Add(' EditText param_self_EditText;');
|
||||
ADest.Add(' LinearLayout param_self_LinearLayout;');
|
||||
ADest.Add(' TimePicker param_self_TimePicker;');
|
||||
ADest.Add(' Display param_self_Display;');
|
||||
ADest.Add(' DisplayMetrics param_self_DisplayMetrics;');
|
||||
ADest.Add(' CompoundButton param_self_CompoundButton;');
|
||||
ADest.Add(' WindowManager param_self_WindowManager;');
|
||||
ADest.Add(' // Params');
|
||||
ADest.Add(' ViewGroup.LayoutParams lViewGroup_LayoutParams_1;');
|
||||
ADest.Add(' DisplayMetrics lDisplayMetrics_1;');
|
||||
ADest.Add(' CharSequence lCharSequence_1;');
|
||||
ADest.Add(' int lint_1, lint_2, lint_3, lint_4;');
|
||||
ADest.Add(' float lfloat_1, lfloat_2;');
|
||||
ADest.Add(' boolean lboolean_1;');
|
||||
ADest.Add(' // Results');
|
||||
ADest.Add(' float lResult_float;');
|
||||
ADest.Add(' int lResult_int;');
|
||||
ADest.Add(' boolean lResult_boolean;');
|
||||
ADest.Add(' Display lResult_Display;');
|
||||
ADest.Add('');
|
||||
ADest.Add(' switch (Buffer)');
|
||||
ADest.Add(' {');
|
||||
ADest.Add('');
|
||||
ADest.AddStrings(FJavaOutputMethods);
|
||||
ADest.Add('');
|
||||
ADest.Add(' default:');
|
||||
ADest.Add(' return false;');
|
||||
ADest.Add(' }');
|
||||
ADest.Add(' return true;');
|
||||
ADest.Add(' }');
|
||||
ADest.Add('}');
|
||||
end;
|
||||
|
||||
procedure TAndroidSDKBindingsGen.ProcessModelFile(ASourceFile, APasOutputFile,
|
||||
AJavaOutputFile: string);
|
||||
var
|
||||
@ -67,137 +211,11 @@ begin
|
||||
end;
|
||||
|
||||
// Now save the Pascal file
|
||||
lPasOutputFile.Add(Format('unit %s;', [ChangeFileExt(ExtractFileName(ASourceFile), '')]));
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.Add('interface');
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.Add('uses javalang, androidpipescomm;');
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.Add('type');
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.Add(' { Forward declaration of classes }');
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.AddStrings(FPasOutputClassesForward);
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.Add(' { Types }');
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.AddStrings(FPasOutputTypes);
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.Add(' { Classes }');
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.AddStrings(FPasOutputClasses);
|
||||
lPasOutputFile.Add(' end;');
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.Add('function HandleMessage(AFirstInt: Integer): Boolean;');
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.Add('implementation');
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.Add('const');
|
||||
lPasOutputFile.Add(' { Constants }');
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.AddStrings(FPasOutputConsts);
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.Add(' { IDs }');
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.AddStrings(FPasOutputIDs);
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.Add('{ Implementation of Classes }');
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.AddStrings(FPasOutputImpl);
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.Add('{ Message Handling }');
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.Add('function HandleMessage(AFirstInt: Integer): Boolean;');
|
||||
lPasOutputFile.Add('var');
|
||||
lPasOutputFile.Add(' lInt: Integer;');
|
||||
lPasOutputFile.Add(' lPascalPointer: PtrInt = -1;');
|
||||
lPasOutputFile.Add('begin');
|
||||
lPasOutputFile.Add(' case AFirstInt of');
|
||||
lPasOutputFile.AddStrings(FPasOutputMessages);
|
||||
lPasOutputFile.Add(' end;');
|
||||
lPasOutputFile.Add('end;');
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.Add('end.');
|
||||
GeneratePascalFile(ASourceFile, lPasOutputFile);
|
||||
|
||||
lPasOutputFile.SaveToFile(APasOutputFile);
|
||||
|
||||
lJavaOutputFile.Add('package com.pascal.androidlcl;');
|
||||
lJavaOutputFile.Add('');
|
||||
lJavaOutputFile.Add('import android.app.*;');
|
||||
lJavaOutputFile.Add('import android.view.*;');
|
||||
lJavaOutputFile.Add('import android.os.*;');
|
||||
lJavaOutputFile.Add('import android.util.*;');
|
||||
lJavaOutputFile.Add('import android.content.*;');
|
||||
lJavaOutputFile.Add('import android.view.*;');
|
||||
lJavaOutputFile.Add('import android.widget.*;');
|
||||
lJavaOutputFile.Add('import java.util.*;');
|
||||
lJavaOutputFile.Add('import java.lang.*;');
|
||||
lJavaOutputFile.Add('');
|
||||
lJavaOutputFile.Add('public class AndroidAll');
|
||||
lJavaOutputFile.Add('{');
|
||||
lJavaOutputFile.Add(' // info from other classes');
|
||||
lJavaOutputFile.Add(' Activity activity;');
|
||||
lJavaOutputFile.Add(' AndroidPipesComm MyAndroidPipesComm;');
|
||||
lJavaOutputFile.Add(' JavaLang MyJavaLang;');
|
||||
lJavaOutputFile.Add(' // lists of variables');
|
||||
lJavaOutputFile.Add(' ArrayList ViewElements;');
|
||||
lJavaOutputFile.Add('');
|
||||
lJavaOutputFile.Add(' public AndroidAll(AndroidPipesComm AAndroidPipesComm, Activity AActivity, JavaLang AJavaLang)');
|
||||
lJavaOutputFile.Add(' {');
|
||||
lJavaOutputFile.Add(' activity = AActivity;');
|
||||
lJavaOutputFile.Add(' MyAndroidPipesComm = AAndroidPipesComm;');
|
||||
lJavaOutputFile.Add(' MyJavaLang = AJavaLang;');
|
||||
lJavaOutputFile.Add(' ViewElements = new ArrayList();');
|
||||
lJavaOutputFile.Add(' }');
|
||||
lJavaOutputFile.Add('');
|
||||
lJavaOutputFile.Add(' public void DebugOut(String Str)');
|
||||
lJavaOutputFile.Add(' {');
|
||||
lJavaOutputFile.Add(' MyAndroidPipesComm.DebugOut(Str);');
|
||||
lJavaOutputFile.Add(' }');
|
||||
lJavaOutputFile.Add('');
|
||||
lJavaOutputFile.AddStrings(FJavaOutputIDs);
|
||||
lJavaOutputFile.Add('');
|
||||
lJavaOutputFile.Add(' public boolean ProcessCommand(int Buffer)');
|
||||
lJavaOutputFile.Add(' {');
|
||||
lJavaOutputFile.Add(' //DebugOut("AndroidUI.ProcessCommand Command=" + java.lang.Integer.toHexString(Buffer));');
|
||||
lJavaOutputFile.Add(' // basic types');
|
||||
lJavaOutputFile.Add(' int lInt, lIndex, lPascalPointer;');
|
||||
lJavaOutputFile.Add(' // Self params');
|
||||
lJavaOutputFile.Add(' View param_self_View;');
|
||||
lJavaOutputFile.Add(' ViewGroup param_self_ViewGroup;');
|
||||
lJavaOutputFile.Add(' TextView param_self_TextView;');
|
||||
lJavaOutputFile.Add(' Button param_self_Button;');
|
||||
lJavaOutputFile.Add(' EditText param_self_EditText;');
|
||||
lJavaOutputFile.Add(' LinearLayout param_self_LinearLayout;');
|
||||
lJavaOutputFile.Add(' TimePicker param_self_TimePicker;');
|
||||
lJavaOutputFile.Add(' Display param_self_Display;');
|
||||
lJavaOutputFile.Add(' DisplayMetrics param_self_DisplayMetrics;');
|
||||
lJavaOutputFile.Add(' CompoundButton param_self_CompoundButton;');
|
||||
lJavaOutputFile.Add(' WindowManager param_self_WindowManager;');
|
||||
lJavaOutputFile.Add(' // Params');
|
||||
lJavaOutputFile.Add(' ViewGroup.LayoutParams lLayoutParams_1;');
|
||||
lJavaOutputFile.Add(' DisplayMetrics lDisplayMetrics_1;');
|
||||
lJavaOutputFile.Add(' CharSequence lCharSequence_1;');
|
||||
lJavaOutputFile.Add(' int lint_1, lint_2, lint_3, lint_4;');
|
||||
lJavaOutputFile.Add(' float lfloat_1, lfloat_2;');
|
||||
lJavaOutputFile.Add(' boolean lboolean_1;');
|
||||
lJavaOutputFile.Add(' // Results');
|
||||
lJavaOutputFile.Add(' float lResult_float;');
|
||||
lJavaOutputFile.Add(' int lResult_int;');
|
||||
lJavaOutputFile.Add(' boolean lResult_boolean;');
|
||||
lJavaOutputFile.Add(' Display lResult_Display;');
|
||||
lJavaOutputFile.Add('');
|
||||
lJavaOutputFile.Add(' switch (Buffer)');
|
||||
lJavaOutputFile.Add(' {');
|
||||
lJavaOutputFile.Add('');
|
||||
lJavaOutputFile.AddStrings(FJavaOutputMethods);
|
||||
lJavaOutputFile.Add('');
|
||||
lJavaOutputFile.Add(' default:');
|
||||
lJavaOutputFile.Add(' return false;');
|
||||
lJavaOutputFile.Add(' }');
|
||||
lJavaOutputFile.Add(' return true;');
|
||||
lJavaOutputFile.Add(' }');
|
||||
lJavaOutputFile.Add('}');
|
||||
GenerateJavaFile(ASourceFile, lJavaOutputFile);
|
||||
|
||||
lJavaOutputFile.SaveToFile(AJavaOutputFile);
|
||||
finally
|
||||
@ -357,8 +375,11 @@ begin
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.SendInt(Integer(' + lParamName + '));');
|
||||
|
||||
// Java parameter reading
|
||||
lJavaParamVar := 'l' + lParamType + '_' + IntToStr(lParamNum);
|
||||
FJavaOutputMethods.Add(' ' + lJavaParamVar + ' = MyAndroidPipesComm.' + GetJavaTypeReader(lParamType) + '();');
|
||||
lJavaParamVar := Format('l%s_%d', [ConvertPointToUnderline(lParamType), lParamNum]);
|
||||
FJavaOutputMethods.Add(Format(' %s = MyAndroidPipesComm.%s();',
|
||||
[GetJavaTypeLocalVar(lParamType), GetJavaTypeReader(lParamType)]));
|
||||
FJavaOutputMethods.Add(Format(' %s = %s;',
|
||||
[lJavaParamVar, GetJavaTypeConverter(lParamType)]));
|
||||
lJavaParams := lJavaParams + lJavaParamVar + ', ';
|
||||
|
||||
Inc(lParamNum);
|
||||
@ -401,7 +422,13 @@ begin
|
||||
else
|
||||
begin
|
||||
FJavaOutputMethods.Add(' lResult_' + lMethodReturn + ' = ' + lJavaParamSelf + '.' + lMethodName + '(' + lJavaParams + ');');
|
||||
FJavaOutputMethods.Add(' MyAndroidPipesComm.' + GetJavaResultFunction(lMethodReturn) + '(lResult_' + lMethodReturn + ');');
|
||||
if IsBasicJavaType(lMethodReturn) then
|
||||
FJavaOutputMethods.Add(' MyAndroidPipesComm.' + GetJavaResultFunction(lMethodReturn) + '(lResult_' + lMethodReturn + ');')
|
||||
else
|
||||
begin
|
||||
FJavaOutputMethods.Add(Format(' ViewElements.add(lResult_%s);', [lMethodReturn]));
|
||||
FJavaOutputMethods.Add(Format(' MyAndroidPipesComm.%s(ViewElements.size() - 1);', [GetJavaResultFunction(lMethodReturn)]))
|
||||
end;
|
||||
end;
|
||||
FJavaOutputMethods.Add(' break;');
|
||||
|
||||
@ -430,9 +457,7 @@ begin
|
||||
|
||||
AddOutputIDs(lIDString);
|
||||
|
||||
FPasOutputClasses.Add(' constructor ' + lMethodName + '();');
|
||||
|
||||
FPasOutputImpl.Add('constructor ' + FClassNamePas + '.' + lMethodName + '();');
|
||||
FPasOutputImplCurLine := FPasOutputImpl.Count;
|
||||
FPasOutputImpl.Add('begin');
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.SendByte(ShortInt(amkUICommand));');
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.SendInt(' + lIDString + ');');
|
||||
@ -488,6 +513,10 @@ begin
|
||||
|
||||
// Finalization of the constructor
|
||||
|
||||
FPasOutputClasses.Add(Format(' constructor %s(%s);', [lMethodName, lConstructorPasParams]));
|
||||
//
|
||||
FPasOutputImpl.Insert(FPasOutputImplCurLine,
|
||||
Format('constructor %s.%s(%s);', [FClassNamePas, lMethodName, lConstructorPasParams]));
|
||||
FPasOutputImpl.Add(' Index := vAndroidPipesComm.WaitForIntReturn();');
|
||||
FPasOutputImpl.Add('end;');
|
||||
|
||||
@ -656,9 +685,25 @@ end;
|
||||
function TAndroidSDKBindingsGen.GetJavaTypeReader(AType: string): string;
|
||||
begin
|
||||
if AType = 'boolean' then Exit('GetBool')
|
||||
else if AType = 'float' then Exit('GetFloat')
|
||||
else Exit('GetInt');
|
||||
end;
|
||||
|
||||
function TAndroidSDKBindingsGen.GetJavaTypeLocalVar(AType: string): string;
|
||||
begin
|
||||
if AType = 'boolean' then Exit('lBool')
|
||||
else if AType = 'float' then Exit('lFloat')
|
||||
else Exit('lInt');
|
||||
end;
|
||||
|
||||
function TAndroidSDKBindingsGen.GetJavaTypeConverter(AType: string): string;
|
||||
begin
|
||||
if AType = 'boolean' then Exit('lBool')
|
||||
else if AType = 'int' then Exit('lInt')
|
||||
else if AType = 'float' then Exit('lFloat')
|
||||
else Result := Format('(%s) ViewElements.get(lInt)', [AType]);
|
||||
end;
|
||||
|
||||
function TAndroidSDKBindingsGen.GetIDString(AMethodName: string): string;
|
||||
begin
|
||||
Result := 'amkUI_' + FClassNamePas + '_' + AMethodName;;
|
||||
@ -671,6 +716,16 @@ begin
|
||||
FJavaOutputIDs.Add(' static final int ' + AIDString + ' = 0x' + IntToHex(FClassNum*$1000+FMethodNum, 8) + ';');
|
||||
end;
|
||||
|
||||
function TAndroidSDKBindingsGen.ConvertPointToUnderline(AStr: string): string;
|
||||
begin
|
||||
Result := SysUtils.StringReplace(AStr, '.', '_', [rfReplaceAll, rfIgnoreCase]);
|
||||
end;
|
||||
|
||||
function TAndroidSDKBindingsGen.IsBasicJavaType(AStr: string): Boolean;
|
||||
begin
|
||||
Result := (AStr = 'boolean') or (AStr = 'int') or (AStr = 'float');
|
||||
end;
|
||||
|
||||
constructor TAndroidSDKBindingsGen.Create;
|
||||
begin
|
||||
FSourceFile := TStringList.Create;
|
||||
|
@ -35,7 +35,7 @@ constructor Create(int width, int height);
|
||||
const FILL_PARENT = $FFFFFFFF;
|
||||
|
||||
[View] TJavaObject
|
||||
method void setLayoutParams(LayoutParams params);
|
||||
method void setLayoutParams(ViewGroup.LayoutParams params);
|
||||
method void setVisibility(int visibility);
|
||||
const VISIBLE = 0;
|
||||
const INVISIBLE = 4;
|
||||
@ -54,7 +54,7 @@ const VERTICAL = 1;
|
||||
[AbsoluteLayout] ViewGroup
|
||||
constructor Create(Activity);
|
||||
|
||||
[AbsoluteLayout_LayoutParams] LayoutParams
|
||||
[AbsoluteLayout.LayoutParams] ViewGroup.LayoutParams
|
||||
constructor Create(int param_width, int param_height, int param_x, int param_y);
|
||||
|
||||
[TextView] View
|
||||
@ -86,7 +86,7 @@ method void setIs24HourView(boolean AIs24HourView);
|
||||
constructor Create(Activity);
|
||||
|
||||
[CompoundButton] Button
|
||||
constructor Create(Activity)
|
||||
#constructor Create(Activity) abstract
|
||||
method boolean isChecked()
|
||||
method boolean performClick()
|
||||
method void setChecked(boolean checked)
|
||||
|
Loading…
Reference in New Issue
Block a user