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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 observationState.nextCallbackPriority = 0; | 65 observationState.nextCallbackPriority = 0; |
66 } | 66 } |
67 | 67 |
68 function ObservationWeakMap(map) { | 68 function ObservationWeakMap(map) { |
69 this.map_ = map; | 69 this.map_ = map; |
70 } | 70 } |
71 | 71 |
72 ObservationWeakMap.prototype = { | 72 ObservationWeakMap.prototype = { |
73 get: function(key) { | 73 get: function(key) { |
74 key = %UnwrapGlobalProxy(key); | 74 key = %UnwrapGlobalProxy(key); |
75 if (!IS_SPEC_OBJECT(key)) return void 0; | 75 if (!IS_SPEC_OBJECT(key)) return UNDEFINED; |
76 return %WeakCollectionGet(this.map_, key); | 76 return %WeakCollectionGet(this.map_, key); |
77 }, | 77 }, |
78 set: function(key, value) { | 78 set: function(key, value) { |
79 key = %UnwrapGlobalProxy(key); | 79 key = %UnwrapGlobalProxy(key); |
80 if (!IS_SPEC_OBJECT(key)) return void 0; | 80 if (!IS_SPEC_OBJECT(key)) return UNDEFINED; |
81 %WeakCollectionSet(this.map_, key, value); | 81 %WeakCollectionSet(this.map_, key, value); |
82 }, | 82 }, |
83 has: function(key) { | 83 has: function(key) { |
84 return !IS_UNDEFINED(this.get(key)); | 84 return !IS_UNDEFINED(this.get(key)); |
85 } | 85 } |
86 }; | 86 }; |
87 | 87 |
88 var callbackInfoMap = | 88 var callbackInfoMap = |
89 new ObservationWeakMap(observationState.callbackInfoMap); | 89 new ObservationWeakMap(observationState.callbackInfoMap); |
90 var objectInfoMap = new ObservationWeakMap(observationState.objectInfoMap); | 90 var objectInfoMap = new ObservationWeakMap(observationState.objectInfoMap); |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 | 485 |
486 if (IS_UNDEFINED(objectInfo)) | 486 if (IS_UNDEFINED(objectInfo)) |
487 throw MakeTypeError("observe_notify_non_notifier"); | 487 throw MakeTypeError("observe_notify_non_notifier"); |
488 if (!IS_STRING(changeType)) | 488 if (!IS_STRING(changeType)) |
489 throw MakeTypeError("observe_perform_non_string"); | 489 throw MakeTypeError("observe_perform_non_string"); |
490 if (!IS_SPEC_FUNCTION(changeFn)) | 490 if (!IS_SPEC_FUNCTION(changeFn)) |
491 throw MakeTypeError("observe_perform_non_function"); | 491 throw MakeTypeError("observe_perform_non_function"); |
492 | 492 |
493 ObjectInfoAddPerformingType(objectInfo, changeType); | 493 ObjectInfoAddPerformingType(objectInfo, changeType); |
494 try { | 494 try { |
495 %_CallFunction(void 0, changeFn); | 495 %_CallFunction(UNDEFINED, changeFn); |
496 } finally { | 496 } finally { |
497 ObjectInfoRemovePerformingType(objectInfo, changeType); | 497 ObjectInfoRemovePerformingType(objectInfo, changeType); |
498 } | 498 } |
499 } | 499 } |
500 | 500 |
501 function ObjectGetNotifier(object) { | 501 function ObjectGetNotifier(object) { |
502 if (!IS_SPEC_OBJECT(object)) | 502 if (!IS_SPEC_OBJECT(object)) |
503 throw MakeTypeError("observe_non_object", ["getNotifier"]); | 503 throw MakeTypeError("observe_non_object", ["getNotifier"]); |
504 | 504 |
505 if (ObjectIsFrozen(object)) return null; | 505 if (ObjectIsFrozen(object)) return null; |
(...skipping 12 matching lines...) Expand all Loading... |
518 var priority = callbackInfo.priority; | 518 var priority = callbackInfo.priority; |
519 callbackInfoMap.set(callback, priority); | 519 callbackInfoMap.set(callback, priority); |
520 | 520 |
521 if (observationState.pendingObservers) | 521 if (observationState.pendingObservers) |
522 delete observationState.pendingObservers[priority]; | 522 delete observationState.pendingObservers[priority]; |
523 | 523 |
524 var delivered = []; | 524 var delivered = []; |
525 %MoveArrayContents(callbackInfo, delivered); | 525 %MoveArrayContents(callbackInfo, delivered); |
526 | 526 |
527 try { | 527 try { |
528 %_CallFunction(void 0, delivered, callback); | 528 %_CallFunction(UNDEFINED, delivered, callback); |
529 } catch (ex) {} | 529 } catch (ex) {} |
530 return true; | 530 return true; |
531 } | 531 } |
532 | 532 |
533 function ObjectDeliverChangeRecords(callback) { | 533 function ObjectDeliverChangeRecords(callback) { |
534 if (!IS_SPEC_FUNCTION(callback)) | 534 if (!IS_SPEC_FUNCTION(callback)) |
535 throw MakeTypeError("observe_non_function", ["deliverChangeRecords"]); | 535 throw MakeTypeError("observe_non_function", ["deliverChangeRecords"]); |
536 | 536 |
537 while (CallbackDeliverPending(callback)) {} | 537 while (CallbackDeliverPending(callback)) {} |
538 } | 538 } |
(...skipping 20 matching lines...) Expand all Loading... |
559 "observe", ArrayObserve, | 559 "observe", ArrayObserve, |
560 "unobserve", ArrayUnobserve | 560 "unobserve", ArrayUnobserve |
561 )); | 561 )); |
562 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( | 562 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( |
563 "notify", ObjectNotifierNotify, | 563 "notify", ObjectNotifierNotify, |
564 "performChange", ObjectNotifierPerformChange | 564 "performChange", ObjectNotifierPerformChange |
565 )); | 565 )); |
566 } | 566 } |
567 | 567 |
568 SetupObjectObserve(); | 568 SetupObjectObserve(); |
OLD | NEW |