OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 11 matching lines...) Expand all Loading... | |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 "use strict"; | 28 "use strict"; |
29 | 29 |
30 var InternalObjectIsFrozen = $Object.isFrozen; | 30 var InternalObjectIsFrozen = $Object.isFrozen; |
31 var InternalObjectFreeze = $Object.freeze; | 31 var InternalObjectFreeze = $Object.freeze; |
32 var InternalObjectDefineProperty = $Object.defineProperty; | |
adamk
2012/11/14 22:32:24
Not sure these are worth it, at least not until we
rafaelw
2012/11/14 22:40:56
Removed.
On 2012/11/14 22:32:24, adamk wrote:
| |
32 | 33 |
33 var observationState = %GetObservationState(); | 34 var observationState = %GetObservationState(); |
34 if (IS_UNDEFINED(observationState.observerInfoMap)) { | 35 if (IS_UNDEFINED(observationState.observerInfoMap)) { |
35 observationState.observerInfoMap = %CreateObjectHashTable(); | 36 observationState.observerInfoMap = %CreateObjectHashTable(); |
36 observationState.objectInfoMap = %CreateObjectHashTable(); | 37 observationState.objectInfoMap = %CreateObjectHashTable(); |
37 observationState.notifierTargetMap = %CreateObjectHashTable(); | 38 observationState.notifierTargetMap = %CreateObjectHashTable(); |
38 observationState.pendingObservers = new InternalArray; | 39 observationState.pendingObservers = new InternalArray; |
39 observationState.observerPriority = 0; | 40 observationState.observerPriority = 0; |
40 } | 41 } |
41 | 42 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 | 158 |
158 if (!objectInfo.changeObservers.length) | 159 if (!objectInfo.changeObservers.length) |
159 return; | 160 return; |
160 | 161 |
161 var newRecord = { | 162 var newRecord = { |
162 object: target | 163 object: target |
163 }; | 164 }; |
164 for (var prop in changeRecord) { | 165 for (var prop in changeRecord) { |
165 if (prop === 'object') | 166 if (prop === 'object') |
166 continue; | 167 continue; |
167 newRecord[prop] = changeRecord[prop]; | 168 |
169 InternalObjectDefineProperty(newRecord, prop, { | |
170 value: changeRecord[prop], | |
171 enumerable: true | |
172 }); | |
168 } | 173 } |
169 InternalObjectFreeze(newRecord); | 174 InternalObjectFreeze(newRecord); |
170 | 175 |
171 EnqueueChangeRecord(newRecord, objectInfo.changeObservers); | 176 EnqueueChangeRecord(newRecord, objectInfo.changeObservers); |
172 } | 177 } |
173 | 178 |
174 function ObjectGetNotifier(object) { | 179 function ObjectGetNotifier(object) { |
175 if (!IS_SPEC_OBJECT(object)) | 180 if (!IS_SPEC_OBJECT(object)) |
176 throw MakeTypeError("observe_non_object", ["getNotifier"]); | 181 throw MakeTypeError("observe_non_object", ["getNotifier"]); |
177 | 182 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 "getNotifier", ObjectGetNotifier, | 239 "getNotifier", ObjectGetNotifier, |
235 "observe", ObjectObserve, | 240 "observe", ObjectObserve, |
236 "unobserve", ObjectUnobserve | 241 "unobserve", ObjectUnobserve |
237 )); | 242 )); |
238 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( | 243 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( |
239 "notify", ObjectNotifierNotify | 244 "notify", ObjectNotifierNotify |
240 )); | 245 )); |
241 } | 246 } |
242 | 247 |
243 SetupObjectObserve(); | 248 SetupObjectObserve(); |
OLD | NEW |