Trapped-Backend.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  1. define("trapped/Trapped-Backend", ["amber/boot"
  2. //>>excludeStart("imports", pragmas.excludeImports);
  3. , "lyst/Lyst"
  4. //>>excludeEnd("imports");
  5. , "amber_core/Kernel-Objects", "axon/Axon", "amber_core/Kernel-Collections"], function($boot
  6. //>>excludeStart("imports", pragmas.excludeImports);
  7. //>>excludeEnd("imports");
  8. ){"use strict";
  9. var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
  10. $core.addPackage('Trapped-Backend');
  11. $core.packages["Trapped-Backend"].innerEval = function (expr) { return eval(expr); };
  12. $core.packages["Trapped-Backend"].imports = ["lyst/Lyst"];
  13. $core.packages["Trapped-Backend"].transport = {"type":"amd","amdNamespace":"trapped"};
  14. $core.addClass('EavModel', $globals.Object, ['getBlock', 'putBlock'], 'Trapped-Backend');
  15. //>>excludeStart("ide", pragmas.excludeIdeData);
  16. $globals.EavModel.comment="External actor value model.";
  17. //>>excludeEnd("ide");
  18. $core.addMethod(
  19. $core.method({
  20. selector: "getBlock:",
  21. protocol: 'accessing',
  22. fn: function (aBlock){
  23. var self=this;
  24. self["@getBlock"]=aBlock;
  25. return self;
  26. },
  27. //>>excludeStart("ide", pragmas.excludeIdeData);
  28. args: ["aBlock"],
  29. source: "getBlock: aBlock\x0a\x0agetBlock := aBlock",
  30. referencedClasses: [],
  31. //>>excludeEnd("ide");
  32. messageSends: []
  33. }),
  34. $globals.EavModel);
  35. $core.addMethod(
  36. $core.method({
  37. selector: "initialize",
  38. protocol: 'initialization',
  39. fn: function (){
  40. var self=this;
  41. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  42. return $core.withContext(function($ctx1) {
  43. //>>excludeEnd("ctx");
  44. (
  45. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  46. $ctx1.supercall = true,
  47. //>>excludeEnd("ctx");
  48. $globals.EavModel.superclass.fn.prototype._initialize.apply($recv(self), []));
  49. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  50. $ctx1.supercall = false;
  51. //>>excludeEnd("ctx");;
  52. self["@getBlock"]=(function(){
  53. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  54. return $core.withContext(function($ctx2) {
  55. //>>excludeEnd("ctx");
  56. return self._error_("No getter block.");
  57. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  58. $ctx2.sendIdx["error:"]=1;
  59. //>>excludeEnd("ctx");
  60. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  61. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  62. //>>excludeEnd("ctx");
  63. });
  64. self["@putBlock"]=(function(){
  65. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  66. return $core.withContext(function($ctx2) {
  67. //>>excludeEnd("ctx");
  68. return self._error_("No putter block.");
  69. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  70. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  71. //>>excludeEnd("ctx");
  72. });
  73. return self;
  74. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  75. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.EavModel)});
  76. //>>excludeEnd("ctx");
  77. },
  78. //>>excludeStart("ide", pragmas.excludeIdeData);
  79. args: [],
  80. source: "initialize\x0a\x09super initialize.\x0a\x09getBlock := [ self error: 'No getter block.' ].\x0a\x09putBlock := [ self error: 'No putter block.' ].",
  81. referencedClasses: [],
  82. //>>excludeEnd("ide");
  83. messageSends: ["initialize", "error:"]
  84. }),
  85. $globals.EavModel);
  86. $core.addMethod(
  87. $core.method({
  88. selector: "on:",
  89. protocol: 'accessing',
  90. fn: function (anObject){
  91. var self=this;
  92. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  93. return $core.withContext(function($ctx1) {
  94. //>>excludeEnd("ctx");
  95. var $1;
  96. $1=$recv(self["@getBlock"])._value_(anObject);
  97. return $1;
  98. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  99. }, function($ctx1) {$ctx1.fill(self,"on:",{anObject:anObject},$globals.EavModel)});
  100. //>>excludeEnd("ctx");
  101. },
  102. //>>excludeStart("ide", pragmas.excludeIdeData);
  103. args: ["anObject"],
  104. source: "on: anObject\x0a\x22Returns value of model applied on object\x22\x0a\x0a^getBlock value: anObject",
  105. referencedClasses: [],
  106. //>>excludeEnd("ide");
  107. messageSends: ["value:"]
  108. }),
  109. $globals.EavModel);
  110. $core.addMethod(
  111. $core.method({
  112. selector: "on:put:",
  113. protocol: 'accessing',
  114. fn: function (anObject,anObject2){
  115. var self=this;
  116. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  117. return $core.withContext(function($ctx1) {
  118. //>>excludeEnd("ctx");
  119. var $1;
  120. $1=$recv(self["@putBlock"])._value_value_(anObject,anObject2);
  121. return $1;
  122. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  123. }, function($ctx1) {$ctx1.fill(self,"on:put:",{anObject:anObject,anObject2:anObject2},$globals.EavModel)});
  124. //>>excludeEnd("ctx");
  125. },
  126. //>>excludeStart("ide", pragmas.excludeIdeData);
  127. args: ["anObject", "anObject2"],
  128. source: "on: anObject put: anObject2\x0a\x22Puts a value via model applied on object\x22\x0a\x0a^putBlock value: anObject value: anObject2",
  129. referencedClasses: [],
  130. //>>excludeEnd("ide");
  131. messageSends: ["value:value:"]
  132. }),
  133. $globals.EavModel);
  134. $core.addMethod(
  135. $core.method({
  136. selector: "putBlock:",
  137. protocol: 'accessing',
  138. fn: function (aBlock){
  139. var self=this;
  140. self["@putBlock"]=aBlock;
  141. return self;
  142. },
  143. //>>excludeStart("ide", pragmas.excludeIdeData);
  144. args: ["aBlock"],
  145. source: "putBlock: aBlock\x0a\x0aputBlock := aBlock",
  146. referencedClasses: [],
  147. //>>excludeEnd("ide");
  148. messageSends: []
  149. }),
  150. $globals.EavModel);
  151. $core.addClass('InterestedInTrapPath', $globals.AxonInterest, [], 'Trapped-Backend');
  152. $core.addMethod(
  153. $core.method({
  154. selector: "accepts:",
  155. protocol: 'testing',
  156. fn: function (anAspect){
  157. var self=this;
  158. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  159. return $core.withContext(function($ctx1) {
  160. //>>excludeEnd("ctx");
  161. var $3,$4,$2,$1;
  162. $3=$recv(anAspect)._size();
  163. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  164. $ctx1.sendIdx["size"]=1;
  165. //>>excludeEnd("ctx");
  166. $4=$recv(self["@aspect"])._size();
  167. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  168. $ctx1.sendIdx["size"]=2;
  169. //>>excludeEnd("ctx");
  170. $2=$recv($3).__lt_eq($4);
  171. $1=$recv($2)._and_((function(){
  172. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  173. return $core.withContext(function($ctx2) {
  174. //>>excludeEnd("ctx");
  175. return $recv(anAspect).__eq($recv(self["@aspect"])._copyFrom_to_((1),$recv(anAspect)._size()));
  176. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  177. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  178. //>>excludeEnd("ctx");
  179. }));
  180. return $1;
  181. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  182. }, function($ctx1) {$ctx1.fill(self,"accepts:",{anAspect:anAspect},$globals.InterestedInTrapPath)});
  183. //>>excludeEnd("ctx");
  184. },
  185. //>>excludeStart("ide", pragmas.excludeIdeData);
  186. args: ["anAspect"],
  187. source: "accepts: anAspect\x0a ^anAspect size <= aspect size and: [anAspect = (aspect copyFrom: 1 to: anAspect size)]",
  188. referencedClasses: [],
  189. //>>excludeEnd("ide");
  190. messageSends: ["and:", "<=", "size", "=", "copyFrom:to:"]
  191. }),
  192. $globals.InterestedInTrapPath);
  193. $core.addClass('InterestedInTrapPathSubtree', $globals.AxonInterest, [], 'Trapped-Backend');
  194. $core.addMethod(
  195. $core.method({
  196. selector: "accepts:",
  197. protocol: 'testing',
  198. fn: function (anAspect){
  199. var self=this;
  200. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  201. return $core.withContext(function($ctx1) {
  202. //>>excludeEnd("ctx");
  203. var $3,$4,$2,$6,$7,$5,$1;
  204. $3=$recv(anAspect)._size();
  205. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  206. $ctx1.sendIdx["size"]=1;
  207. //>>excludeEnd("ctx");
  208. $4=$recv(self["@aspect"])._size();
  209. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  210. $ctx1.sendIdx["size"]=2;
  211. //>>excludeEnd("ctx");
  212. $2=$recv($3).__lt_eq($4);
  213. if($core.assert($2)){
  214. $6=self["@aspect"];
  215. $7=$recv(anAspect)._size();
  216. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  217. $ctx1.sendIdx["size"]=3;
  218. //>>excludeEnd("ctx");
  219. $5=$recv($6)._copyFrom_to_((1),$7);
  220. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  221. $ctx1.sendIdx["copyFrom:to:"]=1;
  222. //>>excludeEnd("ctx");
  223. $1=$recv(anAspect).__eq($5);
  224. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  225. $ctx1.sendIdx["="]=1;
  226. //>>excludeEnd("ctx");
  227. } else {
  228. $1=$recv(self["@aspect"]).__eq($recv(anAspect)._copyFrom_to_((1),$recv(self["@aspect"])._size()));
  229. };
  230. return $1;
  231. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  232. }, function($ctx1) {$ctx1.fill(self,"accepts:",{anAspect:anAspect},$globals.InterestedInTrapPathSubtree)});
  233. //>>excludeEnd("ctx");
  234. },
  235. //>>excludeStart("ide", pragmas.excludeIdeData);
  236. args: ["anAspect"],
  237. source: "accepts: anAspect\x0a ^anAspect size <= aspect size\x0a\x09\x09ifTrue: [anAspect = (aspect copyFrom: 1 to: anAspect size)]\x0a\x09\x09ifFalse: [aspect = (anAspect copyFrom: 1 to: aspect size)]",
  238. referencedClasses: [],
  239. //>>excludeEnd("ide");
  240. messageSends: ["ifTrue:ifFalse:", "<=", "size", "=", "copyFrom:to:"]
  241. }),
  242. $globals.InterestedInTrapPathSubtree);
  243. $core.addClass('Isolator', $globals.Object, ['root'], 'Trapped-Backend');
  244. $core.addMethod(
  245. $core.method({
  246. selector: "model:modify:",
  247. protocol: 'action',
  248. fn: function (anEavModel,aBlock){
  249. var self=this;
  250. var newValue;
  251. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  252. return $core.withContext(function($ctx1) {
  253. //>>excludeEnd("ctx");
  254. newValue=$recv(aBlock)._value_($recv(anEavModel)._on_(self));
  255. $recv(anEavModel)._on_put_(self,$recv(newValue)._deepCopy());
  256. return self;
  257. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  258. }, function($ctx1) {$ctx1.fill(self,"model:modify:",{anEavModel:anEavModel,aBlock:aBlock,newValue:newValue},$globals.Isolator)});
  259. //>>excludeEnd("ctx");
  260. },
  261. //>>excludeStart("ide", pragmas.excludeIdeData);
  262. args: ["anEavModel", "aBlock"],
  263. source: "model: anEavModel modify: aBlock\x0a\x0a| newValue |\x0anewValue := aBlock value: (anEavModel on: self).\x0aanEavModel on: self put: newValue deepCopy",
  264. referencedClasses: [],
  265. //>>excludeEnd("ide");
  266. messageSends: ["value:", "on:", "on:put:", "deepCopy"]
  267. }),
  268. $globals.Isolator);
  269. $core.addMethod(
  270. $core.method({
  271. selector: "model:read:",
  272. protocol: 'action',
  273. fn: function (anEavModel,aBlock){
  274. var self=this;
  275. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  276. return $core.withContext(function($ctx1) {
  277. //>>excludeEnd("ctx");
  278. $recv(aBlock)._value_($recv($recv(anEavModel)._on_(self))._deepCopy());
  279. return self;
  280. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  281. }, function($ctx1) {$ctx1.fill(self,"model:read:",{anEavModel:anEavModel,aBlock:aBlock},$globals.Isolator)});
  282. //>>excludeEnd("ctx");
  283. },
  284. //>>excludeStart("ide", pragmas.excludeIdeData);
  285. args: ["anEavModel", "aBlock"],
  286. source: "model: anEavModel read: aBlock\x0a\x0aaBlock value: (anEavModel on: self) deepCopy",
  287. referencedClasses: [],
  288. //>>excludeEnd("ide");
  289. messageSends: ["value:", "deepCopy", "on:"]
  290. }),
  291. $globals.Isolator);
  292. $core.addMethod(
  293. $core.method({
  294. selector: "root",
  295. protocol: 'accessing',
  296. fn: function (){
  297. var self=this;
  298. var $1;
  299. $1=self["@root"];
  300. return $1;
  301. },
  302. //>>excludeStart("ide", pragmas.excludeIdeData);
  303. args: [],
  304. source: "root\x0a\x0a^root",
  305. referencedClasses: [],
  306. //>>excludeEnd("ide");
  307. messageSends: []
  308. }),
  309. $globals.Isolator);
  310. $core.addMethod(
  311. $core.method({
  312. selector: "root:",
  313. protocol: 'accessing',
  314. fn: function (anObject){
  315. var self=this;
  316. self["@root"]=anObject;
  317. return self;
  318. },
  319. //>>excludeStart("ide", pragmas.excludeIdeData);
  320. args: ["anObject"],
  321. source: "root: anObject\x0a\x0aroot := anObject",
  322. referencedClasses: [],
  323. //>>excludeEnd("ide");
  324. messageSends: []
  325. }),
  326. $globals.Isolator);
  327. $core.addMethod(
  328. $core.method({
  329. selector: "on:",
  330. protocol: 'instance creation',
  331. fn: function (anObject){
  332. var self=this;
  333. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  334. return $core.withContext(function($ctx1) {
  335. //>>excludeEnd("ctx");
  336. var $1;
  337. $1=$recv(self._new())._root_(anObject);
  338. return $1;
  339. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  340. }, function($ctx1) {$ctx1.fill(self,"on:",{anObject:anObject},$globals.Isolator.klass)});
  341. //>>excludeEnd("ctx");
  342. },
  343. //>>excludeStart("ide", pragmas.excludeIdeData);
  344. args: ["anObject"],
  345. source: "on: anObject\x0a^self new root: anObject",
  346. referencedClasses: [],
  347. //>>excludeEnd("ide");
  348. messageSends: ["root:", "new"]
  349. }),
  350. $globals.Isolator.klass);
  351. $core.addClass('TrappedPosition', $globals.Object, ['path', 'model'], 'Trapped-Backend');
  352. $core.addMethod(
  353. $core.method({
  354. selector: "interestOn:block:",
  355. protocol: 'private',
  356. fn: function (anAspect,aBlock){
  357. var self=this;
  358. function $InterestedInTrapPathSubtree(){return $globals.InterestedInTrapPathSubtree||(typeof InterestedInTrapPathSubtree=="undefined"?nil:InterestedInTrapPathSubtree)}
  359. function $InterestedInTrapPath(){return $globals.InterestedInTrapPath||(typeof InterestedInTrapPath=="undefined"?nil:InterestedInTrapPath)}
  360. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  361. return $core.withContext(function($ctx1) {
  362. //>>excludeEnd("ctx");
  363. var $1,$3,$2,$4;
  364. $1=$recv($recv(anAspect)._notEmpty())._and_((function(){
  365. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  366. return $core.withContext(function($ctx2) {
  367. //>>excludeEnd("ctx");
  368. return $recv($recv(anAspect)._last())._isNil();
  369. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  370. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  371. //>>excludeEnd("ctx");
  372. }));
  373. if($core.assert($1)){
  374. $3=$recv($InterestedInTrapPathSubtree())._new();
  375. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  376. $ctx1.sendIdx["new"]=1;
  377. //>>excludeEnd("ctx");
  378. $2=$recv($3)._aspect_block_($recv(anAspect)._allButLast(),aBlock);
  379. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  380. $ctx1.sendIdx["aspect:block:"]=1;
  381. //>>excludeEnd("ctx");
  382. return $2;
  383. } else {
  384. $4=$recv($recv($InterestedInTrapPath())._new())._aspect_block_(anAspect,aBlock);
  385. return $4;
  386. };
  387. return self;
  388. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  389. }, function($ctx1) {$ctx1.fill(self,"interestOn:block:",{anAspect:anAspect,aBlock:aBlock},$globals.TrappedPosition)});
  390. //>>excludeEnd("ctx");
  391. },
  392. //>>excludeStart("ide", pragmas.excludeIdeData);
  393. args: ["anAspect", "aBlock"],
  394. source: "interestOn: anAspect block: aBlock\x0a\x09(anAspect notEmpty and: [ anAspect last isNil ])\x0a\x09\x09ifTrue: [ ^ InterestedInTrapPathSubtree new aspect: anAspect allButLast block: aBlock ]\x0a\x09\x09ifFalse: [ ^ InterestedInTrapPath new aspect: anAspect block: aBlock ]",
  395. referencedClasses: ["InterestedInTrapPathSubtree", "InterestedInTrapPath"],
  396. //>>excludeEnd("ide");
  397. messageSends: ["ifTrue:ifFalse:", "and:", "notEmpty", "isNil", "last", "aspect:block:", "new", "allButLast"]
  398. }),
  399. $globals.TrappedPosition);
  400. $core.addMethod(
  401. $core.method({
  402. selector: "model",
  403. protocol: 'accessing',
  404. fn: function (){
  405. var self=this;
  406. var $1;
  407. $1=self["@model"];
  408. return $1;
  409. },
  410. //>>excludeStart("ide", pragmas.excludeIdeData);
  411. args: [],
  412. source: "model\x0a\x09^model",
  413. referencedClasses: [],
  414. //>>excludeEnd("ide");
  415. messageSends: []
  416. }),
  417. $globals.TrappedPosition);
  418. $core.addMethod(
  419. $core.method({
  420. selector: "modify:",
  421. protocol: 'action',
  422. fn: function (aBlock){
  423. var self=this;
  424. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  425. return $core.withContext(function($ctx1) {
  426. //>>excludeEnd("ctx");
  427. $recv(self._model())._modify_do_(self._path(),aBlock);
  428. return self;
  429. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  430. }, function($ctx1) {$ctx1.fill(self,"modify:",{aBlock:aBlock},$globals.TrappedPosition)});
  431. //>>excludeEnd("ctx");
  432. },
  433. //>>excludeStart("ide", pragmas.excludeIdeData);
  434. args: ["aBlock"],
  435. source: "modify: aBlock\x0a\x09self model modify: self path do: aBlock",
  436. referencedClasses: [],
  437. //>>excludeEnd("ide");
  438. messageSends: ["modify:do:", "model", "path"]
  439. }),
  440. $globals.TrappedPosition);
  441. $core.addMethod(
  442. $core.method({
  443. selector: "path",
  444. protocol: 'accessing',
  445. fn: function (){
  446. var self=this;
  447. var $1;
  448. $1=self["@path"];
  449. return $1;
  450. },
  451. //>>excludeStart("ide", pragmas.excludeIdeData);
  452. args: [],
  453. source: "path\x0a\x09^path",
  454. referencedClasses: [],
  455. //>>excludeEnd("ide");
  456. messageSends: []
  457. }),
  458. $globals.TrappedPosition);
  459. $core.addMethod(
  460. $core.method({
  461. selector: "path:model:",
  462. protocol: 'accessing',
  463. fn: function (anArray,aTrappedMW){
  464. var self=this;
  465. self["@path"]=anArray;
  466. self["@model"]=aTrappedMW;
  467. return self;
  468. },
  469. //>>excludeStart("ide", pragmas.excludeIdeData);
  470. args: ["anArray", "aTrappedMW"],
  471. source: "path: anArray model: aTrappedMW\x0a\x09path := anArray.\x0a model := aTrappedMW",
  472. referencedClasses: [],
  473. //>>excludeEnd("ide");
  474. messageSends: []
  475. }),
  476. $globals.TrappedPosition);
  477. $core.addMethod(
  478. $core.method({
  479. selector: "read:",
  480. protocol: 'action',
  481. fn: function (aBlock){
  482. var self=this;
  483. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  484. return $core.withContext(function($ctx1) {
  485. //>>excludeEnd("ctx");
  486. $recv(self._model())._read_do_(self._path(),aBlock);
  487. return self;
  488. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  489. }, function($ctx1) {$ctx1.fill(self,"read:",{aBlock:aBlock},$globals.TrappedPosition)});
  490. //>>excludeEnd("ctx");
  491. },
  492. //>>excludeStart("ide", pragmas.excludeIdeData);
  493. args: ["aBlock"],
  494. source: "read: aBlock\x0a\x09self model read: self path do: aBlock",
  495. referencedClasses: [],
  496. //>>excludeEnd("ide");
  497. messageSends: ["read:do:", "model", "path"]
  498. }),
  499. $globals.TrappedPosition);
  500. $core.addMethod(
  501. $core.method({
  502. selector: "watch:",
  503. protocol: 'action',
  504. fn: function (aBlock){
  505. var self=this;
  506. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  507. return $core.withContext(function($ctx1) {
  508. //>>excludeEnd("ctx");
  509. $recv($recv(self._model())._axon())._addInterest_(self._interestOn_block_(self._path(),(function(){
  510. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  511. return $core.withContext(function($ctx2) {
  512. //>>excludeEnd("ctx");
  513. return self._read_(aBlock);
  514. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  515. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  516. //>>excludeEnd("ctx");
  517. })));
  518. return self;
  519. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  520. }, function($ctx1) {$ctx1.fill(self,"watch:",{aBlock:aBlock},$globals.TrappedPosition)});
  521. //>>excludeEnd("ctx");
  522. },
  523. //>>excludeStart("ide", pragmas.excludeIdeData);
  524. args: ["aBlock"],
  525. source: "watch: aBlock\x0a\x09self model axon addInterest: (self\x0a\x09\x09interestOn: self path\x0a\x09\x09block: [ self read: aBlock ])",
  526. referencedClasses: [],
  527. //>>excludeEnd("ide");
  528. messageSends: ["addInterest:", "axon", "model", "interestOn:block:", "path", "read:"]
  529. }),
  530. $globals.TrappedPosition);
  531. $core.addClass('Trapper', $globals.AxonizedObject, ['payload'], 'Trapped-Backend');
  532. //>>excludeStart("ide", pragmas.excludeIdeData);
  533. $globals.Trapper.comment="A portmanteau of 'Trapped wrapper', I am base class for model objects wrapped by Trapped.\x0a\x0aWrapped object is indexed by #('string-at-index' #selector numeric-at-index) array paths. Operations using this indexing are:\x0a\x0a - `read:do` to get the indexed content\x0a - `modify:do:` to get and modify the indexed content, and\x0a - `watch:do:` to subscribe to changes of the indexed content.\x0a\x0aThe wrapped model can be any smalltalk object.\x0a\x0aMy subclasses need to provide implementation for:\x0a\x0a - read:do:\x0a - modify:do:\x0a\x0aand must issue these calls when initializing:\x0a\x0a - axon: (with a subclass of `Axon`)\x0a - model: (with a wrapped object, after `axon:`)";
  534. //>>excludeEnd("ide");
  535. $core.addMethod(
  536. $core.method({
  537. selector: "model:",
  538. protocol: 'accessing',
  539. fn: function (anObject){
  540. var self=this;
  541. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  542. return $core.withContext(function($ctx1) {
  543. //>>excludeEnd("ctx");
  544. self["@payload"]=anObject;
  545. $recv(self._axon())._changedAll();
  546. return self;
  547. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  548. }, function($ctx1) {$ctx1.fill(self,"model:",{anObject:anObject},$globals.Trapper)});
  549. //>>excludeEnd("ctx");
  550. },
  551. //>>excludeStart("ide", pragmas.excludeIdeData);
  552. args: ["anObject"],
  553. source: "model: anObject\x0a\x09payload := anObject.\x0a self axon changedAll",
  554. referencedClasses: [],
  555. //>>excludeEnd("ide");
  556. messageSends: ["changedAll", "axon"]
  557. }),
  558. $globals.Trapper);
  559. $core.addMethod(
  560. $core.method({
  561. selector: "modify:do:",
  562. protocol: 'action',
  563. fn: function (path,aBlock){
  564. var self=this;
  565. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  566. return $core.withContext(function($ctx1) {
  567. //>>excludeEnd("ctx");
  568. self._subclassResponsibility();
  569. return self;
  570. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  571. }, function($ctx1) {$ctx1.fill(self,"modify:do:",{path:path,aBlock:aBlock},$globals.Trapper)});
  572. //>>excludeEnd("ctx");
  573. },
  574. //>>excludeStart("ide", pragmas.excludeIdeData);
  575. args: ["path", "aBlock"],
  576. source: "modify: path do: aBlock\x0a\x09self subclassResponsibility",
  577. referencedClasses: [],
  578. //>>excludeEnd("ide");
  579. messageSends: ["subclassResponsibility"]
  580. }),
  581. $globals.Trapper);
  582. $core.addMethod(
  583. $core.method({
  584. selector: "read:do:",
  585. protocol: 'action',
  586. fn: function (path,aBlock){
  587. var self=this;
  588. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  589. return $core.withContext(function($ctx1) {
  590. //>>excludeEnd("ctx");
  591. self._subclassResponsibility();
  592. return self;
  593. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  594. }, function($ctx1) {$ctx1.fill(self,"read:do:",{path:path,aBlock:aBlock},$globals.Trapper)});
  595. //>>excludeEnd("ctx");
  596. },
  597. //>>excludeStart("ide", pragmas.excludeIdeData);
  598. args: ["path", "aBlock"],
  599. source: "read: path do: aBlock\x0a\x09self subclassResponsibility",
  600. referencedClasses: [],
  601. //>>excludeEnd("ide");
  602. messageSends: ["subclassResponsibility"]
  603. }),
  604. $globals.Trapper);
  605. $core.addClass('DirectTrapper', $globals.Trapper, [], 'Trapped-Backend');
  606. //>>excludeStart("ide", pragmas.excludeIdeData);
  607. $globals.DirectTrapper.comment="I am Trapper that directly manipulate\x0athe wrapped model object.";
  608. //>>excludeEnd("ide");
  609. $core.addMethod(
  610. $core.method({
  611. selector: "modify:do:",
  612. protocol: 'action',
  613. fn: function (path,aBlock){
  614. var self=this;
  615. var newValue,eavModel;
  616. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  617. return $core.withContext(function($ctx1) {
  618. //>>excludeEnd("ctx");
  619. eavModel=$recv(path)._asEavModel();
  620. newValue=$recv(aBlock)._value_($recv(eavModel)._on_(self["@payload"]));
  621. $recv((function(){
  622. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  623. return $core.withContext(function($ctx2) {
  624. //>>excludeEnd("ctx");
  625. return $recv(eavModel)._on_put_(self["@payload"],newValue);
  626. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  627. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  628. //>>excludeEnd("ctx");
  629. }))._ensure_((function(){
  630. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  631. return $core.withContext(function($ctx2) {
  632. //>>excludeEnd("ctx");
  633. return self._changed_(path);
  634. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  635. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  636. //>>excludeEnd("ctx");
  637. }));
  638. return self;
  639. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  640. }, function($ctx1) {$ctx1.fill(self,"modify:do:",{path:path,aBlock:aBlock,newValue:newValue,eavModel:eavModel},$globals.DirectTrapper)});
  641. //>>excludeEnd("ctx");
  642. },
  643. //>>excludeStart("ide", pragmas.excludeIdeData);
  644. args: ["path", "aBlock"],
  645. source: "modify: path do: aBlock\x0a | newValue eavModel |\x0a eavModel := path asEavModel.\x0a newValue := aBlock value: (eavModel on: payload).\x0a [ eavModel on: payload put: newValue ] ensure: [ self changed: path ]",
  646. referencedClasses: [],
  647. //>>excludeEnd("ide");
  648. messageSends: ["asEavModel", "value:", "on:", "ensure:", "on:put:", "changed:"]
  649. }),
  650. $globals.DirectTrapper);
  651. $core.addMethod(
  652. $core.method({
  653. selector: "read:do:",
  654. protocol: 'action',
  655. fn: function (path,aBlock){
  656. var self=this;
  657. var eavModel;
  658. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  659. return $core.withContext(function($ctx1) {
  660. //>>excludeEnd("ctx");
  661. eavModel=$recv(path)._asEavModel();
  662. $recv(aBlock)._value_($recv(eavModel)._on_(self["@payload"]));
  663. return self;
  664. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  665. }, function($ctx1) {$ctx1.fill(self,"read:do:",{path:path,aBlock:aBlock,eavModel:eavModel},$globals.DirectTrapper)});
  666. //>>excludeEnd("ctx");
  667. },
  668. //>>excludeStart("ide", pragmas.excludeIdeData);
  669. args: ["path", "aBlock"],
  670. source: "read: path do: aBlock\x0a | eavModel |\x0a eavModel := path asEavModel.\x0a aBlock value: (eavModel on: payload)",
  671. referencedClasses: [],
  672. //>>excludeEnd("ide");
  673. messageSends: ["asEavModel", "value:", "on:"]
  674. }),
  675. $globals.DirectTrapper);
  676. $core.addClass('IsolatingTrapper', $globals.Trapper, [], 'Trapped-Backend');
  677. //>>excludeStart("ide", pragmas.excludeIdeData);
  678. $globals.IsolatingTrapper.comment="I am Trapper that guards access\x0ato the wrapped model object via Isolator.\x0a\x0aIOW, read:do: gets always its own deep copy,\x0amodify:do: is not reentrant\x0aand upon writing the written part is deep-copied as well\x0a(so modifier does not hold the source of truth\x0aand can change it later).\x0a\x0aThis also means, a wrapped object and all its parts\x0amust understand `#deepCopy`.";
  679. //>>excludeEnd("ide");
  680. $core.addMethod(
  681. $core.method({
  682. selector: "model:",
  683. protocol: 'accessing',
  684. fn: function (anObject){
  685. var self=this;
  686. function $Isolator(){return $globals.Isolator||(typeof Isolator=="undefined"?nil:Isolator)}
  687. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  688. return $core.withContext(function($ctx1) {
  689. //>>excludeEnd("ctx");
  690. (
  691. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  692. $ctx1.supercall = true,
  693. //>>excludeEnd("ctx");
  694. $globals.IsolatingTrapper.superclass.fn.prototype._model_.apply($recv(self), [$recv($Isolator())._on_(anObject)]));
  695. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  696. $ctx1.supercall = false;
  697. //>>excludeEnd("ctx");;
  698. return self;
  699. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  700. }, function($ctx1) {$ctx1.fill(self,"model:",{anObject:anObject},$globals.IsolatingTrapper)});
  701. //>>excludeEnd("ctx");
  702. },
  703. //>>excludeStart("ide", pragmas.excludeIdeData);
  704. args: ["anObject"],
  705. source: "model: anObject\x0a\x09super model: (Isolator on: anObject)",
  706. referencedClasses: ["Isolator"],
  707. //>>excludeEnd("ide");
  708. messageSends: ["model:", "on:"]
  709. }),
  710. $globals.IsolatingTrapper);
  711. $core.addMethod(
  712. $core.method({
  713. selector: "modify:do:",
  714. protocol: 'action',
  715. fn: function (path,aBlock){
  716. var self=this;
  717. var eavModel;
  718. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  719. return $core.withContext(function($ctx1) {
  720. //>>excludeEnd("ctx");
  721. eavModel=$recv($recv([["root"]]).__comma(path))._asEavModel();
  722. $recv((function(){
  723. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  724. return $core.withContext(function($ctx2) {
  725. //>>excludeEnd("ctx");
  726. return $recv(self["@payload"])._model_modify_(eavModel,aBlock);
  727. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  728. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  729. //>>excludeEnd("ctx");
  730. }))._ensure_((function(){
  731. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  732. return $core.withContext(function($ctx2) {
  733. //>>excludeEnd("ctx");
  734. return self._changed_(path);
  735. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  736. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  737. //>>excludeEnd("ctx");
  738. }));
  739. return self;
  740. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  741. }, function($ctx1) {$ctx1.fill(self,"modify:do:",{path:path,aBlock:aBlock,eavModel:eavModel},$globals.IsolatingTrapper)});
  742. //>>excludeEnd("ctx");
  743. },
  744. //>>excludeStart("ide", pragmas.excludeIdeData);
  745. args: ["path", "aBlock"],
  746. source: "modify: path do: aBlock\x0a | eavModel |\x0a eavModel := ({{#root}},path) asEavModel.\x0a [ payload model: eavModel modify: aBlock ] ensure: [ self changed: path ]",
  747. referencedClasses: [],
  748. //>>excludeEnd("ide");
  749. messageSends: ["asEavModel", ",", "ensure:", "model:modify:", "changed:"]
  750. }),
  751. $globals.IsolatingTrapper);
  752. $core.addMethod(
  753. $core.method({
  754. selector: "read:do:",
  755. protocol: 'action',
  756. fn: function (path,aBlock){
  757. var self=this;
  758. var eavModel;
  759. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  760. return $core.withContext(function($ctx1) {
  761. //>>excludeEnd("ctx");
  762. eavModel=$recv($recv([["root"]]).__comma(path))._asEavModel();
  763. $recv(self["@payload"])._model_read_(eavModel,aBlock);
  764. return self;
  765. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  766. }, function($ctx1) {$ctx1.fill(self,"read:do:",{path:path,aBlock:aBlock,eavModel:eavModel},$globals.IsolatingTrapper)});
  767. //>>excludeEnd("ctx");
  768. },
  769. //>>excludeStart("ide", pragmas.excludeIdeData);
  770. args: ["path", "aBlock"],
  771. source: "read: path do: aBlock\x0a | eavModel |\x0a eavModel := ({{#root}},path) asEavModel.\x0a payload model: eavModel read: aBlock",
  772. referencedClasses: [],
  773. //>>excludeEnd("ide");
  774. messageSends: ["asEavModel", ",", "model:read:"]
  775. }),
  776. $globals.IsolatingTrapper);
  777. $core.addMethod(
  778. $core.method({
  779. selector: "asEavModel",
  780. protocol: '*Trapped-Backend',
  781. fn: function (){
  782. var self=this;
  783. var model;
  784. function $EavModel(){return $globals.EavModel||(typeof EavModel=="undefined"?nil:EavModel)}
  785. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  786. return $core.withContext(function($ctx1) {
  787. //>>excludeEnd("ctx");
  788. var $1,$2;
  789. model=$recv($EavModel())._new();
  790. $recv(model)._getBlock_((function(anObject){
  791. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  792. return $core.withContext(function($ctx2) {
  793. //>>excludeEnd("ctx");
  794. return $recv(anObject)._atLyst_ifAbsent_(self,(function(){
  795. return nil;
  796. }));
  797. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  798. }, function($ctx2) {$ctx2.fillBlock({anObject:anObject},$ctx1,1)});
  799. //>>excludeEnd("ctx");
  800. }));
  801. $1=self._isEmpty();
  802. if(!$core.assert($1)){
  803. $recv(model)._putBlock_((function(anObject,value){
  804. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  805. return $core.withContext(function($ctx2) {
  806. //>>excludeEnd("ctx");
  807. return $recv(anObject)._atLyst_ifAbsent_put_(self,(function(){
  808. return nil;
  809. }),value);
  810. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  811. }, function($ctx2) {$ctx2.fillBlock({anObject:anObject,value:value},$ctx1,4)});
  812. //>>excludeEnd("ctx");
  813. }));
  814. };
  815. $2=model;
  816. return $2;
  817. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  818. }, function($ctx1) {$ctx1.fill(self,"asEavModel",{model:model},$globals.SequenceableCollection)});
  819. //>>excludeEnd("ctx");
  820. },
  821. //>>excludeStart("ide", pragmas.excludeIdeData);
  822. args: [],
  823. source: "asEavModel\x0a | model |\x0a model := EavModel new.\x0a model getBlock: [ :anObject | anObject atLyst: self ifAbsent: [ nil ] ].\x0a self isEmpty ifFalse: [\x0a model putBlock: [ :anObject :value | anObject atLyst: self ifAbsent: [ nil ] put: value ]].\x0a ^model",
  824. referencedClasses: ["EavModel"],
  825. //>>excludeEnd("ide");
  826. messageSends: ["new", "getBlock:", "atLyst:ifAbsent:", "ifFalse:", "isEmpty", "putBlock:", "atLyst:ifAbsent:put:"]
  827. }),
  828. $globals.SequenceableCollection);
  829. });