Kernel-Announcements.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. smalltalk.addPackage('Kernel-Announcements', {});
  2. smalltalk.addClass('AnnouncementSubscription', smalltalk.Object, ['block', 'announcementClass'], 'Kernel-Announcements');
  3. smalltalk.AnnouncementSubscription.comment="The subscription is a single entry in a subscription registry of an `Announcer`.\x0aSeveral subscriptions by the same object is possible."
  4. smalltalk.addMethod(
  5. "_announcementClass",
  6. smalltalk.method({
  7. selector: "announcementClass",
  8. category: 'accessing',
  9. fn: function (){
  10. var self=this;
  11. return smalltalk.withContext(function($ctx1) { var $1;
  12. $1=self["@announcementClass"];
  13. return $1;
  14. }, function($ctx1) {$ctx1.fill(self,"announcementClass",{}, smalltalk.AnnouncementSubscription)})},
  15. args: [],
  16. source: "announcementClass\x0a\x09^announcementClass",
  17. messageSends: [],
  18. referencedClasses: []
  19. }),
  20. smalltalk.AnnouncementSubscription);
  21. smalltalk.addMethod(
  22. "_announcementClass_",
  23. smalltalk.method({
  24. selector: "announcementClass:",
  25. category: 'accessing',
  26. fn: function (aClass){
  27. var self=this;
  28. return smalltalk.withContext(function($ctx1) { self["@announcementClass"]=aClass;
  29. return self}, function($ctx1) {$ctx1.fill(self,"announcementClass:",{aClass:aClass}, smalltalk.AnnouncementSubscription)})},
  30. args: ["aClass"],
  31. source: "announcementClass: aClass\x0a\x09announcementClass := aClass",
  32. messageSends: [],
  33. referencedClasses: []
  34. }),
  35. smalltalk.AnnouncementSubscription);
  36. smalltalk.addMethod(
  37. "_block",
  38. smalltalk.method({
  39. selector: "block",
  40. category: 'accessing',
  41. fn: function (){
  42. var self=this;
  43. return smalltalk.withContext(function($ctx1) { var $1;
  44. $1=self["@block"];
  45. return $1;
  46. }, function($ctx1) {$ctx1.fill(self,"block",{}, smalltalk.AnnouncementSubscription)})},
  47. args: [],
  48. source: "block\x0a\x09^block",
  49. messageSends: [],
  50. referencedClasses: []
  51. }),
  52. smalltalk.AnnouncementSubscription);
  53. smalltalk.addMethod(
  54. "_block_",
  55. smalltalk.method({
  56. selector: "block:",
  57. category: 'accessing',
  58. fn: function (aBlock){
  59. var self=this;
  60. return smalltalk.withContext(function($ctx1) { self["@block"]=aBlock;
  61. return self}, function($ctx1) {$ctx1.fill(self,"block:",{aBlock:aBlock}, smalltalk.AnnouncementSubscription)})},
  62. args: ["aBlock"],
  63. source: "block: aBlock\x0a\x09block := aBlock",
  64. messageSends: [],
  65. referencedClasses: []
  66. }),
  67. smalltalk.AnnouncementSubscription);
  68. smalltalk.addMethod(
  69. "_deliver_",
  70. smalltalk.method({
  71. selector: "deliver:",
  72. category: 'announcing',
  73. fn: function (anAnnouncement){
  74. var self=this;
  75. return smalltalk.withContext(function($ctx1) { var $1;
  76. $1=_st(self)._handlesAnnouncement_(anAnnouncement);
  77. if(smalltalk.assert($1)){
  78. _st(_st(self)._block())._value_(anAnnouncement);
  79. };
  80. return self}, function($ctx1) {$ctx1.fill(self,"deliver:",{anAnnouncement:anAnnouncement}, smalltalk.AnnouncementSubscription)})},
  81. args: ["anAnnouncement"],
  82. source: "deliver: anAnnouncement\x0a\x09(self handlesAnnouncement: anAnnouncement)\x0a\x09\x09ifTrue: [self block value: anAnnouncement]",
  83. messageSends: ["ifTrue:", "value:", "block", "handlesAnnouncement:"],
  84. referencedClasses: []
  85. }),
  86. smalltalk.AnnouncementSubscription);
  87. smalltalk.addMethod(
  88. "_handlesAnnouncement_",
  89. smalltalk.method({
  90. selector: "handlesAnnouncement:",
  91. category: 'announcing',
  92. fn: function (anAnnouncement){
  93. var self=this;
  94. return smalltalk.withContext(function($ctx1) { var $1;
  95. $1=_st(anAnnouncement)._isKindOf_(_st(self)._announcementClass());
  96. return $1;
  97. }, function($ctx1) {$ctx1.fill(self,"handlesAnnouncement:",{anAnnouncement:anAnnouncement}, smalltalk.AnnouncementSubscription)})},
  98. args: ["anAnnouncement"],
  99. source: "handlesAnnouncement: anAnnouncement\x0a\x09^anAnnouncement isKindOf: self announcementClass",
  100. messageSends: ["isKindOf:", "announcementClass"],
  101. referencedClasses: []
  102. }),
  103. smalltalk.AnnouncementSubscription);
  104. smalltalk.addClass('Announcer', smalltalk.Object, ['registry', 'subscriptions'], 'Kernel-Announcements');
  105. smalltalk.Announcer.comment="The code is based on the announcements as [described by Vassili Bykov](http://www.cincomsmalltalk.com/userblogs/vbykov/blogView?searchCategory=Announcements%20Framework).\x0aThe Announcer holds annoncement subscriptions (`AnnouncementSubscription`) in a private registry.\x0a\x0aUse `#on:do:` to register subscriptions."
  106. smalltalk.addMethod(
  107. "_announce_",
  108. smalltalk.method({
  109. selector: "announce:",
  110. category: 'announcing',
  111. fn: function (anAnnouncement){
  112. var self=this;
  113. return smalltalk.withContext(function($ctx1) { _st(self["@subscriptions"])._do_((function(each){
  114. return smalltalk.withContext(function($ctx2) { return _st(each)._deliver_(anAnnouncement);
  115. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  116. return self}, function($ctx1) {$ctx1.fill(self,"announce:",{anAnnouncement:anAnnouncement}, smalltalk.Announcer)})},
  117. args: ["anAnnouncement"],
  118. source: "announce: anAnnouncement\x0a\x09subscriptions do: [:each |\x0a\x09\x09each deliver: anAnnouncement]",
  119. messageSends: ["do:", "deliver:"],
  120. referencedClasses: []
  121. }),
  122. smalltalk.Announcer);
  123. smalltalk.addMethod(
  124. "_initialize",
  125. smalltalk.method({
  126. selector: "initialize",
  127. category: 'initialization',
  128. fn: function (){
  129. var self=this;
  130. return smalltalk.withContext(function($ctx1) { smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  131. self["@subscriptions"]=_st((smalltalk.Array || Array))._new();
  132. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.Announcer)})},
  133. args: [],
  134. source: "initialize\x0a\x09super initialize.\x0a\x09subscriptions := Array new",
  135. messageSends: ["initialize", "new"],
  136. referencedClasses: ["Array"]
  137. }),
  138. smalltalk.Announcer);
  139. smalltalk.addMethod(
  140. "_on_do_",
  141. smalltalk.method({
  142. selector: "on:do:",
  143. category: 'subscribing',
  144. fn: function (aClass,aBlock){
  145. var self=this;
  146. return smalltalk.withContext(function($ctx1) { var $1,$2;
  147. $1=_st((smalltalk.AnnouncementSubscription || AnnouncementSubscription))._new();
  148. _st($1)._block_(aBlock);
  149. _st($1)._announcementClass_(aClass);
  150. $2=_st($1)._yourself();
  151. _st(self["@subscriptions"])._add_($2);
  152. return self}, function($ctx1) {$ctx1.fill(self,"on:do:",{aClass:aClass,aBlock:aBlock}, smalltalk.Announcer)})},
  153. args: ["aClass", "aBlock"],
  154. source: "on: aClass do: aBlock\x0a\x09subscriptions add: (AnnouncementSubscription new\x0a\x09\x09block: aBlock;\x0a\x09\x09announcementClass: aClass;\x0a\x09\x09yourself)",
  155. messageSends: ["add:", "block:", "new", "announcementClass:", "yourself"],
  156. referencedClasses: ["AnnouncementSubscription"]
  157. }),
  158. smalltalk.Announcer);
  159. smalltalk.addClass('SystemAnnouncer', smalltalk.Announcer, [], 'Kernel-Announcements');
  160. smalltalk.SystemAnnouncer.comment="My unique instance #current is the global announcer handling all Amber system-related announces"
  161. smalltalk.SystemAnnouncer.klass.iVarNames = ['current'];
  162. smalltalk.addMethod(
  163. "_current",
  164. smalltalk.method({
  165. selector: "current",
  166. category: 'accessing',
  167. fn: function (){
  168. var self=this;
  169. return smalltalk.withContext(function($ctx1) { var $2,$1;
  170. $2=self["@current"];
  171. if(($receiver = $2) == nil || $receiver == undefined){
  172. self["@current"]=smalltalk.Announcer.klass.fn.prototype._new.apply(_st(self), []);
  173. $1=self["@current"];
  174. } else {
  175. $1=$2;
  176. };
  177. return $1;
  178. }, function($ctx1) {$ctx1.fill(self,"current",{}, smalltalk.SystemAnnouncer.klass)})},
  179. args: [],
  180. source: "current\x0a\x09^ current ifNil: [ current := super new ]",
  181. messageSends: ["ifNil:", "new"],
  182. referencedClasses: []
  183. }),
  184. smalltalk.SystemAnnouncer.klass);
  185. smalltalk.addMethod(
  186. "_new",
  187. smalltalk.method({
  188. selector: "new",
  189. category: 'instance creation',
  190. fn: function (){
  191. var self=this;
  192. return smalltalk.withContext(function($ctx1) { _st(self)._shouldNotImplement();
  193. return self}, function($ctx1) {$ctx1.fill(self,"new",{}, smalltalk.SystemAnnouncer.klass)})},
  194. args: [],
  195. source: "new\x0a\x09self shouldNotImplement",
  196. messageSends: ["shouldNotImplement"],
  197. referencedClasses: []
  198. }),
  199. smalltalk.SystemAnnouncer.klass);
  200. smalltalk.addClass('SystemAnnouncement', smalltalk.Object, ['theClass'], 'Kernel-Announcements');
  201. smalltalk.SystemAnnouncement.comment="I am the superclass of all system announcements"
  202. smalltalk.addMethod(
  203. "_theClass",
  204. smalltalk.method({
  205. selector: "theClass",
  206. category: 'accessing',
  207. fn: function (){
  208. var self=this;
  209. return smalltalk.withContext(function($ctx1) { var $1;
  210. $1=self["@theClass"];
  211. return $1;
  212. }, function($ctx1) {$ctx1.fill(self,"theClass",{}, smalltalk.SystemAnnouncement)})},
  213. args: [],
  214. source: "theClass\x0a\x09^ theClass",
  215. messageSends: [],
  216. referencedClasses: []
  217. }),
  218. smalltalk.SystemAnnouncement);
  219. smalltalk.addMethod(
  220. "_theClass_",
  221. smalltalk.method({
  222. selector: "theClass:",
  223. category: 'accessing',
  224. fn: function (aClass){
  225. var self=this;
  226. return smalltalk.withContext(function($ctx1) { self["@theClass"]=aClass;
  227. return self}, function($ctx1) {$ctx1.fill(self,"theClass:",{aClass:aClass}, smalltalk.SystemAnnouncement)})},
  228. args: ["aClass"],
  229. source: "theClass: aClass\x0a\x09theClass := aClass",
  230. messageSends: [],
  231. referencedClasses: []
  232. }),
  233. smalltalk.SystemAnnouncement);
  234. smalltalk.addClass('ClassAdded', smalltalk.SystemAnnouncement, [], 'Kernel-Announcements');
  235. smalltalk.ClassAdded.comment="I am emitted when a class is added to the system.\x0aSee ClassBuilder >> #addSubclassOf:... methods"
  236. smalltalk.addClass('ClassCommentChanged', smalltalk.SystemAnnouncement, [], 'Kernel-Announcements');
  237. smalltalk.ClassCommentChanged.comment="I am emitted when the comment of a class changes. (Behavior >> #comment)"
  238. smalltalk.addClass('ClassDefinitionChanged', smalltalk.SystemAnnouncement, [], 'Kernel-Announcements');
  239. smalltalk.ClassDefinitionChanged.comment="I am emitted when the defintion of a class changes.\x0aSee ClassBuilder >> #class:instanceVariableNames:"
  240. smalltalk.addClass('ClassRemoved', smalltalk.SystemAnnouncement, [], 'Kernel-Announcements');
  241. smalltalk.ClassRemoved.comment="I am emitted when a class is removed.\x0aSee Smalltalk >> #removeClass:"
  242. smalltalk.addClass('ClassRenamed', smalltalk.SystemAnnouncement, [], 'Kernel-Announcements');
  243. smalltalk.ClassRenamed.comment="I am emitted when a class is renamed.\x0aSee ClassBuilder >> #renameClass:to:"
  244. smalltalk.addClass('MethodAnnouncement', smalltalk.SystemAnnouncement, ['method'], 'Kernel-Announcements');
  245. smalltalk.addMethod(
  246. "_method",
  247. smalltalk.method({
  248. selector: "method",
  249. category: 'accessing',
  250. fn: function (){
  251. var self=this;
  252. return smalltalk.withContext(function($ctx1) { var $1;
  253. $1=self["@method"];
  254. return $1;
  255. }, function($ctx1) {$ctx1.fill(self,"method",{}, smalltalk.MethodAnnouncement)})},
  256. args: [],
  257. source: "method\x0a\x09^ method",
  258. messageSends: [],
  259. referencedClasses: []
  260. }),
  261. smalltalk.MethodAnnouncement);
  262. smalltalk.addMethod(
  263. "_method_",
  264. smalltalk.method({
  265. selector: "method:",
  266. category: 'accessing',
  267. fn: function (aCompiledMethod){
  268. var self=this;
  269. return smalltalk.withContext(function($ctx1) { self["@method"]=aCompiledMethod;
  270. return self}, function($ctx1) {$ctx1.fill(self,"method:",{aCompiledMethod:aCompiledMethod}, smalltalk.MethodAnnouncement)})},
  271. args: ["aCompiledMethod"],
  272. source: "method: aCompiledMethod\x0a\x09method := aCompiledMethod",
  273. messageSends: [],
  274. referencedClasses: []
  275. }),
  276. smalltalk.MethodAnnouncement);
  277. smalltalk.addClass('MethodAdded', smalltalk.MethodAnnouncement, [], 'Kernel-Announcements');
  278. smalltalk.addClass('MethodRemoved', smalltalk.MethodAnnouncement, [], 'Kernel-Announcements');