[WebIDL] Remove some unnecessary specialization for enum types
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 May 2017 16:30:37 +0000 (16:30 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 May 2017 16:30:37 +0000 (16:30 +0000)
commit56b5031b4fd3dfbe691538b18f115d7d82ec37eb
treee92f273bc2a93cf9bce84f49a98415c180b89efb
parent10df8fe3e3efe445f6ce84e8e9e7937ac654ec14
[WebIDL] Remove some unnecessary specialization for enum types
https://bugs.webkit.org/show_bug.cgi?id=172482

Patch by Sam Weinig <sam@webkit.org> on 2017-05-23
Reviewed by Chris Dumez.

Source/WebCore:

- Removes convertEnumeration template function and generated specialization.
  convert<IDLEnumeration<T>> now does the entire check, and can have specialized
  exceptions.
- Treats enums more like all other types, removing enum specific code in the
  generator.

Also fixes some order of exception bugs as the convertEnumeration<T> implementations
were not correctly catching exceptions thrown in parseEnumeration<T>.

* bindings/js/JSDOMConvertEnumeration.h:
(WebCore::Converter<IDLEnumeration<T>>::convert):
Remove convertEnumeration and move implementation to convert. Add ExceptionThrower
parameter to retain argument conversion exception specialization and allow future
specialization for other contexts.

* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::jsSubtleCryptoFunctionImportKeyPromise):
(WebCore::jsSubtleCryptoFunctionExportKeyPromise):
(WebCore::jsSubtleCryptoFunctionWrapKeyPromise):
(WebCore::jsSubtleCryptoFunctionUnwrapKeyPromise):
Switch from convertEnumeration<T> to convert<IDLEnumeration<T>>.

* bindings/scripts/CodeGeneratorJS.pm:
(GetArgumentExceptionFunction):
Add (really move from GenerateParametersCheck) enum specific argument conversion exception.

(PassArgumentExpression):
Allow the enum specific code for attributes to remain by explicitly checking the context.
Attribute setters use parseEnumeration<T> explicitly, as WebIDL mandates slightly different
behavior, specially that they don't throw.

(GenerateEnumerationImplementationContent):
(GenerateEnumerationHeaderContent):
Remove convertEnumeration<T>.

(GenerateParametersCheck):
Remove entire branch devoted to enums. The main parameter check is now mature enough
to handle them.

(JSValueToNative):
Like in PassArgumentExpression, we need to retain the specialize behavior for attributes.
Before, JSValueToNative was only called for enums with a context of IDLAttribute or IDLDictionaryMember,
but now that we use if IDLArguments as well, it makes more sense to make this check in terms
of the odd man out, IDLAttribute.

* bindings/scripts/test/JS/JSTestCallbackInterface.cpp:
* bindings/scripts/test/JS/JSTestCallbackInterface.h:
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/JS/JSTestObj.h:
* bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp:
* bindings/scripts/test/JS/JSTestStandaloneDictionary.h:
* bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp:
* bindings/scripts/test/JS/JSTestStandaloneEnumeration.h:
Update test results.

LayoutTests:

* crypto/subtle/import-key-malformed-parameters-expected.txt:
* fast/files/blob-constructor-expected.txt:
* fast/files/script-tests/blob-constructor.js:
Update test and results for improved order of exceptions. In this case, the conversion
to String throws before the failure to parse the enumeration (which is what the
plain TypeError was).

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217281 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
LayoutTests/ChangeLog
LayoutTests/crypto/subtle/import-key-malformed-parameters-expected.txt
LayoutTests/fast/files/blob-constructor-expected.txt
LayoutTests/fast/files/script-tests/blob-constructor.js
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDOMConvertEnumeration.h
Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.h
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestObj.h
Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.h
Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneEnumeration.h