mirror of
https://github.com/servo/servo.git
synced 2025-06-23 16:44:33 +01:00
Implement support for returning nullable primitive types.
This commit is contained in:
parent
3d28f31ea9
commit
d063601ba0
3 changed files with 38 additions and 3 deletions
|
@ -1601,9 +1601,9 @@ if %(resultStr)s.is_null() {
|
|||
|
||||
if type.nullable():
|
||||
(recTemplate, recInfal) = getWrapTemplateForType(type.inner, descriptorProvider,
|
||||
"%s.Value()" % result, successCode,
|
||||
"%s.unwrap()" % result, successCode,
|
||||
isCreator, exceptionCode)
|
||||
return ("if (%s.IsNull()) {\n" % result +
|
||||
return ("if (%s.is_none()) {\n" % result +
|
||||
CGIndenter(CGGeneric(setValue("JSVAL_NULL"))).define() + "\n" +
|
||||
"}\n" + recTemplate, recInfal)
|
||||
|
||||
|
@ -1667,7 +1667,7 @@ def getRetvalDeclarationForType(returnType, descriptorProvider):
|
|||
if returnType.isPrimitive() and returnType.tag() in builtinNames:
|
||||
result = CGGeneric(builtinNames[returnType.tag()])
|
||||
if returnType.nullable():
|
||||
result = CGWrapper(result, pre="Nullable<", post=">")
|
||||
result = CGWrapper(result, pre="Option<", post=">")
|
||||
return result, False
|
||||
if returnType.isString():
|
||||
result = CGGeneric("DOMString")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue