Hello. In object.di rt_finalize calls for class objects in
destroy func.
I not found it in dmd source on github and not found in druntime
sources.
I think rt_finalize must call dtors for object and base classes,
but I think that's not all. Or if it all has it code logic
problems?
void myDestroy(T)( T obj ) if( is( T == class ) )
{
mixin( callDtor!( obj.stringof,
TypeTuple!(T,BaseClassesTuple!T) ) );
}
string callDtor( string name, BCT... )() @property
{
import std.string;
static if( BCT.length == 1 ) return ""; // Object has no dtor
else
return format( "%s.%s.__dtor();\n", name,
BCT[0].stringof.split(".")[$-1] ) ~
callDtor!(name, BCT[1..$]);
}
function callDtor generate string like this
obj.C.__dtor();
obj.B.__dtor();
obj.A.__dtor();
for class model
class A{}
class B : A {}
class C : B {}
I want understand why destroy for class objects call extern(C)
function rt_finalize (not pure, with gc, can except), and how it
works (rt_finalize gets void*).