Add missing IsCallable checks.

This commit is contained in:
Ms2ger 2016-09-06 11:37:00 +02:00
parent 89126b44d7
commit 00559f18b1
2 changed files with 12 additions and 9 deletions

View file

@ -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):
"""