<div dir="ltr">AFAIK FPC doesn't support lambdas (yet?)<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Feb 18, 2013 at 9:02 PM, Boian Mitov <span dir="ltr"><<a href="mailto:mitov@mitov.com" target="_blank">mitov@mitov.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">As example this enumerates all attributes of certain type for any public or published member (function, field, or property) for a component:<br>
<br>
<br>
for LMember in TRTRtti.GetType( Component.ClassType() ).GetMembers( [mvPublic, mvPublished] ) do<br>
for LAtrribute in LMember.GetAttributes( TMyCustomAttributeType, True ) do<br>
<br>
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:<br>
<br>
AAttributes := TRTRtti.GetType( Component.ClassType() ).GetCustomAttributes( TVLCommonFilterHostedPreviewAt<u></u>tribute, True );<br>
for AAttribute in AAttributes do<br>
if( AAttribute is TLPComponentEditorAttribute ) then<br>
begin<br>
AAttrItem := GComponentEditorAttributeList.<u></u>Find(<br>
function( AItem : IComponentEditorAttributeItem ) : Boolean<br>
var<br>
AAttributes : IRTAttributes;<br>
AAttributeClass : TCustomAttributeClass;<br>
<br>
begin<br>
AAttributeClass := AItem.GetInstance().<u></u>AttributeClass;<br>
AAttributes := TRTRtti.GetType( Component.ClassType() ).GetCustomAttributes( TLPSuppressAttributeAttribute, True );<br>
if( AAttributes.Find(<br>
function ( ASupressAttribute : TCustomAttribute ) : Boolean<br>
begin<br>
Result := ( AAttributeClass = TLPSuppressAttributeAttribute( ASupressAttribute ).Attribute );<br>
end<br>
) <> NIL ) then<br>
Exit( False );<br>
<br>
Result := ( AAttribute is AAttributeClass );<br>
end<br>
);<br>
<br>
Exit( AAttrItem.GetInstance().<u></u>ComponentEditor.Create( Component, Designer ));<br>
end;<br>
<br>
This actually is a real piece of code from a place we use the new RTTI ;-)<div class="im"><br>
<br>
With best regards,<br>
Boian Mitov<br>
<br>
------------------------------<u></u>-------------------------<br>
Mitov Software<br>
<a href="http://www.mitov.com" target="_blank">www.mitov.com</a><br>
------------------------------<u></u>-------------------------<br></div>
-----Original Message----- From: Boian Mitov<br>
Sent: Monday, February 18, 2013 11:49 AM<br>
To: FPC developers' list<div class="HOEnZb"><div class="h5"><br>
Subject: Re: [fpc-devel] State of extended RTTI<br>
<br>
Hi Sven,<br>
<br>
It is an abstraction API that on the low side is 100% compatible with the<br>
Delphi API, as it uses it to access the information, but on the user side<br>
presents extremely easy to use API. It is probably better than anything<br>
available in the world at the moment, and light years ahead of both the<br>
Microsoft .NET RTTI API and the Embarcadero RTTI API. Being abstraction<br>
layer it also can be hooked on anything you have on the back end without<br>
breaking the code.<br>
<br>
With best regards,<br>
Boian Mitov<br>
<br>
------------------------------<u></u>-------------------------<br>
Mitov Software<br>
<a href="http://www.mitov.com" target="_blank">www.mitov.com</a><br>
------------------------------<u></u>-------------------------<br>
-----Original Message----- From: Sven Barth<br>
Sent: Monday, February 18, 2013 11:37 AM<br>
To: <a href="mailto:fpc-devel@lists.freepascal.org" target="_blank">fpc-devel@lists.freepascal.org</a><br>
Subject: Re: [fpc-devel] State of extended RTTI<br>
<br>
On 18.02.2013 20:30, Boian Mitov wrote:<br>
<br>
How compatible to Delphi's API is your API? If it is not compatible,<br>
then it would not be of much use to us. Please note that we would in any<br>
case only use the API itself, as we might not implement the binary<br>
layout of the RTTI necessarily the same as Delphi did.<br>
<br>
______________________________<u></u>_________________<br>
fpc-devel maillist - <a href="mailto:fpc-devel@lists.freepascal.org" target="_blank">fpc-devel@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-devel" target="_blank">http://lists.freepascal.org/<u></u>mailman/listinfo/fpc-devel</a> <br>
______________________________<u></u>_________________<br>
fpc-devel maillist - <a href="mailto:fpc-devel@lists.freepascal.org" target="_blank">fpc-devel@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-devel" target="_blank">http://lists.freepascal.org/<u></u>mailman/listinfo/fpc-devel</a><br>
</div></div></blockquote></div><br></div>