Trapped-Backend.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. define(["amber/boot"
  2. //>>excludeStart("imports", pragmas.excludeImports);
  3. , "axxord/Axxord"
  4. //>>excludeEnd("imports");
  5. , "amber_core/Kernel-Objects"], 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("Isolator", $globals.Object, ["root"], "Trapped-Backend");
  18. $core.addMethod(
  19. $core.method({
  20. selector: "model:modify:",
  21. protocol: "action",
  22. fn: function (anEavModel,aBlock){
  23. var self=this,$self=this;
  24. var newValue;
  25. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  26. return $core.withContext(function($ctx1) {
  27. //>>excludeEnd("ctx");
  28. newValue=$recv(aBlock)._value_($recv(anEavModel)._on_(self));
  29. $recv(anEavModel)._on_put_(self,$recv(newValue)._deepCopy());
  30. return self;
  31. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  32. }, function($ctx1) {$ctx1.fill(self,"model:modify:",{anEavModel:anEavModel,aBlock:aBlock,newValue:newValue},$globals.Isolator)});
  33. //>>excludeEnd("ctx");
  34. },
  35. //>>excludeStart("ide", pragmas.excludeIdeData);
  36. args: ["anEavModel", "aBlock"],
  37. source: "model: anEavModel modify: aBlock\x0a\x0a| newValue |\x0anewValue := aBlock value: (anEavModel on: self).\x0aanEavModel on: self put: newValue deepCopy",
  38. referencedClasses: [],
  39. //>>excludeEnd("ide");
  40. messageSends: ["value:", "on:", "on:put:", "deepCopy"]
  41. }),
  42. $globals.Isolator);
  43. $core.addMethod(
  44. $core.method({
  45. selector: "model:read:",
  46. protocol: "action",
  47. fn: function (anEavModel,aBlock){
  48. var self=this,$self=this;
  49. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  50. return $core.withContext(function($ctx1) {
  51. //>>excludeEnd("ctx");
  52. $recv(aBlock)._value_($recv($recv(anEavModel)._on_(self))._deepCopy());
  53. return self;
  54. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  55. }, function($ctx1) {$ctx1.fill(self,"model:read:",{anEavModel:anEavModel,aBlock:aBlock},$globals.Isolator)});
  56. //>>excludeEnd("ctx");
  57. },
  58. //>>excludeStart("ide", pragmas.excludeIdeData);
  59. args: ["anEavModel", "aBlock"],
  60. source: "model: anEavModel read: aBlock\x0a\x0aaBlock value: (anEavModel on: self) deepCopy",
  61. referencedClasses: [],
  62. //>>excludeEnd("ide");
  63. messageSends: ["value:", "deepCopy", "on:"]
  64. }),
  65. $globals.Isolator);
  66. $core.addMethod(
  67. $core.method({
  68. selector: "root",
  69. protocol: "accessing",
  70. fn: function (){
  71. var self=this,$self=this;
  72. return $self["@root"];
  73. },
  74. //>>excludeStart("ide", pragmas.excludeIdeData);
  75. args: [],
  76. source: "root\x0a\x0a^root",
  77. referencedClasses: [],
  78. //>>excludeEnd("ide");
  79. messageSends: []
  80. }),
  81. $globals.Isolator);
  82. $core.addMethod(
  83. $core.method({
  84. selector: "root:",
  85. protocol: "accessing",
  86. fn: function (anObject){
  87. var self=this,$self=this;
  88. $self["@root"]=anObject;
  89. return self;
  90. },
  91. //>>excludeStart("ide", pragmas.excludeIdeData);
  92. args: ["anObject"],
  93. source: "root: anObject\x0a\x0aroot := anObject",
  94. referencedClasses: [],
  95. //>>excludeEnd("ide");
  96. messageSends: []
  97. }),
  98. $globals.Isolator);
  99. $core.addMethod(
  100. $core.method({
  101. selector: "on:",
  102. protocol: "instance creation",
  103. fn: function (anObject){
  104. var self=this,$self=this;
  105. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  106. return $core.withContext(function($ctx1) {
  107. //>>excludeEnd("ctx");
  108. return $recv($self._new())._root_(anObject);
  109. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  110. }, function($ctx1) {$ctx1.fill(self,"on:",{anObject:anObject},$globals.Isolator.a$cls)});
  111. //>>excludeEnd("ctx");
  112. },
  113. //>>excludeStart("ide", pragmas.excludeIdeData);
  114. args: ["anObject"],
  115. source: "on: anObject\x0a^self new root: anObject",
  116. referencedClasses: [],
  117. //>>excludeEnd("ide");
  118. messageSends: ["root:", "new"]
  119. }),
  120. $globals.Isolator.a$cls);
  121. $core.addClass("TrappedPosition", $globals.Object, ["path", "model"], "Trapped-Backend");
  122. $core.addMethod(
  123. $core.method({
  124. selector: "interestOn:block:",
  125. protocol: "private",
  126. fn: function (anAspect,aBlock){
  127. var self=this,$self=this;
  128. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  129. return $core.withContext(function($ctx1) {
  130. //>>excludeEnd("ctx");
  131. var $1,$3,$2;
  132. $1=$recv($recv(anAspect)._notEmpty())._and_((function(){
  133. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  134. return $core.withContext(function($ctx2) {
  135. //>>excludeEnd("ctx");
  136. return $recv($recv(anAspect)._last())._isNil();
  137. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  138. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  139. //>>excludeEnd("ctx");
  140. }));
  141. if($core.assert($1)){
  142. $3=$recv($globals.InterestedThruAxes)._new();
  143. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  144. $ctx1.sendIdx["new"]=1;
  145. //>>excludeEnd("ctx");
  146. $2=$recv($3)._aspect_block_($recv(anAspect)._allButLast(),aBlock);
  147. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  148. $ctx1.sendIdx["aspect:block:"]=1;
  149. //>>excludeEnd("ctx");
  150. return $2;
  151. } else {
  152. return $recv($recv($globals.InterestedUpToAxes)._new())._aspect_block_(anAspect,aBlock);
  153. }
  154. return self;
  155. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  156. }, function($ctx1) {$ctx1.fill(self,"interestOn:block:",{anAspect:anAspect,aBlock:aBlock},$globals.TrappedPosition)});
  157. //>>excludeEnd("ctx");
  158. },
  159. //>>excludeStart("ide", pragmas.excludeIdeData);
  160. args: ["anAspect", "aBlock"],
  161. source: "interestOn: anAspect block: aBlock\x0a\x09(anAspect notEmpty and: [ anAspect last isNil ])\x0a\x09\x09ifTrue: [ ^ InterestedThruAxes new aspect: anAspect allButLast block: aBlock ]\x0a\x09\x09ifFalse: [ ^ InterestedUpToAxes new aspect: anAspect block: aBlock ]",
  162. referencedClasses: ["InterestedThruAxes", "InterestedUpToAxes"],
  163. //>>excludeEnd("ide");
  164. messageSends: ["ifTrue:ifFalse:", "and:", "notEmpty", "isNil", "last", "aspect:block:", "new", "allButLast"]
  165. }),
  166. $globals.TrappedPosition);
  167. $core.addMethod(
  168. $core.method({
  169. selector: "model",
  170. protocol: "accessing",
  171. fn: function (){
  172. var self=this,$self=this;
  173. return $self["@model"];
  174. },
  175. //>>excludeStart("ide", pragmas.excludeIdeData);
  176. args: [],
  177. source: "model\x0a\x09^model",
  178. referencedClasses: [],
  179. //>>excludeEnd("ide");
  180. messageSends: []
  181. }),
  182. $globals.TrappedPosition);
  183. $core.addMethod(
  184. $core.method({
  185. selector: "modify:",
  186. protocol: "action",
  187. fn: function (aBlock){
  188. var self=this,$self=this;
  189. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  190. return $core.withContext(function($ctx1) {
  191. //>>excludeEnd("ctx");
  192. $recv($self._model())._axes_transform_($self._path(),aBlock);
  193. return self;
  194. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  195. }, function($ctx1) {$ctx1.fill(self,"modify:",{aBlock:aBlock},$globals.TrappedPosition)});
  196. //>>excludeEnd("ctx");
  197. },
  198. //>>excludeStart("ide", pragmas.excludeIdeData);
  199. args: ["aBlock"],
  200. source: "modify: aBlock\x0a\x09self model axes: self path transform: aBlock",
  201. referencedClasses: [],
  202. //>>excludeEnd("ide");
  203. messageSends: ["axes:transform:", "model", "path"]
  204. }),
  205. $globals.TrappedPosition);
  206. $core.addMethod(
  207. $core.method({
  208. selector: "path",
  209. protocol: "accessing",
  210. fn: function (){
  211. var self=this,$self=this;
  212. return $self["@path"];
  213. },
  214. //>>excludeStart("ide", pragmas.excludeIdeData);
  215. args: [],
  216. source: "path\x0a\x09^path",
  217. referencedClasses: [],
  218. //>>excludeEnd("ide");
  219. messageSends: []
  220. }),
  221. $globals.TrappedPosition);
  222. $core.addMethod(
  223. $core.method({
  224. selector: "path:model:",
  225. protocol: "accessing",
  226. fn: function (anArray,aTrappedMW){
  227. var self=this,$self=this;
  228. $self["@path"]=anArray;
  229. $self["@model"]=aTrappedMW;
  230. return self;
  231. },
  232. //>>excludeStart("ide", pragmas.excludeIdeData);
  233. args: ["anArray", "aTrappedMW"],
  234. source: "path: anArray model: aTrappedMW\x0a\x09path := anArray.\x0a model := aTrappedMW",
  235. referencedClasses: [],
  236. //>>excludeEnd("ide");
  237. messageSends: []
  238. }),
  239. $globals.TrappedPosition);
  240. $core.addMethod(
  241. $core.method({
  242. selector: "read:",
  243. protocol: "action",
  244. fn: function (aBlock){
  245. var self=this,$self=this;
  246. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  247. return $core.withContext(function($ctx1) {
  248. //>>excludeEnd("ctx");
  249. $recv($self._model())._axes_consume_($self._path(),aBlock);
  250. return self;
  251. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  252. }, function($ctx1) {$ctx1.fill(self,"read:",{aBlock:aBlock},$globals.TrappedPosition)});
  253. //>>excludeEnd("ctx");
  254. },
  255. //>>excludeStart("ide", pragmas.excludeIdeData);
  256. args: ["aBlock"],
  257. source: "read: aBlock\x0a\x09self model axes: self path consume: aBlock",
  258. referencedClasses: [],
  259. //>>excludeEnd("ide");
  260. messageSends: ["axes:consume:", "model", "path"]
  261. }),
  262. $globals.TrappedPosition);
  263. $core.addMethod(
  264. $core.method({
  265. selector: "watch:",
  266. protocol: "action",
  267. fn: function (aBlock){
  268. var self=this,$self=this;
  269. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  270. return $core.withContext(function($ctx1) {
  271. //>>excludeEnd("ctx");
  272. $recv($recv($self._model())._registeredAxon())._addInterest_($self._interestOn_block_($self._path(),(function(){
  273. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  274. return $core.withContext(function($ctx2) {
  275. //>>excludeEnd("ctx");
  276. return $self._read_(aBlock);
  277. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  278. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  279. //>>excludeEnd("ctx");
  280. })));
  281. return self;
  282. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  283. }, function($ctx1) {$ctx1.fill(self,"watch:",{aBlock:aBlock},$globals.TrappedPosition)});
  284. //>>excludeEnd("ctx");
  285. },
  286. //>>excludeStart("ide", pragmas.excludeIdeData);
  287. args: ["aBlock"],
  288. source: "watch: aBlock\x0a\x09self model registeredAxon addInterest: (self\x0a\x09\x09interestOn: self path\x0a\x09\x09block: [ self read: aBlock ])",
  289. referencedClasses: [],
  290. //>>excludeEnd("ide");
  291. messageSends: ["addInterest:", "registeredAxon", "model", "interestOn:block:", "path", "read:"]
  292. }),
  293. $globals.TrappedPosition);
  294. });