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

Side by Side Diff: Source/WebCore/bindings/dart/DartUtilities.h

Issue 9188009: Things to unfork. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
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<EventTarget> toEventTarget(Dart_Handle object, Dart_Handle & exception);
80 static void toMessagePortArray(Dart_Handle object, MessagePortArray&, Dart_H andle& exception);
81
82 static PassRefPtr<SerializedScriptValue> toSerializedScriptValue(Dart_Handle object, Dart_Handle& exception);
83 static Dart_Handle fromSerializedScriptValue(SerializedScriptValue*);
84
85 static void registerIsolateContext(Dart_Isolate, ScriptExecutionContext*);
86 static ScriptExecutionContext* isolateContext(Dart_Isolate);
87 static void unregisterIsolateContext(Dart_Isolate);
88 static bool isFullDomIsolate(Dart_Isolate);
89
90 static DOMWindow* domWindowForIsolate(Dart_Isolate);
91 static DOMWindow* domWindowForCurrentIsolate();
92
93 static Dart_Handle domLibraryForCurrentIsolate();
94 static Dart_Handle pageLibraryForCurrentIsolate();
95
96 static DartDOMMap* domMapForIsolate(Dart_Isolate);
97 static DartDOMMap* domMapForCurrentIsolate();
98
99 static int* recursionForIsolate(Dart_Isolate);
100 static int* recursionForCurrentIsolate();
101
102 static ScriptExecutionContext* scriptExecutionContext();
103
104 static bool processingUserGesture();
105
106 static PassRefPtr<ScriptArguments> createScriptArguments(Dart_Handle argumen t, Dart_Handle& exception);
107 static PassRefPtr<ScriptCallStack> createScriptCallStack();
108
109 static const uint8_t* fullSnapshot();
110
111 static void reportProblem(ScriptExecutionContext*, Dart_Handle);
112
113 static Dart_Handle invalidNumberOfArgumentsException()
114 {
115 return Dart_NewString("Invalid number of arguments");
116 }
117
118 static Dart_Handle conditionalFunctionalityException()
119 {
120 return Dart_NewString("Ooops, this functionality is not enabled in this browser");
121 }
122
123 static Dart_Handle notImplementedException()
124 {
125 Dart_Handle library = Dart_LookupLibrary(Dart_NewString(domLibraryName)) ;
126 ASSERT(!Dart_IsError(library));
127 Dart_Handle result = Dart_InvokeStatic(library, Dart_NewString("Utils"), Dart_NewString("makeNotImplementedException"), 0, 0);
128 ASSERT(!Dart_IsError(result));
129 return result;
130 }
131
132 static Dart_Handle domDisabledException()
133 {
134 return Dart_NewString("DOM access is not enabled in this isolate");
135 }
136
137 static Dart_Handle internalErrorException(const char* msg)
138 {
139 // FIXME: wrap into proper type.
140 return Dart_NewString(msg);
141 }
142 };
143
144 class DartApiScope {
145 public:
146 DartApiScope() { Dart_EnterScope(); }
147 ~DartApiScope() { Dart_ExitScope(); }
148 };
149
150 #define DART_UNIMPLEMENTED() Dart_ThrowException(DartUtilities::notImplementedEx ception());
151
152 } // namespace WebCore
153
154 #endif // DartUtilities_h
OLDNEW
« no previous file with comments | « Source/WebCore/bindings/dart/DartScheduledAction.cpp ('k') | Source/WebCore/bindings/dart/DartUtilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698