2
0

Spaces.deploy.js 8.6 KB

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