Trapped-Backend.js 29 KB

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