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

Unified Diff: third_party/WebKit/Source/bindings/tests/results/core/V8TestDictionary.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/V8TestDictionary.cpp
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestDictionary.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestDictionary.cpp
index c3503f05d9e9fc8b06cea28113ae2d3b1d5b69c8..374f023a0f91b3dc5c0721532e4564d99d6afea2 100644
--- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestDictionary.cpp
+++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestDictionary.cpp
@@ -14,6 +14,7 @@
#include "bindings/core/v8/Dictionary.h"
#include "bindings/core/v8/DoubleOrString.h"
#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/IDLTypes.h"
#include "bindings/core/v8/ScriptValue.h"
#include "bindings/core/v8/TestInterface2OrUint8Array.h"
#include "bindings/core/v8/V8ArrayBufferView.h"
@@ -304,6 +305,20 @@ void V8TestDictionary::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value
impl.setObjectOrNullMember(objectOrNullMember);
}
+ v8::Local<v8::Value> oilpanRecordMemberValue;
+ if (!v8Object->Get(isolate->GetCurrentContext(), v8AtomicString(isolate, "oilpanRecordMember")).ToLocal(&oilpanRecordMemberValue)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (oilpanRecordMemberValue.IsEmpty() || oilpanRecordMemberValue->IsUndefined()) {
+ // Do nothing.
+ } else {
+ HeapVector<std::pair<String, Member<TestObject>>> oilpanRecordMember = NativeValueTraits<idl::Record<idl::USVString, TestObject>>::nativeValue(isolate, oilpanRecordMemberValue, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ impl.setOilpanRecordMember(oilpanRecordMember);
+ }
+
v8::Local<v8::Value> otherDoubleOrStringMemberValue;
if (!v8Object->Get(isolate->GetCurrentContext(), v8AtomicString(isolate, "otherDoubleOrStringMember")).ToLocal(&otherDoubleOrStringMemberValue)) {
exceptionState.rethrowV8Exception(block.Exception());
@@ -335,6 +350,20 @@ void V8TestDictionary::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value
impl.setPrefixGetMember(prefixGetMember);
}
+ v8::Local<v8::Value> recordMemberValue;
+ if (!v8Object->Get(isolate->GetCurrentContext(), v8AtomicString(isolate, "recordMember")).ToLocal(&recordMemberValue)) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return;
+ }
+ if (recordMemberValue.IsEmpty() || recordMemberValue->IsUndefined()) {
+ // Do nothing.
+ } else {
+ Vector<std::pair<String, int>> recordMember = NativeValueTraits<idl::Record<idl::ByteString, idl::Byte>>::nativeValue(isolate, recordMemberValue, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ impl.setRecordMember(recordMember);
+ }
+
v8::Local<v8::Value> restrictedDoubleMemberValue;
if (!v8Object->Get(isolate->GetCurrentContext(), v8AtomicString(isolate, "restrictedDoubleMember")).ToLocal(&restrictedDoubleMemberValue)) {
exceptionState.rethrowV8Exception(block.Exception());
@@ -691,6 +720,11 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local<v8::Object> dictio
return false;
}
+ if (impl.hasOilpanRecordMember()) {
+ if (!v8CallBoolean(dictionary->CreateDataProperty(isolate->GetCurrentContext(), v8AtomicString(isolate, "oilpanRecordMember"), ToV8(impl.oilpanRecordMember(), creationContext, isolate))))
+ return false;
+ }
+
if (impl.hasOtherDoubleOrStringMember()) {
if (!v8CallBoolean(dictionary->CreateDataProperty(isolate->GetCurrentContext(), v8AtomicString(isolate, "otherDoubleOrStringMember"), ToV8(impl.otherDoubleOrStringMember(), creationContext, isolate))))
return false;
@@ -705,6 +739,11 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local<v8::Object> dictio
return false;
}
+ if (impl.hasRecordMember()) {
+ if (!v8CallBoolean(dictionary->CreateDataProperty(isolate->GetCurrentContext(), v8AtomicString(isolate, "recordMember"), ToV8(impl.recordMember(), creationContext, isolate))))
+ return false;
+ }
+
if (impl.hasRestrictedDoubleMember()) {
if (!v8CallBoolean(dictionary->CreateDataProperty(isolate->GetCurrentContext(), v8AtomicString(isolate, "restrictedDoubleMember"), v8::Number::New(isolate, impl.restrictedDoubleMember()))))
return false;

Powered by Google App Engine
This is Rietveld 408576698