diff --git a/applications/gobject-introspection/gir2pascal.lpr b/applications/gobject-introspection/gir2pascal.lpr index d0b79559b..cf0c510bc 100644 --- a/applications/gobject-introspection/gir2pascal.lpr +++ b/applications/gobject-introspection/gir2pascal.lpr @@ -129,7 +129,7 @@ begin FindClose(Sr); end; if Result = nil then - WriteLn('Unable to find gir file: ',NamespaceName); + WriteLn('Fatal: Unable to find gir file: ',NamespaceName); end; 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(['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(['d', 'deprecated'], False, 'Include fields and methods marked as deprecated.'); AddOption(['t', 'test'], False ,'Creates a test program per unit to verify struct sizes.'); end; FCmdOptions.ReadOptions; @@ -268,6 +269,9 @@ begin if FCmdOptions.HasOption('dynamic') then Include(FOptions, goLinkDynamic); + if FCmdOptions.HasOption('deprecated') then + Include(FOptions, goIncludeDeprecated); + if FCmdOptions.HasOption('classes') then begin Include(FOptions, goClasses); diff --git a/applications/gobject-introspection/girobjects.pas b/applications/gobject-introspection/girobjects.pas index d487cc78a..2d39d0e26 100644 --- a/applications/gobject-introspection/girobjects.pas +++ b/applications/gobject-introspection/girobjects.pas @@ -220,6 +220,7 @@ type private FCIdentifier: String; FDeprecated: Boolean; + FDeprecatedMsg: String; FDeprecatedVersion: String; FParams: TgirParamList; FReturns: TgirFunctionReturn; @@ -230,6 +231,7 @@ type property Returns: TgirFunctionReturn read FReturns; property CIdentifier: String read FCIdentifier; property Deprecated: Boolean read FDeprecated; + property DeprecatedMsg: String read FDeprecatedMsg; property DeprecatedVersion: String read FDeprecatedVersion; end; @@ -939,7 +941,10 @@ begin end; FDeprecated:=TDOMElement(ANode).GetAttribute('deprecated') <> ''; if FDeprecated then + begin + FDeprecatedMsg:=TDOMElement(ANode).GetAttribute('deprecated'); FDeprecatedVersion:=TDOMElement(ANode).GetAttribute('deprecated-version'); + end; FObjectType:=otFunction; end; diff --git a/applications/gobject-introspection/girpascalwritertypes.pas b/applications/gobject-introspection/girpascalwritertypes.pas index fce0ae367..a0ef29898 100644 --- a/applications/gobject-introspection/girpascalwritertypes.pas +++ b/applications/gobject-introspection/girpascalwritertypes.pas @@ -8,7 +8,7 @@ uses Classes, SysUtils, girNameSpaces, girObjects, girTokens, contnrs; type - TgirOption = (goWantTest, goLinkDynamic, goSeperateConsts, goClasses, goObjects); + TgirOption = (goWantTest, goLinkDynamic, goSeperateConsts, goClasses, goObjects, goIncludeDeprecated); TgirOptions = set of TgirOption; TgirWriteEvent = procedure (Sender: TObject; AUnitName: AnsiString; AStream: TStringStream) of object; @@ -1143,13 +1143,14 @@ var Postfix: String; Entry: String; InLineS: String = ''; + Deprecated: String = ''; ProperUnit: TPascalUnit; OptionsIndicateWrapperMethod: Boolean; begin Result := ''; OptionsIndicateWrapperMethod:= FUnitType = PascalUnitTypeAll; // 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; // 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 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 WriteFunctionTypeAndReturnType(AFunction, RoutineType, Returns); @@ -1173,9 +1175,9 @@ begin if Pos('array of const', Params) + Pos('va_list', Params) > 0 then Prefix:='//'; if not (goLinkDynamic in FOptions) then - Postfix := ' external;'// '+UnitName+'_library;'; + Postfix := ' external;'+ Deprecated// '+UnitName+'_library;'; else - PostFix := ''; + PostFix := ''+Deprecated; // first wrapper proc 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. <---- // result will be written in the object declaration. if OptionsIndicateWrapperMethod then - Result := Entry + Result := Entry + Deprecated else Result := ''; @@ -1283,12 +1285,12 @@ var SetFound := SetFound or (Pos(LookingForSet+'(', Line) > 0); // the first argument must match the property type! (result is the return type) - if SetFound and (Pos(Result+')', Line) = 0) then - writeln('Eliminated ', Line, ' for missing: ', Result); + //if SetFound and (Pos(Result+')', Line) = 0) then + // writeln('Eliminated ', Line, ' for missing: ', Result); SetFound := SetFound and (Pos(Result+')', Line) > 0); // 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 Exit;