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

Side by Side Diff: sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart

Issue 11434079: Adding dart:indexed_db. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks. Created 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 library indexed_db;
2
3 import 'dart:html';
4 import 'dart:html_common';
5 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
6 // for details. All rights reserved. Use of this source code is governed by a
7 // BSD-style license that can be found in the LICENSE file.
8
9 // DO NOT EDIT
10 // Auto-generated dart:svg library.
11
12
13
14
15
16
17 /**
18 * Converts a native IDBKey into a Dart object.
19 *
20 * May return the original input. May mutate the original input (but will be
21 * idempotent if mutation occurs). It is assumed that this conversion happens
22 * on native IDBKeys on all paths that return IDBKeys from native DOM calls.
23 *
24 * If necessary, JavaScript Dates are converted into Dart Dates.
25 */
26 _convertNativeToDart_IDBKey(nativeKey) {
27 containsDate(object) {
28 if (isJavaScriptDate(object)) return true;
29 if (object is List) {
30 for (int i = 0; i < object.length; i++) {
31 if (containsDate(object[i])) return true;
32 }
33 }
34 return false; // number, string.
35 }
36 if (containsDate(nativeKey)) {
37 throw new UnimplementedError('Key containing Date');
38 }
39 // TODO: Cache conversion somewhere?
40 return nativeKey;
41 }
42
43 /**
44 * Converts a Dart object into a valid IDBKey.
45 *
46 * May return the original input. Does not mutate input.
47 *
48 * If necessary, [dartKey] may be copied to ensure all lists are converted into
49 * JavaScript Arrays and Dart Dates into JavaScript Dates.
50 */
51 _convertDartToNative_IDBKey(dartKey) {
52 // TODO: Implement.
53 return dartKey;
54 }
55
56
57
58 /// May modify original. If so, action is idempotent.
59 _convertNativeToDart_IDBAny(object) {
60 return convertNativeToDart_AcceptStructuredClone(object, mustCopy: false);
61 }
62
63
64 const String _idbKey = '=List|=Object|num|String'; // TODO(sra): Add Date.
65 const _annotation_Creates_IDBKey = const Creates(_idbKey);
66 const _annotation_Returns_IDBKey = const Returns(_idbKey);
67 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
68 // for details. All rights reserved. Use of this source code is governed by a
69 // BSD-style license that can be found in the LICENSE file.
70
71
72 class _KeyRangeFactoryProvider {
73
74 static KeyRange createKeyRange_only(/*Key*/ value) =>
75 _only(_class(), _translateKey(value));
76
77 static KeyRange createKeyRange_lowerBound(
78 /*Key*/ bound, [bool open = false]) =>
79 _lowerBound(_class(), _translateKey(bound), open);
80
81 static KeyRange createKeyRange_upperBound(
82 /*Key*/ bound, [bool open = false]) =>
83 _upperBound(_class(), _translateKey(bound), open);
84
85 static KeyRange createKeyRange_bound(/*Key*/ lower, /*Key*/ upper,
86 [bool lowerOpen = false, bool upperOpen = false]) =>
87 _bound(_class(), _translateKey(lower), _translateKey(upper),
88 lowerOpen, upperOpen);
89
90 static var _cachedClass;
91
92 static _class() {
93 if (_cachedClass != null) return _cachedClass;
94 return _cachedClass = _uncachedClass();
95 }
96
97 static _uncachedClass() =>
98 JS('var',
99 '''window.webkitIDBKeyRange || window.mozIDBKeyRange ||
100 window.msIDBKeyRange || window.IDBKeyRange''');
101
102 static _translateKey(idbkey) => idbkey; // TODO: fixme.
103
104 static KeyRange _only(cls, value) =>
105 JS('KeyRange', '#.only(#)', cls, value);
106
107 static KeyRange _lowerBound(cls, bound, open) =>
108 JS('KeyRange', '#.lowerBound(#, #)', cls, bound, open);
109
110 static KeyRange _upperBound(cls, bound, open) =>
111 JS('KeyRange', '#.upperBound(#, #)', cls, bound, open);
112
113 static KeyRange _bound(cls, lower, upper, lowerOpen, upperOpen) =>
114 JS('KeyRange', '#.bound(#, #, #, #)',
115 cls, lower, upper, lowerOpen, upperOpen);
116 }
117 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
118 // for details. All rights reserved. Use of this source code is governed by a
119 // BSD-style license that can be found in the LICENSE file.
120
121
122 /// @domName IDBAny; @docsEditable true
123 class Any native "*IDBAny" {
sra1 2012/12/03 21:15:30 We should get rid of this. While it exists at the
blois 2012/12/03 21:21:52 Opened bug 7116 to track.
124 }
125 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
126 // for details. All rights reserved. Use of this source code is governed by a
127 // BSD-style license that can be found in the LICENSE file.
128
129
130 /// @domName IDBCursor; @docsEditable true
131 class Cursor native "*IDBCursor" {
132
133 static const int NEXT = 0;
134
135 static const int NEXT_NO_DUPLICATE = 1;
136
137 static const int PREV = 2;
138
139 static const int PREV_NO_DUPLICATE = 3;
140
141 /// @domName IDBCursor.direction; @docsEditable true
142 final String direction;
143
144 /// @domName IDBCursor.key; @docsEditable true
145 @_annotation_Creates_IDBKey @_annotation_Returns_IDBKey
146 final Object key;
147
148 /// @domName IDBCursor.primaryKey; @docsEditable true
149 final Object primaryKey;
150
151 /// @domName IDBCursor.source; @docsEditable true
152 final dynamic source;
153
154 /// @domName IDBCursor.advance; @docsEditable true
155 void advance(int count) native;
156
157 /// @domName IDBCursor.continueFunction; @docsEditable true
158 void continueFunction([/*IDBKey*/ key]) {
159 if (?key) {
160 var key_1 = _convertDartToNative_IDBKey(key);
161 _continueFunction_1(key_1);
162 return;
163 }
164 _continueFunction_2();
165 return;
166 }
167 @JSName('continue')
168 void _continueFunction_1(key) native;
169 @JSName('continue')
170 void _continueFunction_2() native;
171
172 /// @domName IDBCursor.delete; @docsEditable true
173 Request delete() native;
174
175 /// @domName IDBCursor.update; @docsEditable true
176 Request update(/*any*/ value) {
177 var value_1 = convertDartToNative_SerializedScriptValue(value);
178 return _update_1(value_1);
179 }
180 @JSName('update')
181 Request _update_1(value) native;
182 }
183 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
184 // for details. All rights reserved. Use of this source code is governed by a
185 // BSD-style license that can be found in the LICENSE file.
186
187
188 /// @domName IDBCursorWithValue; @docsEditable true
189 class CursorWithValue extends Cursor native "*IDBCursorWithValue" {
190
191 /// @domName IDBCursorWithValue.value; @docsEditable true
192 @annotation_Creates_SerializedScriptValue @annotation_Returns_SerializedScript Value
193 final Object value;
194 }
195 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
196 // for details. All rights reserved. Use of this source code is governed by a
197 // BSD-style license that can be found in the LICENSE file.
198
199
200 /// @domName IDBDatabase
201 class Database extends EventTarget native "*IDBDatabase" {
202
203 Transaction transaction(storeName_OR_storeNames, String mode) {
204 if (mode != 'readonly' && mode != 'readwrite') {
205 throw new ArgumentError(mode);
206 }
207
208 // TODO(sra): Ensure storeName_OR_storeNames is a string or List<String>,
209 // and copy to JavaScript array if necessary.
210
211 if (_transaction_fn != null) {
212 return _transaction_fn(this, storeName_OR_storeNames, mode);
213 }
214
215 // Try and create a transaction with a string mode. Browsers that expect a
216 // numeric mode tend to convert the string into a number. This fails
217 // silently, resulting in zero ('readonly').
218 var txn = _transaction(storeName_OR_storeNames, mode);
219 if (_hasNumericMode(txn)) {
220 _transaction_fn = _transaction_numeric_mode;
221 txn = _transaction_fn(this, storeName_OR_storeNames, mode);
222 } else {
223 _transaction_fn = _transaction_string_mode;
224 }
225 return txn;
226 }
227
228 static Transaction _transaction_string_mode(Database db, stores, mode) {
229 return db._transaction(stores, mode);
230 }
231
232 static Transaction _transaction_numeric_mode(Database db, stores, mode) {
233 int intMode;
234 if (mode == 'readonly') intMode = Transaction.READ_ONLY;
235 if (mode == 'readwrite') intMode = Transaction.READ_WRITE;
236 return db._transaction(stores, intMode);
237 }
238
239 @JSName('transaction')
240 Transaction _transaction(stores, mode) native;
241
242 static bool _hasNumericMode(txn) =>
243 JS('bool', 'typeof(#.mode) === "number"', txn);
244
245
246 /// @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev entTarget.dispatchEvent; @docsEditable true
247 DatabaseEvents get on =>
248 new DatabaseEvents(this);
249
250 /// @domName IDBDatabase.name; @docsEditable true
251 final String name;
252
253 /// @domName IDBDatabase.objectStoreNames; @docsEditable true
254 @Returns('_DOMStringList') @Creates('_DOMStringList')
255 final List<String> objectStoreNames;
256
257 /// @domName IDBDatabase.version; @docsEditable true
258 final dynamic version;
259
260 /// @domName IDBDatabase.addEventListener; @docsEditable true
261 @JSName('addEventListener')
262 void $dom_addEventListener(String type, EventListener listener, [bool useCaptu re]) native;
263
264 /// @domName IDBDatabase.close; @docsEditable true
265 void close() native;
266
267 /// @domName IDBDatabase.createObjectStore; @docsEditable true
268 ObjectStore createObjectStore(String name, [Map options]) {
269 if (?options) {
270 var options_1 = convertDartToNative_Dictionary(options);
271 return _createObjectStore_1(name, options_1);
272 }
273 return _createObjectStore_2(name);
274 }
275 @JSName('createObjectStore')
276 ObjectStore _createObjectStore_1(name, options) native;
277 @JSName('createObjectStore')
278 ObjectStore _createObjectStore_2(name) native;
279
280 /// @domName IDBDatabase.deleteObjectStore; @docsEditable true
281 void deleteObjectStore(String name) native;
282
283 /// @domName IDBDatabase.dispatchEvent; @docsEditable true
284 @JSName('dispatchEvent')
285 bool $dom_dispatchEvent(Event evt) native;
286
287 /// @domName IDBDatabase.removeEventListener; @docsEditable true
288 @JSName('removeEventListener')
289 void $dom_removeEventListener(String type, EventListener listener, [bool useCa pture]) native;
290
291 /// @domName IDBDatabase.setVersion; @docsEditable true
292 VersionChangeRequest setVersion(String version) native;
293 }
294
295 // TODO(sra): This should be a static member of IDBTransaction but dart2js
296 // can't handle that. Move it back after dart2js is completely done.
297 var _transaction_fn; // Assigned one of the static methods.
298
299 class DatabaseEvents extends Events {
300 DatabaseEvents(EventTarget _ptr) : super(_ptr);
301
302 EventListenerList get abort => this['abort'];
303
304 EventListenerList get error => this['error'];
305
306 EventListenerList get versionChange => this['versionchange'];
307 }
308 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
309 // for details. All rights reserved. Use of this source code is governed by a
310 // BSD-style license that can be found in the LICENSE file.
311
312
313 /// @domName IDBDatabaseException; @docsEditable true
314 class DatabaseException native "*IDBDatabaseException" {
315
316 static const int ABORT_ERR = 20;
317
318 static const int CONSTRAINT_ERR = 4;
319
320 static const int DATA_ERR = 5;
321
322 static const int NON_TRANSIENT_ERR = 2;
323
324 static const int NOT_ALLOWED_ERR = 6;
325
326 static const int NOT_FOUND_ERR = 8;
327
328 static const int NO_ERR = 0;
329
330 static const int QUOTA_ERR = 22;
331
332 static const int READ_ONLY_ERR = 9;
333
334 static const int TIMEOUT_ERR = 23;
335
336 static const int TRANSACTION_INACTIVE_ERR = 7;
337
338 static const int UNKNOWN_ERR = 1;
339
340 static const int VER_ERR = 12;
341
342 /// @domName IDBDatabaseException.code; @docsEditable true
343 final int code;
344
345 /// @domName IDBDatabaseException.message; @docsEditable true
346 final String message;
347
348 /// @domName IDBDatabaseException.name; @docsEditable true
349 final String name;
350
351 /// @domName IDBDatabaseException.toString; @docsEditable true
352 String toString() native;
353 }
354 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
355 // for details. All rights reserved. Use of this source code is governed by a
356 // BSD-style license that can be found in the LICENSE file.
357
358
359 /// @domName IDBFactory; @docsEditable true
360 class IdbFactory native "*IDBFactory" {
361
362 /// @domName IDBFactory.cmp; @docsEditable true
363 int cmp(/*IDBKey*/ first, /*IDBKey*/ second) {
364 var first_1 = _convertDartToNative_IDBKey(first);
365 var second_2 = _convertDartToNative_IDBKey(second);
366 return _cmp_1(first_1, second_2);
367 }
368 @JSName('cmp')
369 int _cmp_1(first, second) native;
370
371 /// @domName IDBFactory.deleteDatabase; @docsEditable true
372 VersionChangeRequest deleteDatabase(String name) native;
373
374 /// @domName IDBFactory.open; @docsEditable true
375 @Returns('Request') @Creates('Request') @Creates('Database')
376 OpenDBRequest open(String name, [int version]) native;
377
378 /// @domName IDBFactory.webkitGetDatabaseNames; @docsEditable true
379 Request webkitGetDatabaseNames() native;
380 }
381 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
382 // for details. All rights reserved. Use of this source code is governed by a
383 // BSD-style license that can be found in the LICENSE file.
384
385
386 /// @domName IDBIndex; @docsEditable true
387 class Index native "*IDBIndex" {
388
389 /// @domName IDBIndex.keyPath; @docsEditable true
390 final dynamic keyPath;
391
392 /// @domName IDBIndex.multiEntry; @docsEditable true
393 final bool multiEntry;
394
395 /// @domName IDBIndex.name; @docsEditable true
396 final String name;
397
398 /// @domName IDBIndex.objectStore; @docsEditable true
399 final ObjectStore objectStore;
400
401 /// @domName IDBIndex.unique; @docsEditable true
402 final bool unique;
403
404 /// @domName IDBIndex.count; @docsEditable true
405 Request count([key_OR_range]) {
406 if (!?key_OR_range) {
407 return _count_1();
408 }
409 if ((?key_OR_range && (key_OR_range is KeyRange || key_OR_range == null))) {
410 return _count_2(key_OR_range);
411 }
412 if (?key_OR_range) {
413 var key_1 = _convertDartToNative_IDBKey(key_OR_range);
414 return _count_3(key_1);
415 }
416 throw new ArgumentError("Incorrect number or type of arguments");
417 }
418 @JSName('count')
419 Request _count_1() native;
420 @JSName('count')
421 Request _count_2(KeyRange range) native;
422 @JSName('count')
423 Request _count_3(key) native;
424
425 /// @domName IDBIndex.get; @docsEditable true
426 Request get(key) {
427 if ((?key && (key is KeyRange || key == null))) {
428 return _get_1(key);
429 }
430 if (?key) {
431 var key_1 = _convertDartToNative_IDBKey(key);
432 return _get_2(key_1);
433 }
434 throw new ArgumentError("Incorrect number or type of arguments");
435 }
436 @JSName('get')
437 @Returns('Request') @Creates('Request') @annotation_Creates_SerializedScriptVa lue
438 Request _get_1(KeyRange key) native;
439 @JSName('get')
440 @Returns('Request') @Creates('Request') @annotation_Creates_SerializedScriptVa lue
441 Request _get_2(key) native;
442
443 /// @domName IDBIndex.getKey; @docsEditable true
444 Request getKey(key) {
445 if ((?key && (key is KeyRange || key == null))) {
446 return _getKey_1(key);
447 }
448 if (?key) {
449 var key_1 = _convertDartToNative_IDBKey(key);
450 return _getKey_2(key_1);
451 }
452 throw new ArgumentError("Incorrect number or type of arguments");
453 }
454 @JSName('getKey')
455 @Returns('Request') @Creates('Request') @annotation_Creates_SerializedScriptVa lue @Creates('ObjectStore')
456 Request _getKey_1(KeyRange key) native;
457 @JSName('getKey')
458 @Returns('Request') @Creates('Request') @annotation_Creates_SerializedScriptVa lue @Creates('ObjectStore')
459 Request _getKey_2(key) native;
460
461 /// @domName IDBIndex.openCursor; @docsEditable true
462 Request openCursor([key_OR_range, String direction]) {
463 if (!?key_OR_range &&
464 !?direction) {
465 return _openCursor_1();
466 }
467 if ((?key_OR_range && (key_OR_range is KeyRange || key_OR_range == null)) &&
468 !?direction) {
469 return _openCursor_2(key_OR_range);
470 }
471 if ((?key_OR_range && (key_OR_range is KeyRange || key_OR_range == null))) {
472 return _openCursor_3(key_OR_range, direction);
473 }
474 if (?key_OR_range &&
475 !?direction) {
476 var key_1 = _convertDartToNative_IDBKey(key_OR_range);
477 return _openCursor_4(key_1);
478 }
479 if (?key_OR_range) {
480 var key_2 = _convertDartToNative_IDBKey(key_OR_range);
481 return _openCursor_5(key_2, direction);
482 }
483 throw new ArgumentError("Incorrect number or type of arguments");
484 }
485 @JSName('openCursor')
486 @Returns('Request') @Creates('Request') @Creates('Cursor')
487 Request _openCursor_1() native;
488 @JSName('openCursor')
489 @Returns('Request') @Creates('Request') @Creates('Cursor')
490 Request _openCursor_2(KeyRange range) native;
491 @JSName('openCursor')
492 @Returns('Request') @Creates('Request') @Creates('Cursor')
493 Request _openCursor_3(KeyRange range, direction) native;
494 @JSName('openCursor')
495 @Returns('Request') @Creates('Request') @Creates('Cursor')
496 Request _openCursor_4(key) native;
497 @JSName('openCursor')
498 @Returns('Request') @Creates('Request') @Creates('Cursor')
499 Request _openCursor_5(key, direction) native;
500
501 /// @domName IDBIndex.openKeyCursor; @docsEditable true
502 Request openKeyCursor([key_OR_range, String direction]) {
503 if (!?key_OR_range &&
504 !?direction) {
505 return _openKeyCursor_1();
506 }
507 if ((?key_OR_range && (key_OR_range is KeyRange || key_OR_range == null)) &&
508 !?direction) {
509 return _openKeyCursor_2(key_OR_range);
510 }
511 if ((?key_OR_range && (key_OR_range is KeyRange || key_OR_range == null))) {
512 return _openKeyCursor_3(key_OR_range, direction);
513 }
514 if (?key_OR_range &&
515 !?direction) {
516 var key_1 = _convertDartToNative_IDBKey(key_OR_range);
517 return _openKeyCursor_4(key_1);
518 }
519 if (?key_OR_range) {
520 var key_2 = _convertDartToNative_IDBKey(key_OR_range);
521 return _openKeyCursor_5(key_2, direction);
522 }
523 throw new ArgumentError("Incorrect number or type of arguments");
524 }
525 @JSName('openKeyCursor')
526 @Returns('Request') @Creates('Request') @Creates('Cursor')
527 Request _openKeyCursor_1() native;
528 @JSName('openKeyCursor')
529 @Returns('Request') @Creates('Request') @Creates('Cursor')
530 Request _openKeyCursor_2(KeyRange range) native;
531 @JSName('openKeyCursor')
532 @Returns('Request') @Creates('Request') @Creates('Cursor')
533 Request _openKeyCursor_3(KeyRange range, direction) native;
534 @JSName('openKeyCursor')
535 @Returns('Request') @Creates('Request') @Creates('Cursor')
536 Request _openKeyCursor_4(key) native;
537 @JSName('openKeyCursor')
538 @Returns('Request') @Creates('Request') @Creates('Cursor')
539 Request _openKeyCursor_5(key, direction) native;
540 }
541 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
542 // for details. All rights reserved. Use of this source code is governed by a
543 // BSD-style license that can be found in the LICENSE file.
544
545
546 /// @domName IDBKey; @docsEditable true
547 class Key native "*IDBKey" {
548 }
549 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
550 // for details. All rights reserved. Use of this source code is governed by a
551 // BSD-style license that can be found in the LICENSE file.
552
553
554 /// @domName IDBKeyRange
555 class KeyRange native "*IDBKeyRange" {
556 /**
557 * @domName IDBKeyRange.only
558 */
559 factory KeyRange.only(/*Key*/ value) =>
560 _KeyRangeFactoryProvider.createKeyRange_only(value);
561
562 /**
563 * @domName IDBKeyRange.lowerBound
564 */
565 factory KeyRange.lowerBound(/*Key*/ bound, [bool open = false]) =>
566 _KeyRangeFactoryProvider.createKeyRange_lowerBound(bound, open);
567
568 /**
569 * @domName IDBKeyRange.upperBound
570 */
571 factory KeyRange.upperBound(/*Key*/ bound, [bool open = false]) =>
572 _KeyRangeFactoryProvider.createKeyRange_upperBound(bound, open);
573
574 /**
575 * @domName KeyRange.bound
576 */
577 factory KeyRange.bound(/*Key*/ lower, /*Key*/ upper,
578 [bool lowerOpen = false, bool upperOpen = false]) =>
579 _KeyRangeFactoryProvider.createKeyRange_bound(
580 lower, upper, lowerOpen, upperOpen);
581
582
583 /// @domName IDBKeyRange.lower; @docsEditable true
584 dynamic get lower => _convertNativeToDart_IDBKey(this._lower);
585 @JSName('lower')
586 final dynamic _lower;
587
588 /// @domName IDBKeyRange.lowerOpen; @docsEditable true
589 final bool lowerOpen;
590
591 /// @domName IDBKeyRange.upper; @docsEditable true
592 dynamic get upper => _convertNativeToDart_IDBKey(this._upper);
593 @JSName('upper')
594 final dynamic _upper;
595
596 /// @domName IDBKeyRange.upperOpen; @docsEditable true
597 final bool upperOpen;
598
599 /// @domName IDBKeyRange.bound_; @docsEditable true
600 static KeyRange bound_(/*IDBKey*/ lower, /*IDBKey*/ upper, [bool lowerOpen, bo ol upperOpen]) {
601 if (?upperOpen) {
602 var lower_1 = _convertDartToNative_IDBKey(lower);
603 var upper_2 = _convertDartToNative_IDBKey(upper);
604 return _bound__1(lower_1, upper_2, lowerOpen, upperOpen);
605 }
606 if (?lowerOpen) {
607 var lower_3 = _convertDartToNative_IDBKey(lower);
608 var upper_4 = _convertDartToNative_IDBKey(upper);
609 return _bound__2(lower_3, upper_4, lowerOpen);
610 }
611 var lower_5 = _convertDartToNative_IDBKey(lower);
612 var upper_6 = _convertDartToNative_IDBKey(upper);
613 return _bound__3(lower_5, upper_6);
614 }
615 @JSName('bound')
616 static KeyRange _bound__1(lower, upper, lowerOpen, upperOpen) native;
617 @JSName('bound')
618 static KeyRange _bound__2(lower, upper, lowerOpen) native;
619 @JSName('bound')
620 static KeyRange _bound__3(lower, upper) native;
621
622 /// @domName IDBKeyRange.lowerBound_; @docsEditable true
623 static KeyRange lowerBound_(/*IDBKey*/ bound, [bool open]) {
624 if (?open) {
625 var bound_1 = _convertDartToNative_IDBKey(bound);
626 return _lowerBound__1(bound_1, open);
627 }
628 var bound_2 = _convertDartToNative_IDBKey(bound);
629 return _lowerBound__2(bound_2);
630 }
631 @JSName('lowerBound')
632 static KeyRange _lowerBound__1(bound, open) native;
633 @JSName('lowerBound')
634 static KeyRange _lowerBound__2(bound) native;
635
636 /// @domName IDBKeyRange.only_; @docsEditable true
637 static KeyRange only_(/*IDBKey*/ value) {
638 var value_1 = _convertDartToNative_IDBKey(value);
639 return _only__1(value_1);
640 }
641 @JSName('only')
642 static KeyRange _only__1(value) native;
643
644 /// @domName IDBKeyRange.upperBound_; @docsEditable true
645 static KeyRange upperBound_(/*IDBKey*/ bound, [bool open]) {
646 if (?open) {
647 var bound_1 = _convertDartToNative_IDBKey(bound);
648 return _upperBound__1(bound_1, open);
649 }
650 var bound_2 = _convertDartToNative_IDBKey(bound);
651 return _upperBound__2(bound_2);
652 }
653 @JSName('upperBound')
654 static KeyRange _upperBound__1(bound, open) native;
655 @JSName('upperBound')
656 static KeyRange _upperBound__2(bound) native;
657
658 }
659 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
660 // for details. All rights reserved. Use of this source code is governed by a
661 // BSD-style license that can be found in the LICENSE file.
662
663
664 /// @domName IDBObjectStore; @docsEditable true
665 class ObjectStore native "*IDBObjectStore" {
666
667 /// @domName IDBObjectStore.autoIncrement; @docsEditable true
668 final bool autoIncrement;
669
670 /// @domName IDBObjectStore.indexNames; @docsEditable true
671 @Returns('_DOMStringList') @Creates('_DOMStringList')
672 final List<String> indexNames;
673
674 /// @domName IDBObjectStore.keyPath; @docsEditable true
675 final dynamic keyPath;
676
677 /// @domName IDBObjectStore.name; @docsEditable true
678 final String name;
679
680 /// @domName IDBObjectStore.transaction; @docsEditable true
681 final Transaction transaction;
682
683 /// @domName IDBObjectStore.add; @docsEditable true
684 Request add(/*any*/ value, [/*IDBKey*/ key]) {
685 if (?key) {
686 var value_1 = convertDartToNative_SerializedScriptValue(value);
687 var key_2 = _convertDartToNative_IDBKey(key);
688 return _add_1(value_1, key_2);
689 }
690 var value_3 = convertDartToNative_SerializedScriptValue(value);
691 return _add_2(value_3);
692 }
693 @JSName('add')
694 @Returns('Request') @Creates('Request') @_annotation_Creates_IDBKey
695 Request _add_1(value, key) native;
696 @JSName('add')
697 @Returns('Request') @Creates('Request') @_annotation_Creates_IDBKey
698 Request _add_2(value) native;
699
700 /// @domName IDBObjectStore.clear; @docsEditable true
701 Request clear() native;
702
703 /// @domName IDBObjectStore.count; @docsEditable true
704 Request count([key_OR_range]) {
705 if (!?key_OR_range) {
706 return _count_1();
707 }
708 if ((?key_OR_range && (key_OR_range is KeyRange || key_OR_range == null))) {
709 return _count_2(key_OR_range);
710 }
711 if (?key_OR_range) {
712 var key_1 = _convertDartToNative_IDBKey(key_OR_range);
713 return _count_3(key_1);
714 }
715 throw new ArgumentError("Incorrect number or type of arguments");
716 }
717 @JSName('count')
718 Request _count_1() native;
719 @JSName('count')
720 Request _count_2(KeyRange range) native;
721 @JSName('count')
722 Request _count_3(key) native;
723
724 /// @domName IDBObjectStore.createIndex; @docsEditable true
725 Index createIndex(String name, keyPath, [Map options]) {
726 if ((?keyPath && (keyPath is List<String> || keyPath == null)) &&
727 !?options) {
728 List keyPath_1 = convertDartToNative_StringArray(keyPath);
729 return _createIndex_1(name, keyPath_1);
730 }
731 if ((?keyPath && (keyPath is List<String> || keyPath == null))) {
732 List keyPath_2 = convertDartToNative_StringArray(keyPath);
733 var options_3 = convertDartToNative_Dictionary(options);
734 return _createIndex_2(name, keyPath_2, options_3);
735 }
736 if ((?keyPath && (keyPath is String || keyPath == null)) &&
737 !?options) {
738 return _createIndex_3(name, keyPath);
739 }
740 if ((?keyPath && (keyPath is String || keyPath == null))) {
741 var options_4 = convertDartToNative_Dictionary(options);
742 return _createIndex_4(name, keyPath, options_4);
743 }
744 throw new ArgumentError("Incorrect number or type of arguments");
745 }
746 @JSName('createIndex')
747 Index _createIndex_1(name, List keyPath) native;
748 @JSName('createIndex')
749 Index _createIndex_2(name, List keyPath, options) native;
750 @JSName('createIndex')
751 Index _createIndex_3(name, String keyPath) native;
752 @JSName('createIndex')
753 Index _createIndex_4(name, String keyPath, options) native;
754
755 /// @domName IDBObjectStore.delete; @docsEditable true
756 Request delete(key_OR_keyRange) {
757 if ((?key_OR_keyRange && (key_OR_keyRange is KeyRange || key_OR_keyRange == null))) {
758 return _delete_1(key_OR_keyRange);
759 }
760 if (?key_OR_keyRange) {
761 var key_1 = _convertDartToNative_IDBKey(key_OR_keyRange);
762 return _delete_2(key_1);
763 }
764 throw new ArgumentError("Incorrect number or type of arguments");
765 }
766 @JSName('delete')
767 Request _delete_1(KeyRange keyRange) native;
768 @JSName('delete')
769 Request _delete_2(key) native;
770
771 /// @domName IDBObjectStore.deleteIndex; @docsEditable true
772 void deleteIndex(String name) native;
773
774 /// @domName IDBObjectStore.getObject; @docsEditable true
775 Request getObject(key) {
776 if ((?key && (key is KeyRange || key == null))) {
777 return _getObject_1(key);
778 }
779 if (?key) {
780 var key_1 = _convertDartToNative_IDBKey(key);
781 return _getObject_2(key_1);
782 }
783 throw new ArgumentError("Incorrect number or type of arguments");
784 }
785 @JSName('get')
786 @Returns('Request') @Creates('Request') @annotation_Creates_SerializedScriptVa lue
787 Request _getObject_1(KeyRange key) native;
788 @JSName('get')
789 @Returns('Request') @Creates('Request') @annotation_Creates_SerializedScriptVa lue
790 Request _getObject_2(key) native;
791
792 /// @domName IDBObjectStore.index; @docsEditable true
793 Index index(String name) native;
794
795 /// @domName IDBObjectStore.openCursor; @docsEditable true
796 Request openCursor([key_OR_range, String direction]) {
797 if (!?key_OR_range &&
798 !?direction) {
799 return _openCursor_1();
800 }
801 if ((?key_OR_range && (key_OR_range is KeyRange || key_OR_range == null)) &&
802 !?direction) {
803 return _openCursor_2(key_OR_range);
804 }
805 if ((?key_OR_range && (key_OR_range is KeyRange || key_OR_range == null))) {
806 return _openCursor_3(key_OR_range, direction);
807 }
808 if (?key_OR_range &&
809 !?direction) {
810 var key_1 = _convertDartToNative_IDBKey(key_OR_range);
811 return _openCursor_4(key_1);
812 }
813 if (?key_OR_range) {
814 var key_2 = _convertDartToNative_IDBKey(key_OR_range);
815 return _openCursor_5(key_2, direction);
816 }
817 throw new ArgumentError("Incorrect number or type of arguments");
818 }
819 @JSName('openCursor')
820 @Returns('Request') @Creates('Request') @Creates('Cursor')
821 Request _openCursor_1() native;
822 @JSName('openCursor')
823 @Returns('Request') @Creates('Request') @Creates('Cursor')
824 Request _openCursor_2(KeyRange range) native;
825 @JSName('openCursor')
826 @Returns('Request') @Creates('Request') @Creates('Cursor')
827 Request _openCursor_3(KeyRange range, direction) native;
828 @JSName('openCursor')
829 @Returns('Request') @Creates('Request') @Creates('Cursor')
830 Request _openCursor_4(key) native;
831 @JSName('openCursor')
832 @Returns('Request') @Creates('Request') @Creates('Cursor')
833 Request _openCursor_5(key, direction) native;
834
835 /// @domName IDBObjectStore.put; @docsEditable true
836 Request put(/*any*/ value, [/*IDBKey*/ key]) {
837 if (?key) {
838 var value_1 = convertDartToNative_SerializedScriptValue(value);
839 var key_2 = _convertDartToNative_IDBKey(key);
840 return _put_1(value_1, key_2);
841 }
842 var value_3 = convertDartToNative_SerializedScriptValue(value);
843 return _put_2(value_3);
844 }
845 @JSName('put')
846 @Returns('Request') @Creates('Request') @_annotation_Creates_IDBKey
847 Request _put_1(value, key) native;
848 @JSName('put')
849 @Returns('Request') @Creates('Request') @_annotation_Creates_IDBKey
850 Request _put_2(value) native;
851 }
852 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
853 // for details. All rights reserved. Use of this source code is governed by a
854 // BSD-style license that can be found in the LICENSE file.
855
856
857 /// @domName IDBOpenDBRequest; @docsEditable true
858 class OpenDBRequest extends Request implements EventTarget native "*IDBOpenDBReq uest" {
859
860 /// @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev entTarget.dispatchEvent; @docsEditable true
861 OpenDBRequestEvents get on =>
862 new OpenDBRequestEvents(this);
863 }
864
865 class OpenDBRequestEvents extends RequestEvents {
866 OpenDBRequestEvents(EventTarget _ptr) : super(_ptr);
867
868 EventListenerList get blocked => this['blocked'];
869
870 EventListenerList get upgradeNeeded => this['upgradeneeded'];
871 }
872 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
873 // for details. All rights reserved. Use of this source code is governed by a
874 // BSD-style license that can be found in the LICENSE file.
875
876
877 /// @domName IDBRequest; @docsEditable true
878 class Request extends EventTarget native "*IDBRequest" {
879
880 /// @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev entTarget.dispatchEvent; @docsEditable true
881 RequestEvents get on =>
882 new RequestEvents(this);
883
884 /// @domName IDBRequest.error; @docsEditable true
885 final DOMError error;
886
887 /// @domName IDBRequest.errorCode; @docsEditable true
888 final int errorCode;
889
890 /// @domName IDBRequest.readyState; @docsEditable true
891 final String readyState;
892
893 /// @domName IDBRequest.result; @docsEditable true
894 dynamic get result => _convertNativeToDart_IDBAny(this._result);
895 @JSName('result')
896 @Creates('Null')
897 final dynamic _result;
898
899 /// @domName IDBRequest.source; @docsEditable true
900 @Creates('Null')
901 final dynamic source;
902
903 /// @domName IDBRequest.transaction; @docsEditable true
904 final Transaction transaction;
905
906 /// @domName IDBRequest.webkitErrorMessage; @docsEditable true
907 final String webkitErrorMessage;
908
909 /// @domName IDBRequest.addEventListener; @docsEditable true
910 @JSName('addEventListener')
911 void $dom_addEventListener(String type, EventListener listener, [bool useCaptu re]) native;
912
913 /// @domName IDBRequest.dispatchEvent; @docsEditable true
914 @JSName('dispatchEvent')
915 bool $dom_dispatchEvent(Event evt) native;
916
917 /// @domName IDBRequest.removeEventListener; @docsEditable true
918 @JSName('removeEventListener')
919 void $dom_removeEventListener(String type, EventListener listener, [bool useCa pture]) native;
920 }
921
922 class RequestEvents extends Events {
923 RequestEvents(EventTarget _ptr) : super(_ptr);
924
925 EventListenerList get error => this['error'];
926
927 EventListenerList get success => this['success'];
928 }
929 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
930 // for details. All rights reserved. Use of this source code is governed by a
931 // BSD-style license that can be found in the LICENSE file.
932
933
934 /// @domName IDBTransaction; @docsEditable true
935 class Transaction extends EventTarget native "*IDBTransaction" {
936
937 /// @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev entTarget.dispatchEvent; @docsEditable true
938 TransactionEvents get on =>
939 new TransactionEvents(this);
940
941 static const int READ_ONLY = 0;
942
943 static const int READ_WRITE = 1;
944
945 static const int VERSION_CHANGE = 2;
946
947 /// @domName IDBTransaction.db; @docsEditable true
948 final Database db;
949
950 /// @domName IDBTransaction.error; @docsEditable true
951 final DOMError error;
952
953 /// @domName IDBTransaction.mode; @docsEditable true
954 final String mode;
955
956 /// @domName IDBTransaction.abort; @docsEditable true
957 void abort() native;
958
959 /// @domName IDBTransaction.addEventListener; @docsEditable true
960 @JSName('addEventListener')
961 void $dom_addEventListener(String type, EventListener listener, [bool useCaptu re]) native;
962
963 /// @domName IDBTransaction.dispatchEvent; @docsEditable true
964 @JSName('dispatchEvent')
965 bool $dom_dispatchEvent(Event evt) native;
966
967 /// @domName IDBTransaction.objectStore; @docsEditable true
968 ObjectStore objectStore(String name) native;
969
970 /// @domName IDBTransaction.removeEventListener; @docsEditable true
971 @JSName('removeEventListener')
972 void $dom_removeEventListener(String type, EventListener listener, [bool useCa pture]) native;
973 }
974
975 class TransactionEvents extends Events {
976 TransactionEvents(EventTarget _ptr) : super(_ptr);
977
978 EventListenerList get abort => this['abort'];
979
980 EventListenerList get complete => this['complete'];
981
982 EventListenerList get error => this['error'];
983 }
984 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
985 // for details. All rights reserved. Use of this source code is governed by a
986 // BSD-style license that can be found in the LICENSE file.
987
988
989 /// @domName IDBVersionChangeEvent; @docsEditable true
990 class UpgradeNeededEvent extends Event native "*IDBVersionChangeEvent" {
991
992 /// @domName IDBVersionChangeEvent.newVersion; @docsEditable true
993 final int newVersion;
994
995 /// @domName IDBVersionChangeEvent.oldVersion; @docsEditable true
996 final int oldVersion;
997 }
998 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
999 // for details. All rights reserved. Use of this source code is governed by a
1000 // BSD-style license that can be found in the LICENSE file.
1001
1002
1003 /// @domName IDBVersionChangeEvent; @docsEditable true
1004 class VersionChangeEvent extends Event native "*IDBVersionChangeEvent" {
1005
1006 /// @domName IDBVersionChangeEvent.version; @docsEditable true
1007 final String version;
1008 }
1009 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
1010 // for details. All rights reserved. Use of this source code is governed by a
1011 // BSD-style license that can be found in the LICENSE file.
1012
1013
1014 /// @domName IDBVersionChangeRequest; @docsEditable true
1015 class VersionChangeRequest extends Request implements EventTarget native "*IDBVe rsionChangeRequest" {
1016
1017 /// @domName EventTarget.addEventListener, EventTarget.removeEventListener, Ev entTarget.dispatchEvent; @docsEditable true
1018 VersionChangeRequestEvents get on =>
1019 new VersionChangeRequestEvents(this);
1020 }
1021
1022 class VersionChangeRequestEvents extends RequestEvents {
1023 VersionChangeRequestEvents(EventTarget _ptr) : super(_ptr);
1024
1025 EventListenerList get blocked => this['blocked'];
1026 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698