Kernel-Announcements.js 9.7 KB

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