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

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

Issue 8802010: Dart bindings for WebKit (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk
Patch Set: Created 9 years 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.h
diff --git a/Source/WebCore/bindings/dart/DartUtilities.h b/Source/WebCore/bindings/dart/DartUtilities.h
new file mode 100644
index 0000000000000000000000000000000000000000..671d8b0371aaa53582a01623e5cb4c7a2cbca605
--- /dev/null
+++ b/Source/WebCore/bindings/dart/DartUtilities.h
@@ -0,0 +1,145 @@
+// Copyright 2011, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef DartUtilities_h
+#define DartUtilities_h
+
+#include "MessagePort.h"
+
+#include <dart_api.h>
+#include <wtf/HashMap.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class EventListener;
+class EventTarget;
+class Frame;
+class ScriptArguments;
+class ScriptCallStack;
+class ScriptExecutionContext;
+class SerializedScriptValue;
+
+typedef HashMap<void*, Dart_Handle> DartDOMMap;
+
+class DartUtilities {
+public:
+ enum ConversionFlag {
+ ConvertNone = 0,
+ ConvertNullToEmptyString = 1
+ };
+
+ static const char* domLibraryName;
+
+ static PassRefPtr<StringImpl> toStringImpl(Dart_Handle, ConversionFlag flag, Dart_Handle& exception);
+ // FIXME: we should get rid of this one in favour of toStringImpl.
+ static String dartStringToString(Dart_Handle object)
+ {
+ Dart_Handle exception = 0;
+ RefPtr<StringImpl> impl = toStringImpl(object, ConvertNone, exception);
+ ASSERT(!exception);
+ return String(impl.release());
+ }
+ static Dart_Handle stringToDartString(const String&);
+ static Dart_Handle stringToDartString(const AtomicString&);
+
+ static int64_t toInteger(Dart_Handle object, Dart_Handle& exception);
+ static int64_t toInteger(Dart_Handle object);
+ static double toDouble(Dart_Handle object, Dart_Handle& exception);
+ static double toDouble(Dart_Handle object);
+ static bool toBool(Dart_Handle object, Dart_Handle& exception);
+ static bool toBool(Dart_Handle object);
+ static PassRefPtr<EventListener> toEventListener(Dart_Handle object, Dart_Handle& exception);
+ static PassRefPtr<SerializedScriptValue> toSerializedScriptValue(Dart_Handle object, Dart_Handle& exception);
+ static PassRefPtr<EventTarget> toEventTarget(Dart_Handle object, Dart_Handle& exception);
+
+ static void toMessagePortArray(Dart_Handle object, MessagePortArray&, Dart_Handle& exception);
+
+ static void registerIsolateContext(Dart_Isolate, ScriptExecutionContext*);
+ static ScriptExecutionContext* isolateContext(Dart_Isolate);
+ static void unregisterIsolateContext(Dart_Isolate);
+ static bool isFullDomIsolate(Dart_Isolate);
+
+ static DOMWindow* domWindowForIsolate(Dart_Isolate);
+ static DOMWindow* domWindowForCurrentIsolate();
+
+ static Dart_Handle domLibraryForCurrentIsolate();
+ static Dart_Handle pageLibraryForCurrentIsolate();
+
+ static DartDOMMap* domMapForIsolate(Dart_Isolate);
+ static DartDOMMap* domMapForCurrentIsolate();
+
+ static int* recursionForIsolate(Dart_Isolate);
+ static int* recursionForCurrentIsolate();
+
+ static ScriptExecutionContext* scriptExecutionContext();
+
+ static bool processingUserGesture();
+
+ static PassRefPtr<ScriptArguments> createScriptArguments(Dart_Handle argument);
+ static PassRefPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize);
+
+ static void reportProblem(ScriptExecutionContext*, Dart_Handle);
+
+ static Dart_Handle invalidNumberOfArgumentsException()
+ {
+ return Dart_NewString("Invalid number of arguments");
+ }
+
+ static Dart_Handle conditionalFunctionalityException()
+ {
+ return Dart_NewString("Ooops, this functionality is not enabled in this browser");
+ }
+
+ static Dart_Handle notImplementedException()
+ {
+ Dart_Handle library = Dart_LookupLibrary(Dart_NewString(domLibraryName));
+ ASSERT(!Dart_IsError(library));
+ Dart_Handle result = Dart_InvokeStatic(library, Dart_NewString("Utils"), Dart_NewString("makeNotImplementedException"), 0, 0);
+ ASSERT(!Dart_IsError(result));
+ return result;
+ }
+
+ static Dart_Handle domDisabledException()
+ {
+ return Dart_NewString("DOM access is not enabled in this isolate");
+ }
+};
+
+class DartApiScope {
+public:
+ DartApiScope() { Dart_EnterScope(); }
+ ~DartApiScope() { Dart_ExitScope(); }
+};
+
+#define DART_UNIMPLEMENTED() Dart_ThrowException(DartUtilities::notImplementedException());
+
+} // namespace WebCore
+
+#endif // DartUtilities_h
« no previous file with comments | « Source/WebCore/bindings/dart/DartScriptValueSerializer.cpp ('k') | Source/WebCore/bindings/dart/DartUtilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698