Added option to gir2pas to disable wrapper functions and properties. Usefull if trying to use an older gtk3 version than the bindings are based on since all unresolved functions will prevent linking.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2498 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
drewski207
2012-08-27 03:16:20 +00:00
parent d076a47b16
commit 82be41c270
2 changed files with 8 additions and 4 deletions

View File

@ -208,6 +208,7 @@ begin
'Note: If -C or -O are not used then pascal Objects and consts '+ 'Note: If -C or -O are not used then pascal Objects and consts '+
'are in a single unit.'); 'are in a single unit.');
{$ENDIF CreatePascalClasses} {$ENDIF CreatePascalClasses}
AddOption(['N', 'no-wrappers'], False ,'Do not create wrappers for objects.');
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.');
@ -278,6 +279,9 @@ begin
Include(FOptions, goSeperateConsts); Include(FOptions, goSeperateConsts);
end; end;
if FCmdOptions.HasOption('no-wrappers') then
Include(FOptions, goNoWrappers);
if FCmdOptions.HasOption('objects') then if FCmdOptions.HasOption('objects') then
begin begin
Include(FOptions, goObjects); Include(FOptions, goObjects);

View File

@ -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, goIncludeDeprecated); TgirOption = (goWantTest, goLinkDynamic, goSeperateConsts, goClasses, goObjects, goIncludeDeprecated, goNoWrappers);
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;
@ -1189,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 and not(goNoWrappers in FOptions) then
Result := Entry + Deprecated Result := Entry + Deprecated
else else
Result := ''; Result := '';
@ -1223,7 +1223,7 @@ begin
//RoutineType, AObjectName, AObjectFunctionName, AParams, AFunctionReturns, AFlatFunctionName, AWantSelf //RoutineType, AObjectName, AObjectFunctionName, AParams, AFunctionReturns, AFlatFunctionName, AWantSelf
// writes the implementation of what we declared in the object // writes the implementation of what we declared in the object
if AWantWrapperForObject and (Prefix = '') and OptionsIndicateWrapperMethod then if AWantWrapperForObject and (Prefix = '') and OptionsIndicateWrapperMethod and not (goNoWrappers in FOptions) then
WriteWrapperForObject(RoutineType, AItem.TranslatedName, ProperUnit.SanitizeName(AFunction.Name), AFunction.Params, Returns, AFunction.CIdentifier, AIsMethod); WriteWrapperForObject(RoutineType, AItem.TranslatedName, ProperUnit.SanitizeName(AFunction.Name), AFunction.Params, Returns, AFunction.CIdentifier, AIsMethod);
end; end;
@ -1310,7 +1310,7 @@ var
OptionsIndicateWrapperMethod: Boolean; OptionsIndicateWrapperMethod: Boolean;
begin begin
OptionsIndicateWrapperMethod:=FUnitType = PascalUnitTypeAll; OptionsIndicateWrapperMethod:=FUnitType = PascalUnitTypeAll;
if not OptionsIndicateWrapperMethod then if not OptionsIndicateWrapperMethod or (goNoWrappers in FOptions) then
Exit(''); Exit('');
ReadFunc:= 'read '+SanitizeName('get_'+ AProperty.Name); ReadFunc:= 'read '+SanitizeName('get_'+ AProperty.Name);
if AProperty.Writable then if AProperty.Writable then