Scope& Scope::operator=(const Scope& rhs) { if (this != &rhs) { Orphan(); Clear(); mTable.Resize(rhs.mTable.Size()); // this should be OK to call since the hash map is empty after Clear() for (std::uint32_t i = 0; i < rhs.mOrder.Size(); ++i) { if (rhs.mOrder[i]->second.GetType() != Datum::Table) { Datum& d = Append(rhs.mOrder[i]->first); d = rhs.mOrder[i]->second; } else { std::uint32_t datumSize = rhs.mOrder[i]->second.Size(); for (std::uint32_t datumCounter = 0; datumCounter < datumSize; ++datumCounter) { Scope& s = AppendScope(rhs.mOrder[i]->first); // s is a reference to a scope Datum* scopeDatum = Find(rhs.mOrder[i]->first); // scopeDatum contains s Scope* scopePointer = rhs.mOrder[i]->second.GetTable(datumCounter); // scope pointer is a pointer to the corresponding scope in scopeDatum if (scopePointer == nullptr) scopeDatum->Set((Scope*)nullptr, datumCounter); // if the scope in the rhs datum is null, this scope should also be null else s = *scopePointer; // recursive call } } } } return *this; }
static lock_list * getlockstruct(dbref thing, lock_type type) { lock_list *ll; dbref p = thing, ancestor = NOTHING; int cmp, count = 0, ancestor_in_chain = 0; if (GoodObject(thing)) ancestor = Ancestor_Parent(thing); do { for (; GoodObject(p); p = Parent(p)) { if (count++ > 100) return NULL; if (p == ancestor) ancestor_in_chain = 1; ll = Locks(p); while (ll && L_TYPE(ll)) { cmp = strcasecmp(L_TYPE(ll), type); if (cmp == 0) return (p != thing && (ll->flags & LF_PRIVATE)) ? NULL : ll; else if (cmp > 0) break; ll = ll->next; } } p = ancestor; } while (!ancestor_in_chain && !Orphan(thing) && GoodObject(ancestor)); return NULL; }
static void Remove(T* node) { if (Orphan(node)) return; node->prev->next = node->next; node->next->prev = node->prev; node->prev = NULL; node->next = NULL; }
void Append(T* node) { if (!Orphan(node)) fprintf(stdout, "WARNING: Appending non-orphan node to list...\n"); end.prev->next = node; node->prev = end.prev; node->next = &end; end.prev = node; }
void Scene::Remove (Interactor* i) { DoRemove(i); i->parent = nil; if (i->canvas != nil) { Unmap(i); if (i->GetInteractorType() != InteriorInteractor) { i->Deactivate(); } Orphan(i); } }
void Scene::Orphan (Interactor* i) { Interactor* children[100]; Interactor** a; long n; i->GetComponents(children, sizeof(children) / sizeof(Interactor*), a, n); if (n > 0) { register int index; for (index = 0; index < n; index++) { Orphan(a[index]); } if (a != children) { delete a; } } delete i->canvas; i->canvas = nil; }
Scope::~Scope() { Orphan(); Clear(); }