mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 766583 part 5. Stop declaring optional arguments as const on the stack in bindings code. r=smaug
This commit is contained in:
parent
3d72fdf114
commit
080775af23
@ -2913,15 +2913,15 @@ for (uint32_t i = 0; i < length; ++i) {
|
|||||||
constructInternal = "ref"
|
constructInternal = "ref"
|
||||||
if type.nullable():
|
if type.nullable():
|
||||||
if isOptional:
|
if isOptional:
|
||||||
declType = "const Optional<" + name + "*>"
|
declType = "Optional<" + name + "*>"
|
||||||
else:
|
else:
|
||||||
declType = name + "*"
|
declType = name + "*"
|
||||||
else:
|
else:
|
||||||
if isOptional:
|
if isOptional:
|
||||||
declType = "const Optional<" + name + ">"
|
declType = "Optional<" + name + ">"
|
||||||
# We don't need a holder in this case
|
# We don't need a holder in this case
|
||||||
holderType = None
|
holderType = None
|
||||||
constructLoc = "(const_cast<Optional<" + name + ">& >(${declName}))"
|
constructLoc = "${declName}"
|
||||||
constructMethod = "Construct"
|
constructMethod = "Construct"
|
||||||
constructInternal = "Value"
|
constructInternal = "Value"
|
||||||
else:
|
else:
|
||||||
@ -2936,9 +2936,8 @@ for (uint32_t i = 0; i < length; ++i) {
|
|||||||
nullableTarget = ""
|
nullableTarget = ""
|
||||||
if type.nullable():
|
if type.nullable():
|
||||||
if isOptional:
|
if isOptional:
|
||||||
mutableDecl = "(const_cast<Optional<" + name + "*>& >(${declName}))"
|
template += "${declName}.Construct();\n"
|
||||||
template += "%s.Construct();\n" % mutableDecl
|
nullableTarget = "${declName}.Value()"
|
||||||
nullableTarget = "%s.Value()" % mutableDecl
|
|
||||||
else:
|
else:
|
||||||
nullableTarget = "${declName}"
|
nullableTarget = "${declName}"
|
||||||
template += "%s = ${holderName}.addr();" % nullableTarget
|
template += "%s = ${holderName}.addr();" % nullableTarget
|
||||||
@ -3331,11 +3330,8 @@ def instantiateJSToNativeConversionTemplate(templateTuple, replacements,
|
|||||||
originalHolderName = replacements["holderName"]
|
originalHolderName = replacements["holderName"]
|
||||||
if holderType is not None:
|
if holderType is not None:
|
||||||
if dealWithOptional:
|
if dealWithOptional:
|
||||||
replacements["holderName"] = (
|
replacements["holderName"] = "%s.Value()" % originalHolderName
|
||||||
"const_cast< %s & >(%s.Value())" %
|
holderType = CGTemplatedType("Optional", holderType)
|
||||||
(holderType.define(), originalHolderName))
|
|
||||||
mutableHolderType = CGTemplatedType("Optional", holderType)
|
|
||||||
holderType = CGWrapper(mutableHolderType, pre="const ")
|
|
||||||
result.append(
|
result.append(
|
||||||
CGList([holderType, CGGeneric(" "),
|
CGList([holderType, CGGeneric(" "),
|
||||||
CGGeneric(originalHolderName),
|
CGGeneric(originalHolderName),
|
||||||
@ -3344,11 +3340,8 @@ def instantiateJSToNativeConversionTemplate(templateTuple, replacements,
|
|||||||
originalDeclName = replacements["declName"]
|
originalDeclName = replacements["declName"]
|
||||||
if declType is not None:
|
if declType is not None:
|
||||||
if dealWithOptional:
|
if dealWithOptional:
|
||||||
replacements["declName"] = (
|
replacements["declName"] = "%s.Value()" % originalDeclName
|
||||||
"const_cast< %s & >(%s.Value())" %
|
declType = CGTemplatedType("Optional", declType)
|
||||||
(declType.define(), originalDeclName))
|
|
||||||
mutableDeclType = CGTemplatedType("Optional", declType)
|
|
||||||
declType = CGWrapper(mutableDeclType, pre="const ")
|
|
||||||
result.append(
|
result.append(
|
||||||
CGList([declType, CGGeneric(" "),
|
CGList([declType, CGGeneric(" "),
|
||||||
CGGeneric(originalDeclName),
|
CGGeneric(originalDeclName),
|
||||||
@ -3361,12 +3354,10 @@ def instantiateJSToNativeConversionTemplate(templateTuple, replacements,
|
|||||||
if argcAndIndex is not None:
|
if argcAndIndex is not None:
|
||||||
if dealWithOptional:
|
if dealWithOptional:
|
||||||
declConstruct = CGIndenter(
|
declConstruct = CGIndenter(
|
||||||
CGGeneric("const_cast< %s &>(%s).Construct();" %
|
CGGeneric("%s.Construct();" % originalDeclName))
|
||||||
(mutableDeclType.define(), originalDeclName)))
|
|
||||||
if holderType is not None:
|
if holderType is not None:
|
||||||
holderConstruct = CGIndenter(
|
holderConstruct = CGIndenter(
|
||||||
CGGeneric("const_cast< %s &>(%s).Construct();" %
|
CGGeneric("%s.Construct();" % originalHolderName))
|
||||||
(mutableHolderType.define(), originalHolderName)))
|
|
||||||
else:
|
else:
|
||||||
holderConstruct = None
|
holderConstruct = None
|
||||||
else:
|
else:
|
||||||
@ -3985,6 +3976,10 @@ class CGCallGenerator(CGThing):
|
|||||||
return True
|
return True
|
||||||
if a.type.isString():
|
if a.type.isString():
|
||||||
return True
|
return True
|
||||||
|
if a.optional and not a.defaultValue:
|
||||||
|
# If a.defaultValue, then it's not going to use an Optional,
|
||||||
|
# so doesn't need to be const just due to being optional.
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
if needsConst(a):
|
if needsConst(a):
|
||||||
arg = CGWrapper(arg, pre="Constify(", post=")")
|
arg = CGWrapper(arg, pre="Constify(", post=")")
|
||||||
|
Loading…
Reference in New Issue
Block a user