Trapped.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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_read_",
  91. smalltalk.method({
  92. selector: "model:read:",
  93. category: 'action',
  94. fn: function (anEavModel,aBlock){
  95. var self=this;
  96. smalltalk.send(aBlock,"_value_",[smalltalk.send(smalltalk.send(anEavModel,"_on_",[self]),"_deepCopy",[])]);
  97. return self},
  98. args: ["anEavModel", "aBlock"],
  99. source: "model: anEavModel read: aBlock\x0a\x0aaBlock value: (anEavModel on: self) deepCopy",
  100. messageSends: ["value:", "deepCopy", "on:"],
  101. referencedClasses: []
  102. }),
  103. smalltalk.Isolator);
  104. smalltalk.addMethod(
  105. "_root",
  106. smalltalk.method({
  107. selector: "root",
  108. category: 'accessing',
  109. fn: function (){
  110. var self=this;
  111. return self["@root"];
  112. },
  113. args: [],
  114. source: "root\x0a\x0a^root\x0a",
  115. messageSends: [],
  116. referencedClasses: []
  117. }),
  118. smalltalk.Isolator);
  119. smalltalk.addMethod(
  120. "_root_",
  121. smalltalk.method({
  122. selector: "root:",
  123. category: 'accessing',
  124. fn: function (anObject){
  125. var self=this;
  126. self["@root"]=anObject;
  127. return self},
  128. args: ["anObject"],
  129. source: "root: anObject\x0a\x0aroot := anObject",
  130. messageSends: [],
  131. referencedClasses: []
  132. }),
  133. smalltalk.Isolator);
  134. smalltalk.addMethod(
  135. "_on_",
  136. smalltalk.method({
  137. selector: "on:",
  138. category: 'initialization',
  139. fn: function (anObject){
  140. var self=this;
  141. var $1;
  142. $1=smalltalk.send(smalltalk.send(self,"_new",[]),"_root_",[anObject]);
  143. return $1;
  144. },
  145. args: ["anObject"],
  146. source: "on: anObject\x0a^self new root: anObject",
  147. messageSends: ["root:", "new"],
  148. referencedClasses: []
  149. }),
  150. smalltalk.Isolator.klass);
  151. smalltalk.addClass('Trapped', smalltalk.Object, [], 'Trapped');