android-sdk: Adds the possibility of having global objects
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1822 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
a311002a2b
commit
cdc7a41075
@ -119,8 +119,8 @@
|
||||
<UnitName Value="android_sdk_bindings_gen"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="476"/>
|
||||
<CursorPos X="1" Y="497"/>
|
||||
<TopLine Value="401"/>
|
||||
<CursorPos X="36" Y="432"/>
|
||||
<UsageCount Value="42"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit8>
|
||||
@ -200,8 +200,8 @@
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="59"/>
|
||||
<CursorPos X="1" Y="81"/>
|
||||
<TopLine Value="1"/>
|
||||
<CursorPos X="14" Y="7"/>
|
||||
<UsageCount Value="14"/>
|
||||
<Loaded Value="True"/>
|
||||
<DefaultSyntaxHighlighter Value="None"/>
|
||||
@ -246,8 +246,8 @@
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="132"/>
|
||||
<CursorPos X="23" Y="147"/>
|
||||
<TopLine Value="467"/>
|
||||
<CursorPos X="3" Y="467"/>
|
||||
<UsageCount Value="14"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit23>
|
||||
@ -273,123 +273,123 @@
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="582" Column="99" TopLine="507"/>
|
||||
<Caret Line="539" Column="1" TopLine="507"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="524" Column="1" TopLine="507"/>
|
||||
<Caret Line="541" Column="1" TopLine="507"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="525" Column="1" TopLine="507"/>
|
||||
<Caret Line="542" Column="36" TopLine="526"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="528" Column="1" TopLine="507"/>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="145" Column="23" TopLine="99"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="529" Column="1" TopLine="507"/>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="532" Column="1" TopLine="507"/>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="143" Column="21" TopLine="99"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="535" Column="1" TopLine="507"/>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="145" Column="23" TopLine="99"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="539" Column="1" TopLine="507"/>
|
||||
<Caret Line="42" Column="20" TopLine="3"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="541" Column="1" TopLine="507"/>
|
||||
<Filename Value="../../../lazarus/lcl/interfaces/android/android_all.pas"/>
|
||||
<Caret Line="666" Column="17" TopLine="653"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="542" Column="36" TopLine="526"/>
|
||||
<Caret Line="864" Column="22" TopLine="858"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="145" Column="23" TopLine="99"/>
|
||||
<Caret Line="150" Column="1" TopLine="103"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
<Caret Line="42" Column="1" TopLine="1"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="143" Column="21" TopLine="99"/>
|
||||
<Caret Line="151" Column="1" TopLine="108"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="145" Column="23" TopLine="99"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="42" Column="20" TopLine="3"/>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="37" Column="1" TopLine="14"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="../../../lazarus/lcl/interfaces/android/android_all.pas"/>
|
||||
<Caret Line="666" Column="17" TopLine="653"/>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="267" Column="1" TopLine="220"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="864" Column="22" TopLine="858"/>
|
||||
<Caret Line="797" Column="48" TopLine="781"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="150" Column="1" TopLine="103"/>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="42" Column="1" TopLine="1"/>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="33" Column="29" TopLine="1"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="151" Column="1" TopLine="108"/>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="410" Column="23" TopLine="396"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="552" Column="23" TopLine="512"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="37" Column="1" TopLine="14"/>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="15" Column="80" TopLine="6"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="sdk_level_7/android_all.txt"/>
|
||||
<Caret Line="267" Column="1" TopLine="220"/>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="486" Column="65" TopLine="468"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="797" Column="48" TopLine="781"/>
|
||||
<Caret Line="847" Column="64" TopLine="832"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
<Caret Line="38" Column="66" TopLine="38"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="33" Column="29" TopLine="1"/>
|
||||
<Caret Line="506" Column="11" TopLine="476"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="410" Column="23" TopLine="396"/>
|
||||
<Caret Line="38" Column="45" TopLine="1"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="552" Column="23" TopLine="512"/>
|
||||
<Caret Line="760" Column="1" TopLine="727"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="15" Column="80" TopLine="6"/>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="26" Column="75" TopLine="1"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="android_sdk_bindings_gen.pas"/>
|
||||
<Caret Line="486" Column="65" TopLine="468"/>
|
||||
<Caret Line="306" Column="94" TopLine="293"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
|
@ -15,10 +15,13 @@ type
|
||||
private
|
||||
FSourceFile: TStringList;
|
||||
FPasOutputTypes, FPasOutputClassesForward, FPasOutputClasses,
|
||||
FPasOutputConsts, FPasOutputIDs, FPasOutputImpl, FPasOutputMessages: TStringList;
|
||||
FPasOutputConsts, FPasOutputIDs, FPasOutputImpl, FPasOutputMessages,
|
||||
FPasGlobalVars, FPasInitialization: TStringList;
|
||||
FJavaOutputIDs, FJavaOutputMethods: TStringList;
|
||||
FClassName, FClassNamePas: string; // Class name of the class currently being parsed
|
||||
FClassNum, FMethodNum: Integer;
|
||||
FIsGlobalObject: Boolean;
|
||||
FGlobalObject: string;
|
||||
procedure GeneratePascalFile(ASourceFile: string; ADest: TStringList);
|
||||
procedure GenerateJavaFile(ASourceFile: string; ADest: TStringList);
|
||||
procedure ProcessModelFile(ASourceFile, APasOutputFile, AJavaOutputFile: string);
|
||||
@ -85,6 +88,9 @@ begin
|
||||
ADest.Add('');
|
||||
ADest.Add('function HandleMessage(AFirstInt: Integer): Boolean;');
|
||||
ADest.Add('');
|
||||
ADest.Add('var');
|
||||
ADest.AddStrings(FPasGlobalVars);
|
||||
ADest.Add('');
|
||||
ADest.Add('implementation');
|
||||
ADest.Add('');
|
||||
ADest.Add('const');
|
||||
@ -108,6 +114,10 @@ begin
|
||||
ADest.Add(' end;');
|
||||
ADest.Add('end;');
|
||||
ADest.Add('');
|
||||
ADest.Add('initialization');
|
||||
ADest.Add('');
|
||||
ADest.AddStrings(FPasInitialization);
|
||||
ADest.Add('');
|
||||
ADest.Add('end.');
|
||||
end;
|
||||
|
||||
@ -172,7 +182,7 @@ begin
|
||||
ADest.Add(' AbsSpinner param_self_AbsSpinner;');
|
||||
ADest.Add(' ArrayAdapter<String> param_self_ArrayAdapter_String_;');
|
||||
ADest.Add(' // Params');
|
||||
ADest.Add(' ViewGroup.LayoutParams lViewGroup_LayoutParams_1, lViewGroup_LayoutParams_2;');
|
||||
ADest.Add(' ViewGroup.LayoutParams lViewGroup_LayoutParams_1, lViewGroup_LayoutParams_2, lViewGroup_LayoutParams_3;');
|
||||
ADest.Add(' SpinnerAdapter lSpinnerAdapter_1;');
|
||||
ADest.Add(' DisplayMetrics lDisplayMetrics_1;');
|
||||
ADest.Add(' CharSequence lCharSequence_1;');
|
||||
@ -250,6 +260,15 @@ begin
|
||||
// Starting a new class
|
||||
if ASourceLine[1] = '[' then
|
||||
begin
|
||||
FIsGlobalObject := False;
|
||||
ProcessModelClass(ASourceLine, False);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
// Starting a new global object class
|
||||
if ASourceLine[1] = '%' then
|
||||
begin
|
||||
FIsGlobalObject := True;
|
||||
ProcessModelClass(ASourceLine, False);
|
||||
Exit;
|
||||
end;
|
||||
@ -257,6 +276,7 @@ begin
|
||||
// Starting a new interface
|
||||
if ASourceLine[1] = '{' then
|
||||
begin
|
||||
FIsGlobalObject := False;
|
||||
ProcessModelClass(ASourceLine, True);
|
||||
Exit;
|
||||
end;
|
||||
@ -313,6 +333,15 @@ begin
|
||||
|
||||
FClassNamePas := GetPascalTypeName(lCurWord);
|
||||
FClassName := lCurWord;
|
||||
|
||||
// Read the global object, if it is one
|
||||
if FIsGlobalObject then
|
||||
begin
|
||||
FGlobalObject := GetNextWord(ASourceLine, lReaderPos);
|
||||
FPasGlobalVars.Add(Format(' %s: %s;', [FGlobalObject, FClassNamePas]));
|
||||
FPasInitialization.Add(Format(' %s := %s.Create;', [FGlobalObject, FClassNamePas]));
|
||||
end;
|
||||
|
||||
lTmpParent := GetNextWord(ASourceLine, lReaderPos);
|
||||
lParentClassName := GetPascalTypeName(lTmpParent);
|
||||
|
||||
@ -365,6 +394,8 @@ var
|
||||
HasStringParam: Boolean = False;
|
||||
StringParamCount: Integer = 0;
|
||||
i: Integer;
|
||||
//
|
||||
lPascalMethodModifiers: string = '';
|
||||
begin
|
||||
if ASourceLine = '' then Exit;
|
||||
|
||||
@ -385,15 +416,21 @@ begin
|
||||
FPasOutputImpl.Add('begin');
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.SendByte(ShortInt(amkUICommand));');
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.SendInt(' + lIDString + ');');
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.SendInt(Index); // Self, Java Pointer');
|
||||
if not FIsGlobalObject then
|
||||
FPasOutputImpl.Add(' vAndroidPipesComm.SendInt(Index); // Self, Java Pointer');
|
||||
|
||||
lJavaParamSelf := 'param_self_' + JavaRemoveGeneric(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);');
|
||||
if not FIsGlobalObject then
|
||||
begin
|
||||
FJavaOutputMethods.Add(' // Self');
|
||||
FJavaOutputMethods.Add(' lInt = MyAndroidPipesComm.GetInt();');
|
||||
FJavaOutputMethods.Add(' ' + lJavaParamSelf + ' = (' + FClassName + ') ViewElements.get(lInt);');
|
||||
end
|
||||
else
|
||||
lJavaParamSelf := FGlobalObject;
|
||||
FJavaOutputMethods.Add(' // params');
|
||||
|
||||
// Lists of constants for the IDs
|
||||
@ -407,6 +444,11 @@ begin
|
||||
|
||||
// Method modifiers
|
||||
if (lParamType = 'virtual') or (lParamType = 'override') then Continue;
|
||||
if (lParamType = 'overload') then
|
||||
begin
|
||||
lPascalMethodModifiers := ' overload;';
|
||||
Continue;
|
||||
end;
|
||||
|
||||
lParamTypePas := GetPascalTypeName(lParamType);
|
||||
lParamName := GetNextWord(ASourceLine, lReaderPos);
|
||||
@ -465,7 +507,7 @@ begin
|
||||
end;
|
||||
|
||||
// Insert the start
|
||||
FPasOutputClasses.Add(' ' + DeclarationBase + TmpStr);
|
||||
FPasOutputClasses.Add(' ' + DeclarationBase + TmpStr + lPascalMethodModifiers);
|
||||
FPasOutputImpl.Insert(FPasOutputImplCurLine, DeclarationBase + FClassNamePas + '.' + TmpStr);
|
||||
if HasStringParam then
|
||||
begin
|
||||
@ -751,7 +793,7 @@ end;
|
||||
function TAndroidSDKBindingsGen.GetNextWord(ALine: string;
|
||||
var AStartPos: Integer): string;
|
||||
const
|
||||
WordSeparators = [' ','(',')','[',']','{','}',',',';',':',#9{TAB}];
|
||||
WordSeparators = [' ','(',')','[',']','{','}','%',',',';',':',#9{TAB}];
|
||||
var
|
||||
lState: Integer = 0;
|
||||
begin
|
||||
@ -844,9 +886,10 @@ begin
|
||||
else Result := Format('(%s) ViewElements.get(lInt)', [AType]);
|
||||
end;
|
||||
|
||||
// We add the method num too for overloaded routines
|
||||
function TAndroidSDKBindingsGen.GetIDString(AMethodName: string): string;
|
||||
begin
|
||||
Result := 'amkUI_' + FClassNamePas + '_' + AMethodName;;
|
||||
Result := Format('amkUI_%s_%s_%d', [FClassNamePas, AMethodName, FMethodNum]);
|
||||
Result := ConvertJavaSpecialCharsToUnderline(Result);
|
||||
end;
|
||||
|
||||
@ -890,6 +933,8 @@ begin
|
||||
FPasOutputIDs := TStringList.Create;
|
||||
FPasOutputConsts := TStringList.Create;
|
||||
FPasOutputMessages := TStringList.Create;
|
||||
FPasGlobalVars := TStringList.Create;
|
||||
FPasInitialization := TStringList.Create;
|
||||
|
||||
FJavaOutputIDs := TStringList.Create;
|
||||
FJavaOutputMethods := TStringList.Create;
|
||||
@ -908,6 +953,8 @@ begin
|
||||
FPasOutputIDs.Free;
|
||||
FPasOutputConsts.Free;
|
||||
FPasOutputMessages.Free;
|
||||
FPasGlobalVars.Free;
|
||||
FPasInitialization.Free;
|
||||
|
||||
FJavaOutputIDs.Free;
|
||||
FJavaOutputMethods.Free;
|
||||
|
@ -3,6 +3,9 @@
|
||||
# [ClassName] Parent Interface1 Interface2
|
||||
# declarations of fields, contructors, methods, consts, etc
|
||||
#
|
||||
# For Classes which are only used through a global object:
|
||||
# %ClassName%ObjectName% Parent Interface1 Interface2
|
||||
#
|
||||
# For Interfaces:
|
||||
# {InterfaceName} Parent1 Parent2 Parent3
|
||||
#
|
||||
@ -30,6 +33,10 @@ field float ydpi
|
||||
#
|
||||
# android.app.*
|
||||
#
|
||||
%Activity%activity% TJavaObject
|
||||
method void setTitle(CharSequence title)
|
||||
method CharSequence getTitle()
|
||||
|
||||
[Display] TJavaObject
|
||||
method void getMetrics(DisplayMetrics outMetrics)
|
||||
|
||||
@ -53,8 +60,11 @@ const INVISIBLE = 4;
|
||||
const GONE = 8;
|
||||
|
||||
[ViewGroup] View
|
||||
method void addView(View child, ViewGroup.LayoutParams params);
|
||||
# method void addView(View child);
|
||||
method void addView(View child, int aindex, ViewGroup.LayoutParams params); overload;
|
||||
method void addView(View child, ViewGroup.LayoutParams params); overload;
|
||||
method void addView(View child, int aindex); overload;
|
||||
method void addView(View child); overload;
|
||||
method void addView(View child, int width, int height); overload;
|
||||
|
||||
[LinearLayout] ViewGroup
|
||||
constructor Create(Activity);
|
||||
|
Loading…
Reference in New Issue
Block a user