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

Side by Side Diff: client/dom/templates/dom/wrapping/wrapping_dom.js

Issue 9362004: Remove JS from wrapping implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: unused templates Created 8 years, 10 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 (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 // DO NOT EDIT
6 // Auto-generated Dart DOM implementation.
7
8 $!CODE
9
10 function __dom_native_TimeoutHander_method(_this, callback, timeout, operation) {
11 try {
12 return _this.$dom[operation](__dom_unwrap_TimeoutHandler_function(callback),
13 __dom_unwrap(timeout));
14 } catch (e) {
15 throw __dom_wrap_exception(e);
16 }
17 }
18
19 function native__DOMWindowWrappingImplementation__setInterval(_this, callback, t imeout) {
20 return __dom_native_TimeoutHander_method(_this, callback, timeout, 'setInterva l');
21 }
22
23 function native__DOMWindowWrappingImplementation__setTimeout(_this, callback, ti meout) {
24 return __dom_native_TimeoutHander_method(_this, callback, timeout, 'setTimeout ');
25 }
26
27 function native__WorkerContextWrappingImplementation__setInterval(_this, callbac k, timeout) {
28 return __dom_native_TimeoutHander_method(_this, callback, timeout, 'setInterva l');
29 }
30
31 function native__WorkerContextWrappingImplementation__setTimeout(_this, callback , timeout) {
32 return __dom_native_TimeoutHander_method(_this, callback, timeout, 'setTimeout ');
33 }
34
35 function native__DOMWindowWrappingImplementation__get_localStorage(_this) {
36 var domWindow = _this.$dom;
37 try {
38 var isolatetoken = __dom_isolate_token();
39 var wrapper = __dom_get_cached('dart_storage', domWindow, isolatetoken);
40 if (wrapper) return wrapper;
41 wrapper = native__StorageWrappingImplementation_create__StorageWrappingImple mentation();
42 wrapper.$dom = domWindow.localStorage;
43 __dom_set_cached('dart_storage', domWindow, isolatetoken, wrapper)
44 return wrapper;
45 } catch (e) {
46 throw __dom_wrap_exception(e);
47 }
48 }
49
50 // Native methods for factory providers.
51
52 function native__AudioContextFactoryProvider_create() {
53 try {
54 var constructor = window.AudioContext || window.webkitAudioContext;
55 return __dom_wrap(new constructor());
56 } catch (e) {
57 throw __dom_wrap_exception(e);
58 }
59 }
60
61 function native__DOMParserFactoryProvider_create() {
62 try {
63 return __dom_wrap(new DOMParser());
64 } catch (e) {
65 throw __dom_wrap_exception(e);
66 }
67 }
68
69 function native__FileReaderFactoryProvider_create() {
70 try {
71 return __dom_wrap(new FileReader());
72 } catch (e) {
73 throw __dom_wrap_exception(e);
74 }
75 }
76
77 function native__TypedArrayFactoryProvider__F32(arg) {
78 try {
79 return __dom_wrap(new Float32Array(__dom_unwrap(arg)));
80 } catch (e) {
81 throw __dom_wrap_exception(e);
82 }
83 }
84
85 function native__TypedArrayFactoryProvider__F64(arg) {
86 try {
87 return __dom_wrap(new Float64Array(__dom_unwrap(arg)));
88 } catch (e) {
89 throw __dom_wrap_exception(e);
90 }
91 }
92
93 function native__TypedArrayFactoryProvider__I8(arg) {
94 try {
95 return __dom_wrap(new Int8Array(__dom_unwrap(arg)));
96 } catch (e) {
97 throw __dom_wrap_exception(e);
98 }
99 }
100
101 function native__TypedArrayFactoryProvider__I16(arg) {
102 try {
103 return __dom_wrap(new Int16Array(__dom_unwrap(arg)));
104 } catch (e) {
105 throw __dom_wrap_exception(e);
106 }
107 }
108
109 function native__TypedArrayFactoryProvider__I32(arg) {
110 try {
111 return __dom_wrap(new Int32Array(__dom_unwrap(arg)));
112 } catch (e) {
113 throw __dom_wrap_exception(e);
114 }
115 }
116
117 function native__TypedArrayFactoryProvider__U8(arg) {
118 try {
119 return __dom_wrap(new Uint8Array(__dom_unwrap(arg)));
120 } catch (e) {
121 throw __dom_wrap_exception(e);
122 }
123 }
124
125 function native__TypedArrayFactoryProvider__U16(arg) {
126 try {
127 return __dom_wrap(new Uint16Array(__dom_unwrap(arg)));
128 } catch (e) {
129 throw __dom_wrap_exception(e);
130 }
131 }
132
133 function native__TypedArrayFactoryProvider__U32(arg) {
134 try {
135 return __dom_wrap(new Uint32Array(__dom_unwrap(arg)));
136 } catch (e) {
137 throw __dom_wrap_exception(e);
138 }
139 }
140
141 function native__TypedArrayFactoryProvider__U8C(arg) {
142 try {
143 // Use array syntax because JSCompiler doesn't know this symbol.
144 return __dom_wrap(new window['Uint8ClampedArray'](__dom_unwrap(arg)));
145 } catch (e) {
146 throw __dom_wrap_exception(e);
147 }
148 }
149
150 function native__WebKitCSSMatrixFactoryProvider_create(spec) {
151 try {
152 return __dom_wrap(new WebKitCSSMatrix(spec)); // string doesn't need unwrap .
153 } catch (e) {
154 throw __dom_wrap_exception(e);
155 }
156 }
157
158 function native__WebKitPointFactoryProvider_create(x, y) {
159 try {
160 return __dom_wrap(new WebKitPoint(x, y)); // nums don't need unwrap.
161 } catch (e) {
162 throw __dom_wrap_exception(e);
163 }
164 }
165
166 function native__WebSocketFactoryProvider_create(url) {
167 try {
168 return __dom_wrap(new WebSocket(url)); // string doesn't need unwrap.
169 } catch (e) {
170 throw __dom_wrap_exception(e);
171 }
172 }
173
174 function native__XMLHttpRequestFactoryProvider_create() {
175 try {
176 return __dom_wrap(new XMLHttpRequest());
177 } catch (e) {
178 throw __dom_wrap_exception(e);
179 }
180 }
181
182
183 var __dom_type_map = {
184 $!MAP
185 // Patches for non-WebKit browsers
186 'Window': native__DOMWindowWrappingImplementation_create__DOMWindowWrappingImp lementation,
187 'global': native__DOMWindowWrappingImplementation_create__DOMWindowWrappingImp lementation,
188 'KeyEvent': native__KeyboardEventWrappingImplementation_create__KeyboardEventW rappingImplementation, // Opera
189 'HTMLPhraseElement': native__HTMLElementWrappingImplementation_create__HTMLEle mentWrappingImplementation, // IE9
190 'MSStyleCSSProperties': native__CSSStyleDeclarationWrappingImplementation_crea te__CSSStyleDeclarationWrappingImplementation // IE9
191 };
192
193 function __dom_get_class_chrome(ptr) {
194 return __dom_type_map[ptr.constructor.name];
195 }
196
197 function __dom_get_class_generic(ptr) {
198 var str = Object.prototype.toString.call(ptr);
199 var name = str.substring(8, str.length - 1);
200 var cls = __dom_type_map[name];
201 return cls;
202 }
203
204 if (Object.__proto__) {
205 __dom_get_class_generic = function(ptr) {
206 var isolatetoken = __dom_isolate_token();
207 var result = __dom_get_cached('dart_class', ptr.__proto__, isolatetoken);
208 if (result) {
209 return result;
210 }
211 var str = Object.prototype.toString.call(ptr);
212 var name = str.substring(8, str.length - 1);
213 var cls = __dom_type_map[name];
214 __dom_set_cached('dart_class', ptr.__proto__, isolatetoken, cls);
215 return cls;
216 }
217 }
218
219 var __dom_get_class = __dom_get_class_generic;
220 if (typeof window !== 'undefined' && // webworkers don't have a window
221 window.constructor.name == "DOMWindow") {
222 __dom_get_class = __dom_get_class_chrome;
223 }
224
225 function __dom_get_cached(hashtablename, obj, isolatetoken) {
226 if (!obj.hasOwnProperty(hashtablename)) return (void 0);
227 var hashtable = obj[hashtablename];
228 var hash = isolatetoken.hashCode;
229 // Issue 1005 part (1), may be undefined in CSSStyleDeclaration.
230 hashtable = hashtable || {};
231 while (true) {
232 var result = hashtable[hash];
233 if (result) {
234 if (result.$token === isolatetoken) {
235 return result;
236 } else {
237 hash++;
238 }
239 } else {
240 return (void 0);
241 }
242 }
243 }
244
245 function __dom_set_cached(hashtablename, obj, isolatetoken, value) {
246 var hashtable;
247 if (!obj.hasOwnProperty(hashtablename)) {
248 hashtable = {};
249 obj[hashtablename] = hashtable;
250 } else {
251 hashtable = obj[hashtablename];
252 if (!hashtable) obj[hashtablename] = hashtable = {}; // Issue 1005 part (1)
253 }
254 var hash = isolatetoken.hashCode;
255 while (true) {
256 var entry = hashtable[hash];
257 if (entry) {
258 if (entry.$token === isolatetoken) {
259 throw "Wrapper already exists for this object: " + obj;
260 } else {
261 hash++;
262 }
263 } else {
264 value.$token = isolatetoken;
265 hashtable[hash] = value;
266 return;
267 }
268 }
269 }
270
271 function __dom_isolate_token() {
272 return isolate$current.token;
273 }
274
275 /** @suppress {duplicate} */
276 function __dom_wrap(ptr) {
277 if (ptr == null) {
278 return (void 0);
279 }
280 var type = typeof(ptr);
281 if (type != "object" && type != "function") {
282 return ptr;
283 }
284 var isolatetoken = __dom_isolate_token();
285 var wrapper = __dom_get_cached('dart_wrapper', ptr, isolatetoken);
286 if (wrapper) {
287 return wrapper;
288 }
289 var factory = __dom_get_class(ptr);
290 if (!factory) {
291 return ptr;
292 }
293 wrapper = factory();
294 wrapper.$dom = ptr;
295 __dom_set_cached('dart_wrapper', ptr, isolatetoken, wrapper);
296 return wrapper;
297 }
298
299 function __dom_wrap_exception(e) {
300 return __dom_wrap(e);
301 }
302
303 function __dom_wrap_primitive(ptr) {
304 return (ptr === null) ? (void 0) : ptr;
305 }
306
307 /** @suppress {duplicate} */
308 function __dom_unwrap(obj, dropargs) {
309 if (obj == null) {
310 return (void 0);
311 }
312 if (obj.$dom) {
313 return obj.$dom;
314 }
315 if (obj instanceof Function) { // BUGBUG: function from other IFrame
316 var isolatetoken = __dom_isolate_token();
317 var unwrapped = __dom_get_cached('dart_unwrapped', obj, isolatetoken);
318 if (unwrapped) {
319 return unwrapped;
320 }
321 var isolate = isolate$current;
322 unwrapped = function () {
323 var old = isolate$current;
324 isolate$current = isolate;
325 try {
326 if (dropargs) {
327 return $dartcall(obj, []);
328 } else {
329 var args = Array.prototype.slice.call(arguments);
330 return $dartcall(obj, args.map(__dom_wrap));
331 }
332 } finally {
333 isolate$current = old;
334 // TODO(vsm): This really needs to go elsewhere.
335 isolate$runEventLoop();
336 }
337 // BUGBUG? Should the result be unwrapped? Or is it always void/bool ?
338 };
339 __dom_set_cached('dart_unwrapped', obj, isolatetoken, unwrapped);
340 return unwrapped;
341 }
342 return obj;
343 }
344
345 function __dom_unwrap_TimeoutHandler_function(fn) {
346 // Some browsers (e.g. FF) pass data to the timeout function, others do not.
347 // Dart's TimeoutHandler takes no arguments, so drop any arguments passed to
348 // the unwrapped callback.
349 return __dom_unwrap(fn, true);
350 }
351
352 // Declared in src/GlobalProperties.dart
353 function native__NativeDomGlobalProperties_getWindow() {
354 // TODO: Should the window be obtained from an isolate?
355 return __dom_wrap(window);
356 }
357
358 // Declared in src/GlobalProperties.dart
359 function native__NativeDomGlobalProperties_getDocument() {
360 // TODO: Should the window be obtained from an isolate?
361 return __dom_wrap(window.document);
362 }
OLDNEW
« no previous file with comments | « client/dom/scripts/dartgenerator.py ('k') | client/dom/templates/dom/wrapping/wrapping_dom_externs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698