/* static */ bool WebIDLGlobalNameHash::NewEnumerateSystemGlobal( JSContext* aCx, JS::Handle<JSObject*> aObj, JS::AutoIdVector& aProperties, bool aEnumerableOnly) { MOZ_ASSERT(JS_IsGlobalObject(aObj)); if (!JS_NewEnumerateStandardClasses(aCx, aObj, aProperties, aEnumerableOnly)) { return false; } // All properties defined on our global are non-enumerable, so we can skip // remaining properties. if (aEnumerableOnly) { return true; } // Enumerate all entries & add enabled ones. for (size_t i = 0; i < sCount; ++i) { const WebIDLNameTableEntry& entry = sEntries[i]; if (!entry.mEnabled || entry.mEnabled(aCx, aObj)) { JSString* str = JS_AtomizeStringN(aCx, sNames + entry.mNameOffset, entry.mNameLength); if (!str || !aProperties.append(NON_INTEGER_ATOM_TO_JSID(str))) { return false; } } } return true; }
static inline void MarkIdInternal(JSTracer *trc, jsid *id) { JS_SET_TRACING_LOCATION(trc, (void *)id); if (JSID_IS_STRING(*id)) { JSString *str = JSID_TO_STRING(*id); MarkInternal(trc, &str); *id = NON_INTEGER_ATOM_TO_JSID(reinterpret_cast<JSAtom *>(str)); } else if (JS_UNLIKELY(JSID_IS_OBJECT(*id))) { JSObject *obj = JSID_TO_OBJECT(*id); MarkInternal(trc, &obj); *id = OBJECT_TO_JSID(obj); } }
/* static */ bool WebIDLGlobalNameHash::GetNames(JSContext* aCx, JS::Handle<JSObject*> aObj, NameType aNameType, JS::AutoIdVector& aNames) { // aObj is always a Window here, so GetProtoAndIfaceCache on it is safe. ProtoAndIfaceCache* cache = GetProtoAndIfaceCache(aObj); for (size_t i = 0; i < sCount; ++i) { const WebIDLNameTableEntry& entry = sEntries[i]; // If aNameType is not AllNames, only include things whose entry slot in the // ProtoAndIfaceCache is null. if ((aNameType == AllNames || !cache->HasEntryInSlot(entry.mConstructorId)) && (!entry.mEnabled || entry.mEnabled(aCx, aObj))) { JSString* str = JS_AtomizeStringN(aCx, sNames + entry.mNameOffset, entry.mNameLength); if (!str || !aNames.append(NON_INTEGER_ATOM_TO_JSID(str))) { return false; } } } return true; }