Adding AccessSpecifiers via RTTI

Question: “How do I add support for an Indexed property to RAP?”

Answer:  A property such as TStrings.Values, is known as an Access Specifier. If you do a GREP search in the RBuilder source directory, you will find numerous references to AccessSpecifierToRec (see the RAP help for TraRTTI.AccessSpecifierToRec).

AccessSpecifiers are an odd hybrid of property and method, so they require a little bit of the effort of both. Basically, the process is this:

In TraRTTI.CallMethod (here it acts like a method), we get or set values in the aParams parameter. For instance, for TStrings.Values, we do this:

In TraRTTI.GetParams, we treat the AccessSpecifier as a method again, adding two parameters to Result. One for the index and one for the result. Again, with TStrings.Values:

In TraRTTI.GetPropList, add the property as a property:

In TraRTTI.GetPropRec we use the AccessSpecifierToRec method: