Trapped.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. smalltalk.addPackage('Trapped', {});
  2. smalltalk.addClass('EavModel', smalltalk.Object, ['getBlock', 'putBlock'], 'Trapped');
  3. smalltalk.EavModel.comment="External actor value model."
  4. smalltalk.addMethod(
  5. "_getBlock_",
  6. smalltalk.method({
  7. selector: "getBlock:",
  8. category: 'accessing',
  9. fn: function (aBlock){
  10. var self=this;
  11. self["@getBlock"]=aBlock;
  12. return self},
  13. args: ["aBlock"],
  14. source: "getBlock: aBlock\x0a\x0agetBlock := aBlock",
  15. messageSends: [],
  16. referencedClasses: []
  17. }),
  18. smalltalk.EavModel);
  19. smalltalk.addMethod(
  20. "_initialize",
  21. smalltalk.method({
  22. selector: "initialize",
  23. category: 'initialization',
  24. fn: function (){
  25. var self=this;
  26. self["@getBlock"]=(function(){
  27. return smalltalk.send(self,"_error_",["No getter block."]);
  28. });
  29. self["@putBlock"]=(function(){
  30. return smalltalk.send(self,"_error_",["No putter block."]);
  31. });
  32. return self},
  33. args: [],
  34. source: "initialize\x0a\x0agetBlock := [ self error: 'No getter block.' ].\x0aputBlock := [ self error: 'No putter block.' ].",
  35. messageSends: ["error:"],
  36. referencedClasses: []
  37. }),
  38. smalltalk.EavModel);
  39. smalltalk.addMethod(
  40. "_on_",
  41. smalltalk.method({
  42. selector: "on:",
  43. category: 'accessing',
  44. fn: function (anObject){
  45. var self=this;
  46. var $1;
  47. $1=smalltalk.send(self["@getBlock"],"_value_",[anObject]);
  48. return $1;
  49. },
  50. args: ["anObject"],
  51. source: "on: anObject\x0a\x22Returns value of model applied on object\x22\x0a\x0a^getBlock value: anObject",
  52. messageSends: ["value:"],
  53. referencedClasses: []
  54. }),
  55. smalltalk.EavModel);
  56. smalltalk.addMethod(
  57. "_on_put_",
  58. smalltalk.method({
  59. selector: "on:put:",
  60. category: 'accessing',
  61. fn: function (anObject,anObject2){
  62. var self=this;
  63. var $1;
  64. $1=smalltalk.send(self["@putBlock"],"_value_value_",[anObject,anObject2]);
  65. return $1;
  66. },
  67. args: ["anObject", "anObject2"],
  68. source: "on: anObject put: anObject2\x0a\x22Puts a value via model applied on object\x22\x0a\x0a^putBlock value: anObject value: anObject2",
  69. messageSends: ["value:value:"],
  70. referencedClasses: []
  71. }),
  72. smalltalk.EavModel);
  73. smalltalk.addMethod(
  74. "_putBlock_",
  75. smalltalk.method({
  76. selector: "putBlock:",
  77. category: 'accessing',
  78. fn: function (aBlock){
  79. var self=this;
  80. self["@putBlock"]=aBlock;
  81. return self},
  82. args: ["aBlock"],
  83. source: "putBlock: aBlock\x0a\x0aputBlock := aBlock",
  84. messageSends: [],
  85. referencedClasses: []
  86. }),
  87. smalltalk.EavModel);
  88. smalltalk.addClass('Isolator', smalltalk.Object, ['root'], 'Trapped');
  89. smalltalk.addMethod(
  90. "_model_modify_",
  91. smalltalk.method({
  92. selector: "model:modify:",
  93. category: 'action',
  94. fn: function (anEavModel,aBlock){
  95. var self=this;
  96. var newValue;
  97. newValue=smalltalk.send(aBlock,"_value_",[smalltalk.send(anEavModel,"_on_",[self])]);
  98. smalltalk.send(anEavModel,"_on_put_",[self,smalltalk.send(newValue,"_deepCopy",[])]);
  99. return self},
  100. args: ["anEavModel", "aBlock"],
  101. source: "model: anEavModel modify: aBlock\x0a\x0a| newValue |\x0anewValue := aBlock value: (anEavModel on: self).\x0aanEavModel on: self put: newValue deepCopy\x0a",
  102. messageSends: ["value:", "on:", "on:put:", "deepCopy"],
  103. referencedClasses: []
  104. }),
  105. smalltalk.Isolator);
  106. smalltalk.addMethod(
  107. "_model_read_",
  108. smalltalk.method({
  109. selector: "model:read:",
  110. category: 'action',
  111. fn: function (anEavModel,aBlock){
  112. var self=this;
  113. smalltalk.send(aBlock,"_value_",[smalltalk.send(smalltalk.send(anEavModel,"_on_",[self]),"_deepCopy",[])]);
  114. return self},
  115. args: ["anEavModel", "aBlock"],
  116. source: "model: anEavModel read: aBlock\x0a\x0aaBlock value: (anEavModel on: self) deepCopy",
  117. messageSends: ["value:", "deepCopy", "on:"],
  118. referencedClasses: []
  119. }),
  120. smalltalk.Isolator);
  121. smalltalk.addMethod(
  122. "_root",
  123. smalltalk.method({
  124. selector: "root",
  125. category: 'accessing',
  126. fn: function (){
  127. var self=this;
  128. return self["@root"];
  129. },
  130. args: [],
  131. source: "root\x0a\x0a^root\x0a",
  132. messageSends: [],
  133. referencedClasses: []
  134. }),
  135. smalltalk.Isolator);
  136. smalltalk.addMethod(
  137. "_root_",
  138. smalltalk.method({
  139. selector: "root:",
  140. category: 'accessing',
  141. fn: function (anObject){
  142. var self=this;
  143. self["@root"]=anObject;
  144. return self},
  145. args: ["anObject"],
  146. source: "root: anObject\x0a\x0aroot := anObject",
  147. messageSends: [],
  148. referencedClasses: []
  149. }),
  150. smalltalk.Isolator);
  151. smalltalk.addMethod(
  152. "_on_",
  153. smalltalk.method({
  154. selector: "on:",
  155. category: 'initialization',
  156. fn: function (anObject){
  157. var self=this;
  158. var $1;
  159. $1=smalltalk.send(smalltalk.send(self,"_new",[]),"_root_",[anObject]);
  160. return $1;
  161. },
  162. args: ["anObject"],
  163. source: "on: anObject\x0a^self new root: anObject",
  164. messageSends: ["root:", "new"],
  165. referencedClasses: []
  166. }),
  167. smalltalk.Isolator.klass);
  168. smalltalk.addClass('Trapped', smalltalk.Object, [], 'Trapped');