void tvCastToResourceInPlace(TypedValue* tv) { assert(tvIsPlausible(*tv)); tvUnboxIfNeeded(tv); switch (tv->m_type) { case KindOfUninit: case KindOfNull: case KindOfBoolean: case KindOfInt64: case KindOfDouble: case KindOfStaticString: break; case KindOfString: case KindOfArray: case KindOfObject: tvDecRef(tv); break; case KindOfResource: // no op, return return; default: assert(false); break; } tv->m_type = KindOfResource; tv->m_data.pres = NEWOBJ(DummyResource); tv->m_data.pres->incRefCount(); return; }
void tvCastToResourceInPlace(TypedValue* tv) { assert(tvIsPlausible(*tv)); tvUnboxIfNeeded(tv); do { switch (tv->m_type) { DT_UNCOUNTED_CASE: continue; case KindOfString: case KindOfArray: case KindOfObject: tvDecRef(tv); continue; case KindOfResource: // no op, return return; case KindOfRef: case KindOfClass: break; } not_reached(); } while (0); tv->m_type = KindOfResource; tv->m_data.pres = newres<DummyResource>(); tv->m_data.pres->incRefCount(); }
void tvCastToResourceInPlace(TypedValue* tv) { assert(tvIsPlausible(*tv)); tvUnboxIfNeeded(tv); do { switch (tv->m_type) { DT_UNCOUNTED_CASE: continue; case KindOfString: case KindOfVec: case KindOfDict: case KindOfKeyset: case KindOfArray: case KindOfObject: tvDecRef(tv); continue; case KindOfResource: // no op, return return; case KindOfRef: case KindOfClass: break; } not_reached(); } while (0); tv->m_type = KindOfResource; tv->m_data.pres = req::make<DummyResource>().detach()->hdr(); assert(cellIsPlausible(*tv)); }