1
0

Spaces.deploy.js 8.2 KB

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