Changeset 207791 in webkit


Ignore:
Timestamp:
Oct 24, 2016 5:16:29 PM (8 years ago)
Author:
Chris Dumez
Message:

Reduce special handling for typed arrays in JSDOMConvert.h
https://bugs.webkit.org/show_bug.cgi?id=163907

Reviewed by Sam Weinig.

Reduce special handling for typed arrays in JSDOMConvert.h by adding a toWrapped() static
function on JSGenericTypedArrayView, similarly to other wrapper types.

Source/JavaScriptCore:

  • runtime/JSGenericTypedArrayView.h:

(JSC::JSGenericTypedArrayView::typedImpl):
(JSC::JSGenericTypedArrayView<Adaptor>::toWrapped):

Source/WebCore:

No new tests, no web-exposed behavior change.

  • bindings/js/JSDOMConvert.h:

(WebCore::Converter<IDLInterface<JSC::GenericTypedArrayView<Adaptor>>>::convert): Deleted.

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r207789 r207791  
     12016-10-24  Chris Dumez  <cdumez@apple.com>
     2
     3        Reduce special handling for typed arrays in JSDOMConvert.h
     4        https://bugs.webkit.org/show_bug.cgi?id=163907
     5
     6        Reviewed by Sam Weinig.
     7
     8        Reduce special handling for typed arrays in JSDOMConvert.h by adding a toWrapped() static
     9        function on JSGenericTypedArrayView, similarly to other wrapper types.
     10
     11        * runtime/JSGenericTypedArrayView.h:
     12        (JSC::JSGenericTypedArrayView::typedImpl):
     13        (JSC::JSGenericTypedArrayView<Adaptor>::toWrapped):
     14
    1152016-10-24  Yusuke Suzuki  <utatane.tea@gmail.com>
    216
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h

    r207411 r207791  
    226226    bool set(ExecState*, unsigned offset, JSObject*, unsigned objectOffset, unsigned length, CopyType type = CopyType::Unobservable);
    227227   
    228     PassRefPtr<typename Adaptor::ViewType> typedImpl()
     228    RefPtr<typename Adaptor::ViewType> typedImpl()
    229229    {
    230230        return Adaptor::ViewType::create(buffer(), byteOffset(), length());
    231231    }
     232
     233    static RefPtr<typename Adaptor::ViewType> toWrapped(JSValue);
    232234   
    233235    static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
     
    368370}
    369371
     372template<typename Adaptor>
     373RefPtr<typename Adaptor::ViewType> JSGenericTypedArrayView<Adaptor>::toWrapped(JSValue value)
     374{
     375    return JSC::toNativeTypedView<Adaptor>(value);
     376}
     377
    370378} // namespace JSC
  • trunk/Source/WebCore/ChangeLog

    r207790 r207791  
     12016-10-24  Chris Dumez  <cdumez@apple.com>
     2
     3        Reduce special handling for typed arrays in JSDOMConvert.h
     4        https://bugs.webkit.org/show_bug.cgi?id=163907
     5
     6        Reviewed by Sam Weinig.
     7
     8        Reduce special handling for typed arrays in JSDOMConvert.h by adding a toWrapped() static
     9        function on JSGenericTypedArrayView, similarly to other wrapper types.
     10
     11        No new tests, no web-exposed behavior change.
     12
     13        * bindings/js/JSDOMConvert.h:
     14        (WebCore::Converter<IDLInterface<JSC::GenericTypedArrayView<Adaptor>>>::convert): Deleted.
     15
    1162016-10-24  Ryan Haddad  <ryanhaddad@apple.com>
    217
  • trunk/Source/WebCore/bindings/js/JSDOMConvert.h

    r207737 r207791  
    236236};
    237237
     238// Typed arrays support.
     239template<typename Adaptor> struct JSDOMWrapperConverterTraits<JSC::GenericTypedArrayView<Adaptor>> {
     240    using WrapperClass = JSC::JSGenericTypedArrayView<Adaptor>;
     241    using ToWrappedReturnType = RefPtr<JSC::GenericTypedArrayView<Adaptor>>;
     242};
     243
    238244// MARK: -
    239245// MARK: Interface type
     
    262268    {
    263269        return toJS(&exec, &globalObject, WTF::getPtr(value));
    264     }
    265 };
    266 
    267 // Typed arrays support.
    268 
    269 template<typename Adaptor> struct IDLInterface<JSC::GenericTypedArrayView<Adaptor>> : IDLType<Ref<JSC::GenericTypedArrayView<Adaptor>>> {
    270     using RawType = JSC::GenericTypedArrayView<Adaptor>;
    271     using NullableType = RefPtr<JSC::GenericTypedArrayView<Adaptor>>;
    272 };
    273 
    274 template<typename Adaptor> struct Converter<IDLInterface<JSC::GenericTypedArrayView<Adaptor>>> : DefaultConverter<IDLInterface<JSC::GenericTypedArrayView<Adaptor>>> {
    275     using ReturnType = RefPtr<JSC::GenericTypedArrayView<Adaptor>>;
    276 
    277     static ReturnType convert(JSC::ExecState& state, JSC::JSValue value)
    278     {
    279         JSC::VM& vm = state.vm();
    280         auto scope = DECLARE_THROW_SCOPE(vm);
    281         ReturnType object = JSC::toNativeTypedView<Adaptor>(value);
    282         if (!object)
    283             throwTypeError(&state, scope);
    284         return object;
    285270    }
    286271};
Note: See TracChangeset for help on using the changeset viewer.