determining if a void* points to a valid Object
Luís Marques
luismarques+spam at gmail.com
Thu Aug 17 14:52:46 PDT 2006
Sean Kelly wrote:
> It would be a horrible hack, but you might be able to test whether the
> location reserved for the vtbl ptr points to a location where vtbls are
> known to reside. The ABI might be of help here:
> http://www.digitalmars.com/d/abi.html You will have to ask Walter or do
> some sleuthing to sort out how to determine this address range, however.
http://www.digitalmars.com/d/abi.html tells us:
An object consists of:
offset contents
0 pointer to vtable
4 monitor
8... non-static members
So if the NotDObject struct was defined as { void *isobject = null; ...
} then we could look at isobject and if was not null it would be a D
Object. Or can a D Object not have a vtable? That is, could the "pointer
to vtable" be null? Even if that was the case I could add dummy virtual
methods to my classes...
Btw: I guess this ABI is 32 bit only :/
Thanks Sean!
Luís
More information about the Digitalmars-d
mailing list