Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Unified Diff: third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.cpp

Issue 2709983004: WIP bindings: Add support for the record<K,V> WebIDL type. (Closed)
Patch Set: Rebased patch using NativeValueTraits for IDL types Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.cpp
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.cpp
index 11ffa5a54cb7c93a698c7d35ccb126cbd59fb064..69ac4786070ca6c05964de237e993b0c4f9e0474 100644
--- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.cpp
+++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.cpp
@@ -11,7 +11,9 @@
// clang-format off
#include "V8TestTypedefs.h"
+#include "bindings/core/v8/ByteStringSequenceSequenceOrByteStringByteStringRecord.h"
#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/IDLTypes.h"
#include "bindings/core/v8/StringOrDouble.h"
#include "bindings/core/v8/TestInterfaceOrTestInterfaceEmpty.h"
#include "bindings/core/v8/V8DOMConfiguration.h"
@@ -19,6 +21,7 @@
#include "bindings/core/v8/V8TestCallbackInterface.h"
#include "bindings/core/v8/V8TestInterface.h"
#include "bindings/core/v8/V8TestInterfaceEmpty.h"
+#include "bindings/core/v8/V8TestObject.h"
#include "core/dom/Document.h"
#include "core/frame/LocalDOMWindow.h"
#include "wtf/GetPtr.h"
@@ -240,6 +243,66 @@ static void stringArrayMethodStringArrayArgMethod(const v8::FunctionCallbackInfo
v8SetReturnValue(info, ToV8(impl->stringArrayMethodStringArrayArg(stringArrayArg), info.Holder(), info.GetIsolate()));
}
+static void methodTakingRecordMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestTypedefs", "methodTakingRecord");
+
+ TestTypedefs* impl = V8TestTypedefs::toImpl(info.Holder());
+
+ if (UNLIKELY(info.Length() < 1)) {
+ exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
+ return;
+ }
+
+ Vector<std::pair<String, int>> arg;
+ arg = NativeValueTraits<idl::Record<idl::ByteString, idl::Long>>::nativeValue(info.GetIsolate(), info[0], exceptionState);
+ if (exceptionState.hadException())
+ return;
+
+ impl->methodTakingRecord(arg);
+}
+
+static void methodTakingOilpanValueRecordMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestTypedefs", "methodTakingOilpanValueRecord");
+
+ TestTypedefs* impl = V8TestTypedefs::toImpl(info.Holder());
+
+ if (UNLIKELY(info.Length() < 1)) {
+ exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
+ return;
+ }
+
+ HeapVector<std::pair<String, Member<TestObject>>> arg;
+ arg = NativeValueTraits<idl::Record<idl::USVString, TestObject>>::nativeValue(info.GetIsolate(), info[0], exceptionState);
+ if (exceptionState.hadException())
+ return;
+
+ impl->methodTakingOilpanValueRecord(arg);
+}
+
+static void unionWithRecordMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestTypedefs", "unionWithRecordMethod");
+
+ TestTypedefs* impl = V8TestTypedefs::toImpl(info.Holder());
+
+ if (UNLIKELY(info.Length() < 1)) {
+ exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
+ return;
+ }
+
+ ByteStringSequenceSequenceOrByteStringByteStringRecord arg;
+ V8ByteStringSequenceSequenceOrByteStringByteStringRecord::toImpl(info.GetIsolate(), info[0], arg, UnionTypeConversionMode::NotNullable, exceptionState);
+ if (exceptionState.hadException())
+ return;
+
+ v8SetReturnValue(info, impl->unionWithRecordMethod(arg));
+}
+
+static void methodThatReturnsRecordMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ TestTypedefs* impl = V8TestTypedefs::toImpl(info.Holder());
+
+ v8SetReturnValue(info, ToV8(impl->methodThatReturnsRecord(), info.Holder(), info.GetIsolate()));
+}
+
static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) {
if (UNLIKELY(info.Length() < 1)) {
V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToConstruct("TestTypedefs", ExceptionMessages::notEnoughArguments(1, info.Length())));
@@ -311,6 +374,22 @@ void V8TestTypedefs::stringArrayMethodStringArrayArgMethodCallback(const v8::Fun
TestTypedefsV8Internal::stringArrayMethodStringArrayArgMethod(info);
}
+void V8TestTypedefs::methodTakingRecordMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ TestTypedefsV8Internal::methodTakingRecordMethod(info);
+}
+
+void V8TestTypedefs::methodTakingOilpanValueRecordMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ TestTypedefsV8Internal::methodTakingOilpanValueRecordMethod(info);
+}
+
+void V8TestTypedefs::unionWithRecordMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ TestTypedefsV8Internal::unionWithRecordMethodMethod(info);
+}
+
+void V8TestTypedefs::methodThatReturnsRecordMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ TestTypedefsV8Internal::methodThatReturnsRecordMethod(info);
+}
+
// Suppress warning: global constructors, because AttributeConfiguration is trivial
// and does not depend on another global objects.
#if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
@@ -338,6 +417,10 @@ const V8DOMConfiguration::MethodConfiguration V8TestTypedefsMethods[] = {
{"domStringOrDoubleMethod", V8TestTypedefs::domStringOrDoubleMethodMethodCallback, nullptr, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder, V8DOMConfiguration::DoNotCheckAccess},
{"arrayOfStringsMethodArrayOfStringsArg", V8TestTypedefs::arrayOfStringsMethodArrayOfStringsArgMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder, V8DOMConfiguration::DoNotCheckAccess},
{"stringArrayMethodStringArrayArg", V8TestTypedefs::stringArrayMethodStringArrayArgMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder, V8DOMConfiguration::DoNotCheckAccess},
+ {"methodTakingRecord", V8TestTypedefs::methodTakingRecordMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder, V8DOMConfiguration::DoNotCheckAccess},
+ {"methodTakingOilpanValueRecord", V8TestTypedefs::methodTakingOilpanValueRecordMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder, V8DOMConfiguration::DoNotCheckAccess},
+ {"unionWithRecordMethod", V8TestTypedefs::unionWithRecordMethodMethodCallback, nullptr, 1, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder, V8DOMConfiguration::DoNotCheckAccess},
+ {"methodThatReturnsRecord", V8TestTypedefs::methodThatReturnsRecordMethodCallback, nullptr, 0, v8::None, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder, V8DOMConfiguration::DoNotCheckAccess},
};
void V8TestTypedefs::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {

Powered by Google App Engine
This is Rietveld 408576698