зеркало из https://github.com/mozilla/gecko-dev.git
Bug 860473 part 1. Root WebIDL dictionary ParseJSON. r=evilpie, smaug
This commit is contained in:
Родитель
2dca5a07b2
Коммит
3987fa669a
|
@ -34,9 +34,9 @@ struct MainThreadDictionaryBase
|
|||
{
|
||||
protected:
|
||||
JSContext* ParseJSON(const nsAString& aJSON,
|
||||
mozilla::Maybe<JSAutoRequest>& aAr,
|
||||
mozilla::Maybe<JSAutoCompartment>& aAc,
|
||||
JS::Value& aVal);
|
||||
Maybe<JSAutoRequest>& aAr,
|
||||
Maybe<JSAutoCompartment>& aAc,
|
||||
Maybe< JS::Rooted<JS::Value> >& aVal);
|
||||
};
|
||||
|
||||
struct EnumEntry {
|
||||
|
|
|
@ -1307,21 +1307,22 @@ SetXrayExpandoChain(JSObject* obj, JSObject* chain)
|
|||
|
||||
JSContext*
|
||||
MainThreadDictionaryBase::ParseJSON(const nsAString& aJSON,
|
||||
mozilla::Maybe<JSAutoRequest>& aAr,
|
||||
mozilla::Maybe<JSAutoCompartment>& aAc,
|
||||
JS::Value& aVal)
|
||||
Maybe<JSAutoRequest>& aAr,
|
||||
Maybe<JSAutoCompartment>& aAc,
|
||||
Maybe< JS::Rooted<JS::Value> >& aVal)
|
||||
{
|
||||
JSContext* cx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
|
||||
NS_ENSURE_TRUE(cx, nullptr);
|
||||
JSObject* global = JS_GetGlobalObject(cx);
|
||||
aAr.construct(cx);
|
||||
aAc.construct(cx, global);
|
||||
aVal.construct(cx, JS::UndefinedValue());
|
||||
if (aJSON.IsEmpty()) {
|
||||
return cx;
|
||||
}
|
||||
if (!JS_ParseJSON(cx,
|
||||
static_cast<const jschar*>(PromiseFlatString(aJSON).get()),
|
||||
aJSON.Length(), &aVal)) {
|
||||
aJSON.Length(), aVal.ref().address())) {
|
||||
return nullptr;
|
||||
}
|
||||
return cx;
|
||||
|
|
|
@ -6817,12 +6817,12 @@ class CGDictionary(CGThing):
|
|||
"\n" +
|
||||
(" bool Init(const nsAString& aJSON)\n"
|
||||
" {\n"
|
||||
" mozilla::Maybe<JSAutoRequest> ar;\n"
|
||||
" mozilla::Maybe<JSAutoCompartment> ac;\n"
|
||||
" jsval json = JSVAL_VOID;\n"
|
||||
" Maybe<JSAutoRequest> ar;\n"
|
||||
" Maybe<JSAutoCompartment> ac;\n"
|
||||
" Maybe< JS::Rooted<JS::Value> > json;\n"
|
||||
" JSContext* cx = ParseJSON(aJSON, ar, ac, json);\n"
|
||||
" NS_ENSURE_TRUE(cx, false);\n"
|
||||
" return Init(cx, nullptr, json);\n"
|
||||
" return Init(cx, nullptr, json.ref());\n"
|
||||
" }\n" if not self.workers else "") +
|
||||
"\n" +
|
||||
"\n".join(memberDecls) + "\n"
|
||||
|
|
Загрузка…
Ссылка в новой задаче