OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // DO NOT EDIT | 5 // DO NOT EDIT |
6 // Auto-generated dart:indexed_db library. | 6 // Auto-generated dart:indexed_db library. |
7 | 7 |
8 /** | 8 /** |
9 * A client-side key-value store with support for indexes. | 9 * A client-side key-value store with support for indexes. |
10 * | 10 * |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 /*IDBKey*/ lower, /*IDBKey*/ upper, | 105 /*IDBKey*/ lower, /*IDBKey*/ upper, |
106 [bool lowerOpen = false, bool upperOpen = false]) => | 106 [bool lowerOpen = false, bool upperOpen = false]) => |
107 KeyRange.bound_(lower, upper, lowerOpen, upperOpen); | 107 KeyRange.bound_(lower, upper, lowerOpen, upperOpen); |
108 } | 108 } |
109 // FIXME: Can we make this private? | 109 // FIXME: Can we make this private? |
110 @Deprecated("Internal Use Only") | 110 @Deprecated("Internal Use Only") |
111 final indexed_dbBlinkMap = { | 111 final indexed_dbBlinkMap = { |
112 $!TYPE_MAP | 112 $!TYPE_MAP |
113 }; | 113 }; |
114 | 114 |
115 $if JSINTEROP | 115 |
116 // FIXME: Can we make this private? | 116 // |
117 @Deprecated("Internal Use Only") | 117 // Per http://www.w3.org/TR/IndexedDB/#key-construct |
118 final indexed_dbBlinkFunctionMap = { | 118 // |
119 $!TYPE_FUNCTION_MAP | 119 // "A value is said to be a valid key if it is one of the following types: Array |
120 }; | 120 // JavaScript objects [ECMA-262], DOMString [WEBIDL], Date [ECMA-262] or float |
121 $endif | 121 // [WEBIDL]. However Arrays are only valid keys if every item in the array is |
| 122 // defined and is a valid key (i.e. sparse arrays can not be valid keys) and if |
| 123 // the Array doesn't directly or indirectly contain itself. Any non-numeric |
| 124 // properties are ignored, and thus does not affect whether the Array is a valid |
| 125 // key. Additionally, if the value is of type float, it is only a valid key if |
| 126 // it is not NaN, and if the value is of type Date it is only a valid key if its |
| 127 // [[PrimitiveValue]] internal property, as defined by [ECMA-262], is not NaN." |
| 128 |
| 129 // What is required is to ensure that an Lists in the key are actually |
| 130 // JavaScript arrays, and any Dates are JavaScript Dates. |
| 131 |
| 132 |
| 133 /** |
| 134 * Converts a native IDBKey into a Dart object. |
| 135 * |
| 136 * May return the original input. May mutate the original input (but will be |
| 137 * idempotent if mutation occurs). It is assumed that this conversion happens |
| 138 * on native IDBKeys on all paths that return IDBKeys from native DOM calls. |
| 139 * |
| 140 * If necessary, JavaScript Dates are converted into Dart Dates. |
| 141 */ |
| 142 _convertNativeToDart_IDBKey(nativeKey) { |
| 143 containsDate(object) { |
| 144 if (object is DateTime) return true; |
| 145 if (object is List) { |
| 146 for (int i = 0; i < object.length; i++) { |
| 147 if (containsDate(object[i])) return true; |
| 148 } |
| 149 } |
| 150 return false; // number, string. |
| 151 } |
| 152 if (nativeKey is DateTime) { |
| 153 throw new UnimplementedError('Key containing DateTime'); |
| 154 } |
| 155 // TODO: Cache conversion somewhere? |
| 156 return nativeKey; |
| 157 } |
| 158 |
| 159 /** |
| 160 * Converts a Dart object into a valid IDBKey. |
| 161 * |
| 162 * May return the original input. Does not mutate input. |
| 163 * |
| 164 * If necessary, [dartKey] may be copied to ensure all lists are converted into |
| 165 * JavaScript Arrays and Dart Dates into JavaScript Dates. |
| 166 */ |
| 167 _convertDartToNative_IDBKey(dartKey) { |
| 168 // TODO: Implement. |
| 169 return dartKey; |
| 170 } |
| 171 |
| 172 |
| 173 |
| 174 /// May modify original. If so, action is idempotent. |
| 175 _convertNativeToDart_IDBAny(object) { |
| 176 return convertNativeToDart_AcceptStructuredClone(object, mustCopy: false); |
| 177 } |
OLD | NEW |