mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
Bug 788149. Don't use jsids in worker code in bindings, because those are runtime-specific and workers can run on multiple runtimes. r=peterv
This commit is contained in:
parent
97fdaf5406
commit
65e4105d26
@ -5122,9 +5122,10 @@ class CGDictionary(CGThing):
|
|||||||
"\n".join(memberDecls) + "\n"
|
"\n".join(memberDecls) + "\n"
|
||||||
"private:\n"
|
"private:\n"
|
||||||
" // Disallow copy-construction\n"
|
" // Disallow copy-construction\n"
|
||||||
" ${selfName}(const ${selfName}&) MOZ_DELETE;\n"
|
" ${selfName}(const ${selfName}&) MOZ_DELETE;\n" +
|
||||||
" static bool InitIds(JSContext* cx);\n"
|
# NOTE: jsids are per-runtime, so don't use them in workers
|
||||||
" static bool initedIds;\n" +
|
(" static bool InitIds(JSContext* cx);\n"
|
||||||
|
" static bool initedIds;\n" if not self.workers else "") +
|
||||||
"\n".join(" static jsid " +
|
"\n".join(" static jsid " +
|
||||||
self.makeIdName(m.identifier.name) + ";" for
|
self.makeIdName(m.identifier.name) + ";" for
|
||||||
m in d.members) + "\n"
|
m in d.members) + "\n"
|
||||||
@ -5156,26 +5157,28 @@ class CGDictionary(CGThing):
|
|||||||
reindent=True)
|
reindent=True)
|
||||||
|
|
||||||
return string.Template(
|
return string.Template(
|
||||||
"bool ${selfName}::initedIds = false;\n" +
|
# NOTE: jsids are per-runtime, so don't use them in workers
|
||||||
"\n".join("jsid ${selfName}::%s = JSID_VOID;" %
|
("bool ${selfName}::initedIds = false;\n" +
|
||||||
self.makeIdName(m.identifier.name)
|
"\n".join("jsid ${selfName}::%s = JSID_VOID;" %
|
||||||
for m in d.members) + "\n"
|
self.makeIdName(m.identifier.name)
|
||||||
"\n"
|
for m in d.members) + "\n"
|
||||||
"bool\n"
|
"\n"
|
||||||
"${selfName}::InitIds(JSContext* cx)\n"
|
"bool\n"
|
||||||
"{\n"
|
"${selfName}::InitIds(JSContext* cx)\n"
|
||||||
" MOZ_ASSERT(!initedIds);\n"
|
"{\n"
|
||||||
"${idInit}\n"
|
" MOZ_ASSERT(!initedIds);\n"
|
||||||
" initedIds = true;\n"
|
"${idInit}\n"
|
||||||
" return true;\n"
|
" initedIds = true;\n"
|
||||||
"}\n"
|
" return true;\n"
|
||||||
"\n"
|
"}\n"
|
||||||
|
"\n" if not self.workers else "") +
|
||||||
"bool\n"
|
"bool\n"
|
||||||
"${selfName}::Init(JSContext* cx, const JS::Value& val)\n"
|
"${selfName}::Init(JSContext* cx, const JS::Value& val)\n"
|
||||||
"{\n"
|
"{\n" +
|
||||||
" if (!initedIds && !InitIds(cx)) {\n"
|
# NOTE: jsids are per-runtime, so don't use them in workers
|
||||||
" return false;\n"
|
(" if (!initedIds && !InitIds(cx)) {\n"
|
||||||
" }\n"
|
" return false;\n"
|
||||||
|
" }\n" if not self.workers else "") +
|
||||||
"${initParent}"
|
"${initParent}"
|
||||||
" JSBool found;\n"
|
" JSBool found;\n"
|
||||||
" JS::Value temp;\n"
|
" JS::Value temp;\n"
|
||||||
@ -5235,20 +5238,35 @@ class CGDictionary(CGThing):
|
|||||||
if member.defaultValue:
|
if member.defaultValue:
|
||||||
replacements["haveValue"] = "found"
|
replacements["haveValue"] = "found"
|
||||||
|
|
||||||
|
# NOTE: jsids are per-runtime, so don't use them in workers
|
||||||
|
if self.workers:
|
||||||
|
propName = member.identifier.name
|
||||||
|
propCheck = ('JS_HasProperty(cx, &val.toObject(), "%s", &found)' %
|
||||||
|
propName)
|
||||||
|
propGet = ('JS_GetProperty(cx, &val.toObject(), "%s", &temp)' %
|
||||||
|
propName)
|
||||||
|
else:
|
||||||
|
propId = self.makeIdName(member.identifier.name);
|
||||||
|
propCheck = ("JS_HasPropertyById(cx, &val.toObject(), %s, &found)" %
|
||||||
|
propId)
|
||||||
|
propGet = ("JS_GetPropertyById(cx, &val.toObject(), %s, &temp)" %
|
||||||
|
propId)
|
||||||
|
|
||||||
conversionReplacements = {
|
conversionReplacements = {
|
||||||
"propId" : self.makeIdName(member.identifier.name),
|
|
||||||
"prop": "(this->%s)" % member.identifier.name,
|
"prop": "(this->%s)" % member.identifier.name,
|
||||||
"convert": string.Template(templateBody).substitute(replacements)
|
"convert": string.Template(templateBody).substitute(replacements),
|
||||||
|
"propCheck": propCheck,
|
||||||
|
"propGet": propGet
|
||||||
}
|
}
|
||||||
conversion = ("if (isNull) {\n"
|
conversion = ("if (isNull) {\n"
|
||||||
" found = false;\n"
|
" found = false;\n"
|
||||||
"} else if (!JS_HasPropertyById(cx, &val.toObject(), ${propId}, &found)) {\n"
|
"} else if (!${propCheck}) {\n"
|
||||||
" return false;\n"
|
" return false;\n"
|
||||||
"}\n")
|
"}\n")
|
||||||
if member.defaultValue:
|
if member.defaultValue:
|
||||||
conversion += (
|
conversion += (
|
||||||
"if (found) {\n"
|
"if (found) {\n"
|
||||||
" if (!JS_GetPropertyById(cx, &val.toObject(), ${propId}, &temp)) {\n"
|
" if (!${propGet}) {\n"
|
||||||
" return false;\n"
|
" return false;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
@ -5257,7 +5275,7 @@ class CGDictionary(CGThing):
|
|||||||
conversion += (
|
conversion += (
|
||||||
"if (found) {\n"
|
"if (found) {\n"
|
||||||
" ${prop}.Construct();\n"
|
" ${prop}.Construct();\n"
|
||||||
" if (!JS_GetPropertyById(cx, &val.toObject(), ${propId}, &temp)) {\n"
|
" if (!${propGet}) {\n"
|
||||||
" return false;\n"
|
" return false;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"${convert}\n"
|
"${convert}\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user