Kernel-Announcements.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. smalltalk.addPackage('Kernel-Announcements', {});
  2. smalltalk.addClass('Announcer', smalltalk.Object, ['registry', 'subscriptions'], 'Kernel-Announcements');
  3. smalltalk.addMethod(
  4. unescape('_announce_'),
  5. smalltalk.method({
  6. selector: unescape('announce%3A'),
  7. category: 'announcing',
  8. fn: function (anAnnouncement){
  9. var self=this;
  10. smalltalk.send(self['@subscriptions'], "_do_", [(function(each){return smalltalk.send(each, "_deliver_", [anAnnouncement]);})]);
  11. return self;},
  12. args: ["anAnnouncement"],
  13. source: unescape('announce%3A%20anAnnouncement%0A%09subscriptions%20do%3A%20%5B%3Aeach%20%7C%0A%09%09each%20deliver%3A%20anAnnouncement%5D'),
  14. messageSends: ["do:", "deliver:"],
  15. referencedClasses: []
  16. }),
  17. smalltalk.Announcer);
  18. smalltalk.addMethod(
  19. unescape('_initialize'),
  20. smalltalk.method({
  21. selector: unescape('initialize'),
  22. category: 'initialization',
  23. fn: function (){
  24. var self=this;
  25. smalltalk.send(self, "_initialize", [], smalltalk.Object);
  26. (self['@subscriptions']=smalltalk.send((smalltalk.OrderedCollection || OrderedCollection), "_new", []));
  27. return self;},
  28. args: [],
  29. source: unescape('initialize%0A%09super%20initialize.%0A%09subscriptions%20%3A%3D%20OrderedCollection%20new'),
  30. messageSends: ["initialize", "new"],
  31. referencedClasses: ["OrderedCollection"]
  32. }),
  33. smalltalk.Announcer);
  34. smalltalk.addMethod(
  35. unescape('_on_do_'),
  36. smalltalk.method({
  37. selector: unescape('on%3Ado%3A'),
  38. category: 'subscribing',
  39. fn: function (aClass, aBlock){
  40. var self=this;
  41. smalltalk.send(self['@subscriptions'], "_add_", [(function($rec){smalltalk.send($rec, "_block_", [aBlock]);smalltalk.send($rec, "_announcementClass_", [aClass]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.AnnouncementSubscription || AnnouncementSubscription), "_new", []))]);
  42. return self;},
  43. args: ["aClass", "aBlock"],
  44. source: unescape('on%3A%20aClass%20do%3A%20aBlock%0A%09subscriptions%20add%3A%20%28AnnouncementSubscription%20new%0A%09%09block%3A%20aBlock%3B%0A%09%09announcementClass%3A%20aClass%3B%0A%09%09yourself%29'),
  45. messageSends: ["add:", "block:", "announcementClass:", "yourself", "new"],
  46. referencedClasses: ["AnnouncementSubscription"]
  47. }),
  48. smalltalk.Announcer);
  49. smalltalk.addClass('AnnouncementSubscription', smalltalk.Object, ['block', 'announcementClass'], 'Kernel-Announcements');
  50. smalltalk.addMethod(
  51. unescape('_announcementClass'),
  52. smalltalk.method({
  53. selector: unescape('announcementClass'),
  54. category: 'accessing',
  55. fn: function (){
  56. var self=this;
  57. return self['@announcementClass'];
  58. return self;},
  59. args: [],
  60. source: unescape('announcementClass%0A%09%5EannouncementClass'),
  61. messageSends: [],
  62. referencedClasses: []
  63. }),
  64. smalltalk.AnnouncementSubscription);
  65. smalltalk.addMethod(
  66. unescape('_announcementClass_'),
  67. smalltalk.method({
  68. selector: unescape('announcementClass%3A'),
  69. category: 'accessing',
  70. fn: function (aClass){
  71. var self=this;
  72. (self['@announcementClass']=aClass);
  73. return self;},
  74. args: ["aClass"],
  75. source: unescape('announcementClass%3A%20aClass%0A%09announcementClass%20%3A%3D%20aClass'),
  76. messageSends: [],
  77. referencedClasses: []
  78. }),
  79. smalltalk.AnnouncementSubscription);
  80. smalltalk.addMethod(
  81. unescape('_block'),
  82. smalltalk.method({
  83. selector: unescape('block'),
  84. category: 'accessing',
  85. fn: function (){
  86. var self=this;
  87. return self['@block'];
  88. return self;},
  89. args: [],
  90. source: unescape('block%0A%09%5Eblock'),
  91. messageSends: [],
  92. referencedClasses: []
  93. }),
  94. smalltalk.AnnouncementSubscription);
  95. smalltalk.addMethod(
  96. unescape('_block_'),
  97. smalltalk.method({
  98. selector: unescape('block%3A'),
  99. category: 'accessing',
  100. fn: function (aBlock){
  101. var self=this;
  102. (self['@block']=aBlock);
  103. return self;},
  104. args: ["aBlock"],
  105. source: unescape('block%3A%20aBlock%0A%09block%20%3A%3D%20aBlock'),
  106. messageSends: [],
  107. referencedClasses: []
  108. }),
  109. smalltalk.AnnouncementSubscription);
  110. smalltalk.addMethod(
  111. unescape('_deliver_'),
  112. smalltalk.method({
  113. selector: unescape('deliver%3A'),
  114. category: 'announcing',
  115. fn: function (anAnnouncement){
  116. var self=this;
  117. ((($receiver = smalltalk.send(self, "_handlesAnnouncement_", [anAnnouncement])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(smalltalk.send(self, "_block", []), "_value_", [anAnnouncement]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(smalltalk.send(self, "_block", []), "_value_", [anAnnouncement]);})]));
  118. return self;},
  119. args: ["anAnnouncement"],
  120. source: unescape('deliver%3A%20anAnnouncement%0A%09%28self%20handlesAnnouncement%3A%20anAnnouncement%29%0A%09%09ifTrue%3A%20%5Bself%20block%20value%3A%20anAnnouncement%5D'),
  121. messageSends: ["ifTrue:", "handlesAnnouncement:", "value:", "block"],
  122. referencedClasses: []
  123. }),
  124. smalltalk.AnnouncementSubscription);
  125. smalltalk.addMethod(
  126. unescape('_handlesAnnouncement_'),
  127. smalltalk.method({
  128. selector: unescape('handlesAnnouncement%3A'),
  129. category: 'announcing',
  130. fn: function (anAnnouncement){
  131. var self=this;
  132. return smalltalk.send(anAnnouncement, "_isKindOf_", [smalltalk.send(self, "_announcementClass", [])]);
  133. return self;},
  134. args: ["anAnnouncement"],
  135. source: unescape('handlesAnnouncement%3A%20anAnnouncement%0A%09%5EanAnnouncement%20isKindOf%3A%20self%20announcementClass'),
  136. messageSends: ["isKindOf:", "announcementClass"],
  137. referencedClasses: []
  138. }),
  139. smalltalk.AnnouncementSubscription);