Use dynamic dispatch in mozjs::panic::wrap_panic

Pick up https://github.com/servo/rust-mozjs/pull/512

Fixes https://github.com/servo/servo/issues/26585

This diff is best viewed with "ignore whitespace changes", because of indentation change.
This commit is contained in:
Simon Sapin 2020-05-25 20:29:18 +02:00
parent 6114b75403
commit d103e06ba9
3 changed files with 105 additions and 102 deletions

View file

@ -2573,9 +2573,19 @@ class CGAbstractMethod(CGThing):
body = self.definition_body()
if self.catchPanic:
body = CGWrapper(CGIndenter(body),
pre="return wrap_panic(panic::AssertUnwindSafe(|| {\n",
post=("""\n}), %s);""" % ("()" if self.returnType == "void" else "false")))
if self.returnType == "void":
pre = "wrap_panic(&mut || {\n"
post = "\n})"
else:
pre = (
"let mut result = false;\n"
"wrap_panic(&mut || result = (|| {\n"
)
post = (
"\n})());\n"
"return result"
)
body = CGWrapper(CGIndenter(body), pre=pre, post=post)
return CGWrapper(CGIndenter(body),
pre=self.definition_prologue(),