Bug 969022 - remove s*_ids static constructors by explicitly tracking id initialization state; r=bz

This commit is contained in:
Nathan Froyd 2014-02-06 15:05:30 -05:00
Родитель edc1eaf598
Коммит 168d8c1c01
1 изменённых файлов: 12 добавлений и 18 удалений

Просмотреть файл

@ -1477,7 +1477,7 @@ class PropertyDefiner:
',\n'.join(prefableSpecs) + "\n" +
"};\n\n") % (specType, name, specType, name))
if doIdArrays:
arrays += ("static jsid %s_ids[%i] = { JSID_VOID };\n\n" %
arrays += ("static jsid %s_ids[%i];\n\n" %
(name, len(specs)))
return arrays
@ -1885,23 +1885,17 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
if props.hasNonChromeOnly():
idsToInit.append(props.variableName(False))
if len(idsToInit) > 0:
initIds = CGList(
[CGGeneric("!InitIds(aCx, %s, %s_ids)" % (varname, varname)) for
varname in idsToInit], ' ||\n')
if len(idsToInit) > 1:
initIds = CGWrapper(initIds, pre="(", post=")", reindent=True)
initIds = CGList(
[CGGeneric("%s_ids[0] == JSID_VOID &&" % idsToInit[0]),
CGGeneric("NS_IsMainThread() &&"),
initIds],
"\n")
initIds = CGWrapper(initIds, pre="if (", post=") {", reindent=True)
initIds = CGList(
[initIds,
CGGeneric((" %s_ids[0] = JSID_VOID;\n"
" return;") % idsToInit[0]),
CGGeneric("}")],
"\n")
initIdCalls = ["!InitIds(aCx, %s, %s_ids)" % (varname, varname)
for varname in idsToInit]
idsInitedFlag = CGGeneric("static bool sIdsInited = false;")
setFlag = CGGeneric("sIdsInited = true;")
initIdConditionals = [CGIfWrapper(CGGeneric("return;"), call)
for call in initIdCalls]
initIds = CGList([idsInitedFlag,
CGIfWrapper(CGList(initIdConditionals + [setFlag],
"\n"),
"!sIdsInited && NS_IsMainThread()")],
"\n")
else:
initIds = None