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

Unified Diff: Source/bindings/tests/results/V8TestInterface.cpp

Issue 259773008: Add support for type checking of floating point arguments as [TypeChecking=Unrestricted] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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: Source/bindings/tests/results/V8TestInterface.cpp
diff --git a/Source/bindings/tests/results/V8TestInterface.cpp b/Source/bindings/tests/results/V8TestInterface.cpp
index ab358d90396692331bd471b6a6b97d22de40f495..c1f0d862f34dbefba42243cc847f3f379b728834 100644
--- a/Source/bindings/tests/results/V8TestInterface.cpp
+++ b/Source/bindings/tests/results/V8TestInterface.cpp
@@ -28,6 +28,7 @@
#include "platform/TraceEvent.h"
#include "wtf/GetPtr.h"
#include "wtf/RefPtr.h"
+#include "wtf/dtoa/double.h"
namespace WebCore {
@@ -88,6 +89,64 @@ static void testInterfaceAttributeAttributeSetterCallback(v8::Local<v8::String>,
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
+static void doubleAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
+{
+ v8::Handle<v8::Object> holder = info.Holder();
+ TestInterfaceImplementation* impl = V8TestInterface::toNative(holder);
+ v8SetReturnValue(info, impl->doubleAttribute());
+}
+
+static void doubleAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
+ TestInterfaceImplementationV8Internal::doubleAttributeAttributeGetter(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
+}
+
+static void doubleAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
+{
+ v8::Handle<v8::Object> holder = info.Holder();
+ TestInterfaceImplementation* impl = V8TestInterface::toNative(holder);
+ TONATIVE_VOID(double, cppValue, static_cast<double>(v8Value->NumberValue()));
+ impl->setDoubleAttribute(cppValue);
+}
+
+static void doubleAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
+ TestInterfaceImplementationV8Internal::doubleAttributeAttributeSetter(v8Value, info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
+}
+
+static void floatAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
+{
+ v8::Handle<v8::Object> holder = info.Holder();
+ TestInterfaceImplementation* impl = V8TestInterface::toNative(holder);
+ v8SetReturnValue(info, impl->floatAttribute());
+}
+
+static void floatAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
+ TestInterfaceImplementationV8Internal::floatAttributeAttributeGetter(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
+}
+
+static void floatAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
+{
+ v8::Handle<v8::Object> holder = info.Holder();
+ TestInterfaceImplementation* impl = V8TestInterface::toNative(holder);
+ TONATIVE_VOID(float, cppValue, static_cast<float>(v8Value->NumberValue()));
+ impl->setFloatAttribute(cppValue);
+}
+
+static void floatAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
+ TestInterfaceImplementationV8Internal::floatAttributeAttributeSetter(v8Value, info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
+}
+
static void staticStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
{
v8SetReturnValueString(info, TestInterfaceImplementation::staticStringAttribute(), info.GetIsolate());
@@ -757,6 +816,33 @@ static void voidMethodTestInterfaceEmptyArgMethodCallback(const v8::FunctionCall
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
+static void voidMethodDoubleArgFloatArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ if (UNLIKELY(info.Length() < 2)) {
+ throwArityTypeErrorForMethod("voidMethodDoubleArgFloatArg", "TestInterface", 2, info.Length(), info.GetIsolate());
+ return;
+ }
+ TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder());
+ if (info.Length() > 0 && WTF::double_conversion::Double(info[0]->NumberValue()).IsSpecial()) {
+ throwTypeError(ExceptionMessages::failedToExecute("voidMethodDoubleArgFloatArg", "TestInterface", "double parameter 1 is non-finite."), info.GetIsolate());
+ return;
+ }
+ TONATIVE_VOID(double, doubleArg, static_cast<double>(info[0]->NumberValue()));
+ if (info.Length() > 1 && WTF::double_conversion::Double(info[1]->NumberValue()).IsSpecial()) {
+ throwTypeError(ExceptionMessages::failedToExecute("voidMethodDoubleArgFloatArg", "TestInterface", "float parameter 2 is non-finite."), info.GetIsolate());
+ return;
+ }
+ TONATIVE_VOID(float, floatArg, static_cast<float>(info[1]->NumberValue()));
+ impl->voidMethodDoubleArgFloatArg(doubleArg, floatArg);
+}
+
+static void voidMethodDoubleArgFloatArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
+ TestInterfaceImplementationV8Internal::voidMethodDoubleArgFloatArgMethod(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
+}
+
static void voidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TestInterfaceImplementation* impl = V8TestInterface::toNative(info.Holder());
@@ -1184,6 +1270,8 @@ void V8TestInterface::visitDOMWrapper(void* object, const v8::Persistent<v8::Obj
static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceAttributes[] = {
{"testInterfaceAttribute", TestInterfaceImplementationV8Internal::testInterfaceAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::testInterfaceAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
{"testImplementedAsConstructorAttribute", TestInterfaceImplementationV8Internal::TestInterfaceImplementationConstructorGetter, TestInterfaceImplementationV8Internal::TestInterfaceImplementationReplaceableAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8TestImplementedAs::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), 0 /* on instance */},
+ {"doubleAttribute", TestInterfaceImplementationV8Internal::doubleAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::doubleAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
+ {"floatAttribute", TestInterfaceImplementationV8Internal::floatAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::floatAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
{"perWorldBindingsStringAttribute", TestInterfaceImplementationV8Internal::perWorldBindingsStringAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::perWorldBindingsStringAttributeAttributeSetterCallback, TestInterfaceImplementationV8Internal::perWorldBindingsStringAttributeAttributeGetterCallbackForMainWorld, TestInterfaceImplementationV8Internal::perWorldBindingsStringAttributeAttributeSetterCallbackForMainWorld, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
{"implementsReadonlyStringAttribute", TestInterfaceImplementationV8Internal::implementsReadonlyStringAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
{"implementsStringAttribute", TestInterfaceImplementationV8Internal::implementsStringAttributeAttributeGetterCallback, TestInterfaceImplementationV8Internal::implementsStringAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
@@ -1194,6 +1282,7 @@ static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceAttribute
static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceMethods[] = {
{"voidMethodTestInterfaceEmptyArg", TestInterfaceImplementationV8Internal::voidMethodTestInterfaceEmptyArgMethodCallback, 0, 1},
+ {"voidMethodDoubleArgFloatArg", TestInterfaceImplementationV8Internal::voidMethodDoubleArgFloatArgMethodCallback, 0, 2},
{"voidMethod", TestInterfaceImplementationV8Internal::voidMethodMethodCallback, TestInterfaceImplementationV8Internal::voidMethodMethodCallbackForMainWorld, 0},
{"implementsVoidMethod", TestInterfaceImplementationV8Internal::implementsVoidMethodMethodCallback, 0, 0},
{"implementsComplexMethod", TestInterfaceImplementationV8Internal::implementsComplexMethodMethodCallback, 0, 2},

Powered by Google App Engine
This is Rietveld 408576698