More advances for the android sdk bindings gen
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1679 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
5836e593af
commit
2dbb8ee493
@ -39,7 +39,7 @@
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="12">
|
||||
<Units Count="13">
|
||||
<Unit0>
|
||||
<Filename Value="android_bindings_generator.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -68,7 +68,7 @@
|
||||
<Unit2>
|
||||
<Filename Value="../../../p-tools/turbochessclock4android/androidmenu.pas"/>
|
||||
<UnitName Value="androidmenu"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="77"/>
|
||||
<CursorPos X="25" Y="24"/>
|
||||
@ -78,7 +78,7 @@
|
||||
<Unit3>
|
||||
<Filename Value="../../../p-tools/turbochessclock4android/androidutil.pas"/>
|
||||
<UnitName Value="androidutil"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="1"/>
|
||||
<CursorPos X="1" Y="1"/>
|
||||
@ -88,7 +88,7 @@
|
||||
<Unit4>
|
||||
<Filename Value="../../../p-tools/turbochessclock4android/androidview.pas"/>
|
||||
<UnitName Value="androidview"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<EditorIndex Value="7"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="109"/>
|
||||
<CursorPos X="59" Y="419"/>
|
||||
@ -98,7 +98,7 @@
|
||||
<Unit5>
|
||||
<Filename Value="../../../p-tools/turbochessclock4android/androiddialog.pas"/>
|
||||
<UnitName Value="androiddialog"/>
|
||||
<EditorIndex Value="8"/>
|
||||
<EditorIndex Value="9"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="1"/>
|
||||
<CursorPos X="1" Y="1"/>
|
||||
@ -115,7 +115,7 @@
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="../../../p-tools/turbochessclock4android/android/src/com/pascal/turbochessclock/AndroidMenu.java"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="81"/>
|
||||
<CursorPos X="56" Y="104"/>
|
||||
@ -130,15 +130,15 @@
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="40"/>
|
||||
<CursorPos X="44" Y="66"/>
|
||||
<TopLine Value="219"/>
|
||||
<CursorPos X="65" Y="247"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="../../../p-tools/turbochessclock4android/androidapp.pas"/>
|
||||
<UnitName Value="androidapp"/>
|
||||
<EditorIndex Value="7"/>
|
||||
<EditorIndex Value="8"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="1"/>
|
||||
<CursorPos X="16" Y="22"/>
|
||||
@ -161,127 +161,137 @@
|
||||
<UsageCount Value="10"/>
|
||||
<DefaultSyntaxHighlighter Value="Delphi"/>
|
||||
</Unit11>
|
||||
<Unit12>
|
||||
<Filename Value="../../../p-tools/turbochessclock4android/android/src/com/pascal/turbochessclock/AndroidView.java"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="157"/>
|
||||
<CursorPos X="39" Y="177"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
<DefaultSyntaxHighlighter Value="Java"/>
|
||||
</Unit12>
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="43" Column="20" TopLine="15"/>
|
||||
<Caret Line="144" Column="33" TopLine="110"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="45" Column="9" TopLine="20"/>
|
||||
<Caret Line="90" Column="143" TopLine="78"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="72" Column="6" TopLine="43"/>
|
||||
<Caret Line="22" Column="24" TopLine="1"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="73" Column="39" TopLine="50"/>
|
||||
<Caret Line="116" Column="21" TopLine="96"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="74" Column="6" TopLine="51"/>
|
||||
<Caret Line="175" Column="35" TopLine="150"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="38" Column="83" TopLine="1"/>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="21" Column="31" TopLine="40"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="28" Column="1" TopLine="1"/>
|
||||
<Caret Line="98" Column="42" TopLine="75"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="38" Column="13" TopLine="1"/>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="84" Column="3" TopLine="77"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="35" Column="78" TopLine="33"/>
|
||||
<Caret Line="89" Column="1" TopLine="77"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="144" Column="17" TopLine="110"/>
|
||||
<Caret Line="114" Column="29" TopLine="91"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="142" Column="34" TopLine="110"/>
|
||||
<Filename Value="../../../p-tools/turbochessclock4android/androidview.pas"/>
|
||||
<Caret Line="421" Column="3" TopLine="395"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="144" Column="33" TopLine="110"/>
|
||||
<Caret Line="157" Column="85" TopLine="124"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="90" Column="143" TopLine="78"/>
|
||||
<Caret Line="127" Column="88" TopLine="104"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="22" Column="24" TopLine="1"/>
|
||||
<Caret Line="151" Column="31" TopLine="129"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="116" Column="21" TopLine="96"/>
|
||||
<Caret Line="24" Column="24" TopLine="1"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="175" Column="35" TopLine="150"/>
|
||||
<Caret Line="25" Column="34" TopLine="1"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="21" Column="31" TopLine="40"/>
|
||||
<Caret Line="123" Column="82" TopLine="97"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="98" Column="42" TopLine="75"/>
|
||||
<Caret Line="18" Column="26" TopLine="1"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="84" Column="3" TopLine="77"/>
|
||||
<Caret Line="124" Column="120" TopLine="101"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="89" Column="1" TopLine="77"/>
|
||||
<Caret Line="66" Column="44" TopLine="40"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="114" Column="29" TopLine="91"/>
|
||||
<Caret Line="21" Column="27" TopLine="1"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="../../../p-tools/turbochessclock4android/androidview.pas"/>
|
||||
<Caret Line="421" Column="3" TopLine="395"/>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="88" Column="3" TopLine="80"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="157" Column="85" TopLine="124"/>
|
||||
<Caret Line="128" Column="3" TopLine="66"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="127" Column="88" TopLine="104"/>
|
||||
<Caret Line="19" Column="61" TopLine="1"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="151" Column="31" TopLine="129"/>
|
||||
<Caret Line="21" Column="37" TopLine="2"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="24" Column="24" TopLine="1"/>
|
||||
<Caret Line="39" Column="18" TopLine="38"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="25" Column="34" TopLine="1"/>
|
||||
<Caret Line="301" Column="70" TopLine="267"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="123" Column="82" TopLine="97"/>
|
||||
<Caret Line="22" Column="35" TopLine="1"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="18" Column="26" TopLine="1"/>
|
||||
<Caret Line="237" Column="100" TopLine="196"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="124" Column="120" TopLine="101"/>
|
||||
<Caret Line="189" Column="3" TopLine="148"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
|
@ -14,10 +14,13 @@ type
|
||||
TAndroidSDKBindingsGen = class
|
||||
private
|
||||
FSourceFile, FPasOutputClasses, FPasOutputIDs, FPasOutputImpl: TStringList;
|
||||
FJavaOutputIDs, FJavaOutputMethods: TStringList;
|
||||
FClassName: string; // Class name of the class currently being parsed
|
||||
FClassNum, FMethodNum: Integer;
|
||||
procedure ProcessModelFile(ASourceFile, APasOutputFile, AJavaOutputDir: string);
|
||||
procedure ProcessModelFile(ASourceFile, APasOutputFile, AJavaOutputFile: string);
|
||||
procedure ProcessModelLine(ASourceLine: string);
|
||||
procedure ProcessModelMethodClass(ASourceLine: string);
|
||||
procedure ProcessModelMethodLine(ASourceLine: string);
|
||||
function GetNextWord(ALine: string; var AStartPos: Integer): string;
|
||||
function GetPascalTypeName(ABaseName: string): string;
|
||||
public
|
||||
@ -34,12 +37,14 @@ implementation
|
||||
{ TAndroidSDKBindingsGen }
|
||||
|
||||
procedure TAndroidSDKBindingsGen.ProcessModelFile(ASourceFile, APasOutputFile,
|
||||
AJavaOutputDir: string);
|
||||
AJavaOutputFile: string);
|
||||
var
|
||||
i: Integer;
|
||||
lPasOutputFile: TStringList;
|
||||
lJavaOutputFile: TStringList;
|
||||
begin
|
||||
lPasOutputFile := TStringList.Create;
|
||||
lJavaOutputFile := TStringList.Create;
|
||||
try
|
||||
FSourceFile.LoadFromFile(ASourceFile);
|
||||
|
||||
@ -51,7 +56,7 @@ begin
|
||||
ProcessModelLine(FSourceFile.Strings[i]);
|
||||
end;
|
||||
|
||||
// Now save the output
|
||||
// Now save the Pascal file
|
||||
lPasOutputFile.Add('unit ;');
|
||||
lPasOutputFile.Add('');
|
||||
lPasOutputFile.Add('interface');
|
||||
@ -70,7 +75,17 @@ begin
|
||||
lPasOutputFile.Add('end.');
|
||||
|
||||
lPasOutputFile.SaveToFile(APasOutputFile);
|
||||
|
||||
// Now save the Java file
|
||||
lJavaOutputFile.Add('');
|
||||
lJavaOutputFile.AddStrings(FJavaOutputIDs);
|
||||
lJavaOutputFile.Add('');
|
||||
lJavaOutputFile.AddStrings(FJavaOutputMethods);
|
||||
lJavaOutputFile.Add('');
|
||||
|
||||
lJavaOutputFile.SaveToFile(AJavaOutputFile);
|
||||
finally
|
||||
lJavaOutputFile.Free;
|
||||
lPasOutputFile.Free;
|
||||
end;
|
||||
end;
|
||||
@ -78,10 +93,7 @@ end;
|
||||
procedure TAndroidSDKBindingsGen.ProcessModelLine(ASourceLine: string);
|
||||
var
|
||||
lReaderPos: Integer = 1;
|
||||
lCurWord, lParentClassName: string;
|
||||
lMethodReturn, lMethodName, lParamType, lParamName: string;
|
||||
DeclarationBase, TmpStr: string;
|
||||
FPasOutputImplCurLine: Integer;
|
||||
lCurWord: string;
|
||||
begin
|
||||
if ASourceLine = '' then Exit;
|
||||
|
||||
@ -93,84 +105,152 @@ begin
|
||||
// Starting a new class
|
||||
if ASourceLine[1] = '[' then
|
||||
begin
|
||||
if FClassName <> '' then
|
||||
begin
|
||||
FPasOutputClasses.Add(' end;');
|
||||
FPasOutputClasses.Add('');
|
||||
end;
|
||||
|
||||
FClassName := GetPascalTypeName(lCurWord);
|
||||
lParentClassName := GetNextWord(ASourceLine, lReaderPos);
|
||||
lParentClassName := GetPascalTypeName(lParentClassName);
|
||||
FPasOutputClasses.Add(Format(' %s = class(%s)', [FClassName, lParentClassName]));
|
||||
FPasOutputClasses.Add(' public');
|
||||
lCurWord := GetNextWord(ASourceLine, lReaderPos);
|
||||
Inc(FClassNum);
|
||||
FMethodNum := 0;
|
||||
|
||||
ProcessModelMethodClass(ASourceLine);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
// Adding methods to a class
|
||||
if lCurWord = 'method' then
|
||||
begin
|
||||
// Method type and name
|
||||
lMethodReturn := GetNextWord(ASourceLine, lReaderPos);
|
||||
lMethodReturn := GetPascalTypeName(lMethodReturn);
|
||||
lMethodName := GetNextWord(ASourceLine, lReaderPos);
|
||||
|
||||
if lMethodReturn = 'void' then DeclarationBase := 'procedure '
|
||||
else DeclarationBase := 'function ';
|
||||
|
||||
// Beginning of the implementation part
|
||||
FPasOutputImplCurLine := FPasOutputImpl.Count;
|
||||
FPasOutputImpl.Add('begin');
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.SendByte(ShortInt(amkUICommand));');
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.SendInt(amkUI_' + FClassName + '_' + lMethodName + ');');
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.SendInt(Index); // Self, Java Pointer');
|
||||
FPasOutputIDs.Add(' amkUI_' + FClassName + '_' + lMethodName + ' = 0' + IntToHex(FClassNum*$1000+FMethodNum, 8) + ';');
|
||||
|
||||
// Add all parameters
|
||||
TmpStr := lMethodName + '(';
|
||||
|
||||
repeat
|
||||
lParamType := GetNextWord(ASourceLine, lReaderPos);
|
||||
lParamType := GetPascalTypeName(lParamType);
|
||||
lParamName := GetNextWord(ASourceLine, lReaderPos);
|
||||
|
||||
if lParamName = '' then Break;
|
||||
|
||||
TmpStr := TmpStr + lParamName + ': ' + lParamType + '; ';
|
||||
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.SendInt(Integer(' + lParamName + '));');
|
||||
until lParamName = '';
|
||||
|
||||
// Remove the last ; for the parameters, if necessary
|
||||
if TmpStr[Length(TmpStr)-1] = ';' then TmpStr := System.Copy(TmpStr, 0, Length(TmpStr)-2);
|
||||
|
||||
// Add the return
|
||||
if lMethodReturn = 'void' then
|
||||
begin
|
||||
TmpStr := TmpStr + ');';
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.WaitForReturn();');
|
||||
end
|
||||
else
|
||||
begin
|
||||
TmpStr := TmpStr + '): ' + lMethodReturn + ';';
|
||||
FPasOutputImpl.Add(' Result := Boolean(vAndroidPipesComm.WaitForIntReturn());');
|
||||
end;
|
||||
|
||||
FPasOutputClasses.Add(' ' + DeclarationBase + TmpStr);
|
||||
FPasOutputImpl.Insert(FPasOutputImplCurLine, DeclarationBase + FClassName + '.' + TmpStr);
|
||||
FPasOutputImpl.Add('end;');
|
||||
FPasOutputImpl.Add('');
|
||||
|
||||
Inc(FMethodNum);
|
||||
|
||||
ProcessModelMethodLine(ASourceLine);
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAndroidSDKBindingsGen.ProcessModelMethodClass(ASourceLine: string);
|
||||
var
|
||||
lReaderPos: Integer = 1;
|
||||
lCurWord, lParentClassName: string;
|
||||
begin
|
||||
if ASourceLine = '' then Exit;
|
||||
|
||||
lCurWord := GetNextWord(ASourceLine, lReaderPos);
|
||||
|
||||
if FClassName <> '' then
|
||||
begin
|
||||
FPasOutputClasses.Add(' end;');
|
||||
FPasOutputClasses.Add('');
|
||||
end;
|
||||
|
||||
FClassName := GetPascalTypeName(lCurWord);
|
||||
lParentClassName := GetNextWord(ASourceLine, lReaderPos);
|
||||
lParentClassName := GetPascalTypeName(lParentClassName);
|
||||
FPasOutputClasses.Add(Format(' %s = class(%s)', [FClassName, lParentClassName]));
|
||||
FPasOutputClasses.Add(' public');
|
||||
lCurWord := GetNextWord(ASourceLine, lReaderPos);
|
||||
Inc(FClassNum);
|
||||
FMethodNum := 0;
|
||||
|
||||
FPasOutputIDs.Add(' // ' + FClassName);
|
||||
FJavaOutputIDs.Add(' // ' + FClassName);
|
||||
end;
|
||||
|
||||
procedure TAndroidSDKBindingsGen.ProcessModelMethodLine(
|
||||
ASourceLine: string);
|
||||
var
|
||||
lReaderPos: Integer = 1;
|
||||
lParamNum: Integer = 1;
|
||||
lCurWord, lParentClassName: string;
|
||||
lMethodReturn, lMethodName, lParamType, lParamName: string;
|
||||
DeclarationBase, TmpStr, lIDString: string;
|
||||
FPasOutputImplCurLine: Integer;
|
||||
lJavaParamVar, lJavaParams, lJavaParamSelf: string;
|
||||
begin
|
||||
if ASourceLine = '' then Exit;
|
||||
|
||||
lCurWord := GetNextWord(ASourceLine, lReaderPos);
|
||||
|
||||
// Method type and name
|
||||
lMethodReturn := GetNextWord(ASourceLine, lReaderPos);
|
||||
lMethodReturn := GetPascalTypeName(lMethodReturn);
|
||||
lMethodName := GetNextWord(ASourceLine, lReaderPos);
|
||||
|
||||
if lMethodReturn = 'void' then DeclarationBase := 'procedure '
|
||||
else DeclarationBase := 'function ';
|
||||
|
||||
// Beginning of the implementation part
|
||||
FPasOutputImplCurLine := FPasOutputImpl.Count;
|
||||
lIDString := 'amkUI_' + FClassName + '_' + lMethodName;
|
||||
|
||||
FPasOutputImpl.Add('begin');
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.SendByte(ShortInt(amkUICommand));');
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.SendInt(' + lIDString + ');');
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.SendInt(Index); // Self, Java Pointer');
|
||||
|
||||
lJavaParamSelf := 'param_self_' + FClassName;
|
||||
FJavaOutputMethods.Add(' // ' + ASourceLine);
|
||||
FJavaOutputMethods.Add(' case ' + lIDString + ':');
|
||||
FJavaOutputMethods.Add(' DebugOut("' + lIDString + '");');
|
||||
FJavaOutputMethods.Add(' // Self');
|
||||
FJavaOutputMethods.Add(' lInt = MyAndroidPipesComm.GetInt();');
|
||||
FJavaOutputMethods.Add(' ' + lJavaParamSelf + ' = (' + FClassName + ') ViewElements.get(lInt);');
|
||||
FJavaOutputMethods.Add(' // params');
|
||||
|
||||
// Lists of constants for the IDs
|
||||
FPasOutputIDs.Add(' ' + lIDString + ' = 0' + IntToHex(FClassNum*$1000+FMethodNum, 8) + ';');
|
||||
FJavaOutputIDs.Add(' static final int ' + lIDString + ' = 0x0' + IntToHex(FClassNum*$1000+FMethodNum, 8) + ';');
|
||||
|
||||
// Add all parameters
|
||||
TmpStr := lMethodName + '(';
|
||||
|
||||
repeat
|
||||
lParamType := GetNextWord(ASourceLine, lReaderPos);
|
||||
lParamType := GetPascalTypeName(lParamType);
|
||||
lParamName := GetNextWord(ASourceLine, lReaderPos);
|
||||
|
||||
if lParamName = '' then Break;
|
||||
|
||||
TmpStr := TmpStr + lParamName + ': ' + lParamType + '; ';
|
||||
|
||||
// Pascal parameter sending
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.SendInt(Integer(' + lParamName + '));');
|
||||
|
||||
// Java parameter reading
|
||||
lJavaParamVar := 'l' + lParamType + '_' + IntToStr(lParamNum);
|
||||
FJavaOutputMethods.Add(' ' + lJavaParamVar + ' = MyAndroidPipesComm.GetInt();');
|
||||
lJavaParams := lJavaParams + lJavaParamVar + ', ';
|
||||
|
||||
Inc(lParamNum);
|
||||
until lParamName = '';
|
||||
|
||||
// Remove the last ; for the parameters, if necessary
|
||||
if TmpStr[Length(TmpStr)-1] = ';' then TmpStr := System.Copy(TmpStr, 0, Length(TmpStr)-2);
|
||||
// And for Java params too
|
||||
lJavaParams := System.Copy(lJavaParams, 0, Length(lJavaParams)-2);
|
||||
|
||||
// Add the return
|
||||
if lMethodReturn = 'void' then
|
||||
begin
|
||||
TmpStr := TmpStr + ');';
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.WaitForReturn();');
|
||||
end
|
||||
else
|
||||
begin
|
||||
TmpStr := TmpStr + '): ' + lMethodReturn + ';';
|
||||
FPasOutputImpl.Add(' Result := Boolean(vAndroidPipesComm.WaitForIntReturn());');
|
||||
end;
|
||||
|
||||
FPasOutputClasses.Add(' ' + DeclarationBase + TmpStr);
|
||||
FPasOutputImpl.Insert(FPasOutputImplCurLine, DeclarationBase + FClassName + '.' + TmpStr);
|
||||
FPasOutputImpl.Add('end;');
|
||||
FPasOutputImpl.Add('');
|
||||
|
||||
FJavaOutputMethods.Add(' //');
|
||||
if lMethodReturn = 'void' then
|
||||
begin
|
||||
FJavaOutputMethods.Add(' ' + lJavaParamSelf + '.' + lMethodName + '(' + lJavaParams + ');');
|
||||
FJavaOutputMethods.Add(' MyAndroidPipesComm.SendResult();');
|
||||
end
|
||||
else
|
||||
begin
|
||||
FJavaOutputMethods.Add(' lResult_' + lMethodReturn + ' ' + lJavaParamSelf + '.' + lMethodName + '(' + lJavaParams + ');');
|
||||
FJavaOutputMethods.Add(' MyAndroidPipesComm.SendIntResult(lResult_' + lMethodReturn + ');');
|
||||
end;
|
||||
FJavaOutputMethods.Add(' break;');
|
||||
|
||||
Inc(FMethodNum);
|
||||
end;
|
||||
|
||||
{ Reads one word in a string, starting at AStartPos (1-based index)
|
||||
and going up to a space or comma or ( or ) or another separator }
|
||||
function TAndroidSDKBindingsGen.GetNextWord(ALine: string;
|
||||
@ -226,6 +306,10 @@ begin
|
||||
FPasOutputClasses := TStringList.Create;
|
||||
FPasOutputImpl := TStringList.Create;
|
||||
FPasOutputIDs := TStringList.Create;
|
||||
|
||||
FJavaOutputIDs := TStringList.Create;
|
||||
FJavaOutputMethods := TStringList.Create;
|
||||
|
||||
FClassNum := $100;
|
||||
end;
|
||||
|
||||
@ -236,6 +320,9 @@ begin
|
||||
FPasOutputImpl.Free;
|
||||
FPasOutputIDs.Free;
|
||||
|
||||
FJavaOutputIDs.Free;
|
||||
FJavaOutputMethods.Free;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
@ -244,7 +331,7 @@ procedure TAndroidSDKBindingsGen.GenerateAllBindings(AInputDir, APasOutputDir,
|
||||
begin
|
||||
ProcessModelFile(IncludeTrailingPathDelimiter(AInputDir) + 'android_view.txt',
|
||||
IncludeTrailingPathDelimiter(APasOutputDir) + 'android_view.pas',
|
||||
IncludeTrailingPathDelimiter(AJavaOutputDir));
|
||||
IncludeTrailingPathDelimiter(AJavaOutputDir) + 'android_view.java');
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
Loading…
Reference in New Issue
Block a user