Kernel-Announcements.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  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. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  131. return smalltalk.withContext(function($ctx1) { smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  132. self["@subscriptions"]=_st($Array())._new();
  133. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.Announcer)})},
  134. args: [],
  135. source: "initialize\x0a\x09super initialize.\x0a\x09subscriptions := Array new",
  136. messageSends: ["initialize", "new"],
  137. referencedClasses: ["Array"]
  138. }),
  139. smalltalk.Announcer);
  140. smalltalk.addMethod(
  141. "_on_do_",
  142. smalltalk.method({
  143. selector: "on:do:",
  144. category: 'subscribing',
  145. fn: function (aClass,aBlock){
  146. var self=this;
  147. function $AnnouncementSubscription(){return smalltalk.AnnouncementSubscription||(typeof AnnouncementSubscription=="undefined"?nil:AnnouncementSubscription)}
  148. return smalltalk.withContext(function($ctx1) { var $1,$2;
  149. $1=_st($AnnouncementSubscription())._new();
  150. _st($1)._block_(aBlock);
  151. _st($1)._announcementClass_(aClass);
  152. $2=_st($1)._yourself();
  153. _st(self["@subscriptions"])._add_($2);
  154. return self}, function($ctx1) {$ctx1.fill(self,"on:do:",{aClass:aClass,aBlock:aBlock},smalltalk.Announcer)})},
  155. args: ["aClass", "aBlock"],
  156. source: "on: aClass do: aBlock\x0a\x09subscriptions add: (AnnouncementSubscription new\x0a\x09\x09block: aBlock;\x0a\x09\x09announcementClass: aClass;\x0a\x09\x09yourself)",
  157. messageSends: ["add:", "block:", "new", "announcementClass:", "yourself"],
  158. referencedClasses: ["AnnouncementSubscription"]
  159. }),
  160. smalltalk.Announcer);
  161. smalltalk.addClass('SystemAnnouncer', smalltalk.Announcer, [], 'Kernel-Announcements');
  162. smalltalk.SystemAnnouncer.comment="My unique instance #current is the global announcer handling all Amber system-related announces"
  163. smalltalk.SystemAnnouncer.klass.iVarNames = ['current'];
  164. smalltalk.addMethod(
  165. "_current",
  166. smalltalk.method({
  167. selector: "current",
  168. category: 'accessing',
  169. fn: function (){
  170. var self=this;
  171. return smalltalk.withContext(function($ctx1) { var $2,$1;
  172. $2=self["@current"];
  173. if(($receiver = $2) == nil || $receiver == undefined){
  174. self["@current"]=smalltalk.Announcer.klass.fn.prototype._new.apply(_st(self), []);
  175. $1=self["@current"];
  176. } else {
  177. $1=$2;
  178. };
  179. return $1;
  180. }, function($ctx1) {$ctx1.fill(self,"current",{},smalltalk.SystemAnnouncer.klass)})},
  181. args: [],
  182. source: "current\x0a\x09^ current ifNil: [ current := super new ]",
  183. messageSends: ["ifNil:", "new"],
  184. referencedClasses: []
  185. }),
  186. smalltalk.SystemAnnouncer.klass);
  187. smalltalk.addMethod(
  188. "_new",
  189. smalltalk.method({
  190. selector: "new",
  191. category: 'instance creation',
  192. fn: function (){
  193. var self=this;
  194. return smalltalk.withContext(function($ctx1) { _st(self)._shouldNotImplement();
  195. return self}, function($ctx1) {$ctx1.fill(self,"new",{},smalltalk.SystemAnnouncer.klass)})},
  196. args: [],
  197. source: "new\x0a\x09self shouldNotImplement",
  198. messageSends: ["shouldNotImplement"],
  199. referencedClasses: []
  200. }),
  201. smalltalk.SystemAnnouncer.klass);
  202. smalltalk.addClass('SystemAnnouncement', smalltalk.Object, ['theClass'], 'Kernel-Announcements');
  203. smalltalk.SystemAnnouncement.comment="I am the superclass of all system announcements"
  204. smalltalk.addMethod(
  205. "_theClass",
  206. smalltalk.method({
  207. selector: "theClass",
  208. category: 'accessing',
  209. fn: function (){
  210. var self=this;
  211. return smalltalk.withContext(function($ctx1) { var $1;
  212. $1=self["@theClass"];
  213. return $1;
  214. }, function($ctx1) {$ctx1.fill(self,"theClass",{},smalltalk.SystemAnnouncement)})},
  215. args: [],
  216. source: "theClass\x0a\x09^ theClass",
  217. messageSends: [],
  218. referencedClasses: []
  219. }),
  220. smalltalk.SystemAnnouncement);
  221. smalltalk.addMethod(
  222. "_theClass_",
  223. smalltalk.method({
  224. selector: "theClass:",
  225. category: 'accessing',
  226. fn: function (aClass){
  227. var self=this;
  228. return smalltalk.withContext(function($ctx1) { self["@theClass"]=aClass;
  229. return self}, function($ctx1) {$ctx1.fill(self,"theClass:",{aClass:aClass},smalltalk.SystemAnnouncement)})},
  230. args: ["aClass"],
  231. source: "theClass: aClass\x0a\x09theClass := aClass",
  232. messageSends: [],
  233. referencedClasses: []
  234. }),
  235. smalltalk.SystemAnnouncement);
  236. smalltalk.addClass('ClassAnnouncement', smalltalk.SystemAnnouncement, ['theClass'], 'Kernel-Announcements');
  237. smalltalk.addMethod(
  238. "_theClass",
  239. smalltalk.method({
  240. selector: "theClass",
  241. category: 'accessing',
  242. fn: function (){
  243. var self=this;
  244. return smalltalk.withContext(function($ctx1) { var $1;
  245. $1=self["@theClass"];
  246. return $1;
  247. }, function($ctx1) {$ctx1.fill(self,"theClass",{},smalltalk.ClassAnnouncement)})},
  248. args: [],
  249. source: "theClass\x0a\x09^ theClass",
  250. messageSends: [],
  251. referencedClasses: []
  252. }),
  253. smalltalk.ClassAnnouncement);
  254. smalltalk.addMethod(
  255. "_theClass_",
  256. smalltalk.method({
  257. selector: "theClass:",
  258. category: 'accessing',
  259. fn: function (aClass){
  260. var self=this;
  261. return smalltalk.withContext(function($ctx1) { self["@theClass"]=aClass;
  262. return self}, function($ctx1) {$ctx1.fill(self,"theClass:",{aClass:aClass},smalltalk.ClassAnnouncement)})},
  263. args: ["aClass"],
  264. source: "theClass: aClass\x0a\x09theClass := aClass",
  265. messageSends: [],
  266. referencedClasses: []
  267. }),
  268. smalltalk.ClassAnnouncement);
  269. smalltalk.addClass('ClassAdded', smalltalk.ClassAnnouncement, [], 'Kernel-Announcements');
  270. smalltalk.ClassAdded.comment="I am emitted when a class is added to the system.\x0aSee ClassBuilder >> #addSubclassOf:... methods"
  271. smalltalk.addClass('ClassCommentChanged', smalltalk.ClassAnnouncement, [], 'Kernel-Announcements');
  272. smalltalk.ClassCommentChanged.comment="I am emitted when the comment of a class changes. (Behavior >> #comment)"
  273. smalltalk.addClass('ClassDefinitionChanged', smalltalk.ClassAnnouncement, [], 'Kernel-Announcements');
  274. smalltalk.ClassDefinitionChanged.comment="I am emitted when the defintion of a class changes.\x0aSee ClassBuilder >> #class:instanceVariableNames:"
  275. smalltalk.addClass('ClassRemoved', smalltalk.ClassAnnouncement, [], 'Kernel-Announcements');
  276. smalltalk.ClassRemoved.comment="I am emitted when a class is removed.\x0aSee Smalltalk >> #removeClass:"
  277. smalltalk.addClass('ClassRenamed', smalltalk.ClassAnnouncement, [], 'Kernel-Announcements');
  278. smalltalk.ClassRenamed.comment="I am emitted when a class is renamed.\x0aSee ClassBuilder >> #renameClass:to:"
  279. smalltalk.addClass('MethodAnnouncement', smalltalk.SystemAnnouncement, ['method'], 'Kernel-Announcements');
  280. smalltalk.addMethod(
  281. "_method",
  282. smalltalk.method({
  283. selector: "method",
  284. category: 'accessing',
  285. fn: function (){
  286. var self=this;
  287. return smalltalk.withContext(function($ctx1) { var $1;
  288. $1=self["@method"];
  289. return $1;
  290. }, function($ctx1) {$ctx1.fill(self,"method",{},smalltalk.MethodAnnouncement)})},
  291. args: [],
  292. source: "method\x0a\x09^ method",
  293. messageSends: [],
  294. referencedClasses: []
  295. }),
  296. smalltalk.MethodAnnouncement);
  297. smalltalk.addMethod(
  298. "_method_",
  299. smalltalk.method({
  300. selector: "method:",
  301. category: 'accessing',
  302. fn: function (aCompiledMethod){
  303. var self=this;
  304. return smalltalk.withContext(function($ctx1) { self["@method"]=aCompiledMethod;
  305. return self}, function($ctx1) {$ctx1.fill(self,"method:",{aCompiledMethod:aCompiledMethod},smalltalk.MethodAnnouncement)})},
  306. args: ["aCompiledMethod"],
  307. source: "method: aCompiledMethod\x0a\x09method := aCompiledMethod",
  308. messageSends: [],
  309. referencedClasses: []
  310. }),
  311. smalltalk.MethodAnnouncement);
  312. smalltalk.addClass('MethodAdded', smalltalk.MethodAnnouncement, [], 'Kernel-Announcements');
  313. smalltalk.addClass('MethodModified', smalltalk.MethodAnnouncement, ['oldMethod'], 'Kernel-Announcements');
  314. smalltalk.addMethod(
  315. "_oldMethod",
  316. smalltalk.method({
  317. selector: "oldMethod",
  318. category: 'accessing',
  319. fn: function (){
  320. var self=this;
  321. return smalltalk.withContext(function($ctx1) { var $1;
  322. $1=self["@oldMethod"];
  323. return $1;
  324. }, function($ctx1) {$ctx1.fill(self,"oldMethod",{},smalltalk.MethodModified)})},
  325. args: [],
  326. source: "oldMethod\x0a\x09^ oldMethod",
  327. messageSends: [],
  328. referencedClasses: []
  329. }),
  330. smalltalk.MethodModified);
  331. smalltalk.addMethod(
  332. "_oldMethod_",
  333. smalltalk.method({
  334. selector: "oldMethod:",
  335. category: 'accessing',
  336. fn: function (aMethod){
  337. var self=this;
  338. return smalltalk.withContext(function($ctx1) { self["@oldMethod"]=aMethod;
  339. return self}, function($ctx1) {$ctx1.fill(self,"oldMethod:",{aMethod:aMethod},smalltalk.MethodModified)})},
  340. args: ["aMethod"],
  341. source: "oldMethod: aMethod\x0a\x09oldMethod := aMethod",
  342. messageSends: [],
  343. referencedClasses: []
  344. }),
  345. smalltalk.MethodModified);
  346. smalltalk.addClass('MethodRemoved', smalltalk.MethodAnnouncement, [], 'Kernel-Announcements');
  347. smalltalk.addClass('PackageAnnouncement', smalltalk.SystemAnnouncement, ['package'], 'Kernel-Announcements');
  348. smalltalk.addMethod(
  349. "_package",
  350. smalltalk.method({
  351. selector: "package",
  352. category: 'accessing',
  353. fn: function (){
  354. var self=this;
  355. return smalltalk.withContext(function($ctx1) { var $1;
  356. $1=self["@package"];
  357. return $1;
  358. }, function($ctx1) {$ctx1.fill(self,"package",{},smalltalk.PackageAnnouncement)})},
  359. args: [],
  360. source: "package\x0a\x09^ package",
  361. messageSends: [],
  362. referencedClasses: []
  363. }),
  364. smalltalk.PackageAnnouncement);
  365. smalltalk.addMethod(
  366. "_package_",
  367. smalltalk.method({
  368. selector: "package:",
  369. category: 'accessing',
  370. fn: function (aPackage){
  371. var self=this;
  372. return smalltalk.withContext(function($ctx1) { self["@package"]=aPackage;
  373. return self}, function($ctx1) {$ctx1.fill(self,"package:",{aPackage:aPackage},smalltalk.PackageAnnouncement)})},
  374. args: ["aPackage"],
  375. source: "package: aPackage\x0a\x09package := aPackage",
  376. messageSends: [],
  377. referencedClasses: []
  378. }),
  379. smalltalk.PackageAnnouncement);
  380. smalltalk.addClass('PackageAdded', smalltalk.PackageAnnouncement, [], 'Kernel-Announcements');
  381. smalltalk.addClass('PackageRemoved', smalltalk.PackageAnnouncement, [], 'Kernel-Announcements');
  382. smalltalk.addClass('ProtocolAnnouncement', smalltalk.SystemAnnouncement, ['theClass', 'protocol'], 'Kernel-Announcements');
  383. smalltalk.addMethod(
  384. "_protocol",
  385. smalltalk.method({
  386. selector: "protocol",
  387. category: 'accessing',
  388. fn: function (){
  389. var self=this;
  390. return smalltalk.withContext(function($ctx1) { var $1;
  391. $1=self["@protocol"];
  392. return $1;
  393. }, function($ctx1) {$ctx1.fill(self,"protocol",{},smalltalk.ProtocolAnnouncement)})},
  394. args: [],
  395. source: "protocol\x0a\x09^ protocol",
  396. messageSends: [],
  397. referencedClasses: []
  398. }),
  399. smalltalk.ProtocolAnnouncement);
  400. smalltalk.addMethod(
  401. "_protocol_",
  402. smalltalk.method({
  403. selector: "protocol:",
  404. category: 'accessing',
  405. fn: function (aString){
  406. var self=this;
  407. return smalltalk.withContext(function($ctx1) { self["@protocol"]=aString;
  408. return self}, function($ctx1) {$ctx1.fill(self,"protocol:",{aString:aString},smalltalk.ProtocolAnnouncement)})},
  409. args: ["aString"],
  410. source: "protocol: aString\x0a\x09protocol := aString",
  411. messageSends: [],
  412. referencedClasses: []
  413. }),
  414. smalltalk.ProtocolAnnouncement);
  415. smalltalk.addMethod(
  416. "_theClass",
  417. smalltalk.method({
  418. selector: "theClass",
  419. category: 'accessing',
  420. fn: function (){
  421. var self=this;
  422. return smalltalk.withContext(function($ctx1) { var $1;
  423. $1=self["@theClass"];
  424. return $1;
  425. }, function($ctx1) {$ctx1.fill(self,"theClass",{},smalltalk.ProtocolAnnouncement)})},
  426. args: [],
  427. source: "theClass\x0a\x09^ theClass",
  428. messageSends: [],
  429. referencedClasses: []
  430. }),
  431. smalltalk.ProtocolAnnouncement);
  432. smalltalk.addMethod(
  433. "_theClass_",
  434. smalltalk.method({
  435. selector: "theClass:",
  436. category: 'accessing',
  437. fn: function (aClass){
  438. var self=this;
  439. return smalltalk.withContext(function($ctx1) { self["@theClass"]=aClass;
  440. return self}, function($ctx1) {$ctx1.fill(self,"theClass:",{aClass:aClass},smalltalk.ProtocolAnnouncement)})},
  441. args: ["aClass"],
  442. source: "theClass: aClass\x0a\x09theClass := aClass",
  443. messageSends: [],
  444. referencedClasses: []
  445. }),
  446. smalltalk.ProtocolAnnouncement);
  447. smalltalk.addClass('ProtocolAdded', smalltalk.ProtocolAnnouncement, [], 'Kernel-Announcements');
  448. smalltalk.addClass('ProtocolRemoved', smalltalk.ProtocolAnnouncement, [], 'Kernel-Announcements');