From dc39460b7efce72e570eadf72eba0e1034ee6dac Mon Sep 17 00:00:00 2001 From: drewski207 Date: Sat, 22 Oct 2011 20:09:07 +0000 Subject: [PATCH] Latest fixes. Fixed bug where params that were pointers to types were not recognized git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2086 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../gobject-introspection/gir2pascal.lpi | 2 +- .../gobject-introspection/girobjects.pas | 3 ++- .../gobject-introspection/girpascalwriter.pas | 21 ++++++++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/applications/gobject-introspection/gir2pascal.lpi b/applications/gobject-introspection/gir2pascal.lpi index 5fe3707e9..1960d9639 100644 --- a/applications/gobject-introspection/gir2pascal.lpi +++ b/applications/gobject-introspection/gir2pascal.lpi @@ -30,7 +30,7 @@ - + diff --git a/applications/gobject-introspection/girobjects.pas b/applications/gobject-introspection/girobjects.pas index 5581eaadb..cc114895e 100644 --- a/applications/gobject-introspection/girobjects.pas +++ b/applications/gobject-introspection/girobjects.pas @@ -822,10 +822,11 @@ begin gtDoc:; gtType: begin C_Type := Node.GetAttribute('c:type'); + FCType:= C_Type; VarTypeName:=Node.GetAttribute('name'); if VarTypeName = '' then VarTypeName:= StringReplace(C_Type, '*', '', [rfReplaceAll]); - FVarType := TgirNamespace(Owner).LookupTypeByName(VarTypeName, C_Type); + FVarType := TgirNamespace(Owner).LookupTypeByName(VarTypeName, C_Type); end; gtArray: begin C_Type := Node.GetAttribute('c:type'); diff --git a/applications/gobject-introspection/girpascalwriter.pas b/applications/gobject-introspection/girpascalwriter.pas index 6c244b1bc..c374e516c 100644 --- a/applications/gobject-introspection/girpascalwriter.pas +++ b/applications/gobject-introspection/girpascalwriter.pas @@ -993,7 +993,7 @@ var begin Result := ''; // we skip deprecated functions - if AFunction.Deprecated and (CompareStr(AFunction.DeprecatedVersion, NameSpace.Version) >= 0) then + if AFunction.Deprecated 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 :( @@ -1454,7 +1454,7 @@ begin else begin AFunctionType:='function'; - AFunctionReturnType:= ': '+TypeAsString(AItem.Returns.VarType, AItem.Returns.PointerLevel)+'; cdecl;' ; + AFunctionReturnType:= ': '+TypeAsString(AItem.Returns.VarType, AItem.Returns.PointerLevel, AItem.Returns.CType)+'; cdecl;' ; // will skip if written ProcessType(AItem.Returns.VarType); @@ -1488,11 +1488,19 @@ end; function TPascalUnit.TypeAsString(AType: TGirBaseType; APointerLevel: Integer; ACTypeAsBackup: String = ''): String; var BackupNoPointers: String; + TranslatedName: String; begin ResolveTypeTranslation(AType); + TranslatedName := AType.TranslatedName; BackupNoPointers := StringReplace(ACTypeAsBackup, '*', '', [rfReplaceAll]); + // some types are pointers but contain no "*" so it thinks it has a pointer level 0 when really it's 1 + if (APointerLevel = 0) and (ACTypeAsBackup = 'gpointer') and (TranslatedName <> '') and (TranslatedName <> 'gpointer') then + begin + APointerLevel := 1; + end; + if APointerLevel = 0 then begin Result := AType.TranslatedName; @@ -1868,9 +1876,16 @@ begin end; procedure TPascalUnit.ResolveTypeTranslation(ABaseType: TGirBaseType); +var + RawName: String; begin if ABaseType.TranslatedName = '' then - ABaseType.TranslatedName:=MakePascalTypeFromCType(ABaseType.CType, 0); + begin + RawName := ABaseType.CType; + if RawName = '' then + RawName:= ABaseType.Name; + ABaseType.TranslatedName:=MakePascalTypeFromCType(RawName, 0); + end; end; constructor TPascalUnit.Create(ANameSpace: TgirNamespace; ALinkDynamic: Boolean; AWantTest: Boolean);