Spaces.deploy.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. smalltalk.addPackage('Spaces', {});
  2. smalltalk.addClass('ObjectSpace', smalltalk.Object, ['frame'], 'Spaces');
  3. smalltalk.addMethod(
  4. "_connectTo_",
  5. smalltalk.method({
  6. selector: "connectTo:",
  7. fn: function (aFrame) {
  8. var self = this;
  9. smalltalk.send(self, "_release", []);
  10. self['@frame'] = aFrame;
  11. return self;
  12. }
  13. }),
  14. smalltalk.ObjectSpace);
  15. smalltalk.addMethod(
  16. "_create",
  17. smalltalk.method({
  18. selector: "create",
  19. fn: function () {
  20. var self = this;
  21. smalltalk.send(smalltalk.send(window, "_jQuery_", ["body"]), "_append_", ["<iframe style=\"display: none;\"></iframe>"]);
  22. self['@frame'] = smalltalk.send(smalltalk.send(smalltalk.send(window, "_jQuery_", ["iframe"]), "_get", []), "_last", []);
  23. smalltalk.send(smalltalk.send(self['@frame'], "_contentWindow", []), "_location_", [smalltalk.send(window, "_location", [])]);
  24. return self;
  25. }
  26. }),
  27. smalltalk.ObjectSpace);
  28. smalltalk.addMethod(
  29. "_destroy",
  30. smalltalk.method({
  31. selector: "destroy",
  32. fn: function () {
  33. var self = this;
  34. if (($receiver = self['@frame']) == nil || $receiver == undefined) {
  35. return self;
  36. } else {
  37. self['@frame'];
  38. }
  39. smalltalk.send(smalltalk.send(window, "_jQuery_", [self['@frame']]), "_remove", []);
  40. smalltalk.send(self, "_release", []);
  41. return self;
  42. }
  43. }),
  44. smalltalk.ObjectSpace);
  45. smalltalk.addMethod(
  46. "_do_",
  47. smalltalk.method({
  48. selector: "do:",
  49. fn: function (aBlock) {
  50. var self = this;
  51. var $1, $2, $3;
  52. $1 = smalltalk.send(self, "_isConnected", []);
  53. if (!smalltalk.assert($1)) {
  54. $2 = smalltalk.send(smalltalk.ObjectSpaceConnectionError ||
  55. ObjectSpaceConnectionError, "_signal", []);
  56. return $2;
  57. }
  58. $3 = smalltalk.send(smalltalk.send(self['@frame'], "_contentWindow", []), "_eval_", [smalltalk.send(smalltalk.send("(", "__comma", [smalltalk.send(aBlock, "_compiledSource", [])]), "__comma", [")()"])]);
  59. return $3;
  60. }
  61. }),
  62. smalltalk.ObjectSpace);
  63. smalltalk.addMethod(
  64. "_frame",
  65. smalltalk.method({
  66. selector: "frame",
  67. fn: function () {
  68. var self = this;
  69. return self['@frame'];
  70. }
  71. }),
  72. smalltalk.ObjectSpace);
  73. smalltalk.addMethod(
  74. "_initialize",
  75. smalltalk.method({
  76. selector: "initialize",
  77. fn: function () {
  78. var self = this;
  79. smalltalk.send(self, "_initialize", [], smalltalk.Object);
  80. smalltalk.send(self, "_create", []);
  81. return self;
  82. }
  83. }),
  84. smalltalk.ObjectSpace);
  85. smalltalk.addMethod(
  86. "_isConnected",
  87. smalltalk.method({
  88. selector: "isConnected",
  89. fn: function () {
  90. var self = this;
  91. var $1;
  92. $1 = smalltalk.send(smalltalk.send(self, "_frame", []), "_notNil", []);
  93. return $1;
  94. }
  95. }),
  96. smalltalk.ObjectSpace);
  97. smalltalk.addMethod(
  98. "_release",
  99. smalltalk.method({
  100. selector: "release",
  101. fn: function () {
  102. var self = this;
  103. self['@frame'] = nil;
  104. return self;
  105. }
  106. }),
  107. smalltalk.ObjectSpace);
  108. smalltalk.addMethod(
  109. "_whenReadyDo_",
  110. smalltalk.method({
  111. selector: "whenReadyDo:",
  112. fn: function (aBlock) {
  113. var self = this;
  114. smalltalk.send(smalltalk.send(window, "_jQuery_", [self['@frame']]), "_bind_do_", ["load", aBlock]);
  115. return self;
  116. }
  117. }),
  118. smalltalk.ObjectSpace);
  119. smalltalk.addMethod(
  120. "_on_",
  121. smalltalk.method({
  122. selector: "on:",
  123. fn: function (aFrame) {
  124. var self = this;
  125. var $2, $3, $1;
  126. $2 = smalltalk.send(self, "_basicNew", []);
  127. smalltalk.send($2, "_connectTo_", [aFrame]);
  128. $3 = smalltalk.send($2, "_yourself", []);
  129. $1 = $3;
  130. return $1;
  131. }
  132. }),
  133. smalltalk.ObjectSpace.klass);
  134. smalltalk.addClass('ObjectSpaceConnectionError', smalltalk.Error, [], 'Spaces');
  135. smalltalk.addMethod(
  136. "_messageText",
  137. smalltalk.method({
  138. selector: "messageText",
  139. fn: function () {
  140. var self = this;
  141. return "The ObjectSpace is not connected";
  142. }
  143. }),
  144. smalltalk.ObjectSpaceConnectionError);
  145. smalltalk.addClass('ObjectSpaceTest', smalltalk.TestCase, ['space'], 'Spaces');
  146. smalltalk.addMethod(
  147. "_setUp",
  148. smalltalk.method({
  149. selector: "setUp",
  150. fn: function () {
  151. var self = this;
  152. self['@space'] = smalltalk.send(smalltalk.ObjectSpace || ObjectSpace, "_new", []);
  153. return self;
  154. }
  155. }),
  156. smalltalk.ObjectSpaceTest);
  157. smalltalk.addMethod(
  158. "_tearDown",
  159. smalltalk.method({
  160. selector: "tearDown",
  161. fn: function () {
  162. var self = this;
  163. smalltalk.send(self['@space'], "_destroy", []);
  164. return self;
  165. }
  166. }),
  167. smalltalk.ObjectSpaceTest);
  168. smalltalk.addMethod(
  169. "_testConnection",
  170. smalltalk.method({
  171. selector: "testConnection",
  172. fn: function () {
  173. var self = this;
  174. smalltalk.send(self['@space'], "_destroy", []);
  175. smalltalk.send(self, "_deny_", [smalltalk.send(self['@space'], "_isConnected", [])]);
  176. smalltalk.send(self, "_should_raise_", [function () {return smalltalk.send(self['@space'], "_do_", [function () {}]);}, smalltalk.ObjectSpaceConnectionError || ObjectSpaceConnectionError]);
  177. return self;
  178. }
  179. }),
  180. smalltalk.ObjectSpaceTest);
  181. smalltalk.addMethod(
  182. "_testCreate",
  183. smalltalk.method({
  184. selector: "testCreate",
  185. fn: function () {
  186. var self = this;
  187. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(self['@space'], "_frame", []), "_notNil", [])]);
  188. smalltalk.send(self, "_assert_", [smalltalk.send(self['@space'], "_isConnected", [])]);
  189. return self;
  190. }
  191. }),
  192. smalltalk.ObjectSpaceTest);
  193. smalltalk.addMethod(
  194. "_testEvaluation",
  195. smalltalk.method({
  196. selector: "testEvaluation",
  197. fn: function () {
  198. var self = this;
  199. var result;
  200. smalltalk.send(self['@space'], "_whenReadyDo_", [function () {result = smalltalk.send(self['@space'], "_do_", [function () {return smalltalk;}]);result;smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(result, "_class", []), "_name", []), "Smalltalk"]);smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(result, "_class", []), "__eq", [smalltalk.Smalltalk || Smalltalk])]);return smalltalk.send(self, "_deny_", [smalltalk.send(result, "__eq_eq", [smalltalk])]);}]);
  201. return self;
  202. }
  203. }),
  204. smalltalk.ObjectSpaceTest);
  205. smalltalk.addMethod(
  206. "_testRelease",
  207. smalltalk.method({
  208. selector: "testRelease",
  209. fn: function () {
  210. var self = this;
  211. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(self['@space'], "_frame", []), "_isNil", [])]);
  212. smalltalk.send(self['@space'], "_release", []);
  213. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(self['@space'], "_frame", []), "_isNil", [])]);
  214. return self;
  215. }
  216. }),
  217. smalltalk.ObjectSpaceTest);