Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: src/object-observe.js

Issue 23727006: performChange no longer takes a |receiver| argument (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/harmony/object-observe.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 for (var prop in changeRecord) { 459 for (var prop in changeRecord) {
460 if (prop === 'object') continue; 460 if (prop === 'object') continue;
461 %DefineOrRedefineDataProperty(newRecord, prop, changeRecord[prop], 461 %DefineOrRedefineDataProperty(newRecord, prop, changeRecord[prop],
462 READ_ONLY + DONT_DELETE); 462 READ_ONLY + DONT_DELETE);
463 } 463 }
464 ObjectFreeze(newRecord); 464 ObjectFreeze(newRecord);
465 465
466 ObjectInfoEnqueueChangeRecord(objectInfo, newRecord); 466 ObjectInfoEnqueueChangeRecord(objectInfo, newRecord);
467 } 467 }
468 468
469 function ObjectNotifierPerformChange(changeType, changeFn, receiver) { 469 function ObjectNotifierPerformChange(changeType, changeFn) {
470 if (!IS_SPEC_OBJECT(this)) 470 if (!IS_SPEC_OBJECT(this))
471 throw MakeTypeError("called_on_non_object", ["performChange"]); 471 throw MakeTypeError("called_on_non_object", ["performChange"]);
472 472
473 var objectInfo = ObjectInfoGetFromNotifier(this); 473 var objectInfo = ObjectInfoGetFromNotifier(this);
474 474
475 if (IS_UNDEFINED(objectInfo)) 475 if (IS_UNDEFINED(objectInfo))
476 throw MakeTypeError("observe_notify_non_notifier"); 476 throw MakeTypeError("observe_notify_non_notifier");
477 if (!IS_STRING(changeType)) 477 if (!IS_STRING(changeType))
478 throw MakeTypeError("observe_perform_non_string"); 478 throw MakeTypeError("observe_perform_non_string");
479 if (!IS_SPEC_FUNCTION(changeFn)) 479 if (!IS_SPEC_FUNCTION(changeFn))
480 throw MakeTypeError("observe_perform_non_function"); 480 throw MakeTypeError("observe_perform_non_function");
481 481
482 if (IS_NULL_OR_UNDEFINED(receiver)) {
483 receiver = %GetDefaultReceiver(changeFn) || receiver;
484 } else if (!IS_SPEC_OBJECT(receiver) && %IsClassicModeFunction(changeFn)) {
485 receiver = ToObject(receiver);
486 }
487
488 ObjectInfoAddPerformingType(objectInfo, changeType); 482 ObjectInfoAddPerformingType(objectInfo, changeType);
489 try { 483 try {
490 %_CallFunction(receiver, changeFn); 484 %_CallFunction(void 0, changeFn);
491 } finally { 485 } finally {
492 ObjectInfoRemovePerformingType(objectInfo, changeType); 486 ObjectInfoRemovePerformingType(objectInfo, changeType);
493 } 487 }
494 } 488 }
495 489
496 function ObjectGetNotifier(object) { 490 function ObjectGetNotifier(object) {
497 if (!IS_SPEC_OBJECT(object)) 491 if (!IS_SPEC_OBJECT(object))
498 throw MakeTypeError("observe_non_object", ["getNotifier"]); 492 throw MakeTypeError("observe_non_object", ["getNotifier"]);
499 493
500 if (ObjectIsFrozen(object)) return null; 494 if (ObjectIsFrozen(object)) return null;
(...skipping 12 matching lines...) Expand all
513 var priority = callbackInfo.priority; 507 var priority = callbackInfo.priority;
514 callbackInfoMap.set(callback, priority); 508 callbackInfoMap.set(callback, priority);
515 509
516 if (observationState.pendingObservers) 510 if (observationState.pendingObservers)
517 delete observationState.pendingObservers[priority]; 511 delete observationState.pendingObservers[priority];
518 512
519 var delivered = []; 513 var delivered = [];
520 %MoveArrayContents(callbackInfo, delivered); 514 %MoveArrayContents(callbackInfo, delivered);
521 515
522 try { 516 try {
523 %Call(void 0, delivered, callback); 517 %_CallFunction(void 0, delivered, callback);
rafaelw 2013/09/10 18:30:43 Note: For consistency, both function invocations i
524 } catch (ex) {} 518 } catch (ex) {}
525 return true; 519 return true;
526 } 520 }
527 521
528 function ObjectDeliverChangeRecords(callback) { 522 function ObjectDeliverChangeRecords(callback) {
529 if (!IS_SPEC_FUNCTION(callback)) 523 if (!IS_SPEC_FUNCTION(callback))
530 throw MakeTypeError("observe_non_function", ["deliverChangeRecords"]); 524 throw MakeTypeError("observe_non_function", ["deliverChangeRecords"]);
531 525
532 while (CallbackDeliverPending(callback)) {} 526 while (CallbackDeliverPending(callback)) {}
533 } 527 }
(...skipping 20 matching lines...) Expand all
554 "observe", ArrayObserve, 548 "observe", ArrayObserve,
555 "unobserve", ArrayUnobserve 549 "unobserve", ArrayUnobserve
556 )); 550 ));
557 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( 551 InstallFunctions(notifierPrototype, DONT_ENUM, $Array(
558 "notify", ObjectNotifierNotify, 552 "notify", ObjectNotifierNotify,
559 "performChange", ObjectNotifierPerformChange 553 "performChange", ObjectNotifierPerformChange
560 )); 554 ));
561 } 555 }
562 556
563 SetupObjectObserve(); 557 SetupObjectObserve();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/harmony/object-observe.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698