Spaces.deploy.js 8.4 KB

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