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

Unified Diff: Source/WebCore/bindings/dart/DartUtilities.cpp

Issue 9231022: WebGL support. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Final version. Created 8 years, 11 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/WebCore/bindings/dart/DartUtilities.cpp
diff --git a/Source/WebCore/bindings/dart/DartUtilities.cpp b/Source/WebCore/bindings/dart/DartUtilities.cpp
index 11f674e7facf3743e084478934eec29dab147eb9..56927609a05b3dc30b947722e23844b405ca066f 100644
--- a/Source/WebCore/bindings/dart/DartUtilities.cpp
+++ b/Source/WebCore/bindings/dart/DartUtilities.cpp
@@ -126,17 +126,63 @@ struct IntegerTrait {
}
};
-int64_t DartUtilities::toInteger(Dart_Handle object, Dart_Handle& exception)
+template <>
+double DartUtilities::toWebGLArrayElement<double>(Dart_Handle object, Dart_Handle& exception)
{
- return convert<IntegerTrait>(object, exception);
+ return DartUtilities::toDouble(object, exception);
}
-int64_t DartUtilities::toInteger(Dart_Handle object)
+template <>
+float DartUtilities::toWebGLArrayElement<float>(Dart_Handle object, Dart_Handle& exception)
{
- Dart_Handle exception = 0;
- int64_t value = DartUtilities::toInteger(object, exception);
- ASSERT(!exception);
- return value;
+ return DartUtilities::toDouble(object, exception);
+}
+
+template <>
+int8_t DartUtilities::toWebGLArrayElement<int8_t>(Dart_Handle object, Dart_Handle& exception)
+{
+ return DartUtilities::toInteger(object, exception);
+}
+
+template <>
+int16_t DartUtilities::toWebGLArrayElement<int16_t>(Dart_Handle object, Dart_Handle& exception)
+{
+ return DartUtilities::toInteger(object, exception);
+}
+
+template <>
+int32_t DartUtilities::toWebGLArrayElement<int32_t>(Dart_Handle object, Dart_Handle& exception)
+{
+ return DartUtilities::toInteger(object, exception);
+}
+
+template <>
+int64_t DartUtilities::toWebGLArrayElement<int64_t>(Dart_Handle object, Dart_Handle& exception)
+{
+ return DartUtilities::toInteger(object, exception);
+}
+
+template <>
+uint8_t DartUtilities::toWebGLArrayElement<uint8_t>(Dart_Handle object, Dart_Handle& exception)
+{
+ return DartUtilities::toInteger(object, exception);
+}
+
+template <>
+uint16_t DartUtilities::toWebGLArrayElement<uint16_t>(Dart_Handle object, Dart_Handle& exception)
+{
+ return DartUtilities::toInteger(object, exception);
+}
+
+template <>
+uint32_t DartUtilities::toWebGLArrayElement<uint32_t>(Dart_Handle object, Dart_Handle& exception)
+{
+ return DartUtilities::toInteger(object, exception);
+}
+
+int64_t DartUtilities::toInteger(Dart_Handle object, Dart_Handle& exception)
+{
+ return convert<IntegerTrait>(object, exception);
}
struct DoubleTrait {
@@ -146,9 +192,11 @@ struct DoubleTrait {
if (!Dart_IsNumber(object))
return Dart_Error("the object !is Number");
- object = Dart_InvokeDynamic(object, Dart_NewString("toDouble"), 0, 0);
- if (Dart_IsError(object))
- return object;
+ if (!Dart_IsDouble(object)) {
+ object = Dart_InvokeDynamic(object, Dart_NewString("toDouble"), 0, 0);
+ if (Dart_IsError(object))
+ return object;
+ }
return Dart_DoubleValue(object, value);
}
@@ -159,14 +207,6 @@ double DartUtilities::toDouble(Dart_Handle object, Dart_Handle& exception)
return convert<DoubleTrait>(object, exception);
}
-double DartUtilities::toDouble(Dart_Handle object)
-{
- Dart_Handle exception = 0;
- double value = DartUtilities::toDouble(object, exception);
- ASSERT(!exception);
- return value;
-}
-
struct BoolTrait {
typedef bool nativeType;
static Dart_Handle convert(Dart_Handle object, bool* value) { return Dart_BooleanValue(object, value); }
@@ -177,14 +217,6 @@ bool DartUtilities::toBool(Dart_Handle object, Dart_Handle& exception)
return convert<BoolTrait>(object, exception);
}
-bool DartUtilities::toBool(Dart_Handle object)
-{
- Dart_Handle exception = 0;
- bool value = DartUtilities::toBool(object, exception);
- ASSERT(!exception);
- return value;
-}
-
PassRefPtr<EventListener> DartUtilities::toEventListener(Dart_Handle object, Dart_Handle& exception)
{
if (Dart_IsNull(object)) {
@@ -246,11 +278,8 @@ void DartUtilities::toMessagePortArray(Dart_Handle value, MessagePortArray& port
ASSERT(!Dart_IsError(dom));
Dart_Handle asList = Dart_InvokeStatic(dom, Dart_NewString("Utils"), Dart_NewString("convertToList"), 1, &value);
- if (Dart_IsError(asList)) {
- DartUtilities::reportProblem(DartUtilities::scriptExecutionContext(), asList);
- exception = DartDOMWrapper::exceptionCodeToDartException(INVALID_STATE_ERR);
+ if (!checkResult(asList, exception))
return;
- }
ASSERT(Dart_IsList(asList));
intptr_t length = 0;
@@ -258,16 +287,12 @@ void DartUtilities::toMessagePortArray(Dart_Handle value, MessagePortArray& port
portArray.resize(length);
for (int i = 0; i < length; i++) {
Dart_Handle element = Dart_ListGetAt(asList, i);
- if (Dart_IsError(element)) {
- exception = DartDOMWrapper::exceptionCodeToDartException(INVALID_STATE_ERR);
+ if (!checkResult(element, exception))
return;
- }
MessagePort* messagePort = DartMessagePort::toNative(element, exception).get();
- if (exception) {
- exception = DartDOMWrapper::exceptionCodeToDartException(INVALID_STATE_ERR);
+ if (exception)
return;
- }
ASSERT(messagePort);
portArray[i] = messagePort;
« no previous file with comments | « Source/WebCore/bindings/dart/DartUtilities.h ('k') | Source/WebCore/bindings/dart/custom/DartArrayBufferCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698