mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Remove getJSToNativeConversionTemplate's initialValue return value.
This commit does not change the generated code.
This commit is contained in:
parent
455465f3c6
commit
cb2723c4ed
1 changed files with 8 additions and 13 deletions
|
@ -479,16 +479,13 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
||||||
if isOptional:
|
if isOptional:
|
||||||
template = "Some(%s)" % template
|
template = "Some(%s)" % template
|
||||||
declType = CGWrapper(declType, pre="Option<", post=">")
|
declType = CGWrapper(declType, pre="Option<", post=">")
|
||||||
initialValue = "None"
|
|
||||||
else:
|
|
||||||
initialValue = None
|
|
||||||
|
|
||||||
if default is not None:
|
if default is not None:
|
||||||
template = CGIfElseWrapper("${haveValue}",
|
template = CGIfElseWrapper("${haveValue}",
|
||||||
CGGeneric(template),
|
CGGeneric(template),
|
||||||
CGGeneric(default)).define()
|
CGGeneric(default)).define()
|
||||||
|
|
||||||
return (template, declType, isOptional, initialValue, needsRooting)
|
return (template, declType, isOptional, needsRooting)
|
||||||
|
|
||||||
# Unfortunately, .capitalize() on a string will lowercase things inside the
|
# Unfortunately, .capitalize() on a string will lowercase things inside the
|
||||||
# string, which we do not want.
|
# string, which we do not want.
|
||||||
|
@ -762,7 +759,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
||||||
assert not isOptional
|
assert not isOptional
|
||||||
# This one only happens for return values, and its easy: Just
|
# This one only happens for return values, and its easy: Just
|
||||||
# ignore the jsval.
|
# ignore the jsval.
|
||||||
return ("", None, False, None, False)
|
return ("", None, False, False)
|
||||||
|
|
||||||
if not type.isPrimitive():
|
if not type.isPrimitive():
|
||||||
raise TypeError("Need conversion for argument type '%s'" % str(type))
|
raise TypeError("Need conversion for argument type '%s'" % str(type))
|
||||||
|
@ -813,7 +810,7 @@ def instantiateJSToNativeConversionTemplate(templateTuple, replacements,
|
||||||
replace ${argc} and ${index}, where ${index} is the index of this
|
replace ${argc} and ${index}, where ${index} is the index of this
|
||||||
argument (0-based) and ${argc} is the total number of arguments.
|
argument (0-based) and ${argc} is the total number of arguments.
|
||||||
"""
|
"""
|
||||||
(templateBody, declType, dealWithOptional, initialValue, needsRooting) = templateTuple
|
(templateBody, declType, dealWithOptional, needsRooting) = templateTuple
|
||||||
|
|
||||||
if dealWithOptional and argcAndIndex is None:
|
if dealWithOptional and argcAndIndex is None:
|
||||||
raise TypeError("Have to deal with optional things, but don't know how")
|
raise TypeError("Have to deal with optional things, but don't know how")
|
||||||
|
@ -832,8 +829,8 @@ def instantiateJSToNativeConversionTemplate(templateTuple, replacements,
|
||||||
CGGeneric(replacements["declName"]),
|
CGGeneric(replacements["declName"]),
|
||||||
CGGeneric(": "),
|
CGGeneric(": "),
|
||||||
declType]
|
declType]
|
||||||
if initialValue:
|
if dealWithOptional:
|
||||||
newDecl.append(CGGeneric(" = " + initialValue))
|
newDecl.append(CGGeneric(" = None"))
|
||||||
newDecl.append(CGGeneric(";"))
|
newDecl.append(CGGeneric(";"))
|
||||||
result.append(CGList(newDecl))
|
result.append(CGList(newDecl))
|
||||||
conversion = CGWrapper(conversion,
|
conversion = CGWrapper(conversion,
|
||||||
|
@ -2702,7 +2699,7 @@ def getUnionTypeTemplateVars(type, descriptorProvider):
|
||||||
name = type.name
|
name = type.name
|
||||||
typeName = "/*" + type.name + "*/"
|
typeName = "/*" + type.name + "*/"
|
||||||
|
|
||||||
(template, _, _, _, _) = getJSToNativeConversionTemplate(
|
(template, _, _, _) = getJSToNativeConversionTemplate(
|
||||||
type, descriptorProvider, failureCode="return Ok(None);",
|
type, descriptorProvider, failureCode="return Ok(None);",
|
||||||
exceptionCode='return Err(());',
|
exceptionCode='return Err(());',
|
||||||
isDefinitelyObject=True, isOptional=False)
|
isDefinitelyObject=True, isOptional=False)
|
||||||
|
@ -4083,15 +4080,13 @@ class CGDictionary(CGThing):
|
||||||
return "/* uh oh */ %s" % name
|
return "/* uh oh */ %s" % name
|
||||||
|
|
||||||
def getMemberType(self, memberInfo):
|
def getMemberType(self, memberInfo):
|
||||||
(member, (templateBody, declType,
|
(member, (templateBody, declType, dealWithOptional, _)) = memberInfo
|
||||||
dealWithOptional, initialValue, _)) = memberInfo
|
|
||||||
if dealWithOptional:
|
if dealWithOptional:
|
||||||
declType = CGWrapper(declType, pre="Optional< ", post=" >")
|
declType = CGWrapper(declType, pre="Optional< ", post=" >")
|
||||||
return declType.define()
|
return declType.define()
|
||||||
|
|
||||||
def getMemberConversion(self, memberInfo):
|
def getMemberConversion(self, memberInfo):
|
||||||
(member, (templateBody, declType,
|
(member, (templateBody, declType, dealWithOptional, _)) = memberInfo
|
||||||
dealWithOptional, initialValue, _)) = memberInfo
|
|
||||||
replacements = { "val": "value.unwrap()" }
|
replacements = { "val": "value.unwrap()" }
|
||||||
if member.defaultValue:
|
if member.defaultValue:
|
||||||
replacements["haveValue"] = "value.is_some()"
|
replacements["haveValue"] = "value.is_some()"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue