Spaces.deploy.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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;
  52. $1 = smalltalk.send(smalltalk.send(self['@frame'], "_contentWindow", []), "_eval_", [smalltalk.send(smalltalk.send("(", "__comma", [smalltalk.send(aBlock, "_compiledSource", [])]), "__comma", [")()"])]);
  53. return $1;
  54. }
  55. }),
  56. smalltalk.ObjectSpace);
  57. smalltalk.addMethod(
  58. "_frame",
  59. smalltalk.method({
  60. selector: "frame",
  61. fn: function () {
  62. var self = this;
  63. return self['@frame'];
  64. }
  65. }),
  66. smalltalk.ObjectSpace);
  67. smalltalk.addMethod(
  68. "_initialize",
  69. smalltalk.method({
  70. selector: "initialize",
  71. fn: function () {
  72. var self = this;
  73. smalltalk.send(self, "_initialize", [], smalltalk.Object);
  74. smalltalk.send(self, "_create", []);
  75. return self;
  76. }
  77. }),
  78. smalltalk.ObjectSpace);
  79. smalltalk.addMethod(
  80. "_release",
  81. smalltalk.method({
  82. selector: "release",
  83. fn: function () {
  84. var self = this;
  85. self['@frame'] = nil;
  86. return self;
  87. }
  88. }),
  89. smalltalk.ObjectSpace);
  90. smalltalk.addMethod(
  91. "_whenReadyDo_",
  92. smalltalk.method({
  93. selector: "whenReadyDo:",
  94. fn: function (aBlock) {
  95. var self = this;
  96. smalltalk.send(smalltalk.send(window, "_jQuery_", [self['@frame']]), "_bind_do_", ["load", aBlock]);
  97. return self;
  98. }
  99. }),
  100. smalltalk.ObjectSpace);
  101. smalltalk.addMethod(
  102. "_on_",
  103. smalltalk.method({
  104. selector: "on:",
  105. fn: function (aFrame) {
  106. var self = this;
  107. var $2, $3, $1;
  108. $2 = smalltalk.send(self, "_basicNew", []);
  109. smalltalk.send($2, "_connectTo_", [aFrame]);
  110. $3 = smalltalk.send($2, "_yourself", []);
  111. $1 = $3;
  112. return $1;
  113. }
  114. }),
  115. smalltalk.ObjectSpace.klass);
  116. smalltalk.addClass('ObjectSpaceTest', smalltalk.TestCase, ['space'], 'Spaces');
  117. smalltalk.addMethod(
  118. "_setUp",
  119. smalltalk.method({
  120. selector: "setUp",
  121. fn: function () {
  122. var self = this;
  123. self['@space'] = smalltalk.send(smalltalk.ObjectSpace || ObjectSpace, "_new", []);
  124. return self;
  125. }
  126. }),
  127. smalltalk.ObjectSpaceTest);
  128. smalltalk.addMethod(
  129. "_tearDown",
  130. smalltalk.method({
  131. selector: "tearDown",
  132. fn: function () {
  133. var self = this;
  134. smalltalk.send(self['@space'], "_destroy", []);
  135. self['@space'] = nil;
  136. return self;
  137. }
  138. }),
  139. smalltalk.ObjectSpaceTest);
  140. smalltalk.addMethod(
  141. "_testCreate",
  142. smalltalk.method({
  143. selector: "testCreate",
  144. fn: function () {
  145. var self = this;
  146. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(self['@space'], "_frame", []), "_notNil", [])]);
  147. return self;
  148. }
  149. }),
  150. smalltalk.ObjectSpaceTest);
  151. smalltalk.addMethod(
  152. "_testEvaluation",
  153. smalltalk.method({
  154. selector: "testEvaluation",
  155. fn: function () {
  156. var self = this;
  157. var result;
  158. 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])]);}]);
  159. return self;
  160. }
  161. }),
  162. smalltalk.ObjectSpaceTest);
  163. smalltalk.addMethod(
  164. "_testRelease",
  165. smalltalk.method({
  166. selector: "testRelease",
  167. fn: function () {
  168. var self = this;
  169. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(self['@space'], "_frame", []), "_isNil", [])]);
  170. smalltalk.send(self['@space'], "_release", []);
  171. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(self['@space'], "_frame", []), "_isNil", [])]);
  172. return self;
  173. }
  174. }),
  175. smalltalk.ObjectSpaceTest);