First step in using "enum class" instead of "String" for enumerations in DOM
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Apr 2016 05:09:10 +0000 (05:09 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 Apr 2016 05:09:10 +0000 (05:09 +0000)
commit3c5a6832506481f5327f4bd02b1c9860e0ad8751
treeead971d7254ccb26572a275d33d431300df50d47
parentdfcbb6966c3f3752b5a34606f5300e6bc1d2bd4b
First step in using "enum class" instead of "String" for enumerations in DOM
https://bugs.webkit.org/show_bug.cgi?id=157163

Reviewed by Chris Dumez.

Source/JavaScriptCore:

* runtime/JSString.h:
(JSC::jsStringWithCache): Deleted unneeded overload for AtomicString.

Source/WebCore:

This patch adds the basic support for using "enum class" to implement enumerations
in the C++ DOM. This is enough so we can use it for one case, but not enough for
others. For example, it correctly generates code to get an attribute, but likely
does not correctly generate code to set an attribute or call a function with an
argument type that is the new style of enum.

* bindings/scripts/CodeGenerator.pm: Cleaned up the formatting of the hashes
at the start of this file. Added a new one named stringBasedEnumerationHash
and a comment explaining that we need to eventually make it empty.
(ProcessDocument): Pass the enumerations into the GenerateInterface function.
(IsStringBasedEnumType): Added. Returns 1 for the old-style string-based enumerations,
as opposed to enumerations we use "enum class" for.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateInterface): Take the enumerations argument and pass it along to the
functions that generate headers and implementation files.
(EnumerationClassName): Added. Maps from an enumeration type name as seen
in the IDL file to the enumeration class name used in the C++ DOM implementation.
(EnumerationValueName): Added. Maps from an anumeration string value as seen
in the IDL file to an enumeration value name used in the C++ DOM implementatino.
(EnumerationImplementationContent): Added. Generates a string with all the content
needed in the implementation file to define the helper functions for enumerations.
(GenerateHeader): Tweak.
(GenerateImplementation): Added call to EnumerationImplementationContent.
(GenerateParametersCheck): Use toWTFString instead of toString/value, which is a
longer way of writing out the same thing.
(GenerateCallbackHeader): Tweak.
(GenerateCallbackImplementation): Added call to EnumerationImplementationContent.
(GetNativeType): Continue to return String for string-based enum types, but for
other enum types, return the result of EnumerationClassName instead.
(JSValueToNative): Use toWTFString instead of toString/value (see above), convert
to a string only for string-based enum types, and add a preliminary, probably not
yet working, version of the code for non-string-based enum types. Will finish this
in the next patch when we are trying to use one of the new enumerations for a setter
or a function argument.
(NativeToJSValue): Call the stringValue function to convert an enumeration value
into a string when it's not a string-based enumeration.

* bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
* bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
* bindings/scripts/test/JS/JSTestGlobalObject.cpp:
* bindings/scripts/test/JS/JSTestInterface.cpp:
* bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
* bindings/scripts/test/JS/JSTestNode.cpp:
* bindings/scripts/test/JS/JSTestNondeterministic.cpp:
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/JS/JSTestObj.h:
* bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
* bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp:
* bindings/scripts/test/JS/JSTestTypedefs.cpp:
Regenerated.

* css/FontFace.cpp:
(WebCore::FontFace::status): Updated to return enum values rather than strings.

* css/FontFace.h: Removed unneeded forward declaration of Deprecated::ScriptValue.
Added enum class for FontFaceLoadStatus, with names that match the names from the
enumeration in the IDL, but with our standard enum capitalization style. Changed
the return value of the status function to FontFaceLoadStatus.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200288 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSString.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestNondeterministic.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
Source/WebCore/css/FontFace.cpp
Source/WebCore/css/FontFace.h