std.reflection prototype

bitwise via Digitalmars-d digitalmars-d at puremagic.com
Mon Mar 30 14:31:21 PDT 2015


https://github.com/D-Programming-Language/druntime/pull/775
https://github.com/D-Programming-Language/dmd/pull/2271

I've read over the comments of the above two pull-requests, and 
I'm confused about what is trying to be achieved.

A ModuleInfo for each module already exists and is available at 
runtime. Each ModuleInfo has the method localClasses() to get all 
it's classes. Why not just add an array of MethodInfo and 
FieldInfo to TypeInfo_Class?

It seems like the above two pulls are trying to add some kind of 
custom per-module info. For my purposes, some very basic info for 
suffice.

At the very minimum, if TypeInfo_Class could be completed to 
contain these, I would be happy:

// one per field
class FieldInfo
{
     string name();
     TypeInfo type();
     void *getAddress(void *instance);
}

// one per overload
class MethodInfo
{
     string name();
     TypeInfo returnType();
     TypeInfo[] parameterTypes();
     bool isProperty();
     bool isStatic();
     void *getAddress(void *instance);
}

The above two would be more than enough to do serialization and 
runtime modification of unknown objects.

What am I missing here?



More information about the Digitalmars-d mailing list