mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Remove getDefaultRetval.
getDefaultRetval was supposed to be used after throwing an exception on the ErrorResult outparam in C++. However, as we throw exceptions through the return value in Servo, we don't need it at all.
This commit is contained in:
parent
e5eac5b538
commit
7abbef8919
1 changed files with 10 additions and 26 deletions
|
@ -4676,17 +4676,16 @@ class CGCallback(CGClass):
|
||||||
|
|
||||||
setupCall = ("let s = CallSetup::new(cx_for_dom_object(${cxProvider}), aExceptionHandling);\n"
|
setupCall = ("let s = CallSetup::new(cx_for_dom_object(${cxProvider}), aExceptionHandling);\n"
|
||||||
"if s.GetContext().is_null() {\n"
|
"if s.GetContext().is_null() {\n"
|
||||||
" return${errorReturn};\n"
|
" return Err(FailureUnknown);\n"
|
||||||
"}\n")
|
"}\n")
|
||||||
|
|
||||||
bodyWithThis = string.Template(
|
bodyWithThis = string.Template(
|
||||||
setupCall+
|
setupCall+
|
||||||
"let thisObjJS = WrapCallThisObject(s.GetContext(), ptr::null() /*XXXjdm proper scope*/, thisObj);\n"
|
"let thisObjJS = WrapCallThisObject(s.GetContext(), ptr::null() /*XXXjdm proper scope*/, thisObj);\n"
|
||||||
"if thisObjJS.is_null() {\n"
|
"if thisObjJS.is_null() {\n"
|
||||||
" return${errorReturn};\n"
|
" return Err(FailureUnknown);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"return ${methodName}(${callArgs});").substitute({
|
"return ${methodName}(${callArgs});").substitute({
|
||||||
"errorReturn" : method.getDefaultRetval(),
|
|
||||||
"callArgs" : ", ".join(argnamesWithThis),
|
"callArgs" : ", ".join(argnamesWithThis),
|
||||||
"methodName": 'self.' + method.name,
|
"methodName": 'self.' + method.name,
|
||||||
"cxProvider": 'thisObj'
|
"cxProvider": 'thisObj'
|
||||||
|
@ -4694,7 +4693,6 @@ class CGCallback(CGClass):
|
||||||
bodyWithoutThis = string.Template(
|
bodyWithoutThis = string.Template(
|
||||||
setupCall +
|
setupCall +
|
||||||
"return ${methodName}(${callArgs});").substitute({
|
"return ${methodName}(${callArgs});").substitute({
|
||||||
"errorReturn" : method.getDefaultRetval(),
|
|
||||||
"callArgs" : ", ".join(argnamesWithoutThis),
|
"callArgs" : ", ".join(argnamesWithoutThis),
|
||||||
"methodName": 'self.' + method.name,
|
"methodName": 'self.' + method.name,
|
||||||
"cxProvider": args[2].name #XXXjdm There's no guarantee that this is a DOM object
|
"cxProvider": args[2].name #XXXjdm There's no guarantee that this is a DOM object
|
||||||
|
@ -4811,7 +4809,6 @@ class CallbackMember(CGNativeMember):
|
||||||
def getImpl(self):
|
def getImpl(self):
|
||||||
replacements = {
|
replacements = {
|
||||||
"declRval": self.getRvalDecl(),
|
"declRval": self.getRvalDecl(),
|
||||||
"errorReturn" : self.getDefaultRetval(),
|
|
||||||
"returnResult": self.getResultConversion(),
|
"returnResult": self.getResultConversion(),
|
||||||
"convertArgs": self.getArgConversions(),
|
"convertArgs": self.getArgConversions(),
|
||||||
"doCall": self.getCall(),
|
"doCall": self.getCall(),
|
||||||
|
@ -4928,12 +4925,6 @@ class CallbackMember(CGNativeMember):
|
||||||
"}" % (i+1, i))
|
"}" % (i+1, i))
|
||||||
return conversion
|
return conversion
|
||||||
|
|
||||||
def getDefaultRetval(self):
|
|
||||||
default = self.getRetvalInfo(self.retvalType, False)[1]
|
|
||||||
if len(default) != 0:
|
|
||||||
default = " " + default
|
|
||||||
return default
|
|
||||||
|
|
||||||
def getArgs(self, returnType, argList):
|
def getArgs(self, returnType, argList):
|
||||||
args = CGNativeMember.getArgs(self, returnType, argList)
|
args = CGNativeMember.getArgs(self, returnType, argList)
|
||||||
if not self.needThisHandling:
|
if not self.needThisHandling:
|
||||||
|
@ -4966,11 +4957,10 @@ class CallbackMember(CGNativeMember):
|
||||||
"${callSetup}\n"
|
"${callSetup}\n"
|
||||||
"JSContext* cx = s.GetContext();\n"
|
"JSContext* cx = s.GetContext();\n"
|
||||||
"if (!cx) {\n"
|
"if (!cx) {\n"
|
||||||
" return${errorReturn};\n"
|
" return Err(FailureUnknown);\n"
|
||||||
"}\n").substitute({
|
"}\n").substitute({
|
||||||
"callSetup": callSetup,
|
"callSetup": callSetup,
|
||||||
"errorReturn" : self.getDefaultRetval(),
|
})
|
||||||
})
|
|
||||||
|
|
||||||
def getArgcDecl(self):
|
def getArgcDecl(self):
|
||||||
return CGGeneric("let argc = %su32;" % self.argCountStr);
|
return CGGeneric("let argc = %su32;" % self.argCountStr);
|
||||||
|
@ -4999,7 +4989,6 @@ class CallbackMethod(CallbackMember):
|
||||||
|
|
||||||
def getCall(self):
|
def getCall(self):
|
||||||
replacements = {
|
replacements = {
|
||||||
"errorReturn" : self.getDefaultRetval(),
|
|
||||||
"thisObj": self.getThisObj(),
|
"thisObj": self.getThisObj(),
|
||||||
"getCallable": self.getCallableDecl()
|
"getCallable": self.getCallableDecl()
|
||||||
}
|
}
|
||||||
|
@ -5015,7 +5004,7 @@ class CallbackMethod(CallbackMember):
|
||||||
" ${argc}, ${argv}, &rval)\n"
|
" ${argc}, ${argv}, &rval)\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
"if ok == 0 {\n"
|
"if ok == 0 {\n"
|
||||||
" return${errorReturn};\n"
|
" return Err(FailureUnknown);\n"
|
||||||
"}\n").substitute(replacements)
|
"}\n").substitute(replacements)
|
||||||
|
|
||||||
class CallCallback(CallbackMethod):
|
class CallCallback(CallbackMethod):
|
||||||
|
@ -5048,12 +5037,11 @@ class CallbackOperationBase(CallbackMethod):
|
||||||
|
|
||||||
def getCallableDecl(self):
|
def getCallableDecl(self):
|
||||||
replacements = {
|
replacements = {
|
||||||
"errorReturn" : self.getDefaultRetval(),
|
|
||||||
"methodName": self.methodName
|
"methodName": self.methodName
|
||||||
}
|
}
|
||||||
getCallableFromProp = string.Template(
|
getCallableFromProp = string.Template(
|
||||||
'match self.parent.GetCallableProperty(cx, "${methodName}") {\n'
|
'match self.parent.GetCallableProperty(cx, "${methodName}") {\n'
|
||||||
' Err(_) => return${errorReturn},\n'
|
' Err(_) => return Err(FailureUnknown),\n'
|
||||||
' Ok(callable) => callable,\n'
|
' Ok(callable) => callable,\n'
|
||||||
'}').substitute(replacements)
|
'}').substitute(replacements)
|
||||||
if not self.singleOperation:
|
if not self.singleOperation:
|
||||||
|
@ -5094,13 +5082,11 @@ class CallbackGetter(CallbackMember):
|
||||||
|
|
||||||
def getCall(self):
|
def getCall(self):
|
||||||
replacements = {
|
replacements = {
|
||||||
"errorReturn" : self.getDefaultRetval(),
|
|
||||||
"attrName": self.attrName
|
"attrName": self.attrName
|
||||||
}
|
}
|
||||||
return string.Template(
|
return string.Template(
|
||||||
'if (!JS_GetProperty(cx, mCallback, "${attrName}", &rval)) {\n'
|
'if (!JS_GetProperty(cx, mCallback, "${attrName}", &rval)) {\n'
|
||||||
' aRv.Throw(NS_ERROR_UNEXPECTED);\n'
|
' return Err(FailureUnknown);\n'
|
||||||
' return${errorReturn};\n'
|
|
||||||
'}\n').substitute(replacements);
|
'}\n').substitute(replacements);
|
||||||
|
|
||||||
class CallbackSetter(CallbackMember):
|
class CallbackSetter(CallbackMember):
|
||||||
|
@ -5121,15 +5107,13 @@ class CallbackSetter(CallbackMember):
|
||||||
|
|
||||||
def getCall(self):
|
def getCall(self):
|
||||||
replacements = {
|
replacements = {
|
||||||
"errorReturn" : self.getDefaultRetval(),
|
|
||||||
"attrName": self.attrName,
|
"attrName": self.attrName,
|
||||||
"argv": "argv.handleAt(0)",
|
"argv": "argv.handleAt(0)",
|
||||||
}
|
}
|
||||||
return string.Template(
|
return string.Template(
|
||||||
'MOZ_ASSERT(argv.length() == 1);\n'
|
'MOZ_ASSERT(argv.length() == 1);\n'
|
||||||
'if (!JS_SetProperty(cx, mCallback, "${attrName}", ${argv})) {\n'
|
'if (!JS_SetProperty(cx, mCallback, "${attrName}", ${argv})) {\n'
|
||||||
' aRv.Throw(NS_ERROR_UNEXPECTED);\n'
|
' return Err(FailureUnknown);\n'
|
||||||
' return${errorReturn};\n'
|
|
||||||
'}\n').substitute(replacements)
|
'}\n').substitute(replacements)
|
||||||
|
|
||||||
def getArgcDecl(self):
|
def getArgcDecl(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue