mirror of
https://github.com/servo/servo.git
synced 2025-06-25 09:34:32 +01:00
Stop returning None from getRetvalDeclarationForType and update documentation.
This commit is contained in:
parent
322893009d
commit
077243caa7
1 changed files with 7 additions and 13 deletions
|
@ -1195,13 +1195,11 @@ def typeNeedsCx(type, retVal=False):
|
||||||
def memberIsCreator(member):
|
def memberIsCreator(member):
|
||||||
return member.getExtendedAttribute("Creator") is not None
|
return member.getExtendedAttribute("Creator") is not None
|
||||||
|
|
||||||
# Returns a tuple consisting of a CGThing containing the type of the return
|
# Returns a CGThing containing the type of the return value.
|
||||||
# value, or None if there is no need for a return value, and a boolean signaling
|
|
||||||
# whether the return value is passed in an out parameter.
|
|
||||||
def getRetvalDeclarationForType(returnType, descriptorProvider):
|
def getRetvalDeclarationForType(returnType, descriptorProvider):
|
||||||
if returnType is None or returnType.isVoid():
|
if returnType is None or returnType.isVoid():
|
||||||
# Nothing to declare
|
# Nothing to declare
|
||||||
return None
|
return CGGeneric("()")
|
||||||
if returnType.isPrimitive() and returnType.tag() in builtinNames:
|
if returnType.isPrimitive() and returnType.tag() in builtinNames:
|
||||||
result = CGGeneric(builtinNames[returnType.tag()])
|
result = CGGeneric(builtinNames[returnType.tag()])
|
||||||
if returnType.nullable():
|
if returnType.nullable():
|
||||||
|
@ -2426,19 +2424,16 @@ class CGCallGenerator(CGThing):
|
||||||
call = CGList([call, CGWrapper(args, pre="(", post=");")])
|
call = CGList([call, CGWrapper(args, pre="(", post=");")])
|
||||||
|
|
||||||
if isFallible:
|
if isFallible:
|
||||||
self.cgRoot.prepend(CGWrapper(result if result is not None else CGGeneric("()"),
|
self.cgRoot.prepend(CGWrapper(result,
|
||||||
pre="let result_fallible: Result<", post=",Error>;"))
|
pre="let result_fallible: Result<", post=",Error>;"))
|
||||||
|
|
||||||
if result is not None:
|
|
||||||
result = CGWrapper(result, pre="let result: ", post=";")
|
result = CGWrapper(result, pre="let result: ", post=";")
|
||||||
self.cgRoot.prepend(result)
|
self.cgRoot.prepend(result)
|
||||||
|
|
||||||
if isFallible:
|
if isFallible:
|
||||||
call = CGWrapper(call, pre="result_fallible = ")
|
call = CGWrapper(call, pre="result_fallible = ")
|
||||||
elif result is not None:
|
|
||||||
call = CGWrapper(call, pre="result = ")
|
|
||||||
else:
|
else:
|
||||||
call = CGWrapper(call, pre="let _: () = ")
|
call = CGWrapper(call, pre="result = ")
|
||||||
|
|
||||||
call = CGWrapper(call)
|
call = CGWrapper(call)
|
||||||
self.cgRoot.append(call)
|
self.cgRoot.append(call)
|
||||||
|
@ -2447,7 +2442,6 @@ class CGCallGenerator(CGThing):
|
||||||
self.cgRoot.append(CGGeneric("if result_fallible.is_err() {"))
|
self.cgRoot.append(CGGeneric("if result_fallible.is_err() {"))
|
||||||
self.cgRoot.append(CGIndenter(errorReport))
|
self.cgRoot.append(CGIndenter(errorReport))
|
||||||
self.cgRoot.append(CGGeneric("}"))
|
self.cgRoot.append(CGGeneric("}"))
|
||||||
if result is not None:
|
|
||||||
self.cgRoot.append(CGGeneric("result = result_fallible.unwrap();"))
|
self.cgRoot.append(CGGeneric("result = result_fallible.unwrap();"))
|
||||||
|
|
||||||
def define(self):
|
def define(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue