<div dir="ltr"><div><div><div>On Sun Nov 23 18:03:55 CET 2014, Joao Morais wrote:</div></div><div>> Hello list, is there a safe way to know the PTypeInfo, or at least the </div><div>> string literal of the type(s) used to specialize a generic? Eg:</div><div>> <br></div><div>> TBarList = specialize TGenericList<TBar></div><div>> <br></div><div>> On the sample above, starting with PTypeInfo of TBarList I know it was </div><div>> specialized using TBar type. I was using the following hack on 2.6.x:</div><div>> <br></div><div>> VPos := Pos('$', AClassName);</div><div>> if VPos > 0 then</div><div>> VTypeName := Copy(AClassName, VPos + 1, Length(AClassName));</div><div>> <br></div><div>> ...which is broken on 2.7.</div></div><div><br></div><div>Unfortunatelly, no.</div><div><br></div><div>In Delphi, you can:</div><div><br></div><div><div> TBar = class(TObject)</div><div> end;</div><div><br></div><div> TBarList = class(TList<TBar>)</div><div> end;</div></div><div><br></div><div> WriteLn(TBarList.ClassParent.ClassName);<br></div><div><br></div><div>Result: TList<Unit1.TBar> // so you can get the unit/type used between "<>"</div><div><br></div><div>But currently in FPC (tested from trunk):</div><div><br></div><div>{$mode delphi}<br></div><div><br></div><div><div> TBar = class(TObject)</div><div> end;</div><div><br></div><div> TBarList = class(TFPGList<TBar>)</div><div> end;</div></div><div><br></div><div>WriteLn(TBarList.ClassParent.ClassName);<br></div><div><br></div><div>Result: TFPGList$1$crc07FFF574</div><div><br></div>-- <br><div class="gmail_signature">Silvio Clécio<br>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a></div>
</div>