2
0

Kernel-Announcements.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  1. define("amber_core/Kernel-Announcements", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st, globals){
  2. smalltalk.addPackage('Kernel-Announcements');
  3. smalltalk.packages["Kernel-Announcements"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('AnnouncementSubscription', globals.Object, ['valuable', 'announcementClass'], 'Kernel-Announcements');
  5. globals.AnnouncementSubscription.comment="I am a single entry in a subscription registry of an `Announcer`.\x0aSeveral subscriptions by the same object is possible.";
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "announcementClass",
  9. protocol: 'accessing',
  10. fn: function (){
  11. var self=this;
  12. var $1;
  13. $1=self["@announcementClass"];
  14. return $1;
  15. },
  16. args: [],
  17. source: "announcementClass\x0a\x09^ announcementClass",
  18. messageSends: [],
  19. referencedClasses: []
  20. }),
  21. globals.AnnouncementSubscription);
  22. smalltalk.addMethod(
  23. smalltalk.method({
  24. selector: "announcementClass:",
  25. protocol: 'accessing',
  26. fn: function (aClass){
  27. var self=this;
  28. self["@announcementClass"]=aClass;
  29. return self},
  30. args: ["aClass"],
  31. source: "announcementClass: aClass\x0a\x09announcementClass := aClass",
  32. messageSends: [],
  33. referencedClasses: []
  34. }),
  35. globals.AnnouncementSubscription);
  36. smalltalk.addMethod(
  37. smalltalk.method({
  38. selector: "block",
  39. protocol: 'accessing',
  40. fn: function (){
  41. var self=this;
  42. return smalltalk.withContext(function($ctx1) {
  43. var $1;
  44. self._deprecatedAPI();
  45. $1=self._valuable();
  46. return $1;
  47. }, function($ctx1) {$ctx1.fill(self,"block",{},globals.AnnouncementSubscription)})},
  48. args: [],
  49. source: "block\x0a\x09\x22Use #valuable instead\x22\x0a\x09\x0a\x09self deprecatedAPI.\x0a\x09^ self valuable",
  50. messageSends: ["deprecatedAPI", "valuable"],
  51. referencedClasses: []
  52. }),
  53. globals.AnnouncementSubscription);
  54. smalltalk.addMethod(
  55. smalltalk.method({
  56. selector: "block:",
  57. protocol: 'accessing',
  58. fn: function (aValuable){
  59. var self=this;
  60. return smalltalk.withContext(function($ctx1) {
  61. self._deprecatedAPI();
  62. self._valuable_(aValuable);
  63. return self}, function($ctx1) {$ctx1.fill(self,"block:",{aValuable:aValuable},globals.AnnouncementSubscription)})},
  64. args: ["aValuable"],
  65. source: "block: aValuable\x0a\x09\x22Use #valuable instead\x22\x0a\x09\x0a\x09self deprecatedAPI.\x0a\x09self valuable: aValuable",
  66. messageSends: ["deprecatedAPI", "valuable:"],
  67. referencedClasses: []
  68. }),
  69. globals.AnnouncementSubscription);
  70. smalltalk.addMethod(
  71. smalltalk.method({
  72. selector: "deliver:",
  73. protocol: 'announcing',
  74. fn: function (anAnnouncement){
  75. var self=this;
  76. return smalltalk.withContext(function($ctx1) {
  77. var $1;
  78. $1=self._handlesAnnouncement_(anAnnouncement);
  79. if(smalltalk.assert($1)){
  80. _st(self._valuable())._value_(anAnnouncement);
  81. };
  82. return self}, function($ctx1) {$ctx1.fill(self,"deliver:",{anAnnouncement:anAnnouncement},globals.AnnouncementSubscription)})},
  83. args: ["anAnnouncement"],
  84. source: "deliver: anAnnouncement\x0a\x09(self handlesAnnouncement: anAnnouncement)\x0a\x09\x09ifTrue: [ self valuable value: anAnnouncement ]",
  85. messageSends: ["ifTrue:", "handlesAnnouncement:", "value:", "valuable"],
  86. referencedClasses: []
  87. }),
  88. globals.AnnouncementSubscription);
  89. smalltalk.addMethod(
  90. smalltalk.method({
  91. selector: "handlesAnnouncement:",
  92. protocol: 'announcing',
  93. fn: function (anAnnouncement){
  94. var self=this;
  95. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  96. return smalltalk.withContext(function($ctx1) {
  97. var $3,$4,$2,$1,$receiver;
  98. $3=_st($Smalltalk())._globals();
  99. $ctx1.sendIdx["globals"]=1;
  100. $4=_st(self._announcementClass())._name();
  101. $ctx1.sendIdx["name"]=1;
  102. $2=_st($3)._at_($4);
  103. $ctx1.sendIdx["at:"]=1;
  104. if(($receiver = $2) == nil || $receiver == null){
  105. return false;
  106. } else {
  107. var class_;
  108. class_=$receiver;
  109. $1=_st(_st(_st($Smalltalk())._globals())._at_(_st(_st(_st(anAnnouncement)._class())._theNonMetaClass())._name()))._includesBehavior_(class_);
  110. };
  111. return $1;
  112. }, function($ctx1) {$ctx1.fill(self,"handlesAnnouncement:",{anAnnouncement:anAnnouncement},globals.AnnouncementSubscription)})},
  113. args: ["anAnnouncement"],
  114. source: "handlesAnnouncement: anAnnouncement\x0a\x09\x22anAnnouncement might be announced from within another Amber environment\x22\x0a\x09\x0a\x09^ (Smalltalk globals at: self announcementClass name)\x0a\x09\x09ifNil: [ ^ false ]\x0a\x09\x09ifNotNil: [ :class |\x0a\x09\x09(Smalltalk globals at: anAnnouncement class theNonMetaClass name) includesBehavior: class ]",
  115. messageSends: ["ifNil:ifNotNil:", "at:", "globals", "name", "announcementClass", "includesBehavior:", "theNonMetaClass", "class"],
  116. referencedClasses: ["Smalltalk"]
  117. }),
  118. globals.AnnouncementSubscription);
  119. smalltalk.addMethod(
  120. smalltalk.method({
  121. selector: "receiver",
  122. protocol: 'accessing',
  123. fn: function (){
  124. var self=this;
  125. return smalltalk.withContext(function($ctx1) {
  126. var $1;
  127. $1=_st(self._valuable())._receiver();
  128. return $1;
  129. }, function($ctx1) {$ctx1.fill(self,"receiver",{},globals.AnnouncementSubscription)})},
  130. args: [],
  131. source: "receiver\x0a\x09^ self valuable receiver",
  132. messageSends: ["receiver", "valuable"],
  133. referencedClasses: []
  134. }),
  135. globals.AnnouncementSubscription);
  136. smalltalk.addMethod(
  137. smalltalk.method({
  138. selector: "valuable",
  139. protocol: 'accessing',
  140. fn: function (){
  141. var self=this;
  142. var $1;
  143. $1=self["@valuable"];
  144. return $1;
  145. },
  146. args: [],
  147. source: "valuable\x0a\x09^ valuable",
  148. messageSends: [],
  149. referencedClasses: []
  150. }),
  151. globals.AnnouncementSubscription);
  152. smalltalk.addMethod(
  153. smalltalk.method({
  154. selector: "valuable:",
  155. protocol: 'accessing',
  156. fn: function (aValuable){
  157. var self=this;
  158. self["@valuable"]=aValuable;
  159. return self},
  160. args: ["aValuable"],
  161. source: "valuable: aValuable\x0a\x09valuable := aValuable",
  162. messageSends: [],
  163. referencedClasses: []
  164. }),
  165. globals.AnnouncementSubscription);
  166. smalltalk.addClass('AnnouncementValuable', globals.Object, ['valuable', 'receiver'], 'Kernel-Announcements');
  167. globals.AnnouncementValuable.comment="I wrap `valuable` objects (typically instances of `BlockClosure`) with a `receiver` to be able to unregister subscriptions based on a `receiver`.";
  168. smalltalk.addMethod(
  169. smalltalk.method({
  170. selector: "receiver",
  171. protocol: 'accessing',
  172. fn: function (){
  173. var self=this;
  174. var $1;
  175. $1=self["@receiver"];
  176. return $1;
  177. },
  178. args: [],
  179. source: "receiver\x0a\x09^ receiver",
  180. messageSends: [],
  181. referencedClasses: []
  182. }),
  183. globals.AnnouncementValuable);
  184. smalltalk.addMethod(
  185. smalltalk.method({
  186. selector: "receiver:",
  187. protocol: 'accessing',
  188. fn: function (anObject){
  189. var self=this;
  190. self["@receiver"]=anObject;
  191. return self},
  192. args: ["anObject"],
  193. source: "receiver: anObject\x0a\x09receiver := anObject",
  194. messageSends: [],
  195. referencedClasses: []
  196. }),
  197. globals.AnnouncementValuable);
  198. smalltalk.addMethod(
  199. smalltalk.method({
  200. selector: "valuable",
  201. protocol: 'accessing',
  202. fn: function (){
  203. var self=this;
  204. var $1;
  205. $1=self["@valuable"];
  206. return $1;
  207. },
  208. args: [],
  209. source: "valuable\x0a\x09^ valuable",
  210. messageSends: [],
  211. referencedClasses: []
  212. }),
  213. globals.AnnouncementValuable);
  214. smalltalk.addMethod(
  215. smalltalk.method({
  216. selector: "valuable:",
  217. protocol: 'accessing',
  218. fn: function (anObject){
  219. var self=this;
  220. self["@valuable"]=anObject;
  221. return self},
  222. args: ["anObject"],
  223. source: "valuable: anObject\x0a\x09valuable := anObject",
  224. messageSends: [],
  225. referencedClasses: []
  226. }),
  227. globals.AnnouncementValuable);
  228. smalltalk.addMethod(
  229. smalltalk.method({
  230. selector: "value",
  231. protocol: 'evaluating',
  232. fn: function (){
  233. var self=this;
  234. return smalltalk.withContext(function($ctx1) {
  235. var $1;
  236. $1=_st(self._valuable())._value();
  237. return $1;
  238. }, function($ctx1) {$ctx1.fill(self,"value",{},globals.AnnouncementValuable)})},
  239. args: [],
  240. source: "value\x0a\x09^ self valuable value",
  241. messageSends: ["value", "valuable"],
  242. referencedClasses: []
  243. }),
  244. globals.AnnouncementValuable);
  245. smalltalk.addMethod(
  246. smalltalk.method({
  247. selector: "value:",
  248. protocol: 'evaluating',
  249. fn: function (anObject){
  250. var self=this;
  251. return smalltalk.withContext(function($ctx1) {
  252. var $1;
  253. $1=_st(self._valuable())._value_(anObject);
  254. return $1;
  255. }, function($ctx1) {$ctx1.fill(self,"value:",{anObject:anObject},globals.AnnouncementValuable)})},
  256. args: ["anObject"],
  257. source: "value: anObject\x0a\x09^ self valuable value: anObject",
  258. messageSends: ["value:", "valuable"],
  259. referencedClasses: []
  260. }),
  261. globals.AnnouncementValuable);
  262. smalltalk.addClass('Announcer', globals.Object, ['registry', 'subscriptions'], 'Kernel-Announcements');
  263. globals.Announcer.comment="I hold annoncement subscriptions (instances of `AnnouncementSubscription`) in a private registry.\x0aI announce (trigger) announces, which are then dispatched to all subscriptions.\x0a\x0aThe code is based on the announcements as [described by Vassili Bykov](http://www.cincomsmalltalk.com/userblogs/vbykov/blogView?searchCategory=Announcements%20Framework).\x0a\x0a## API\x0a\x0aUse `#announce:` to trigger an announcement.\x0a\x0aUse `#on:do:` or `#on:send:to:` to register subscriptions.\x0a\x0aWhen using `#on:send:to:`, unregistration can be done with `#unregister:`.\x0a\x0a## Usage example:\x0a\x0a SystemAnnouncer current\x0a on: ClassAdded\x0a do: [ :ann | window alert: ann theClass name, ' added' ].";
  264. smalltalk.addMethod(
  265. smalltalk.method({
  266. selector: "announce:",
  267. protocol: 'announcing',
  268. fn: function (anAnnouncement){
  269. var self=this;
  270. return smalltalk.withContext(function($ctx1) {
  271. _st(self["@subscriptions"])._do_((function(each){
  272. return smalltalk.withContext(function($ctx2) {
  273. return _st(each)._deliver_(anAnnouncement);
  274. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  275. return self}, function($ctx1) {$ctx1.fill(self,"announce:",{anAnnouncement:anAnnouncement},globals.Announcer)})},
  276. args: ["anAnnouncement"],
  277. source: "announce: anAnnouncement\x0a\x09subscriptions do: [ :each |\x0a\x09\x09each deliver: anAnnouncement ]",
  278. messageSends: ["do:", "deliver:"],
  279. referencedClasses: []
  280. }),
  281. globals.Announcer);
  282. smalltalk.addMethod(
  283. smalltalk.method({
  284. selector: "initialize",
  285. protocol: 'initialization',
  286. fn: function (){
  287. var self=this;
  288. function $OrderedCollection(){return globals.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  289. return smalltalk.withContext(function($ctx1) {
  290. globals.Announcer.superclass.fn.prototype._initialize.apply(_st(self), []);
  291. self["@subscriptions"]=_st($OrderedCollection())._new();
  292. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.Announcer)})},
  293. args: [],
  294. source: "initialize\x0a\x09super initialize.\x0a\x09subscriptions := OrderedCollection new",
  295. messageSends: ["initialize", "new"],
  296. referencedClasses: ["OrderedCollection"]
  297. }),
  298. globals.Announcer);
  299. smalltalk.addMethod(
  300. smalltalk.method({
  301. selector: "on:do:",
  302. protocol: 'subscribing',
  303. fn: function (aClass,aBlock){
  304. var self=this;
  305. return smalltalk.withContext(function($ctx1) {
  306. self._on_do_for_(aClass,aBlock,nil);
  307. return self}, function($ctx1) {$ctx1.fill(self,"on:do:",{aClass:aClass,aBlock:aBlock},globals.Announcer)})},
  308. args: ["aClass", "aBlock"],
  309. source: "on: aClass do: aBlock\x0a\x09self on: aClass do: aBlock for: nil",
  310. messageSends: ["on:do:for:"],
  311. referencedClasses: []
  312. }),
  313. globals.Announcer);
  314. smalltalk.addMethod(
  315. smalltalk.method({
  316. selector: "on:do:for:",
  317. protocol: 'subscribing',
  318. fn: function (aClass,aBlock,aReceiver){
  319. var self=this;
  320. function $AnnouncementSubscription(){return globals.AnnouncementSubscription||(typeof AnnouncementSubscription=="undefined"?nil:AnnouncementSubscription)}
  321. function $AnnouncementValuable(){return globals.AnnouncementValuable||(typeof AnnouncementValuable=="undefined"?nil:AnnouncementValuable)}
  322. return smalltalk.withContext(function($ctx1) {
  323. var $1,$3,$4,$6,$7,$5,$8,$2;
  324. $1=self["@subscriptions"];
  325. $3=_st($AnnouncementSubscription())._new();
  326. $ctx1.sendIdx["new"]=1;
  327. $4=$3;
  328. $6=_st($AnnouncementValuable())._new();
  329. _st($6)._valuable_(aBlock);
  330. _st($6)._receiver_(aReceiver);
  331. $7=_st($6)._yourself();
  332. $ctx1.sendIdx["yourself"]=1;
  333. $5=$7;
  334. _st($4)._valuable_($5);
  335. $ctx1.sendIdx["valuable:"]=1;
  336. _st($3)._announcementClass_(aClass);
  337. $8=_st($3)._yourself();
  338. $2=$8;
  339. _st($1)._add_($2);
  340. return self}, function($ctx1) {$ctx1.fill(self,"on:do:for:",{aClass:aClass,aBlock:aBlock,aReceiver:aReceiver},globals.Announcer)})},
  341. args: ["aClass", "aBlock", "aReceiver"],
  342. source: "on: aClass do: aBlock for: aReceiver\x0a\x09subscriptions add: (AnnouncementSubscription new\x0a\x09\x09valuable: (AnnouncementValuable new\x0a\x09\x09\x09valuable: aBlock;\x0a\x09\x09\x09receiver: aReceiver;\x0a\x09\x09\x09yourself);\x0a\x09\x09announcementClass: aClass;\x0a\x09\x09yourself)",
  343. messageSends: ["add:", "valuable:", "new", "receiver:", "yourself", "announcementClass:"],
  344. referencedClasses: ["AnnouncementSubscription", "AnnouncementValuable"]
  345. }),
  346. globals.Announcer);
  347. smalltalk.addMethod(
  348. smalltalk.method({
  349. selector: "on:doOnce:",
  350. protocol: 'subscribing',
  351. fn: function (aClass,aBlock){
  352. var self=this;
  353. var subscription;
  354. function $AnnouncementSubscription(){return globals.AnnouncementSubscription||(typeof AnnouncementSubscription=="undefined"?nil:AnnouncementSubscription)}
  355. return smalltalk.withContext(function($ctx1) {
  356. var $1,$2;
  357. $1=_st($AnnouncementSubscription())._new();
  358. _st($1)._announcementClass_(aClass);
  359. $2=_st($1)._yourself();
  360. subscription=$2;
  361. _st(subscription)._valuable_((function(ann){
  362. return smalltalk.withContext(function($ctx2) {
  363. _st(self["@subscriptions"])._remove_(subscription);
  364. return _st(aBlock)._value_(ann);
  365. }, function($ctx2) {$ctx2.fillBlock({ann:ann},$ctx1,1)})}));
  366. _st(self["@subscriptions"])._add_(subscription);
  367. return self}, function($ctx1) {$ctx1.fill(self,"on:doOnce:",{aClass:aClass,aBlock:aBlock,subscription:subscription},globals.Announcer)})},
  368. args: ["aClass", "aBlock"],
  369. source: "on: aClass doOnce: aBlock\x0a\x09| subscription |\x0a\x09\x0a\x09subscription := AnnouncementSubscription new\x0a\x09\x09announcementClass: aClass;\x0a\x09\x09yourself.\x0a\x09subscription valuable: [ :ann |\x0a\x09\x09subscriptions remove: subscription.\x0a\x09\x09aBlock value: ann ].\x0a\x0a\x09subscriptions add: subscription",
  370. messageSends: ["announcementClass:", "new", "yourself", "valuable:", "remove:", "value:", "add:"],
  371. referencedClasses: ["AnnouncementSubscription"]
  372. }),
  373. globals.Announcer);
  374. smalltalk.addMethod(
  375. smalltalk.method({
  376. selector: "on:send:to:",
  377. protocol: 'subscribing',
  378. fn: function (aClass,aSelector,anObject){
  379. var self=this;
  380. function $AnnouncementSubscription(){return globals.AnnouncementSubscription||(typeof AnnouncementSubscription=="undefined"?nil:AnnouncementSubscription)}
  381. function $MessageSend(){return globals.MessageSend||(typeof MessageSend=="undefined"?nil:MessageSend)}
  382. return smalltalk.withContext(function($ctx1) {
  383. var $1,$3,$4,$6,$7,$5,$8,$2;
  384. $1=self["@subscriptions"];
  385. $3=_st($AnnouncementSubscription())._new();
  386. $ctx1.sendIdx["new"]=1;
  387. $4=$3;
  388. $6=_st($MessageSend())._new();
  389. _st($6)._receiver_(anObject);
  390. _st($6)._selector_(aSelector);
  391. $7=_st($6)._yourself();
  392. $ctx1.sendIdx["yourself"]=1;
  393. $5=$7;
  394. _st($4)._valuable_($5);
  395. _st($3)._announcementClass_(aClass);
  396. $8=_st($3)._yourself();
  397. $2=$8;
  398. _st($1)._add_($2);
  399. return self}, function($ctx1) {$ctx1.fill(self,"on:send:to:",{aClass:aClass,aSelector:aSelector,anObject:anObject},globals.Announcer)})},
  400. args: ["aClass", "aSelector", "anObject"],
  401. source: "on: aClass send: aSelector to: anObject\x0a\x09subscriptions add: (AnnouncementSubscription new\x0a\x09\x09valuable: (MessageSend new\x0a\x09\x09\x09receiver: anObject;\x0a\x09\x09\x09selector: aSelector;\x0a\x09\x09\x09yourself);\x0a\x09\x09announcementClass: aClass;\x0a\x09\x09yourself)",
  402. messageSends: ["add:", "valuable:", "new", "receiver:", "selector:", "yourself", "announcementClass:"],
  403. referencedClasses: ["AnnouncementSubscription", "MessageSend"]
  404. }),
  405. globals.Announcer);
  406. smalltalk.addMethod(
  407. smalltalk.method({
  408. selector: "unsubscribe:",
  409. protocol: 'subscribing',
  410. fn: function (anObject){
  411. var self=this;
  412. return smalltalk.withContext(function($ctx1) {
  413. self["@subscriptions"]=_st(self["@subscriptions"])._reject_((function(each){
  414. return smalltalk.withContext(function($ctx2) {
  415. return _st(_st(each)._receiver()).__eq(anObject);
  416. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  417. return self}, function($ctx1) {$ctx1.fill(self,"unsubscribe:",{anObject:anObject},globals.Announcer)})},
  418. args: ["anObject"],
  419. source: "unsubscribe: anObject\x0a\x09subscriptions := subscriptions reject: [ :each |\x0a\x09\x09each receiver = anObject ]",
  420. messageSends: ["reject:", "=", "receiver"],
  421. referencedClasses: []
  422. }),
  423. globals.Announcer);
  424. smalltalk.addClass('SystemAnnouncer', globals.Announcer, [], 'Kernel-Announcements');
  425. globals.SystemAnnouncer.comment="My unique instance is the global announcer handling all Amber system-related announces.\x0a\x0a## API\x0a\x0aAccess to the unique instance is done via `#current`";
  426. globals.SystemAnnouncer.klass.iVarNames = ['current'];
  427. smalltalk.addMethod(
  428. smalltalk.method({
  429. selector: "current",
  430. protocol: 'accessing',
  431. fn: function (){
  432. var self=this;
  433. return smalltalk.withContext(function($ctx1) {
  434. var $2,$1,$receiver;
  435. $2=self["@current"];
  436. if(($receiver = $2) == nil || $receiver == null){
  437. self["@current"]=globals.SystemAnnouncer.klass.superclass.fn.prototype._new.apply(_st(self), []);
  438. $1=self["@current"];
  439. } else {
  440. $1=$2;
  441. };
  442. return $1;
  443. }, function($ctx1) {$ctx1.fill(self,"current",{},globals.SystemAnnouncer.klass)})},
  444. args: [],
  445. source: "current\x0a\x09^ current ifNil: [ current := super new ]",
  446. messageSends: ["ifNil:", "new"],
  447. referencedClasses: []
  448. }),
  449. globals.SystemAnnouncer.klass);
  450. smalltalk.addMethod(
  451. smalltalk.method({
  452. selector: "new",
  453. protocol: 'instance creation',
  454. fn: function (){
  455. var self=this;
  456. return smalltalk.withContext(function($ctx1) {
  457. self._shouldNotImplement();
  458. return self}, function($ctx1) {$ctx1.fill(self,"new",{},globals.SystemAnnouncer.klass)})},
  459. args: [],
  460. source: "new\x0a\x09self shouldNotImplement",
  461. messageSends: ["shouldNotImplement"],
  462. referencedClasses: []
  463. }),
  464. globals.SystemAnnouncer.klass);
  465. smalltalk.addClass('SystemAnnouncement', globals.Object, [], 'Kernel-Announcements');
  466. globals.SystemAnnouncement.comment="I am the superclass of all system announcements";
  467. smalltalk.addMethod(
  468. smalltalk.method({
  469. selector: "heliosClass",
  470. protocol: 'helios',
  471. fn: function (){
  472. var self=this;
  473. return "announcement";
  474. },
  475. args: [],
  476. source: "heliosClass\x0a\x09^ 'announcement'",
  477. messageSends: [],
  478. referencedClasses: []
  479. }),
  480. globals.SystemAnnouncement.klass);
  481. smalltalk.addClass('ClassAnnouncement', globals.SystemAnnouncement, ['theClass'], 'Kernel-Announcements');
  482. globals.ClassAnnouncement.comment="I am the abstract superclass of class-related announcements.";
  483. smalltalk.addMethod(
  484. smalltalk.method({
  485. selector: "theClass",
  486. protocol: 'accessing',
  487. fn: function (){
  488. var self=this;
  489. var $1;
  490. $1=self["@theClass"];
  491. return $1;
  492. },
  493. args: [],
  494. source: "theClass\x0a\x09^ theClass",
  495. messageSends: [],
  496. referencedClasses: []
  497. }),
  498. globals.ClassAnnouncement);
  499. smalltalk.addMethod(
  500. smalltalk.method({
  501. selector: "theClass:",
  502. protocol: 'accessing',
  503. fn: function (aClass){
  504. var self=this;
  505. self["@theClass"]=aClass;
  506. return self},
  507. args: ["aClass"],
  508. source: "theClass: aClass\x0a\x09theClass := aClass",
  509. messageSends: [],
  510. referencedClasses: []
  511. }),
  512. globals.ClassAnnouncement);
  513. smalltalk.addClass('ClassAdded', globals.ClassAnnouncement, [], 'Kernel-Announcements');
  514. globals.ClassAdded.comment="I am emitted when a class is added to the system.\x0aSee ClassBuilder >> #addSubclassOf:... methods";
  515. smalltalk.addClass('ClassCommentChanged', globals.ClassAnnouncement, [], 'Kernel-Announcements');
  516. globals.ClassCommentChanged.comment="I am emitted when the comment of a class changes. (Behavior >> #comment)";
  517. smalltalk.addClass('ClassDefinitionChanged', globals.ClassAnnouncement, [], 'Kernel-Announcements');
  518. globals.ClassDefinitionChanged.comment="I am emitted when the definition of a class changes.\x0aSee ClassBuilder >> #class:instanceVariableNames:";
  519. smalltalk.addClass('ClassMigrated', globals.ClassAnnouncement, ['oldClass'], 'Kernel-Announcements');
  520. globals.ClassMigrated.comment="I am emitted when a class is migrated.";
  521. smalltalk.addMethod(
  522. smalltalk.method({
  523. selector: "oldClass",
  524. protocol: 'accessing',
  525. fn: function (){
  526. var self=this;
  527. var $1;
  528. $1=self["@oldClass"];
  529. return $1;
  530. },
  531. args: [],
  532. source: "oldClass\x0a\x09^ oldClass",
  533. messageSends: [],
  534. referencedClasses: []
  535. }),
  536. globals.ClassMigrated);
  537. smalltalk.addMethod(
  538. smalltalk.method({
  539. selector: "oldClass:",
  540. protocol: 'accessing',
  541. fn: function (aClass){
  542. var self=this;
  543. self["@oldClass"]=aClass;
  544. return self},
  545. args: ["aClass"],
  546. source: "oldClass: aClass\x0a\x09oldClass := aClass",
  547. messageSends: [],
  548. referencedClasses: []
  549. }),
  550. globals.ClassMigrated);
  551. smalltalk.addClass('ClassMoved', globals.ClassAnnouncement, ['oldPackage'], 'Kernel-Announcements');
  552. globals.ClassMoved.comment="I am emitted when a class is moved from one package to another.";
  553. smalltalk.addMethod(
  554. smalltalk.method({
  555. selector: "oldPackage",
  556. protocol: 'accessing',
  557. fn: function (){
  558. var self=this;
  559. var $1;
  560. $1=self["@oldPackage"];
  561. return $1;
  562. },
  563. args: [],
  564. source: "oldPackage\x0a\x09^ oldPackage",
  565. messageSends: [],
  566. referencedClasses: []
  567. }),
  568. globals.ClassMoved);
  569. smalltalk.addMethod(
  570. smalltalk.method({
  571. selector: "oldPackage:",
  572. protocol: 'accessing',
  573. fn: function (aPackage){
  574. var self=this;
  575. self["@oldPackage"]=aPackage;
  576. return self},
  577. args: ["aPackage"],
  578. source: "oldPackage: aPackage\x0a\x09oldPackage := aPackage",
  579. messageSends: [],
  580. referencedClasses: []
  581. }),
  582. globals.ClassMoved);
  583. smalltalk.addClass('ClassRemoved', globals.ClassAnnouncement, [], 'Kernel-Announcements');
  584. globals.ClassRemoved.comment="I am emitted when a class is removed.\x0aSee Smalltalk >> #removeClass:";
  585. smalltalk.addClass('ClassRenamed', globals.ClassAnnouncement, [], 'Kernel-Announcements');
  586. globals.ClassRenamed.comment="I am emitted when a class is renamed.\x0aSee ClassBuilder >> #renameClass:to:";
  587. smalltalk.addClass('MethodAnnouncement', globals.SystemAnnouncement, ['method'], 'Kernel-Announcements');
  588. globals.MethodAnnouncement.comment="I am the abstract superclass of method-related announcements.";
  589. smalltalk.addMethod(
  590. smalltalk.method({
  591. selector: "method",
  592. protocol: 'accessing',
  593. fn: function (){
  594. var self=this;
  595. var $1;
  596. $1=self["@method"];
  597. return $1;
  598. },
  599. args: [],
  600. source: "method\x0a\x09^ method",
  601. messageSends: [],
  602. referencedClasses: []
  603. }),
  604. globals.MethodAnnouncement);
  605. smalltalk.addMethod(
  606. smalltalk.method({
  607. selector: "method:",
  608. protocol: 'accessing',
  609. fn: function (aCompiledMethod){
  610. var self=this;
  611. self["@method"]=aCompiledMethod;
  612. return self},
  613. args: ["aCompiledMethod"],
  614. source: "method: aCompiledMethod\x0a\x09method := aCompiledMethod",
  615. messageSends: [],
  616. referencedClasses: []
  617. }),
  618. globals.MethodAnnouncement);
  619. smalltalk.addClass('MethodAdded', globals.MethodAnnouncement, [], 'Kernel-Announcements');
  620. globals.MethodAdded.comment="I am emitted when a `CompiledMethod` is added to a class.";
  621. smalltalk.addClass('MethodModified', globals.MethodAnnouncement, ['oldMethod'], 'Kernel-Announcements');
  622. globals.MethodModified.comment="I am emitted when a `CompiledMethod` is modified (a new method is installed). I hold a reference to the old method being replaced.";
  623. smalltalk.addMethod(
  624. smalltalk.method({
  625. selector: "oldMethod",
  626. protocol: 'accessing',
  627. fn: function (){
  628. var self=this;
  629. var $1;
  630. $1=self["@oldMethod"];
  631. return $1;
  632. },
  633. args: [],
  634. source: "oldMethod\x0a\x09^ oldMethod",
  635. messageSends: [],
  636. referencedClasses: []
  637. }),
  638. globals.MethodModified);
  639. smalltalk.addMethod(
  640. smalltalk.method({
  641. selector: "oldMethod:",
  642. protocol: 'accessing',
  643. fn: function (aMethod){
  644. var self=this;
  645. self["@oldMethod"]=aMethod;
  646. return self},
  647. args: ["aMethod"],
  648. source: "oldMethod: aMethod\x0a\x09oldMethod := aMethod",
  649. messageSends: [],
  650. referencedClasses: []
  651. }),
  652. globals.MethodModified);
  653. smalltalk.addClass('MethodMoved', globals.MethodAnnouncement, ['oldProtocol'], 'Kernel-Announcements');
  654. globals.MethodMoved.comment="I am emitted when a `CompiledMethod` is moved to another protocol. I hold a refernce to the old protocol of the method.";
  655. smalltalk.addMethod(
  656. smalltalk.method({
  657. selector: "oldProtocol",
  658. protocol: 'accessing',
  659. fn: function (){
  660. var self=this;
  661. var $1;
  662. $1=self["@oldProtocol"];
  663. return $1;
  664. },
  665. args: [],
  666. source: "oldProtocol\x0a\x09^ oldProtocol",
  667. messageSends: [],
  668. referencedClasses: []
  669. }),
  670. globals.MethodMoved);
  671. smalltalk.addMethod(
  672. smalltalk.method({
  673. selector: "oldProtocol:",
  674. protocol: 'accessing',
  675. fn: function (aString){
  676. var self=this;
  677. self["@oldProtocol"]=aString;
  678. return self},
  679. args: ["aString"],
  680. source: "oldProtocol: aString\x0a\x09oldProtocol := aString",
  681. messageSends: [],
  682. referencedClasses: []
  683. }),
  684. globals.MethodMoved);
  685. smalltalk.addClass('MethodRemoved', globals.MethodAnnouncement, [], 'Kernel-Announcements');
  686. globals.MethodRemoved.comment="I am emitted when a `CompiledMethod` is removed from a class.";
  687. smalltalk.addClass('PackageAnnouncement', globals.SystemAnnouncement, ['package'], 'Kernel-Announcements');
  688. globals.PackageAnnouncement.comment="I am the abstract superclass of package-related announcements.";
  689. smalltalk.addMethod(
  690. smalltalk.method({
  691. selector: "package",
  692. protocol: 'accessing',
  693. fn: function (){
  694. var self=this;
  695. var $1;
  696. $1=self["@package"];
  697. return $1;
  698. },
  699. args: [],
  700. source: "package\x0a\x09^ package",
  701. messageSends: [],
  702. referencedClasses: []
  703. }),
  704. globals.PackageAnnouncement);
  705. smalltalk.addMethod(
  706. smalltalk.method({
  707. selector: "package:",
  708. protocol: 'accessing',
  709. fn: function (aPackage){
  710. var self=this;
  711. self["@package"]=aPackage;
  712. return self},
  713. args: ["aPackage"],
  714. source: "package: aPackage\x0a\x09package := aPackage",
  715. messageSends: [],
  716. referencedClasses: []
  717. }),
  718. globals.PackageAnnouncement);
  719. smalltalk.addClass('PackageAdded', globals.PackageAnnouncement, [], 'Kernel-Announcements');
  720. globals.PackageAdded.comment="I am emitted when a `Package` is added to the system.";
  721. smalltalk.addClass('PackageClean', globals.PackageAnnouncement, [], 'Kernel-Announcements');
  722. globals.PackageClean.comment="I am emitted when a package is committed and becomes clean.";
  723. smalltalk.addClass('PackageDirty', globals.PackageAnnouncement, [], 'Kernel-Announcements');
  724. globals.PackageDirty.comment="I am emitted when a package becomes dirty.";
  725. smalltalk.addClass('PackageRemoved', globals.PackageAnnouncement, [], 'Kernel-Announcements');
  726. globals.PackageRemoved.comment="I am emitted when a `Package` is removed from the system.";
  727. smalltalk.addClass('ProtocolAnnouncement', globals.SystemAnnouncement, ['theClass', 'protocol'], 'Kernel-Announcements');
  728. globals.ProtocolAnnouncement.comment="I am the abstract superclass of protocol-related announcements.";
  729. smalltalk.addMethod(
  730. smalltalk.method({
  731. selector: "protocol",
  732. protocol: 'accessing',
  733. fn: function (){
  734. var self=this;
  735. var $1;
  736. $1=self["@protocol"];
  737. return $1;
  738. },
  739. args: [],
  740. source: "protocol\x0a\x09^ protocol",
  741. messageSends: [],
  742. referencedClasses: []
  743. }),
  744. globals.ProtocolAnnouncement);
  745. smalltalk.addMethod(
  746. smalltalk.method({
  747. selector: "protocol:",
  748. protocol: 'accessing',
  749. fn: function (aString){
  750. var self=this;
  751. self["@protocol"]=aString;
  752. return self},
  753. args: ["aString"],
  754. source: "protocol: aString\x0a\x09protocol := aString",
  755. messageSends: [],
  756. referencedClasses: []
  757. }),
  758. globals.ProtocolAnnouncement);
  759. smalltalk.addMethod(
  760. smalltalk.method({
  761. selector: "theClass",
  762. protocol: 'accessing',
  763. fn: function (){
  764. var self=this;
  765. var $1;
  766. $1=self["@theClass"];
  767. return $1;
  768. },
  769. args: [],
  770. source: "theClass\x0a\x09^ theClass",
  771. messageSends: [],
  772. referencedClasses: []
  773. }),
  774. globals.ProtocolAnnouncement);
  775. smalltalk.addMethod(
  776. smalltalk.method({
  777. selector: "theClass:",
  778. protocol: 'accessing',
  779. fn: function (aClass){
  780. var self=this;
  781. self["@theClass"]=aClass;
  782. return self},
  783. args: ["aClass"],
  784. source: "theClass: aClass\x0a\x09theClass := aClass",
  785. messageSends: [],
  786. referencedClasses: []
  787. }),
  788. globals.ProtocolAnnouncement);
  789. smalltalk.addClass('ProtocolAdded', globals.ProtocolAnnouncement, [], 'Kernel-Announcements');
  790. globals.ProtocolAdded.comment="I am emitted when a protocol is added to a class.";
  791. smalltalk.addClass('ProtocolRemoved', globals.ProtocolAnnouncement, [], 'Kernel-Announcements');
  792. globals.ProtocolRemoved.comment="I am emitted when a protocol is removed from a class.";
  793. });