Descriptionbindings: Add support for the record<K,V> WebIDL type.
Records (https://heycam.github.io/webidl/#idl-record) are ordered
associative arrays mapping instances of K to instances of V, where K must be
a ByteString, a DOMString or an USVString.
In C++, we represent records as Vector<std::pair<k,v>> (or HeapVector),
which are converted from V8 objects via
NativeValueTraits<IDLRecord<K, V>>::nativeValue()
To convert the C++ Vectors back to V8 objects, we piggyback on already
existing ToV8() overloads for Vector<std::pair<>> and HeapVector.
The majority of the required work to support this new IDL type has already
landed and concerned making it possible to convert JS values to arbitrary
C++ types without knowing much about them (there is a single JS->C++
conversion function that needs to work for pretty much any JS data type).
This CL mainly makes the Python bindings code aware of this new type and
allows it to generate the appropriate JS->C++ and C++->V8 calls, and adds
the IDLRecord NativeValueTraits template specialization mentioned above. All
the rest is new tests and updates to existing expectations.
It is also important to note that the JS->C++ conversion code relies on a
NativeValueTraits specialization existing for the record value types, and
they are always used regardless of whether they are the fastest way to
convert data or not -- for example, it always creates and uses an
ExceptionState even if the actual conversion functions do not use it (as is
the case for toDOMWindow() or ScriptValue()).
Finally, while here rename IDLSequence::MaybeWrappedCppType to IDLSequence::MaybeMemberCppType to avoid confusion (and do the same for IDLRecord), as "wrapper" in a bindings context tends to refer to the V8 wrapper for DOM objects, which is not the case here.
BUG=685754
R=bashi@chromium.org,haraken@chromium.org,yukishiino@chromium.org
Review-Url: https://codereview.chromium.org/2732093003
Cr-Commit-Position: refs/heads/master@{#456048}
Committed: https://chromium.googlesource.com/chromium/src/+/90659e8a6bbc7e40ea3145c19af3138f484beb52
Patch Set 1 #Patch Set 2 : Small build fix #Patch Set 3 : Blind attempt at fixing Windows component builds #Patch Set 4 : Remove static from isPropertyEnumerable #Patch Set 5 : It turns out static was indeed necessary #
Total comments: 11
Patch Set 6 : Address most review comments #
Total comments: 24
Patch Set 7 : Address most review comments #Patch Set 8 : Make isPropertyEnumerable rethrow exceptions in Get(), add more tests #
Total comments: 8
Patch Set 9 : s/oilpanRecordMember/garbageCollectedRecordMember/ #Patch Set 10 : Remove isPropertyEnumerable and simplify the checks #
Total comments: 1
Patch Set 11 : s/isolate->GetCurrentContext()/context/ #Messages
Total messages: 53 (27 generated)
|