mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 917843 - Handlify JS identifier APIs r=billm
This commit is contained in:
parent
607c80c4e2
commit
e562fc4cfa
@ -327,7 +327,7 @@ nsXBLProtoImplField::InstallAccessors(JSContext* aCx,
|
||||
// Get the field name as an id.
|
||||
JS::Rooted<jsid> id(aCx);
|
||||
JS::TwoByteChars chars(mName, NS_strlen(mName));
|
||||
if (!JS_CharsToId(aCx, chars, id.address()))
|
||||
if (!JS_CharsToId(aCx, chars, &id))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// Properties/Methods have historically taken precendence over fields. We
|
||||
|
@ -46,8 +46,8 @@ IsValidKeyPathString(JSContext* aCx, const nsAString& aKeyPath)
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_ASSERTION(JSVAL_IS_STRING(stringVal), "This should never happen");
|
||||
JSString* str = JSVAL_TO_STRING(stringVal);
|
||||
NS_ASSERTION(stringVal.toString(), "This should never happen");
|
||||
JS::RootedString str(aCx, stringVal.toString());
|
||||
|
||||
bool isIdentifier = false;
|
||||
if (!JS_IsIdentifier(aCx, str, &isIdentifier) || !isIdentifier) {
|
||||
|
@ -6126,17 +6126,13 @@ BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
|
||||
#endif
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_IndexToId(JSContext *cx, uint32_t index, jsid *idp)
|
||||
JS_IndexToId(JSContext *cx, uint32_t index, MutableHandleId id)
|
||||
{
|
||||
RootedId id(cx);
|
||||
if (!IndexToId(cx, index, &id))
|
||||
return false;
|
||||
*idp = id;
|
||||
return true;
|
||||
return IndexToId(cx, index, id);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_CharsToId(JSContext* cx, JS::TwoByteChars chars, jsid *idp)
|
||||
JS_CharsToId(JSContext* cx, JS::TwoByteChars chars, MutableHandleId idp)
|
||||
{
|
||||
RootedAtom atom(cx, AtomizeChars<CanGC>(cx, chars.start().get(), chars.length()));
|
||||
if (!atom)
|
||||
@ -6145,12 +6141,12 @@ JS_CharsToId(JSContext* cx, JS::TwoByteChars chars, jsid *idp)
|
||||
uint32_t dummy;
|
||||
MOZ_ASSERT(!atom->isIndex(&dummy), "API misuse: |chars| must not encode an index");
|
||||
#endif
|
||||
*idp = AtomToId(atom);
|
||||
idp.set(AtomToId(atom));
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_IsIdentifier(JSContext *cx, JSString *str, bool *isIdentifier)
|
||||
JS_IsIdentifier(JSContext *cx, HandleString str, bool *isIdentifier)
|
||||
{
|
||||
assertSameCompartment(cx, str);
|
||||
|
||||
|
@ -4273,7 +4273,7 @@ JS_SetGlobalJitCompilerOption(JSContext *cx, JSJitCompilerOption opt, uint32_t v
|
||||
* Convert a uint32_t index into a jsid.
|
||||
*/
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_IndexToId(JSContext *cx, uint32_t index, jsid *id);
|
||||
JS_IndexToId(JSContext *cx, uint32_t index, JS::MutableHandleId);
|
||||
|
||||
/*
|
||||
* Convert chars into a jsid.
|
||||
@ -4281,13 +4281,13 @@ JS_IndexToId(JSContext *cx, uint32_t index, jsid *id);
|
||||
* |chars| may not be an index.
|
||||
*/
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_CharsToId(JSContext* cx, JS::TwoByteChars chars, jsid *idp);
|
||||
JS_CharsToId(JSContext* cx, JS::TwoByteChars chars, JS::MutableHandleId);
|
||||
|
||||
/*
|
||||
* Test if the given string is a valid ECMAScript identifier
|
||||
*/
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_IsIdentifier(JSContext *cx, JSString *str, bool *isIdentifier);
|
||||
JS_IsIdentifier(JSContext *cx, JS::HandleString str, bool *isIdentifier);
|
||||
|
||||
/*
|
||||
* Return the current script and line number of the most currently running
|
||||
|
Loading…
Reference in New Issue
Block a user