Add design time support for custom attributes

Issue #85 new
Anders Melander created an issue

Presently it is only possible to declare custom attributes in script (i.e. at run time).

In support of #84 I request that TdwsClass, TdwsFunctionSymbol and TdwsProperty be extended with design time support for custom attributes.

An alternative could be that TdwsSymbol was extended with a generic use string or string list property. This would enable us to specify additional meta data to any symbol at design time and apply this meta data to the run time symbols at run time.

Comments (1)

  1. Eric Grange repo owner

    Fitting attribute declaration at design time might be a bit more complicated, given that attributes are class constructor calls, so they are code more than declaration, and you will want to pass parameters (like in your Issue #85 example), so some interpretation/parsing would be required to figure out constants, types, etc.

    Plus it might not be very convenient (like the rest of TdwUnit class declaration..., which is a bit heavy even when using structure view). I have been mulling over changing the whole TdwsUnit approach so that instead of collections of properties and such "DFM-friendly" stuff, a TdwsUnit could be based upon straight source code (like an interface section).

    The remaining problem would be of how to attach Delphi-side events to symbols declared in the code in a convenient fashion, so that is an unresolved issue, especially when considering coding errors, renames, etc.

    Attaching a generic data string to a symbol could be done through a special case of the current attributes mechanism, f.i. by having a global/standard attribute class, with a standard constructor taking just a string parameter.

    Doing so would also make that data naturally accessibly via RTTI through the script.

    However in your case, if it is for security and rights purposes, it may be preferable if that metadata was not accessible through RTTI at all?

    (for instance, at some point in the future, RTTI could gain the ability to manipulate attributes)

  2. Log in to comment