- Changed DObject's pointer substitution so that the pointers inside an
object are handled by a virtual function. This allows subclasses to implement their own handling if they need it. SVN r797 (trunk)
This commit is contained in:
parent
f609f43187
commit
07e795e656
6 changed files with 32 additions and 23 deletions
|
|
@ -379,7 +379,7 @@ DObject::~DObject ()
|
|||
}
|
||||
|
||||
// Find all pointers that reference this object and NULL them.
|
||||
PointerSubstitution(this, NULL);
|
||||
StaticPointerSubstitution(this, NULL);
|
||||
|
||||
// Now unlink this object from the GC list.
|
||||
for (probe = &GC::Root; *probe != NULL; probe = &((*probe)->ObjNext))
|
||||
|
|
@ -433,6 +433,25 @@ size_t DObject::PropagateMark()
|
|||
}
|
||||
|
||||
void DObject::PointerSubstitution (DObject *old, DObject *notOld)
|
||||
{
|
||||
const PClass *info = GetClass();
|
||||
const size_t *offsets = info->FlatPointers;
|
||||
if (offsets == NULL)
|
||||
{
|
||||
const_cast<PClass *>(info)->BuildFlatPointers();
|
||||
offsets = info->FlatPointers;
|
||||
}
|
||||
while (*offsets != ~(size_t)0)
|
||||
{
|
||||
if (*(DObject **)((BYTE *)this + *offsets) == old)
|
||||
{
|
||||
*(DObject **)((BYTE *)this + *offsets) = notOld;
|
||||
}
|
||||
offsets++;
|
||||
}
|
||||
}
|
||||
|
||||
void DObject::StaticPointerSubstitution (DObject *old, DObject *notOld)
|
||||
{
|
||||
DObject *probe;
|
||||
int i;
|
||||
|
|
@ -440,21 +459,7 @@ void DObject::PointerSubstitution (DObject *old, DObject *notOld)
|
|||
// Go through all objects.
|
||||
for (probe = GC::Root; probe != NULL; probe = probe->ObjNext)
|
||||
{
|
||||
const PClass *info = probe->GetClass();
|
||||
const size_t *offsets = info->FlatPointers;
|
||||
if (offsets == NULL)
|
||||
{
|
||||
const_cast<PClass *>(info)->BuildFlatPointers();
|
||||
offsets = info->FlatPointers;
|
||||
}
|
||||
while (*offsets != ~(size_t)0)
|
||||
{
|
||||
if (*(DObject **)((BYTE *)probe + *offsets) == old)
|
||||
{
|
||||
*(DObject **)((BYTE *)probe + *offsets) = notOld;
|
||||
}
|
||||
offsets++;
|
||||
}
|
||||
probe->PointerSubstitution(old, notOld);
|
||||
}
|
||||
|
||||
// Go through the bodyque.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue