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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2011, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 #ifndef DartUtilities_h
31 #define DartUtilities_h
32
33 #include "MessagePort.h"
34
35 #include <dart_api.h>
36 #include <wtf/HashMap.h>
37 #include <wtf/text/WTFString.h>
38
39 namespace WebCore {
40
41 class EventListener;
42 class EventTarget;
43 class Frame;
44 class ScriptArguments;
45 class ScriptCallStack;
46 class ScriptExecutionContext;
47 class SerializedScriptValue;
48
49 typedef HashMap<void*, Dart_Handle> DartDOMMap;
50
51 class DartUtilities {
52 public:
53 enum ConversionFlag {
54 ConvertNone = 0,
55 ConvertNullToEmptyString = 1
56 };
57
58 static const char* domLibraryName;
59
60 static PassRefPtr<StringImpl> toStringImpl(Dart_Handle, ConversionFlag flag, Dart_Handle& exception);
61 // FIXME: we should get rid of this one in favour of toStringImpl.
62 static String dartStringToString(Dart_Handle object)
63 {
64 Dart_Handle exception = 0;
65 RefPtr<StringImpl> impl = toStringImpl(object, ConvertNone, exception);
66 ASSERT(!exception);
67 return String(impl.release());
68 }
69 static Dart_Handle stringToDartString(const String&);
70 static Dart_Handle stringToDartString(const AtomicString&);
71
72 static int64_t toInteger(Dart_Handle object, Dart_Handle& exception);
73 static int64_t toInteger(Dart_Handle object);
74 static double toDouble(Dart_Handle object, Dart_Handle& exception);
75 static double toDouble(Dart_Handle object);
76 static bool toBool(Dart_Handle object, Dart_Handle& exception);
77 static bool toBool(Dart_Handle object);
78 static PassRefPtr<EventListener> toEventListener(Dart_Handle object, Dart_Ha ndle& exception);
79 static PassRefPtr<SerializedScriptValue> toSerializedScriptValue(Dart_Handle object, Dart_Handle& exception);
80 static PassRefPtr<EventTarget> toEventTarget(Dart_Handle object, Dart_Handle & exception);
81
82 static void toMessagePortArray(Dart_Handle object, MessagePortArray&, Dart_H andle& exception);
83
84 static void registerIsolateContext(Dart_Isolate, ScriptExecutionContext*);
85 static ScriptExecutionContext* isolateContext(Dart_Isolate);
86 static void unregisterIsolateContext(Dart_Isolate);
87 static bool isFullDomIsolate(Dart_Isolate);
88
89 static DOMWindow* domWindowForIsolate(Dart_Isolate);
90 static DOMWindow* domWindowForCurrentIsolate();
91
92 static Dart_Handle domLibraryForCurrentIsolate();
93 static Dart_Handle pageLibraryForCurrentIsolate();
94
95 static DartDOMMap* domMapForIsolate(Dart_Isolate);
96 static DartDOMMap* domMapForCurrentIsolate();
97
98 static int* recursionForIsolate(Dart_Isolate);
99 static int* recursionForCurrentIsolate();
100
101 static ScriptExecutionContext* scriptExecutionContext();
102
103 static bool processingUserGesture();
104
105 static PassRefPtr<ScriptArguments> createScriptArguments(Dart_Handle argumen t);
106 static PassRefPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize );
107
108 static void reportProblem(ScriptExecutionContext*, Dart_Handle);
109
110 static Dart_Handle invalidNumberOfArgumentsException()
111 {
112 return Dart_NewString("Invalid number of arguments");
113 }
114
115 static Dart_Handle conditionalFunctionalityException()
116 {
117 return Dart_NewString("Ooops, this functionality is not enabled in this browser");
118 }
119
120 static Dart_Handle notImplementedException()
121 {
122 Dart_Handle library = Dart_LookupLibrary(Dart_NewString(domLibraryName)) ;
123 ASSERT(!Dart_IsError(library));
124 Dart_Handle result = Dart_InvokeStatic(library, Dart_NewString("Utils"), Dart_NewString("makeNotImplementedException"), 0, 0);
125 ASSERT(!Dart_IsError(result));
126 return result;
127 }
128
129 static Dart_Handle domDisabledException()
130 {
131 return Dart_NewString("DOM access is not enabled in this isolate");
132 }
133 };
134
135 class DartApiScope {
136 public:
137 DartApiScope() { Dart_EnterScope(); }
138 ~DartApiScope() { Dart_ExitScope(); }
139 };
140
141 #define DART_UNIMPLEMENTED() Dart_ThrowException(DartUtilities::notImplementedEx ception());
142
143 } // namespace WebCore
144
145 #endif // DartUtilities_h
OLDNEW
« 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