mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
Tighten stream helper interface realms
This commit is contained in:
parent
8c6e09601c
commit
8c4ece641e
1 changed files with 25 additions and 13 deletions
|
|
@ -5157,7 +5157,8 @@ DequeueValue(JSContext* cx, HandleNativeObject container, MutableHandleValue chu
|
||||||
|
|
||||||
// Step 2: Assert: queue is not empty.
|
// Step 2: Assert: queue is not empty.
|
||||||
RootedValue val(cx, container->getFixedSlot(QueueContainerSlot_Queue));
|
RootedValue val(cx, container->getFixedSlot(QueueContainerSlot_Queue));
|
||||||
RootedNativeObject queue(cx, &val.toObject().as<NativeObject>());
|
RootedNativeObject queue(cx);
|
||||||
|
queue = UnwrapInternalSlotObject<NativeObject>(&val.toObject());
|
||||||
MOZ_ASSERT(queue->getDenseInitializedLength() > 0);
|
MOZ_ASSERT(queue->getDenseInitializedLength() > 0);
|
||||||
|
|
||||||
// Step 3. Let pair be the first element of queue.
|
// Step 3. Let pair be the first element of queue.
|
||||||
|
|
@ -5179,7 +5180,10 @@ DequeueValue(JSContext* cx, HandleNativeObject container, MutableHandleValue chu
|
||||||
container->setFixedSlot(QueueContainerSlot_TotalSize, NumberValue(totalSize));
|
container->setFixedSlot(QueueContainerSlot_TotalSize, NumberValue(totalSize));
|
||||||
|
|
||||||
// Step 7: Return pair.[[value]].
|
// Step 7: Return pair.[[value]].
|
||||||
chunk.set(pair->value());
|
RootedValue chunkVal(cx, pair->value());
|
||||||
|
if (!JS_WrapValue(cx, &chunkVal))
|
||||||
|
return false;
|
||||||
|
chunk.set(chunkVal);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5208,9 +5212,16 @@ EnqueueValueWithSize(JSContext* cx, HandleNativeObject container, HandleValue va
|
||||||
// Step 4: Append Record {[[value]]: value, [[size]]: size} as the last element
|
// Step 4: Append Record {[[value]]: value, [[size]]: size} as the last element
|
||||||
// of container.[[queue]].
|
// of container.[[queue]].
|
||||||
RootedValue val(cx, container->getFixedSlot(QueueContainerSlot_Queue));
|
RootedValue val(cx, container->getFixedSlot(QueueContainerSlot_Queue));
|
||||||
RootedNativeObject queue(cx, &val.toObject().as<NativeObject>());
|
RootedNativeObject queue(cx);
|
||||||
|
queue = UnwrapInternalSlotObject<NativeObject>(&val.toObject());
|
||||||
|
|
||||||
QueueEntry* entry = QueueEntry::create(cx, value, size);
|
{
|
||||||
|
JSAutoCompartment ac(cx, queue);
|
||||||
|
RootedValue wrappedValue(cx, value);
|
||||||
|
if (!JS_WrapValue(cx, &wrappedValue))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QueueEntry* entry = QueueEntry::create(cx, wrappedValue, size);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return false;
|
return false;
|
||||||
val = ObjectValue(*entry);
|
val = ObjectValue(*entry);
|
||||||
|
|
@ -5221,6 +5232,7 @@ EnqueueValueWithSize(JSContext* cx, HandleNativeObject container, HandleValue va
|
||||||
// container.[[queueTotalSize]] + size.
|
// container.[[queueTotalSize]] + size.
|
||||||
double totalSize = container->getFixedSlot(QueueContainerSlot_TotalSize).toNumber();
|
double totalSize = container->getFixedSlot(QueueContainerSlot_TotalSize).toNumber();
|
||||||
container->setFixedSlot(QueueContainerSlot_TotalSize, NumberValue(totalSize + size));
|
container->setFixedSlot(QueueContainerSlot_TotalSize, NumberValue(totalSize + size));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue