[fpc-devel] State of extended RTTI

Kostas Michalopoulos badsectoracula at gmail.com
Tue Feb 19 14:36:10 CET 2013


AFAIK FPC doesn't support lambdas (yet?)


On Mon, Feb 18, 2013 at 9:02 PM, Boian Mitov <mitov at mitov.com> wrote:

> As example this enumerates all attributes of certain type for any public
> or published member (function, field, or property) for a component:
>
>
> for LMember in TRTRtti.GetType( Component.ClassType() ).GetMembers(
> [mvPublic, mvPublished] ) do
>  for LAtrribute in LMember.GetAttributes( TMyCustomAttributeType, True ) do
>
> You can see how much can be achieved with almost no code :-D  and this is
> just the tip of the iceberg ;-) . It supports filtering with lambdas, and
> in general is designed in the principles of functional programming, so you
> can as example filter like this:
>
> AAttributes := TRTRtti.GetType( Component.ClassType()
> ).GetCustomAttributes( TVLCommonFilterHostedPreviewAt**tribute, True );
> for AAttribute in AAttributes do
>  if( AAttribute is TLPComponentEditorAttribute ) then
>    begin
>    AAttrItem := GComponentEditorAttributeList.**Find(
>                      function( AItem : IComponentEditorAttributeItem ) :
> Boolean
>                      var
>                        AAttributes       : IRTAttributes;
>                        AAttributeClass   : TCustomAttributeClass;
>
>                      begin
>                        AAttributeClass := AItem.GetInstance().**
> AttributeClass;
>                        AAttributes := TRTRtti.GetType(
> Component.ClassType() ).GetCustomAttributes( TLPSuppressAttributeAttribute,
> True );
>                        if( AAttributes.Find(
>                                function ( ASupressAttribute :
> TCustomAttribute ) : Boolean
>                                begin
>                                  Result := ( AAttributeClass =
> TLPSuppressAttributeAttribute( ASupressAttribute ).Attribute );
>                                end
>                              ) <> NIL ) then
>                          Exit( False );
>
>                        Result := ( AAttribute is AAttributeClass );
>                      end
>                   );
>
>    Exit( AAttrItem.GetInstance().**ComponentEditor.Create( Component,
> Designer ));
>    end;
>
> This actually is a real piece of code from a place we use the new RTTI ;-)
>
>
> With best regards,
> Boian Mitov
>
> ------------------------------**-------------------------
> Mitov Software
> www.mitov.com
> ------------------------------**-------------------------
> -----Original Message----- From: Boian Mitov
> Sent: Monday, February 18, 2013 11:49 AM
> To: FPC developers' list
>
> Subject: Re: [fpc-devel] State of extended RTTI
>
>    Hi Sven,
>
> It is an abstraction API that on the low side is 100% compatible with the
> Delphi API, as it uses it to access the information, but on the user side
> presents extremely easy to use API. It is probably better than anything
> available in the world at the moment, and light years ahead of both the
> Microsoft .NET RTTI API and the Embarcadero RTTI API. Being abstraction
> layer it also can be hooked on anything you have on the back end without
> breaking the code.
>
> With best regards,
> Boian Mitov
>
> ------------------------------**-------------------------
> Mitov Software
> www.mitov.com
> ------------------------------**-------------------------
> -----Original Message----- From: Sven Barth
> Sent: Monday, February 18, 2013 11:37 AM
> To: fpc-devel at lists.freepascal.org
> Subject: Re: [fpc-devel] State of extended RTTI
>
> On 18.02.2013 20:30, Boian Mitov wrote:
>
> How compatible to Delphi's API is your API? If it is not compatible,
> then it would not be of much use to us. Please note that we would in any
> case only use the API itself, as we might not implement the binary
> layout of the RTTI necessarily the same as Delphi did.
>
> ______________________________**_________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/**mailman/listinfo/fpc-devel<http://lists.freepascal.org/mailman/listinfo/fpc-devel>
> ______________________________**_________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/**mailman/listinfo/fpc-devel<http://lists.freepascal.org/mailman/listinfo/fpc-devel>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20130219/bb0ba9bc/attachment.html>


More information about the fpc-devel mailing list