| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 readSlot(int i) => copies[i]; | 110 readSlot(int i) => copies[i]; |
| 111 writeSlot(int i, x) { copies[i] = x; } | 111 writeSlot(int i, x) { copies[i] = x; } |
| 112 cleanupSlots() {} // Will be needed if we mark objects with a property. | 112 cleanupSlots() {} // Will be needed if we mark objects with a property. |
| 113 | 113 |
| 114 // Returns the input, or a clone of the input. | 114 // Returns the input, or a clone of the input. |
| 115 walk(e) { | 115 walk(e) { |
| 116 if (e == null) return e; | 116 if (e == null) return e; |
| 117 if (e is bool) return e; | 117 if (e is bool) return e; |
| 118 if (e is num) return e; | 118 if (e is num) return e; |
| 119 if (e is String) return e; | 119 if (e is String) return e; |
| 120 if (e is Date) { | 120 if (e is DateTime) { |
| 121 // TODO(sra). | 121 // TODO(sra). |
| 122 throw new UnimplementedError('structured clone of Date'); | 122 throw new UnimplementedError('structured clone of DateTime'); |
| 123 } | 123 } |
| 124 if (e is RegExp) { | 124 if (e is RegExp) { |
| 125 // TODO(sra). | 125 // TODO(sra). |
| 126 throw new UnimplementedError('structured clone of RegExp'); | 126 throw new UnimplementedError('structured clone of RegExp'); |
| 127 } | 127 } |
| 128 | 128 |
| 129 // The browser's internal structured cloning algorithm will copy certain | 129 // The browser's internal structured cloning algorithm will copy certain |
| 130 // types of object, but it will copy only its own implementations and not | 130 // types of object, but it will copy only its own implementations and not |
| 131 // just any Dart implementations of the interface. | 131 // just any Dart implementations of the interface. |
| 132 | 132 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 writeSlot(int i, x) { copies[i] = x; } | 258 writeSlot(int i, x) { copies[i] = x; } |
| 259 | 259 |
| 260 walk(e) { | 260 walk(e) { |
| 261 if (e == null) return e; | 261 if (e == null) return e; |
| 262 if (e is bool) return e; | 262 if (e is bool) return e; |
| 263 if (e is num) return e; | 263 if (e is num) return e; |
| 264 if (e is String) return e; | 264 if (e is String) return e; |
| 265 | 265 |
| 266 if (isJavaScriptDate(e)) { | 266 if (isJavaScriptDate(e)) { |
| 267 // TODO(sra). | 267 // TODO(sra). |
| 268 throw new UnimplementedError('structured clone of Date'); | 268 throw new UnimplementedError('structured clone of DateTime'); |
| 269 } | 269 } |
| 270 | 270 |
| 271 if (isJavaScriptRegExp(e)) { | 271 if (isJavaScriptRegExp(e)) { |
| 272 // TODO(sra). | 272 // TODO(sra). |
| 273 throw new UnimplementedError('structured clone of RegExp'); | 273 throw new UnimplementedError('structured clone of RegExp'); |
| 274 } | 274 } |
| 275 | 275 |
| 276 if (isJavaScriptSimpleObject(e)) { | 276 if (isJavaScriptSimpleObject(e)) { |
| 277 // TODO(sra): If mustCopy is false, swizzle the prototype for one of a Map | 277 // TODO(sra): If mustCopy is false, swizzle the prototype for one of a Map |
| 278 // implementation that uses the properies as storage. | 278 // implementation that uses the properies as storage. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 const String _serializedScriptValue = | 328 const String _serializedScriptValue = |
| 329 'num|String|bool|' | 329 'num|String|bool|' |
| 330 '=List|=Object|' | 330 '=List|=Object|' |
| 331 'Blob|File|ArrayBuffer|ArrayBufferView' | 331 'Blob|File|ArrayBuffer|ArrayBufferView' |
| 332 // TODO(sra): Add Date, RegExp. | 332 // TODO(sra): Add Date, RegExp. |
| 333 ; | 333 ; |
| 334 const annotation_Creates_SerializedScriptValue = | 334 const annotation_Creates_SerializedScriptValue = |
| 335 const Creates(_serializedScriptValue); | 335 const Creates(_serializedScriptValue); |
| 336 const annotation_Returns_SerializedScriptValue = | 336 const annotation_Returns_SerializedScriptValue = |
| 337 const Returns(_serializedScriptValue); | 337 const Returns(_serializedScriptValue); |
| OLD | NEW |