Kernel-Announcements.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  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('ClassAnnouncement', smalltalk.SystemAnnouncement, ['theClass'], 'Kernel-Announcements');
  235. smalltalk.addMethod(
  236. "_theClass",
  237. smalltalk.method({
  238. selector: "theClass",
  239. category: 'accessing',
  240. fn: function (){
  241. var self=this;
  242. return smalltalk.withContext(function($ctx1) { var $1;
  243. $1=self["@theClass"];
  244. return $1;
  245. }, function($ctx1) {$ctx1.fill(self,"theClass",{},smalltalk.ClassAnnouncement)})},
  246. args: [],
  247. source: "theClass\x0a\x09^ theClass",
  248. messageSends: [],
  249. referencedClasses: []
  250. }),
  251. smalltalk.ClassAnnouncement);
  252. smalltalk.addMethod(
  253. "_theClass_",
  254. smalltalk.method({
  255. selector: "theClass:",
  256. category: 'accessing',
  257. fn: function (aClass){
  258. var self=this;
  259. return smalltalk.withContext(function($ctx1) { self["@theClass"]=aClass;
  260. return self}, function($ctx1) {$ctx1.fill(self,"theClass:",{aClass:aClass},smalltalk.ClassAnnouncement)})},
  261. args: ["aClass"],
  262. source: "theClass: aClass\x0a\x09theClass := aClass",
  263. messageSends: [],
  264. referencedClasses: []
  265. }),
  266. smalltalk.ClassAnnouncement);
  267. smalltalk.addClass('ClassAdded', smalltalk.ClassAnnouncement, [], 'Kernel-Announcements');
  268. smalltalk.ClassAdded.comment="I am emitted when a class is added to the system.\x0aSee ClassBuilder >> #addSubclassOf:... methods"
  269. smalltalk.addClass('ClassCommentChanged', smalltalk.ClassAnnouncement, [], 'Kernel-Announcements');
  270. smalltalk.ClassCommentChanged.comment="I am emitted when the comment of a class changes. (Behavior >> #comment)"
  271. smalltalk.addClass('ClassDefinitionChanged', smalltalk.ClassAnnouncement, [], 'Kernel-Announcements');
  272. smalltalk.ClassDefinitionChanged.comment="I am emitted when the defintion of a class changes.\x0aSee ClassBuilder >> #class:instanceVariableNames:"
  273. smalltalk.addClass('ClassRemoved', smalltalk.ClassAnnouncement, [], 'Kernel-Announcements');
  274. smalltalk.ClassRemoved.comment="I am emitted when a class is removed.\x0aSee Smalltalk >> #removeClass:"
  275. smalltalk.addClass('ClassRenamed', smalltalk.ClassAnnouncement, [], 'Kernel-Announcements');
  276. smalltalk.ClassRenamed.comment="I am emitted when a class is renamed.\x0aSee ClassBuilder >> #renameClass:to:"
  277. smalltalk.addClass('MethodAnnouncement', smalltalk.SystemAnnouncement, ['method'], 'Kernel-Announcements');
  278. smalltalk.addMethod(
  279. "_method",
  280. smalltalk.method({
  281. selector: "method",
  282. category: 'accessing',
  283. fn: function (){
  284. var self=this;
  285. return smalltalk.withContext(function($ctx1) { var $1;
  286. $1=self["@method"];
  287. return $1;
  288. }, function($ctx1) {$ctx1.fill(self,"method",{},smalltalk.MethodAnnouncement)})},
  289. args: [],
  290. source: "method\x0a\x09^ method",
  291. messageSends: [],
  292. referencedClasses: []
  293. }),
  294. smalltalk.MethodAnnouncement);
  295. smalltalk.addMethod(
  296. "_method_",
  297. smalltalk.method({
  298. selector: "method:",
  299. category: 'accessing',
  300. fn: function (aCompiledMethod){
  301. var self=this;
  302. return smalltalk.withContext(function($ctx1) { self["@method"]=aCompiledMethod;
  303. return self}, function($ctx1) {$ctx1.fill(self,"method:",{aCompiledMethod:aCompiledMethod},smalltalk.MethodAnnouncement)})},
  304. args: ["aCompiledMethod"],
  305. source: "method: aCompiledMethod\x0a\x09method := aCompiledMethod",
  306. messageSends: [],
  307. referencedClasses: []
  308. }),
  309. smalltalk.MethodAnnouncement);
  310. smalltalk.addClass('MethodAdded', smalltalk.MethodAnnouncement, [], 'Kernel-Announcements');
  311. smalltalk.addClass('MethodModified', smalltalk.MethodAnnouncement, ['oldMethod'], 'Kernel-Announcements');
  312. smalltalk.addMethod(
  313. "_oldMethod",
  314. smalltalk.method({
  315. selector: "oldMethod",
  316. category: 'accessing',
  317. fn: function (){
  318. var self=this;
  319. return smalltalk.withContext(function($ctx1) { var $1;
  320. $1=self["@oldMethod"];
  321. return $1;
  322. }, function($ctx1) {$ctx1.fill(self,"oldMethod",{},smalltalk.MethodModified)})},
  323. args: [],
  324. source: "oldMethod\x0a\x09^ oldMethod",
  325. messageSends: [],
  326. referencedClasses: []
  327. }),
  328. smalltalk.MethodModified);
  329. smalltalk.addMethod(
  330. "_oldMethod_",
  331. smalltalk.method({
  332. selector: "oldMethod:",
  333. category: 'accessing',
  334. fn: function (aMethod){
  335. var self=this;
  336. return smalltalk.withContext(function($ctx1) { self["@oldMethod"]=aMethod;
  337. return self}, function($ctx1) {$ctx1.fill(self,"oldMethod:",{aMethod:aMethod},smalltalk.MethodModified)})},
  338. args: ["aMethod"],
  339. source: "oldMethod: aMethod\x0a\x09oldMethod := aMethod",
  340. messageSends: [],
  341. referencedClasses: []
  342. }),
  343. smalltalk.MethodModified);
  344. smalltalk.addClass('MethodRemoved', smalltalk.MethodAnnouncement, [], 'Kernel-Announcements');
  345. smalltalk.addClass('PackageAnnouncement', smalltalk.SystemAnnouncement, ['package'], 'Kernel-Announcements');
  346. smalltalk.addMethod(
  347. "_package",
  348. smalltalk.method({
  349. selector: "package",
  350. category: 'accessing',
  351. fn: function (){
  352. var self=this;
  353. return smalltalk.withContext(function($ctx1) { var $1;
  354. $1=self["@package"];
  355. return $1;
  356. }, function($ctx1) {$ctx1.fill(self,"package",{},smalltalk.PackageAnnouncement)})},
  357. args: [],
  358. source: "package\x0a\x09^ package",
  359. messageSends: [],
  360. referencedClasses: []
  361. }),
  362. smalltalk.PackageAnnouncement);
  363. smalltalk.addMethod(
  364. "_package_",
  365. smalltalk.method({
  366. selector: "package:",
  367. category: 'accessing',
  368. fn: function (aPackage){
  369. var self=this;
  370. return smalltalk.withContext(function($ctx1) { self["@package"]=aPackage;
  371. return self}, function($ctx1) {$ctx1.fill(self,"package:",{aPackage:aPackage},smalltalk.PackageAnnouncement)})},
  372. args: ["aPackage"],
  373. source: "package: aPackage\x0a\x09package := aPackage",
  374. messageSends: [],
  375. referencedClasses: []
  376. }),
  377. smalltalk.PackageAnnouncement);
  378. smalltalk.addClass('PackageAdded', smalltalk.PackageAnnouncement, [], 'Kernel-Announcements');
  379. smalltalk.addClass('PackageRemoved', smalltalk.PackageAnnouncement, [], 'Kernel-Announcements');
  380. smalltalk.addClass('ProtocolAnnouncement', smalltalk.SystemAnnouncement, ['theClass', 'protocol'], 'Kernel-Announcements');
  381. smalltalk.addMethod(
  382. "_protocol",
  383. smalltalk.method({
  384. selector: "protocol",
  385. category: 'accessing',
  386. fn: function (){
  387. var self=this;
  388. return smalltalk.withContext(function($ctx1) { var $1;
  389. $1=self["@protocol"];
  390. return $1;
  391. }, function($ctx1) {$ctx1.fill(self,"protocol",{},smalltalk.ProtocolAnnouncement)})},
  392. args: [],
  393. source: "protocol\x0a\x09^ protocol",
  394. messageSends: [],
  395. referencedClasses: []
  396. }),
  397. smalltalk.ProtocolAnnouncement);
  398. smalltalk.addMethod(
  399. "_protocol_",
  400. smalltalk.method({
  401. selector: "protocol:",
  402. category: 'accessing',
  403. fn: function (aString){
  404. var self=this;
  405. return smalltalk.withContext(function($ctx1) { self["@protocol"]=aString;
  406. return self}, function($ctx1) {$ctx1.fill(self,"protocol:",{aString:aString},smalltalk.ProtocolAnnouncement)})},
  407. args: ["aString"],
  408. source: "protocol: aString\x0a\x09protocol := aString",
  409. messageSends: [],
  410. referencedClasses: []
  411. }),
  412. smalltalk.ProtocolAnnouncement);
  413. smalltalk.addMethod(
  414. "_theClass",
  415. smalltalk.method({
  416. selector: "theClass",
  417. category: 'accessing',
  418. fn: function (){
  419. var self=this;
  420. return smalltalk.withContext(function($ctx1) { var $1;
  421. $1=self["@theClass"];
  422. return $1;
  423. }, function($ctx1) {$ctx1.fill(self,"theClass",{},smalltalk.ProtocolAnnouncement)})},
  424. args: [],
  425. source: "theClass\x0a\x09^ theClass",
  426. messageSends: [],
  427. referencedClasses: []
  428. }),
  429. smalltalk.ProtocolAnnouncement);
  430. smalltalk.addMethod(
  431. "_theClass_",
  432. smalltalk.method({
  433. selector: "theClass:",
  434. category: 'accessing',
  435. fn: function (aClass){
  436. var self=this;
  437. return smalltalk.withContext(function($ctx1) { self["@theClass"]=aClass;
  438. return self}, function($ctx1) {$ctx1.fill(self,"theClass:",{aClass:aClass},smalltalk.ProtocolAnnouncement)})},
  439. args: ["aClass"],
  440. source: "theClass: aClass\x0a\x09theClass := aClass",
  441. messageSends: [],
  442. referencedClasses: []
  443. }),
  444. smalltalk.ProtocolAnnouncement);
  445. smalltalk.addClass('ProtocolAdded', smalltalk.ProtocolAnnouncement, [], 'Kernel-Announcements');
  446. smalltalk.addClass('ProtocolRemoved', smalltalk.ProtocolAnnouncement, [], 'Kernel-Announcements');