Bug 766583 part 7. Stop declaring variadic arguments as const on the stack in bindings code. r=smaug
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -3463,25 +3463,24 @@ class CGArgumentConverter(CGThing):
if elementHolderType is not None:
raise TypeError("Shouldn't need holders for variadics")
replacer = dict(self.argcAndIndex, **self.replacementVariables)
replacer["seqType"] = CGTemplatedType("AutoSequence", elementDeclType).define()
replacer["elemType"] = elementDeclType.define()
# NOTE: Keep this in sync with sequence conversions as needed
- variadicConversion = string.Template("""const ${seqType} ${declName};
+ variadicConversion = string.Template("""${seqType} ${declName};
if (${argc} > ${index}) {
- ${seqType}& arr = const_cast< ${seqType}& >(${declName});
- if (!arr.SetCapacity(${argc} - ${index})) {
+ if (!${declName}.SetCapacity(${argc} - ${index})) {
JS_ReportOutOfMemory(cx);
return false;
}
for (uint32_t variadicArg = ${index}; variadicArg < ${argc}; ++variadicArg) {
- ${elemType}& slot = *arr.AppendElement();
+ ${elemType}& slot = *${declName}.AppendElement();
""").substitute(replacer)
val = string.Template("${argv}[variadicArg]").substitute(replacer)
variadicConversion += CGIndenter(CGGeneric(
string.Template(elementTemplate).substitute(
{
"val" : val,
"valPtr": "&" + val,
@@ -3969,16 +3968,17 @@ class CGCallGenerator(CGThing):
return True
if a.type.nullable():
return True
if a.type.isString():
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.
+ # This also covers variadic arguments.
return True
if a.type.isUnion():
return True
return False
if needsConst(a):
arg = CGWrapper(arg, pre="Constify(", post=")")
args.append(arg)