Specify default parameter values where it is useful, that is to say where undefined would be converted to something else than the default value otherwise.
rdar://problem/22545600
Created attachment 261489 [details] Patch
Comment on attachment 261489 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=261489&action=review > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3387 > + push(@$outputArray, " $name = String(ASCIILiteral(" . $parameter->default . "));\n"); Why is the String() needed here? > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3389 > + push(@$outputArray, " $name = exec->uncheckedArgument($argsIndex).toString(exec)->value(exec);\n"); Why did you remove the early return when toString had an exception before calling value that the old code had? > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3396 > + push(@$outputArray, " auto* ${name}String = ${argValue}.toString(exec);\n"); > + push(@$outputArray, " auto& $name = ${name}String->value(exec);\n"); Same question here.
Comment on attachment 261489 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=261489&action=review >> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3387 >> + push(@$outputArray, " $name = String(ASCIILiteral(" . $parameter->default . "));\n"); > > Why is the String() needed here? iirc, the compiler did not let me have different types (literal vs String) on both sides on the ternary but I can try without again. >> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3389 >> + push(@$outputArray, " $name = exec->uncheckedArgument($argsIndex).toString(exec)->value(exec);\n"); > > Why did you remove the early return when toString had an exception before calling value that the old code had? I believe this was a bug. This is inconsistent with how we usually convert String in the bindings. In regular cases, we do .toString(exec)->value(exec) then do the exception check. However, we were doing it differently in the string enumeration case only which does not make much sense to me. If JSString::value() throws an exception, I think it makes sense to do the exception check after the call the value() as well. At the very least, it is consistent with how we usually convert strings.
Comment on attachment 261489 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=261489&action=review >>> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3389 >>> + push(@$outputArray, " $name = exec->uncheckedArgument($argsIndex).toString(exec)->value(exec);\n"); >> >> Why did you remove the early return when toString had an exception before calling value that the old code had? > > I believe this was a bug. This is inconsistent with how we usually convert String in the bindings. In regular cases, we do .toString(exec)->value(exec) then do the exception check. However, we were doing it differently in the string enumeration case only which does not make much sense to me. If JSString::value() throws an exception, I think it makes sense to do the exception check after the call the value() as well. At the very least, it is consistent with how we usually convert strings. I have just talked to Geoff about this: 1. Calling toString(exec)->value(exec) is safe because toString() will return an empty string (not null) in case of exception. 2. We should do an exception check after the call to value(exec) because it can throw in case it runs out of memory.
Comment on attachment 261489 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=261489&action=review >>> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3387 >>> + push(@$outputArray, " $name = String(ASCIILiteral(" . $parameter->default . "));\n"); >> >> Why is the String() needed here? > > iirc, the compiler did not let me have different types (literal vs String) on both sides on the ternary but I can try without again. I don’t see a ternary. Maybe you had that in an earlier version.
Comment on attachment 261489 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=261489&action=review >>>> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3387 >>>> + push(@$outputArray, " $name = String(ASCIILiteral(" . $parameter->default . "));\n"); >>> >>> Why is the String() needed here? >> >> iirc, the compiler did not let me have different types (literal vs String) on both sides on the ternary but I can try without again. > > I don’t see a ternary. Maybe you had that in an earlier version. Oh right, this iteration no longer has a ternary, sorry. I'll fix before landing.
Created attachment 261591 [details] Patch
Comment on attachment 261591 [details] Patch Clearing flags on attachment: 261591 Committed r190021: <http://trac.webkit.org/changeset/190021>
All reviewed patches have been landed. Closing bug.