[WebIDL] Add support for record types
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Nov 2016 21:47:42 +0000 (21:47 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Nov 2016 21:47:42 +0000 (21:47 +0000)
commitd32907015317d99f85ff5d3c847b2b8c2dafeec2
tree653787455707d2b1a8f86d3dcf3006c7cf51d5a3
parent0498dd6af3b2f6277f412b33bf8505b4e708c863
[WebIDL] Add support for record types
https://bugs.webkit.org/show_bug.cgi?id=164935

Reviewed by Tim Horton.

Source/WebCore:

Add support for WebIDLs record types. We map them to HashMap<String, {OtherType}>.

* bindings/generic/IDLTypes.h:
- Add IDLRecord type and helper predicate.
- Remove IDLRegExp which is no longer in WebIDL and we never supported.

* bindings/js/JSDOMBinding.cpp:
(WebCore::stringToByteString):
(WebCore::identifierToByteString):
(WebCore::valueToByteString):
(WebCore::hasUnpairedSurrogate):
(WebCore::stringToUSVString):
(WebCore::identifierToUSVString):
(WebCore::valueToUSVString):
* bindings/js/JSDOMBinding.h:
Refactor ByteString and USVString conversion to support converting from
either a JSValue or Identifier.

* bindings/js/JSDOMConvert.h:
(WebCore::DetailConverter<IDLRecord<K, V>>):
(WebCore::JSConverter<IDLRecord<K, V>>):
Add conversion support for record types. Use Detail::IdentifierConverter helper
to convert identifiers to strings using the correct conversion rules.

(WebCore::Converter<IDLUnion<T...>>::convert):
Update comments in union conversion to match current spec. Remove check
for regular expressions and add support for record types.

* bindings/scripts/CodeGenerator.pm:
(IsRefPtrType):
Add record and union types to the list of things that aren't RefPtrs.

(IsRecordType):
Add predicate for testing if a type is a record.

(IsWrapperType):
Remove check for union. This is now handled in the IsRefPtrType check.

(SkipIncludeHeader): Deleted.
(GetSequenceInnerType): Deleted.
(GetFrozenArrayInnerType): Deleted.
(GetSequenceOrFrozenArrayInnerType): Deleted.
Remove no longer necessary functions.

* bindings/scripts/CodeGeneratorJS.pm:
(AddIncludesForImplementationType):
Remove check for includes to skip. This is now only called for interfaces, which should be included
unconditionally.

(AddToIncludesForIDLType):
Add includes and recursive includes for record types.

(GenerateOverloadedFunctionOrConstructor):
Update to account for records.

(GetGnuVTableRefForInterface):
(GetGnuVTableNameForInterface):
(GetGnuMangledNameForInterface):
(GetWinVTableNameForInterface):
(GetWinMangledNameForInterface):
Strength-reduce GetNativeTypeForConversions and GetNamespaceForInterface into their callers.

(GetBaseIDLType):
Add support for IDLRecord. Remove call to GetIDLInterfaceName now that is simply the type name.

(GetNativeType):
Simplify sequence/FrozenArray support and add record support.

(GetNativeInnerType):
Generalize GetNativeVectorInnerType to work for record types as well.

(ShouldPassWrapperByReference):
Moved so native type accessors can be together.

(NativeToJSValueDOMConvertNeedsState):
(NativeToJSValueDOMConvertNeedsGlobalObject):
Add record support.

(GetNativeTypeForConversions): Deleted.
(GetNamespaceForInterface): Deleted.
(GetNativeVectorType): Deleted.
(GetIDLInterfaceName): Deleted.
(GetNativeVectorInnerType): Deleted.
Remove unneeded functions.

* bindings/scripts/IDLParser.pm:
(typeDescription):
Add helper useful for debugging, that constructs the string form of a type.

(typeByApplyingTypedefs):
Add missing call to typeByApplyingTypedefs (this is noted by a fix in JSTestCallbackFunctionWithTypedefs.h)

(parseNonAnyType):
Remove unused $subtypeName variables and add support for parsing record types.

* bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp:
* bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.h:
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/TestObj.idl:
Add tests for records and update results.

* testing/TypeConversions.h:
(WebCore::TypeConversions::testLongRecord):
(WebCore::TypeConversions::setTestLongRecord):
(WebCore::TypeConversions::testNodeRecord):
(WebCore::TypeConversions::setTestNodeRecord):
(WebCore::TypeConversions::testSequenceRecord):
(WebCore::TypeConversions::setTestSequenceRecord):
* testing/TypeConversions.idl:
Add record types so it can be tested from layout tests.

LayoutTests:

* js/dom/webidl-type-mapping-expected.txt:
* js/dom/webidl-type-mapping.html:
Add tests for WebIDL record types.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208893 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/js/dom/webidl-type-mapping-expected.txt
LayoutTests/js/dom/webidl-type-mapping.html
Source/WebCore/ChangeLog
Source/WebCore/bindings/generic/IDLTypes.h
Source/WebCore/bindings/js/JSDOMBinding.cpp
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/js/JSDOMConvert.h
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLParser.pm
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.h
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/TestObj.idl
Source/WebCore/testing/TypeConversions.h
Source/WebCore/testing/TypeConversions.idl