aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-09-06 07:51:12 -0500
committerGitHub <noreply@github.com>2016-09-06 07:51:12 -0500
commit69b5a0d0d0b2869dd6f96cb71fea6135bb0e94fe (patch)
tree11a67dc5bfa5a154c8d8866b83522514e8fce015 /components/script/dom/bindings/codegen
parent47e832dbd37e4ea1a321dc8f92a75cfd48fb6be9 (diff)
parent00559f18b1cc3283c8b91a928a6dcaa62731fb56 (diff)
downloadservo-69b5a0d0d0b2869dd6f96cb71fea6135bb0e94fe.tar.gz
servo-69b5a0d0d0b2869dd6f96cb71fea6135bb0e94fe.zip
Auto merge of #13181 - servo:iscallable, r=nox
Add missing IsCallable checks. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13181) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/bindings/codegen')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index cf918feb8e3..78748cea869 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -6508,7 +6508,8 @@ class CallbackMethod(CallbackMember):
def getCall(self):
replacements = {
"thisObj": self.getThisObj(),
- "getCallable": self.getCallableDecl()
+ "getCallable": self.getCallableDecl(),
+ "callGuard": self.getCallGuard(),
}
if self.argCount > 0:
replacements["argv"] = "argv.as_ptr()"
@@ -6519,7 +6520,7 @@ class CallbackMethod(CallbackMember):
return string.Template(
"${getCallable}"
"rooted!(in(cx) let rootedThis = ${thisObj});\n"
- "let ok = JS_CallFunctionValue(\n"
+ "let ok = ${callGuard}JS_CallFunctionValue(\n"
" cx, rootedThis.handle(), callable.handle(),\n"
" &HandleValueArray {\n"
" length_: ${argc} as ::libc::size_t,\n"
@@ -6535,6 +6536,7 @@ class CallbackMethod(CallbackMember):
class CallCallback(CallbackMethod):
def __init__(self, callback, descriptorProvider):
+ self.callback = callback
CallbackMethod.__init__(self, callback.signatures()[0], "Call",
descriptorProvider, needThisHandling=True)
@@ -6544,6 +6546,11 @@ class CallCallback(CallbackMethod):
def getCallableDecl(self):
return "rooted!(in(cx) let callable = ObjectValue(&*self.parent.callback()));\n"
+ def getCallGuard(self):
+ if self.callback._treatNonObjectAsNull:
+ return "!IsCallable(self.parent.callback()) || "
+ return ""
+
class CallbackOperationBase(CallbackMethod):
"""
@@ -6579,6 +6586,9 @@ class CallbackOperationBase(CallbackMethod):
CGGeneric('ObjectValue(&*self.parent.callback())'),
CGGeneric(getCallableFromProp))).define() + ');\n')
+ def getCallGuard(self):
+ return ""
+
class CallbackOperation(CallbackOperationBase):
"""