[fpc-devel] Closures via interfaces

Maciej Izak hnb.code at gmail.com
Mon May 27 11:17:12 CEST 2013


>
> Sven, I did not ask what and how delphi implemented. I asked Maciej Izak
> what he wants from extended RTTI. Maybe this is a small subset which is not
> very hard to implement.
> Best regards,
> Paul Ishenin
>

Unfortunately, Sven is right :). I need this to share another free library
for FPC. It was originally intended for sale to the Embarcadero. Absolute
automatic binary streaming (seriously, for each type that exists in Pascal,
including Class, ClassRef, Interfaces, Pointers, menaged records with help
of attributes). Small demo:

===begin code===
  // save
  f := TFileStream.Create(dSaveLDFM.FileName, fmCreate);
  f.Write<AnsiChar>(4, FILE_TAG[0]);
  f.Write<UInt32>(1);
  f.Write<TArray<string>>(FDfmDictionary.Keys.ToArray);
  f.Free;

  // read
  f := TFileStream.Create(dOpenLDFM.FileName, fmOpenRead);
  f.Read<AnsiChar>(4, stag);
  if stag <> FILE_TAG then raise EProgrammerNotFound.Create('File is
corrupted');
  if f.Read<UInt32> <> 1 then raise EProgrammerNotFound.Create('Wrong file
version');
  f.Read<TArray<string>>(LList);
  f.Free;
===end code===

Implemented as helpers for streams :). It will be another "stress test" for
generic types, and RTTI.
To done this, FPC needs:

1. Extended RTTI (especially with attributes and access to
private/protected/public members. This library don't need
TVirtualMethodInterceptor,
Invoke (but I think attributes needs Invoke :( ) and TValue)
2. Fix/implementation of: http://bugs.freepascal.org/view.php?id=24254

Regards,
HNB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20130527/0515237a/attachment.html>


More information about the fpc-devel mailing list