bindings: Generalize Vector<ScriptValue> -> Vector<T> conversion |
||||
Issue descriptionThis originally started as a comment from Yuki in https://codereview.chromium.org/2825033003/. I'm creating the ticket to keep track of all the items mentioned there (and also because it makes more sense to discuss it here instead). From https://codereview.chromium.org/2825033003/#msg11: ---- Hmm, now I think it would be better to keep ToImplArray. Why is it better to remove? TL;DR: What about just renaming ToImplArray to a better name, and continue using it? I see that SQLTransaction::executeSql is the only client of ToImplArray, but potentially there could be more clients in future. Using ToImplArray would be safer / more robust than implementing it on each client side. I'm afraid that clients wouldn't handle error cases appropriately. My current understanding is that: * NativeValueTraits::NativeValue is responsible to convert a v8::Value to a value of an arbitrary implementation type T. * ScriptValue::To is just an alias of NativeValueTraits::NativeValue. I don't understand why we need this function now. Not sure, but we could want to remove this. * ScriptValue is designed to hold a raw v8::Value. So, I think it makes sense to treat a ScriptValue as if it's a v8::Value, i.e. Having a following overload. template <typename T> T NativeValue(isolate, scriptValue, exceptionState) { return NativeValue(isolate, scriptValue.V8Value(), exceptionState) } * SQLTransaction::executeSql needs a kind of "map" higher-order function. Vector<ScriptValue> input; Vector<SQLValue> output; output = map(NativeValueTraits::NativeValue, input); ToImplArray is a kind of non-general "map" function. * Probably, it's not a bad idea to provide this kind of "map" function. Thus, I'm now thinking it would be good to rename ToImplArray to "a map higher-order function from Vector<v8:Value or ScriptValue> to Vector<T>", and continue using it. What do you think? ----
,
Apr 19 2017
I agree with your points :-) I haven't given a lot of thought to how to actually do this, but getting rid of ScriptValue::To() would be good, and so is centralizing the kind of conversion ToImplArray(Vector<ScriptValue>) does. And hopefully without having to add a ton of new NativeValue() overloads for ScriptValue...
,
Apr 25 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/345e0fb9fe291f6d32d47365f5767099ccf87d30 commit 345e0fb9fe291f6d32d47365f5767099ccf87d30 Author: raphael.kubo.da.costa <raphael.kubo.da.costa@intel.com> Date: Tue Apr 25 10:32:08 2017 bindings: Remove unused To*Array() and ToV8Sequence() functions. With all callers converted to NativeValueTraits<IDLSequence<T>>::NativeValue(), which implements the most recent WebIDL JS->Sequence conversion steps (including custom iterators), we can remove several unused functions and deprecated NativeValueTraits specializations. Of all the To*Array() functions left, only ToImplArray(Vector<ScriptValue>) was not removed, as it still serves a purpose and will just be renamed in the future. V8BindingTest was accordingly adjust to only test that one function. BUG= 690428 , 713200 R=bashi@chromium.org,haraken@chromium.org,yukishiino@chromium.org Review-Url: https://codereview.chromium.org/2840563002 Cr-Commit-Position: refs/heads/master@{#466940} [modify] https://crrev.com/345e0fb9fe291f6d32d47365f5767099ccf87d30/third_party/WebKit/Source/bindings/core/v8/ExceptionMessages.cpp [modify] https://crrev.com/345e0fb9fe291f6d32d47365f5767099ccf87d30/third_party/WebKit/Source/bindings/core/v8/ExceptionMessages.h [modify] https://crrev.com/345e0fb9fe291f6d32d47365f5767099ccf87d30/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.h [modify] https://crrev.com/345e0fb9fe291f6d32d47365f5767099ccf87d30/third_party/WebKit/Source/bindings/core/v8/V8BindingTest.cpp
,
Apr 25 2018
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Apr 25 2018
rakuco, what remains here?
,
Apr 30 2018
Ultimately, we ended up going the opposite way: https://chromium-review.googlesource.com/c/chromium/src/+/849002 removed ToImplArray(Vector<ScriptValue>) altogether, as it looked like we were better off killing it and simplifying the code than generalising the ScriptValue conversions and adding more overloads to NVT::NativeValue(). ScriptValue::To() still exists, but it's unclear if we still want to get rid of it.
,
May 1 2018
Just FYI, I'm wondering if we could remove ScriptValue itself. v8::Value would work better now, I guess. Nothing is decided yet, though. Just as my personal thoughts. |
||||
►
Sign in to add a comment |
||||
Comment 1 by raphael....@intel.com
, Apr 19 2017