Introspection/Reflection/etc on Linux
J Arrizza
cppgent0 at gmail.com
Wed Oct 19 02:24:08 PDT 2011
Just noticed an odd thing when I was trying Jacob's code.
This works great:
auto x = new someClass();
Object o = x;
void delegate() dg;
foreach(i, m; __traits(derivedMembers, someClass))
{
writeln("i=", i, " m=", m);
if(m != "__ctor")
{
dg.funcptr = cast(void function()) o.classinfo.vtbl[i + 6];
dg.ptr = cast(void*) o;
dg();
}
}
but this doesn't (it segfaults):
Object o = Object.factory("someClass");
void delegate() dg;
foreach(i, m; __traits(derivedMembers, someClass))
{
writeln("i=", i, " m=", m);
if(m != "__ctor")
{
dg.funcptr = cast(void function()) o.classinfo.vtbl[i + 6];
dg.ptr = cast(void*) o;
dg();
}
}
Is the object returned by Object.factory() not the same somehow as the one
returned by new()?
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20111019/f6c3c234/attachment.html>
More information about the Digitalmars-d
mailing list