mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-27 09:37:31 +09:00
Fix up some minor issues with default value handling in codegen
This commit is contained in:
parent
4faee1f41a
commit
bc82c959ec
1 changed files with 9 additions and 5 deletions
|
|
@ -4290,6 +4290,9 @@ class JSToNativeConversionInfo():
|
||||||
for whether we have a JS::Value. Only used when
|
for whether we have a JS::Value. Only used when
|
||||||
defaultValue is not None or when True is passed for
|
defaultValue is not None or when True is passed for
|
||||||
checkForValue to instantiateJSToNativeConversion.
|
checkForValue to instantiateJSToNativeConversion.
|
||||||
|
This expression may not be already-parenthesized, so if
|
||||||
|
you use it with && or || make sure to put parens
|
||||||
|
around it.
|
||||||
${passedToJSImpl} replaced by an expression that evaluates to a boolean
|
${passedToJSImpl} replaced by an expression that evaluates to a boolean
|
||||||
for whether this value is being passed to a JS-
|
for whether this value is being passed to a JS-
|
||||||
implemented interface.
|
implemented interface.
|
||||||
|
|
@ -5146,7 +5149,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||||
if isinstance(defaultValue, IDLNullValue):
|
if isinstance(defaultValue, IDLNullValue):
|
||||||
extraConditionForNull = "!(${haveValue}) || "
|
extraConditionForNull = "!(${haveValue}) || "
|
||||||
else:
|
else:
|
||||||
extraConditionForNull = "${haveValue} && "
|
extraConditionForNull = "(${haveValue}) && "
|
||||||
else:
|
else:
|
||||||
extraConditionForNull = ""
|
extraConditionForNull = ""
|
||||||
templateBody = handleNull(templateBody, declLoc,
|
templateBody = handleNull(templateBody, declLoc,
|
||||||
|
|
@ -5690,7 +5693,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||||
haveCallable = "${val}.isObject() && " + haveCallable
|
haveCallable = "${val}.isObject() && " + haveCallable
|
||||||
if defaultValue is not None:
|
if defaultValue is not None:
|
||||||
assert(isinstance(defaultValue, IDLNullValue))
|
assert(isinstance(defaultValue, IDLNullValue))
|
||||||
haveCallable = "${haveValue} && " + haveCallable
|
haveCallable = "(${haveValue}) && " + haveCallable
|
||||||
template = (
|
template = (
|
||||||
("if (%s) {\n" % haveCallable) +
|
("if (%s) {\n" % haveCallable) +
|
||||||
conversion +
|
conversion +
|
||||||
|
|
@ -5702,7 +5705,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||||
haveObject = "${val}.isObject()"
|
haveObject = "${val}.isObject()"
|
||||||
if defaultValue is not None:
|
if defaultValue is not None:
|
||||||
assert(isinstance(defaultValue, IDLNullValue))
|
assert(isinstance(defaultValue, IDLNullValue))
|
||||||
haveObject = "${haveValue} && " + haveObject
|
haveObject = "(${haveValue}) && " + haveObject
|
||||||
template = CGIfElseWrapper(haveObject,
|
template = CGIfElseWrapper(haveObject,
|
||||||
CGGeneric(conversion),
|
CGGeneric(conversion),
|
||||||
CGGeneric("${declName} = nullptr;\n")).define()
|
CGGeneric("${declName} = nullptr;\n")).define()
|
||||||
|
|
@ -5770,8 +5773,9 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||||
return handleJSObjectType(type, isMember, failureCode, exceptionCode, sourceDescription)
|
return handleJSObjectType(type, isMember, failureCode, exceptionCode, sourceDescription)
|
||||||
|
|
||||||
if type.isDictionary():
|
if type.isDictionary():
|
||||||
# There are no nullable dictionaries
|
# There are no nullable dictionary arguments or dictionary members
|
||||||
assert not type.nullable() or isCallbackReturnValue
|
assert(not type.nullable() or isCallbackReturnValue or
|
||||||
|
(isMember and isMember != "Dictionary"))
|
||||||
# All optional dictionaries always have default values, so we
|
# All optional dictionaries always have default values, so we
|
||||||
# should be able to assume not isOptional here.
|
# should be able to assume not isOptional here.
|
||||||
assert not isOptional
|
assert not isOptional
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue