Attribute syntax in Delphi 2009 RTL / VCL?

Where I work, we are still using Delphi 2009. I happened to look at the Forms block in VCL and came across:

[UIPermission(SecurityAction.LinkDemand, Window=UIPermissionWindow.AllWindows)] function DisableTaskWindows(ActiveWindow: HWnd): TTaskWindowList; 

This attribute is clearly a CLR class of UIPermissionAttribute , but unlike other CLR references, this attribute is not wrapped in conditional compilation directives .

This surprised me because AFAIK in versions of Delphi Win32 until 2010, brackets were used only to indicate indexes in arrays and collection types, defining sets and assigning GUIDs to interfaces. This is not true.

I did a regex search and found dozens of examples throughout RTL / VCL. Some of them were type attributes, and some were methods.

Is this simply ignored by the compiler, or do they serve some purpose in Win32?


I also found a syntax that looked like this:

 [!UnitName] [!InterfaceName] 

This seems to be related to generating the source files from the template in the IDE wizard, but they were not in the RTL source folder. They were in the repository folder of the object.

+4
source share
1 answer

I was hoping that perhaps the attributes were an undocumented function, similar to how class helpers were available for many years before they were documented, but this does not seem to be the case.

I tried a simple test and added attribute notation before the class definition. The compiler did not strangle him, but he issued a warning that user attributes were not supported.

0
source

Source: https://habr.com/ru/post/1396890/


All Articles