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

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

Issue 2730183003: bindings: Add C++ versions of WebIDL types and generalize NativeValueTraits. (Closed)
Patch Set: Move specialization for SerializedScriptValue to the appropriate header Created 3 years, 9 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/V8TestInterface.cpp
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp
index 61912cd52eb52cb677462908a4ee8198ed6c4560..729ed5c4140fe18bb1007842957bbc2de6eabf3d 100644
--- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp
+++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp
@@ -12,6 +12,8 @@
#include "V8TestInterface.h"
#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/IDLTypes.h"
+#include "bindings/core/v8/NativeValueTraitsImpl.h"
#include "bindings/core/v8/ScriptPromise.h"
#include "bindings/core/v8/ScriptState.h"
#include "bindings/core/v8/ScriptValue.h"
@@ -118,7 +120,7 @@ static void doubleAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface", "doubleAttribute");
// Prepare the value to be set.
- double cppValue = toRestrictedDouble(info.GetIsolate(), v8Value, exceptionState);
+ double cppValue = NativeValueTraits<IDLDouble>::nativeValue(info.GetIsolate(), v8Value, exceptionState);
if (exceptionState.hadException())
return;
@@ -140,7 +142,7 @@ static void floatAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface", "floatAttribute");
// Prepare the value to be set.
- float cppValue = toRestrictedFloat(info.GetIsolate(), v8Value, exceptionState);
+ float cppValue = NativeValueTraits<IDLFloat>::nativeValue(info.GetIsolate(), v8Value, exceptionState);
if (exceptionState.hadException())
return;
@@ -162,7 +164,7 @@ static void unrestrictedDoubleAttributeAttributeSetter(v8::Local<v8::Value> v8Va
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface", "unrestrictedDoubleAttribute");
// Prepare the value to be set.
- double cppValue = toDouble(info.GetIsolate(), v8Value, exceptionState);
+ double cppValue = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(info.GetIsolate(), v8Value, exceptionState);
if (exceptionState.hadException())
return;
@@ -184,7 +186,7 @@ static void unrestrictedFloatAttributeAttributeSetter(v8::Local<v8::Value> v8Val
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface", "unrestrictedFloatAttribute");
// Prepare the value to be set.
- float cppValue = toFloat(info.GetIsolate(), v8Value, exceptionState);
+ float cppValue = NativeValueTraits<IDLUnrestrictedFloat>::nativeValue(info.GetIsolate(), v8Value, exceptionState);
if (exceptionState.hadException())
return;
@@ -268,7 +270,7 @@ static void conditionalLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface", "conditionalLongAttribute");
// Prepare the value to be set.
- int32_t cppValue = toInt32(info.GetIsolate(), v8Value, NormalConversion, exceptionState);
+ int32_t cppValue = NativeValueTraits<IDLLong>::nativeValue(info.GetIsolate(), v8Value, exceptionState, NormalConversion);
if (exceptionState.hadException())
return;
@@ -370,7 +372,7 @@ static void alwaysExposedAttributeAttributeSetter(v8::Local<v8::Value> v8Value,
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface", "alwaysExposedAttribute");
// Prepare the value to be set.
- int32_t cppValue = toInt32(info.GetIsolate(), v8Value, NormalConversion, exceptionState);
+ int32_t cppValue = NativeValueTraits<IDLLong>::nativeValue(info.GetIsolate(), v8Value, exceptionState, NormalConversion);
if (exceptionState.hadException())
return;
@@ -392,7 +394,7 @@ static void workerExposedAttributeAttributeSetter(v8::Local<v8::Value> v8Value,
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface", "workerExposedAttribute");
// Prepare the value to be set.
- int32_t cppValue = toInt32(info.GetIsolate(), v8Value, NormalConversion, exceptionState);
+ int32_t cppValue = NativeValueTraits<IDLLong>::nativeValue(info.GetIsolate(), v8Value, exceptionState, NormalConversion);
if (exceptionState.hadException())
return;
@@ -414,7 +416,7 @@ static void windowExposedAttributeAttributeSetter(v8::Local<v8::Value> v8Value,
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface", "windowExposedAttribute");
// Prepare the value to be set.
- int32_t cppValue = toInt32(info.GetIsolate(), v8Value, NormalConversion, exceptionState);
+ int32_t cppValue = NativeValueTraits<IDLLong>::nativeValue(info.GetIsolate(), v8Value, exceptionState, NormalConversion);
if (exceptionState.hadException())
return;
@@ -803,7 +805,7 @@ static void partialLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, co
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface", "partialLongAttribute");
// Prepare the value to be set.
- int32_t cppValue = toInt32(info.GetIsolate(), v8Value, NormalConversion, exceptionState);
+ int32_t cppValue = NativeValueTraits<IDLLong>::nativeValue(info.GetIsolate(), v8Value, exceptionState, NormalConversion);
if (exceptionState.hadException())
return;
@@ -818,7 +820,7 @@ static void partialStaticLongAttributeAttributeSetter(v8::Local<v8::Value> v8Val
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface", "partialStaticLongAttribute");
// Prepare the value to be set.
- int32_t cppValue = toInt32(info.GetIsolate(), v8Value, NormalConversion, exceptionState);
+ int32_t cppValue = NativeValueTraits<IDLLong>::nativeValue(info.GetIsolate(), v8Value, exceptionState, NormalConversion);
if (exceptionState.hadException())
return;
@@ -842,7 +844,7 @@ static void partialCallWithExecutionContextLongAttributeAttributeSetter(v8::Loca
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface", "partialCallWithExecutionContextLongAttribute");
// Prepare the value to be set.
- int32_t cppValue = toInt32(info.GetIsolate(), v8Value, NormalConversion, exceptionState);
+ int32_t cppValue = NativeValueTraits<IDLLong>::nativeValue(info.GetIsolate(), v8Value, exceptionState, NormalConversion);
if (exceptionState.hadException())
return;
@@ -900,7 +902,7 @@ static void partialSecureContextLongAttributeAttributeSetter(v8::Local<v8::Value
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface", "partialSecureContextLongAttribute");
// Prepare the value to be set.
- int32_t cppValue = toInt32(info.GetIsolate(), v8Value, NormalConversion, exceptionState);
+ int32_t cppValue = NativeValueTraits<IDLLong>::nativeValue(info.GetIsolate(), v8Value, exceptionState, NormalConversion);
if (exceptionState.hadException())
return;
@@ -922,7 +924,7 @@ static void partial2LongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, c
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface", "partial2LongAttribute");
// Prepare the value to be set.
- int32_t cppValue = toInt32(info.GetIsolate(), v8Value, NormalConversion, exceptionState);
+ int32_t cppValue = NativeValueTraits<IDLLong>::nativeValue(info.GetIsolate(), v8Value, exceptionState, NormalConversion);
if (exceptionState.hadException())
return;
@@ -937,7 +939,7 @@ static void partial2StaticLongAttributeAttributeSetter(v8::Local<v8::Value> v8Va
ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterface", "partial2StaticLongAttribute");
// Prepare the value to be set.
- int32_t cppValue = toInt32(info.GetIsolate(), v8Value, NormalConversion, exceptionState);
+ int32_t cppValue = NativeValueTraits<IDLLong>::nativeValue(info.GetIsolate(), v8Value, exceptionState, NormalConversion);
if (exceptionState.hadException())
return;
@@ -1157,11 +1159,11 @@ static void voidMethodDoubleArgFloatArgMethod(const v8::FunctionCallbackInfo<v8:
double doubleArg;
float floatArg;
- doubleArg = toRestrictedDouble(info.GetIsolate(), info[0], exceptionState);
+ doubleArg = NativeValueTraits<IDLDouble>::nativeValue(info.GetIsolate(), info[0], exceptionState);
if (exceptionState.hadException())
return;
- floatArg = toRestrictedFloat(info.GetIsolate(), info[1], exceptionState);
+ floatArg = NativeValueTraits<IDLFloat>::nativeValue(info.GetIsolate(), info[1], exceptionState);
if (exceptionState.hadException())
return;
@@ -1180,11 +1182,11 @@ static void voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethod(const v8::
double unrestrictedDoubleArg;
float unrestrictedFloatArg;
- unrestrictedDoubleArg = toDouble(info.GetIsolate(), info[0], exceptionState);
+ unrestrictedDoubleArg = NativeValueTraits<IDLUnrestrictedDouble>::nativeValue(info.GetIsolate(), info[0], exceptionState);
if (exceptionState.hadException())
return;
- unrestrictedFloatArg = toFloat(info.GetIsolate(), info[1], exceptionState);
+ unrestrictedFloatArg = NativeValueTraits<IDLUnrestrictedFloat>::nativeValue(info.GetIsolate(), info[1], exceptionState);
if (exceptionState.hadException())
return;
@@ -1276,7 +1278,7 @@ static void overloadMethodWithExposedAndRuntimeEnabledFlag1Method(const v8::Func
TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder());
int32_t longArg;
- longArg = toInt32(info.GetIsolate(), info[0], NormalConversion, exceptionState);
+ longArg = NativeValueTraits<IDLLong>::nativeValue(info.GetIsolate(), info[0], exceptionState, NormalConversion);
if (exceptionState.hadException())
return;
@@ -1372,7 +1374,7 @@ static void voidMethodPartialOverload2Method(const v8::FunctionCallbackInfo<v8::
TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder());
double doubleArg;
- doubleArg = toRestrictedDouble(info.GetIsolate(), info[0], exceptionState);
+ doubleArg = NativeValueTraits<IDLDouble>::nativeValue(info.GetIsolate(), info[0], exceptionState);
if (exceptionState.hadException())
return;
@@ -1553,7 +1555,7 @@ static void partialVoidMethodLongArgMethod(const v8::FunctionCallbackInfo<v8::Va
}
int32_t longArg;
- longArg = toInt32(info.GetIsolate(), info[0], NormalConversion, exceptionState);
+ longArg = NativeValueTraits<IDLLong>::nativeValue(info.GetIsolate(), info[0], exceptionState, NormalConversion);
if (exceptionState.hadException())
return;
@@ -2785,6 +2787,10 @@ TestInterfaceImplementation* V8TestInterface::toImplWithTypeCheck(v8::Isolate* i
return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value)) : nullptr;
}
+TestInterfaceImplementation* NativeValueTraits<TestInterfaceImplementation>::nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionState) {
+ return V8TestInterface::toImplWithTypeCheck(isolate, value);
+}
+
void V8TestInterface::preparePrototypeAndInterfaceObject(v8::Local<v8::Context> context, const DOMWrapperWorld& world, v8::Local<v8::Object> prototypeObject, v8::Local<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> interfaceTemplate) {
v8::Isolate* isolate = context->GetIsolate();
v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemplate);

Powered by Google App Engine
This is Rietveld 408576698