[cfe-dev] Reflection

David Chisnall theraven at sucs.org
Tue Dec 14 14:24:53 PST 2010


On 14 Dec 2010, at 22:04, variadic.template wrote:

> Introspecting C++/Objective-C-classes is what i am currently trying to do
> with clang. The idea of adding reflections to C/C++/ObjC is in mind for
> quite a long time. My main purpose is the serialization/deserialization
> of more-or-less complex objects into different formats, without having
> the need of using boost.serialization or something similar. For this
> purpose, traits would be sufficient and i think they should be included
> in an approach of realizing introspection. Of course, there should also
> be a dynamic runtime for the use of doing some scripting or other
> use-cases, which already have been mentioned.
> Also, the use of reflection-specific attributes should bear in mind.

Objective-C classes already contain introspection information.  In the EtoileSerialise framework, we use the information about instance variable layout to automatically serialise most Objective-C classes (anything that doesn't contain pointers to C types - those need some manual assistance, since we can't tell if they're arrays, and if they are what their size is).  LanguageKit, similarly, uses this information when compiling classes from Smalltalk or EScript to access instance variables in the superclass and to determine the correct types when calling Objective-C methods.  

If you want to add metadata to Objective-C classes, be careful that you're not duplicating something that's already there...

David

-- Sent from my brain





More information about the cfe-dev mailing list