mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1364816
part 4. Add a JS friend API for getting an jsid from a known-atom JSString*. r=jandem
This commit is contained in:
parent
60d80c3c4e
commit
d6c61dbb66
@ -1302,6 +1302,12 @@ js::detail::IdMatchesAtom(jsid id, JSAtom* atom)
|
||||
return id == INTERNED_STRING_TO_JSID(nullptr, atom);
|
||||
}
|
||||
|
||||
bool
|
||||
js::detail::IdMatchesAtom(jsid id, JSString* atom)
|
||||
{
|
||||
return id == INTERNED_STRING_TO_JSID(nullptr, atom);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
js::PrepareScriptEnvironmentAndInvoke(JSContext* cx, HandleObject scope, ScriptEnvironmentPreparer::Closure& closure)
|
||||
{
|
||||
|
@ -2602,6 +2602,7 @@ JSID_FROM_BITS(size_t bits)
|
||||
namespace js {
|
||||
namespace detail {
|
||||
bool IdMatchesAtom(jsid id, JSAtom* atom);
|
||||
bool IdMatchesAtom(jsid id, JSString* atom);
|
||||
} // namespace detail
|
||||
} // namespace js
|
||||
|
||||
@ -2635,6 +2636,15 @@ NON_INTEGER_ATOM_TO_JSID(JSAtom* atom)
|
||||
return id;
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE jsid
|
||||
NON_INTEGER_ATOM_TO_JSID(JSString* atom)
|
||||
{
|
||||
MOZ_ASSERT(((size_t)atom & 0x7) == 0);
|
||||
jsid id = JSID_FROM_BITS((size_t)atom);
|
||||
MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
|
||||
return id;
|
||||
}
|
||||
|
||||
/* All strings stored in jsids are atomized, but are not necessarily property names. */
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
JSID_IS_ATOM(jsid id)
|
||||
|
Loading…
Reference in New Issue
Block a user