void ObjectWrapper::Key::del(JSContext* cx, JS::HandleObject o) { switch (_type) { case Type::Field: if (JS_DeleteProperty(cx, o, _field)) return; break; case Type::Index: if (JS_DeleteElement(cx, o, _idx)) return; break; case Type::Id: { JS::RootedId id(cx, _id); // For some reason JS_DeletePropertyById doesn't link if (JS_DeleteProperty(cx, o, IdWrapper(cx, id).toString().c_str())) return; break; } case Type::InternedString: { InternedStringId id(cx, _internedString); if (JS_DeleteProperty(cx, o, IdWrapper(cx, id).toString().c_str())) break; } } throwCurrentJSException(cx, ErrorCodes::InternalError, "Failed to delete value on a JSObject"); }
void FFSessionHandler::freeValue(HostChannel& channel, int idCount, const int* ids) { Debug::DebugStream& dbg = Debug::log(Debug::Spam) << "FFSessionHandler::freeValue [ "; JSContext* ctx = getJSContext(); for (int i = 0; i < idCount; ++i) { int objId = ids[i]; dbg << objId << " "; jsval toRemove; if (JS_GetElement(ctx, jsObjectsById, objId, &toRemove) && #ifdef JSVAL_IS_OBJECT JSVAL_IS_OBJECT(toRemove)) { #else !JSVAL_IS_PRIMITIVE(toRemove)) { #endif jsIdsByObject.erase(identityFromObject(JSVAL_TO_OBJECT(toRemove))); JS_DeleteElement(ctx, jsObjectsById, objId); } else { Debug::log(Debug::Error) << "Error deleting js objId=" << objId << Debug::flush; } }