mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 766583 part 6. Stop declaring unions as const on the stack in bindings code. r=smaug
This commit is contained in:
parent
080775af23
commit
aa284f1a66
@ -2717,11 +2717,6 @@ for (uint32_t i = 0; i < length; ++i) {
|
||||
argumentTypeName = typeName + "Argument"
|
||||
if nullable:
|
||||
typeName = "Nullable<" + typeName + " >"
|
||||
if isOptional:
|
||||
nonConstDecl = "const_cast<Optional<" + typeName + " >& >(${declName})"
|
||||
else:
|
||||
nonConstDecl = "const_cast<" + typeName + "& >(${declName})"
|
||||
typeName = "const " + typeName
|
||||
|
||||
def handleNull(templateBody, setToNullVar, extraConditionForNull=""):
|
||||
null = CGGeneric("if (%s${val}.isNullOrUndefined()) {\n"
|
||||
@ -2736,16 +2731,16 @@ for (uint32_t i = 0; i < length; ++i) {
|
||||
declType = CGGeneric(typeName)
|
||||
holderType = CGGeneric(argumentTypeName)
|
||||
if isOptional:
|
||||
mutableDecl = nonConstDecl + ".Value()"
|
||||
declType = CGTemplatedType("Optional", declType, isConst=True)
|
||||
mutableDecl = "${declName}.Value()"
|
||||
declType = CGTemplatedType("Optional", declType)
|
||||
holderType = CGTemplatedType("Maybe", holderType)
|
||||
constructDecl = CGGeneric(nonConstDecl + ".Construct();")
|
||||
constructDecl = CGGeneric("${declName}.Construct();")
|
||||
if nullable:
|
||||
constructHolder = CGGeneric("${holderName}.construct(%s.SetValue());" % mutableDecl)
|
||||
else:
|
||||
constructHolder = CGGeneric("${holderName}.construct(${declName}.Value());")
|
||||
else:
|
||||
mutableDecl = nonConstDecl
|
||||
mutableDecl = "${declName}"
|
||||
constructDecl = None
|
||||
if nullable:
|
||||
holderType = CGTemplatedType("Maybe", holderType)
|
||||
@ -3980,6 +3975,8 @@ class CGCallGenerator(CGThing):
|
||||
# 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
|
||||
if a.type.isUnion():
|
||||
return True
|
||||
return False
|
||||
if needsConst(a):
|
||||
arg = CGWrapper(arg, pre="Constify(", post=")")
|
||||
@ -5603,6 +5600,7 @@ class CGUnionConversionStruct(CGThing):
|
||||
return string.Template("""
|
||||
class ${structName}Argument {
|
||||
public:
|
||||
// Argument needs to be a const ref because that's all Maybe<> allows
|
||||
${structName}Argument(const ${structName}& aUnion) : mUnion(const_cast<${structName}&>(aUnion))
|
||||
{
|
||||
}
|
||||
|
@ -709,6 +709,14 @@ private:
|
||||
|
||||
// Make sure various nullable things are always const
|
||||
void PassNullableEnum(Nullable<TestEnum>&) MOZ_DELETE;
|
||||
|
||||
// Make sure unions are always const
|
||||
void PassUnion(JSContext*, ObjectOrLong& arg) MOZ_DELETE;
|
||||
void PassUnionWithNullable(JSContext*, ObjectOrNullOrLong& arg) MOZ_DELETE;
|
||||
void PassNullableUnion(JSContext*, Nullable<ObjectOrLong>&) MOZ_DELETE;
|
||||
void PassOptionalUnion(JSContext*, Optional<ObjectOrLong>&) MOZ_DELETE;
|
||||
void PassOptionalNullableUnion(JSContext*, Optional<Nullable<ObjectOrLong> >&) MOZ_DELETE;
|
||||
void PassOptionalNullableUnionWithDefaultValue(JSContext*, Nullable<ObjectOrLong>&) MOZ_DELETE;
|
||||
};
|
||||
|
||||
class TestIndexedGetterInterface : public nsISupports,
|
||||
|
Loading…
Reference in New Issue
Block a user