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 | 5 |
6 // Conversions for IDBKey. | 6 // Conversions for IDBKey. |
7 // | 7 // |
8 // Per http://www.w3.org/TR/IndexedDB/#key-construct | 8 // Per http://www.w3.org/TR/IndexedDB/#key-construct |
9 // | 9 // |
10 // "A value is said to be a valid key if it is one of the following types: Array | 10 // "A value is said to be a valid key if it is one of the following types: Array |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 * [object] is the result of a structured clone operation. | 212 * [object] is the result of a structured clone operation. |
213 * | 213 * |
214 * If necessary, JavaScript Dates are converted into Dart Dates. | 214 * If necessary, JavaScript Dates are converted into Dart Dates. |
215 * | 215 * |
216 * If [mustCopy] is [:true:], the entire object is copied and the original input | 216 * If [mustCopy] is [:true:], the entire object is copied and the original input |
217 * is not mutated. This should be the case where Dart and JavaScript code can | 217 * is not mutated. This should be the case where Dart and JavaScript code can |
218 * access the value, for example, via multiple event listeners for | 218 * access the value, for example, via multiple event listeners for |
219 * MessageEvents. Mutating the object to make it more 'Dart-like' would corrupt | 219 * MessageEvents. Mutating the object to make it more 'Dart-like' would corrupt |
220 * the value as seen from the JavaScript listeners. | 220 * the value as seen from the JavaScript listeners. |
221 */ | 221 */ |
222 convertNativeToDart_AcceptStructuredClone(object, {mustCopy = false}) { | 222 convertNativeToDart_AcceptStructuredClone(object, {mustCopy: false}) { |
223 | 223 |
224 // TODO(sra): Replace slots with identity hash table that works on non-dart | 224 // TODO(sra): Replace slots with identity hash table that works on non-dart |
225 // objects. | 225 // objects. |
226 var values = []; | 226 var values = []; |
227 var copies = []; | 227 var copies = []; |
228 | 228 |
229 int findSlot(value) { | 229 int findSlot(value) { |
230 int length = values.length; | 230 int length = values.length; |
231 for (int i = 0; i < length; i++) { | 231 for (int i = 0; i < length; i++) { |
232 if (identical(values[i], value)) return i; | 232 if (identical(values[i], value)) return i; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 const String _serializedScriptValue = | 351 const String _serializedScriptValue = |
352 'num|String|bool|' | 352 'num|String|bool|' |
353 'JSExtendableArray|=Object|' | 353 'JSExtendableArray|=Object|' |
354 'Blob|File|ByteBuffer|TypedData' | 354 'Blob|File|ByteBuffer|TypedData' |
355 // TODO(sra): Add Date, RegExp. | 355 // TODO(sra): Add Date, RegExp. |
356 ; | 356 ; |
357 const annotation_Creates_SerializedScriptValue = | 357 const annotation_Creates_SerializedScriptValue = |
358 const Creates(_serializedScriptValue); | 358 const Creates(_serializedScriptValue); |
359 const annotation_Returns_SerializedScriptValue = | 359 const annotation_Returns_SerializedScriptValue = |
360 const Returns(_serializedScriptValue); | 360 const Returns(_serializedScriptValue); |
OLD | NEW |