mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-10 02:08:38 +09:00
Change JS to MozMap conversion to more closely follow the record<> spec
This commit is contained in:
parent
17d23ee848
commit
69cc954889
1 changed files with 24 additions and 6 deletions
|
|
@ -4780,8 +4780,11 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
|||
auto& mozMapEntries = ${mozMapRef}.Entries();
|
||||
|
||||
JS::Rooted<JSObject*> mozMapObj(cx, &$${val}.toObject());
|
||||
JS::Rooted<JS::IdVector> ids(cx, JS::IdVector(cx));
|
||||
if (!JS_Enumerate(cx, mozMapObj, &ids)) {
|
||||
JS::AutoIdVector ids(cx);
|
||||
// Keep skipping symbols until
|
||||
// https://github.com/heycam/webidl/issues/294 is sorted out.
|
||||
if (!js::GetPropertyKeys(cx, mozMapObj,
|
||||
JSITER_OWNONLY | JSITER_HIDDEN, &ids)) {
|
||||
$*{exceptionCode}
|
||||
}
|
||||
if (!mozMapEntries.SetCapacity(ids.length(), mozilla::fallible)) {
|
||||
|
|
@ -4793,16 +4796,31 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
|||
JS::Rooted<jsid> curId(cx);
|
||||
for (size_t i = 0; i < ids.length(); ++i) {
|
||||
curId = ids[i];
|
||||
binding_detail::FakeString propName;
|
||||
bool isSymbol;
|
||||
if (!ConvertIdToString(cx, curId, propName, isSymbol) ||
|
||||
(!isSymbol && !JS_GetPropertyById(cx, mozMapObj, curId, &temp))) {
|
||||
|
||||
MOZ_ASSERT(!JSID_IS_SYMBOL(curId), "No symbols, we said!");
|
||||
|
||||
JS::Rooted<JS::PropertyDescriptor> desc(cx);
|
||||
if (!JS_GetOwnPropertyDescriptorById(cx, mozMapObj, curId,
|
||||
&desc)) {
|
||||
$*{exceptionCode}
|
||||
}
|
||||
if (isSymbol) {
|
||||
|
||||
if (!desc.object() /* == undefined in spec terms */ ||
|
||||
!desc.enumerable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
binding_detail::FakeString propName;
|
||||
bool isSymbol;
|
||||
if (!ConvertIdToString(cx, curId, propName, isSymbol)) {
|
||||
$*{exceptionCode}
|
||||
}
|
||||
MOZ_ASSERT(!isSymbol, "We said, no symbols!");
|
||||
|
||||
if (!JS_GetPropertyById(cx, mozMapObj, curId, &temp)) {
|
||||
$*{exceptionCode}
|
||||
}
|
||||
|
||||
// Safe to do an infallible append here, because we did a
|
||||
// SetCapacity above to the right capacity.
|
||||
${mozMapType}::EntryType* entry = mozMapEntries.AppendElement();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue