1
0

Nemo.deploy.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. smalltalk.addPackage('Nemo', {});
  2. smalltalk.addClass('NemoConnection', smalltalk.Object, ['socket'], 'Nemo');
  3. smalltalk.addMethod(
  4. "_close",
  5. smalltalk.method({
  6. selector: "close",
  7. fn: function (){
  8. var self=this;
  9. smalltalk.send(self['@socket'], "_close", []);
  10. (self['@socket']=nil);
  11. return self;}
  12. }),
  13. smalltalk.NemoConnection);
  14. smalltalk.addMethod(
  15. "_createDefaultSocket",
  16. smalltalk.method({
  17. selector: "createDefaultSocket",
  18. fn: function (){
  19. var self=this;
  20. smalltalk.send(self, "_createSocketOn_", [smalltalk.send(self, "_defaultURL", [])]);
  21. return self;}
  22. }),
  23. smalltalk.NemoConnection);
  24. smalltalk.addMethod(
  25. "_createLocalSocketOn_",
  26. smalltalk.method({
  27. selector: "createLocalSocketOn:",
  28. fn: function (aPort){
  29. var self=this;
  30. return smalltalk.send(self, "_createSocketOn_", [smalltalk.send(smalltalk.send("ws://localhost:", "__comma", [smalltalk.send(aPort, "_asString", [])]), "__comma", ["/nemo"])]);
  31. return self;}
  32. }),
  33. smalltalk.NemoConnection);
  34. smalltalk.addMethod(
  35. "_createSocketOn_",
  36. smalltalk.method({
  37. selector: "createSocketOn:",
  38. fn: function (uri){
  39. var self=this;
  40. (self['@socket']=new WebSocket(uri));
  41. smalltalk.send(self['@socket'], "_at_put_", ["onmessage", (function(message){return smalltalk.send(self, "_handleMessage_", [message]);})]);
  42. smalltalk.send(self['@socket'], "_at_put_", ["onerror", (function(err){return smalltalk.send((typeof console == 'undefined' ? nil : console), "_log_", [err]);})]);
  43. return self;}
  44. }),
  45. smalltalk.NemoConnection);
  46. smalltalk.addMethod(
  47. "_defaultURL",
  48. smalltalk.method({
  49. selector: "defaultURL",
  50. fn: function (){
  51. var self=this;
  52. return smalltalk.send(smalltalk.send(self, "_class", []), "_defaultURL", []);
  53. return self;}
  54. }),
  55. smalltalk.NemoConnection);
  56. smalltalk.addMethod(
  57. "_handleMessage_",
  58. smalltalk.method({
  59. selector: "handleMessage:",
  60. fn: function (aMessage){
  61. var self=this;
  62. var $early={};
  63. try{var string=nil;
  64. var result=nil;
  65. (string=smalltalk.send(aMessage, "_data", []));
  66. ((($receiver = smalltalk.send(string, "_isString", [])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return (function(){throw $early=[self]})();})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return (function(){throw $early=[self]})();})]));
  67. smalltalk.send((function(){return (result=smalltalk.send(smalltalk.send((smalltalk.Compiler || Compiler), "_new", []), "_evaluateExpression_", [string]));}), "_on_do_", [(smalltalk.Error || Error), (function(ex){return (function(){throw $early=[smalltalk.send(self['@socket'], "_send_", [smalltalk.send(ex, "_asNemoString", [])])]})();})]);
  68. smalltalk.send(self['@socket'], "_send_", [smalltalk.send(result, "_asNemoString", [])]);
  69. return self;
  70. } catch(e) {if(e===$early)return e[0]; throw e}}
  71. }),
  72. smalltalk.NemoConnection);
  73. smalltalk.addMethod(
  74. "_send_",
  75. smalltalk.method({
  76. selector: "send:",
  77. fn: function (aString){
  78. var self=this;
  79. smalltalk.send(self['@socket'], "_send_", [aString]);
  80. return self;}
  81. }),
  82. smalltalk.NemoConnection);
  83. smalltalk.NemoConnection.klass.iVarNames = ['default'];
  84. smalltalk.addMethod(
  85. "_default",
  86. smalltalk.method({
  87. selector: "default",
  88. fn: function (){
  89. var self=this;
  90. return (($receiver = self['@default']) == nil || $receiver == undefined) ? (function(){return (self['@default']=smalltalk.send(self, "_new", []));})() : $receiver;
  91. return self;}
  92. }),
  93. smalltalk.NemoConnection.klass);
  94. smalltalk.addMethod(
  95. "_defaultURL",
  96. smalltalk.method({
  97. selector: "defaultURL",
  98. fn: function (){
  99. var self=this;
  100. return "ws://localhost:8010/nemo";
  101. return self;}
  102. }),
  103. smalltalk.NemoConnection.klass);
  104. smalltalk.addMethod(
  105. "_asNemo",
  106. smalltalk.method({
  107. selector: "asNemo",
  108. fn: function (){
  109. var self=this;
  110. return smalltalk.send(self, "_asJSON", []);
  111. return self;}
  112. }),
  113. smalltalk.Object);
  114. smalltalk.addMethod(
  115. "_asNemoString",
  116. smalltalk.method({
  117. selector: "asNemoString",
  118. fn: function (){
  119. var self=this;
  120. return smalltalk.send((smalltalk.JSON || JSON), "_stringify_", [smalltalk.send(self, "_asNemo", [])]);
  121. return self;}
  122. }),
  123. smalltalk.Object);
  124. smalltalk.addMethod(
  125. "_asNemo",
  126. smalltalk.method({
  127. selector: "asNemo",
  128. fn: function (){
  129. var self=this;
  130. return (function($rec){smalltalk.send($rec, "_at_put_", ["name", smalltalk.send(self, "_name", [])]);smalltalk.send($rec, "_at_put_", ["superclass", (($receiver = smalltalk.send(self, "_superclass", [])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(smalltalk.send(self, "_superclass", []), "_name", []);})() : nil]);smalltalk.send($rec, "_at_put_", ["classComment", smalltalk.send(self, "_comment", [])]);smalltalk.send($rec, "_at_put_", ["definition", smalltalk.send(self, "_definition", [])]);smalltalk.send($rec, "_at_put_", ["package", smalltalk.send(self, "_category", [])]);smalltalk.send($rec, "_at_put_", ["instVarNames", smalltalk.send(self, "_instanceVariableNames", [])]);return smalltalk.send($rec, "_asNemo", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  131. return self;}
  132. }),
  133. smalltalk.Class);
  134. smalltalk.addMethod(
  135. "_asNemo",
  136. smalltalk.method({
  137. selector: "asNemo",
  138. fn: function (){
  139. var self=this;
  140. return (function($rec){smalltalk.send($rec, "_at_put_", ["definition", smalltalk.send(self, "_definition", [])]);smalltalk.send($rec, "_at_put_", ["instVarNames", smalltalk.send(self, "_instanceVariableNames", [])]);return smalltalk.send($rec, "_asNemo", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  141. return self;}
  142. }),
  143. smalltalk.Metaclass);
  144. smalltalk.addMethod(
  145. "_asNemo",
  146. smalltalk.method({
  147. selector: "asNemo",
  148. fn: function (){
  149. var self=this;
  150. return smalltalk.send(smalltalk.send(self, "_asArray", []), "_collect_", [(function(each){return smalltalk.send(each, "_asNemo", []);})]);
  151. return self;}
  152. }),
  153. smalltalk.Collection);
  154. smalltalk.addMethod(
  155. "_asNemo",
  156. smalltalk.method({
  157. selector: "asNemo",
  158. fn: function (){
  159. var self=this;
  160. var c=nil;
  161. (c=smalltalk.send(smalltalk.send(self, "_class", []), "_new", []));
  162. smalltalk.send(self, "_keysAndValuesDo_", [(function(key, value){return smalltalk.send(c, "_at_put_", [key, smalltalk.send(value, "_asNemo", [])]);})]);
  163. return c;
  164. return self;}
  165. }),
  166. smalltalk.HashedCollection);
  167. smalltalk.addMethod(
  168. "_asNemo",
  169. smalltalk.method({
  170. selector: "asNemo",
  171. fn: function (){
  172. var self=this;
  173. return smalltalk.send(smalltalk.send(self, "_asHashedCollection", []), "_asNemo", []);
  174. return self;}
  175. }),
  176. smalltalk.Dictionary);
  177. smalltalk.addMethod(
  178. "_asNemo",
  179. smalltalk.method({
  180. selector: "asNemo",
  181. fn: function (){
  182. var self=this;
  183. return self;
  184. return self;}
  185. }),
  186. smalltalk.String);
  187. smalltalk.addMethod(
  188. "_asNemo",
  189. smalltalk.method({
  190. selector: "asNemo",
  191. fn: function (){
  192. var self=this;
  193. return (function($rec){smalltalk.send($rec, "_at_put_", ["name", smalltalk.send(self, "_selector", [])]);smalltalk.send($rec, "_at_put_", ["protocol", smalltalk.send(self, "_category", [])]);smalltalk.send($rec, "_at_put_", ["sourceCode", smalltalk.send(self, "_source", [])]);smalltalk.send($rec, "_at_put_", ["compiledSource", smalltalk.send(smalltalk.send(self, "_fn", []), "_compiledSource", [])]);smalltalk.send($rec, "_at_put_", ["messageSends", smalltalk.send(self, "_messageSends", [])]);return smalltalk.send($rec, "_asNemo", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  194. return self;}
  195. }),
  196. smalltalk.CompiledMethod);
  197. smalltalk.addMethod(
  198. "_asNemo",
  199. smalltalk.method({
  200. selector: "asNemo",
  201. fn: function (){
  202. var self=this;
  203. return (function($rec){smalltalk.send($rec, "_at_put_", ["error", smalltalk.send(self, "_messageText", [])]);return smalltalk.send($rec, "_asNemo", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  204. return self;}
  205. }),
  206. smalltalk.Error);
  207. smalltalk.addMethod(
  208. "_asNemo",
  209. smalltalk.method({
  210. selector: "asNemo",
  211. fn: function (){
  212. var self=this;
  213. return (function($rec){smalltalk.send($rec, "_at_put_", ["name", smalltalk.send(self, "_name", [])]);return smalltalk.send($rec, "_asNemo", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  214. return self;}
  215. }),
  216. smalltalk.Package);