From 8ebe4628c8db71f40ef105d05a6e46dd4e8ec94b Mon Sep 17 00:00:00 2001 From: Abou Al Montacir Date: Sat, 20 May 2023 09:55:05 +0200 Subject: [PATCH] Generate pointer types for all declared types. If the type is not used within the unit it was declared in, then pointer types will not generated. This causes an error when a pointer type is used by a unit using it. An example is a compilation error on `Pango1` that uses `Glib2` because the type `Pgconstpointer` was not defined. The new code generates a lost of pointer types, but at least it allows get a code that compiles fine. --- tools/gir2pascal/girpascalwritertypes.pas | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/gir2pascal/girpascalwritertypes.pas b/tools/gir2pascal/girpascalwritertypes.pas index 3a544dfbce..301e34f087 100644 --- a/tools/gir2pascal/girpascalwritertypes.pas +++ b/tools/gir2pascal/girpascalwritertypes.pas @@ -914,6 +914,8 @@ begin //WriteLn('Warning: Forwards definitions already written for : ', Aitem.TranslatedName); AItem.ForwardDefinitionWritten := True; PTypes := MakePointerTypesForType(ATypeName, APointerLevel); + ALines.Add(''); + Alines.Add(IndentText('{ ' + ATypeName + ' }', 2, 0)); PTypes.Insert(0, ATypeName); for i := PTypes.Count-1 downto 1 do ALines.Add(IndentText(PTypes[i]+ ' = ^'+PTypes[i-1]+';',2,0)); @@ -939,7 +941,7 @@ begin TypeSect := WantTypeSection; AItem.TranslatedName:=AItem.CType; - //WritePointerTypesForType(Aitem, AItem.CType, AItem.ImpliedPointerLevel, TypeSect.Lines); + WritePointerTypesForType(Aitem, AItem.CType, AItem.ImpliedPointerLevel, TypeSect.Lines); if AItem.Name <> 'file' then TypeSect.Lines.Add(IndentText(SanitizeName(AItem.CType)+ ' = '+ AItem.PascalName+';', 2,0)); end;