You've already forked lazarus-ccr
Added option -d to gir2pas to include deprecated functions in bindings
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2495 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -129,7 +129,7 @@ begin
|
|||||||
FindClose(Sr);
|
FindClose(Sr);
|
||||||
end;
|
end;
|
||||||
if Result = nil then
|
if Result = nil then
|
||||||
WriteLn('Unable to find gir file: ',NamespaceName);
|
WriteLn('Fatal: Unable to find gir file: ',NamespaceName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGirConsoleConverter.WriteFile(Sender: TObject; AName: String; AStream: TStringStream);
|
procedure TGirConsoleConverter.WriteFile(Sender: TObject; AName: String; AStream: TStringStream);
|
||||||
@@ -211,6 +211,7 @@ begin
|
|||||||
AddOption(['w', 'overwrite-files'], False ,'If the output .pas file(s) already exists then overwrite them.');
|
AddOption(['w', 'overwrite-files'], False ,'If the output .pas file(s) already exists then overwrite them.');
|
||||||
AddOption(['n', 'no-default'], False ,'/usr/share/gir-1.0 is not added as a search location for needed .gir files.');
|
AddOption(['n', 'no-default'], False ,'/usr/share/gir-1.0 is not added as a search location for needed .gir files.');
|
||||||
AddOption(['p', 'paths'], True ,'List of paths seperated by ":" to search for needed .gir files.');
|
AddOption(['p', 'paths'], True ,'List of paths seperated by ":" to search for needed .gir files.');
|
||||||
|
AddOption(['d', 'deprecated'], False, 'Include fields and methods marked as deprecated.');
|
||||||
AddOption(['t', 'test'], False ,'Creates a test program per unit to verify struct sizes.');
|
AddOption(['t', 'test'], False ,'Creates a test program per unit to verify struct sizes.');
|
||||||
end;
|
end;
|
||||||
FCmdOptions.ReadOptions;
|
FCmdOptions.ReadOptions;
|
||||||
@@ -268,6 +269,9 @@ begin
|
|||||||
if FCmdOptions.HasOption('dynamic') then
|
if FCmdOptions.HasOption('dynamic') then
|
||||||
Include(FOptions, goLinkDynamic);
|
Include(FOptions, goLinkDynamic);
|
||||||
|
|
||||||
|
if FCmdOptions.HasOption('deprecated') then
|
||||||
|
Include(FOptions, goIncludeDeprecated);
|
||||||
|
|
||||||
if FCmdOptions.HasOption('classes') then
|
if FCmdOptions.HasOption('classes') then
|
||||||
begin
|
begin
|
||||||
Include(FOptions, goClasses);
|
Include(FOptions, goClasses);
|
||||||
|
@@ -220,6 +220,7 @@ type
|
|||||||
private
|
private
|
||||||
FCIdentifier: String;
|
FCIdentifier: String;
|
||||||
FDeprecated: Boolean;
|
FDeprecated: Boolean;
|
||||||
|
FDeprecatedMsg: String;
|
||||||
FDeprecatedVersion: String;
|
FDeprecatedVersion: String;
|
||||||
FParams: TgirParamList;
|
FParams: TgirParamList;
|
||||||
FReturns: TgirFunctionReturn;
|
FReturns: TgirFunctionReturn;
|
||||||
@@ -230,6 +231,7 @@ type
|
|||||||
property Returns: TgirFunctionReturn read FReturns;
|
property Returns: TgirFunctionReturn read FReturns;
|
||||||
property CIdentifier: String read FCIdentifier;
|
property CIdentifier: String read FCIdentifier;
|
||||||
property Deprecated: Boolean read FDeprecated;
|
property Deprecated: Boolean read FDeprecated;
|
||||||
|
property DeprecatedMsg: String read FDeprecatedMsg;
|
||||||
property DeprecatedVersion: String read FDeprecatedVersion;
|
property DeprecatedVersion: String read FDeprecatedVersion;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -939,7 +941,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
FDeprecated:=TDOMElement(ANode).GetAttribute('deprecated') <> '';
|
FDeprecated:=TDOMElement(ANode).GetAttribute('deprecated') <> '';
|
||||||
if FDeprecated then
|
if FDeprecated then
|
||||||
|
begin
|
||||||
|
FDeprecatedMsg:=TDOMElement(ANode).GetAttribute('deprecated');
|
||||||
FDeprecatedVersion:=TDOMElement(ANode).GetAttribute('deprecated-version');
|
FDeprecatedVersion:=TDOMElement(ANode).GetAttribute('deprecated-version');
|
||||||
|
end;
|
||||||
FObjectType:=otFunction;
|
FObjectType:=otFunction;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@@ -8,7 +8,7 @@ uses
|
|||||||
Classes, SysUtils, girNameSpaces, girObjects, girTokens, contnrs;
|
Classes, SysUtils, girNameSpaces, girObjects, girTokens, contnrs;
|
||||||
|
|
||||||
type
|
type
|
||||||
TgirOption = (goWantTest, goLinkDynamic, goSeperateConsts, goClasses, goObjects);
|
TgirOption = (goWantTest, goLinkDynamic, goSeperateConsts, goClasses, goObjects, goIncludeDeprecated);
|
||||||
TgirOptions = set of TgirOption;
|
TgirOptions = set of TgirOption;
|
||||||
TgirWriteEvent = procedure (Sender: TObject; AUnitName: AnsiString; AStream: TStringStream) of object;
|
TgirWriteEvent = procedure (Sender: TObject; AUnitName: AnsiString; AStream: TStringStream) of object;
|
||||||
|
|
||||||
@@ -1143,13 +1143,14 @@ var
|
|||||||
Postfix: String;
|
Postfix: String;
|
||||||
Entry: String;
|
Entry: String;
|
||||||
InLineS: String = '';
|
InLineS: String = '';
|
||||||
|
Deprecated: String = '';
|
||||||
ProperUnit: TPascalUnit;
|
ProperUnit: TPascalUnit;
|
||||||
OptionsIndicateWrapperMethod: Boolean;
|
OptionsIndicateWrapperMethod: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := '';
|
Result := '';
|
||||||
OptionsIndicateWrapperMethod:= FUnitType = PascalUnitTypeAll;
|
OptionsIndicateWrapperMethod:= FUnitType = PascalUnitTypeAll;
|
||||||
// we skip deprecated functions
|
// we skip deprecated functions
|
||||||
if AFunction.Deprecated then //and (CompareStr(AFunction.DeprecatedVersion, NameSpace.Version) >= 0) then
|
if AFunction.Deprecated and not (goIncludeDeprecated in FOptions) then //and (CompareStr(AFunction.DeprecatedVersion, NameSpace.Version) >= 0) then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
// some abstract functions that are to be implemented by a module and shouldn't be declared. There is no indicator in the gir file that this is so :(
|
// some abstract functions that are to be implemented by a module and shouldn't be declared. There is no indicator in the gir file that this is so :(
|
||||||
@@ -1162,6 +1163,7 @@ begin
|
|||||||
if AWantWrapperForObject then
|
if AWantWrapperForObject then
|
||||||
InLineS:=' inline;';
|
InLineS:=' inline;';
|
||||||
|
|
||||||
|
if AFunction.Deprecated then Deprecated :=' deprecated ''Since ' + NameSpace.NameSpace + ' ' + AFunction.DeprecatedVersion+' '+StringReplace(AFunction.DeprecatedMsg,'''','`', [rfReplaceAll])+''';';
|
||||||
// this fills in the values for procedure/function and the return type
|
// this fills in the values for procedure/function and the return type
|
||||||
WriteFunctionTypeAndReturnType(AFunction, RoutineType, Returns);
|
WriteFunctionTypeAndReturnType(AFunction, RoutineType, Returns);
|
||||||
|
|
||||||
@@ -1173,9 +1175,9 @@ begin
|
|||||||
if Pos('array of const', Params) + Pos('va_list', Params) > 0 then
|
if Pos('array of const', Params) + Pos('va_list', Params) > 0 then
|
||||||
Prefix:='//';
|
Prefix:='//';
|
||||||
if not (goLinkDynamic in FOptions) then
|
if not (goLinkDynamic in FOptions) then
|
||||||
Postfix := ' external;'// '+UnitName+'_library;';
|
Postfix := ' external;'+ Deprecated// '+UnitName+'_library;';
|
||||||
else
|
else
|
||||||
PostFix := '';
|
PostFix := ''+Deprecated;
|
||||||
|
|
||||||
// first wrapper proc
|
// first wrapper proc
|
||||||
Entry := Prefix + RoutineType +' '+ SanitizeName(AFunction.Name, AExistingUsedNames)+ParenParams(Params)+Returns+InLineS;
|
Entry := Prefix + RoutineType +' '+ SanitizeName(AFunction.Name, AExistingUsedNames)+ParenParams(Params)+Returns+InLineS;
|
||||||
@@ -1187,7 +1189,7 @@ begin
|
|||||||
// This is the line that will be used by in the TObject declaration. <----
|
// This is the line that will be used by in the TObject declaration. <----
|
||||||
// result will be written in the object declaration.
|
// result will be written in the object declaration.
|
||||||
if OptionsIndicateWrapperMethod then
|
if OptionsIndicateWrapperMethod then
|
||||||
Result := Entry
|
Result := Entry + Deprecated
|
||||||
else
|
else
|
||||||
Result := '';
|
Result := '';
|
||||||
|
|
||||||
@@ -1283,12 +1285,12 @@ var
|
|||||||
SetFound := SetFound or (Pos(LookingForSet+'(', Line) > 0);
|
SetFound := SetFound or (Pos(LookingForSet+'(', Line) > 0);
|
||||||
|
|
||||||
// the first argument must match the property type! (result is the return type)
|
// the first argument must match the property type! (result is the return type)
|
||||||
if SetFound and (Pos(Result+')', Line) = 0) then
|
//if SetFound and (Pos(Result+')', Line) = 0) then
|
||||||
writeln('Eliminated ', Line, ' for missing: ', Result);
|
// writeln('Eliminated ', Line, ' for missing: ', Result);
|
||||||
SetFound := SetFound and (Pos(Result+')', Line) > 0);
|
SetFound := SetFound and (Pos(Result+')', Line) > 0);
|
||||||
|
|
||||||
// pascal properties cannot use functions for the set 'procedure'
|
// pascal properties cannot use functions for the set 'procedure'
|
||||||
SetFound := SetFound and (Pos('procedure ', Line) > 0);
|
SetFound := SetFound and (Pos('procedure ', Line) > 0) and (Pos('property '+AProperty.Name, Line) = 0);
|
||||||
|
|
||||||
if SetFound then
|
if SetFound then
|
||||||
Exit;
|
Exit;
|
||||||
|
Reference in New Issue
Block a user