Kernel-Transcript.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. define(["smalltalk","nil","_st"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Kernel-Transcript');
  3. smalltalk.addClass('ConsoleTranscript', smalltalk.Object, ['textarea'], 'Kernel-Transcript');
  4. smalltalk.ConsoleTranscript.comment="I am a specific transcript emitting to the JavaScript console.\x0a\x0aIf no other transcript is registered, I am the default.";
  5. smalltalk.addMethod(
  6. smalltalk.method({
  7. selector: "clear",
  8. category: 'printing',
  9. fn: function (){
  10. var self=this;
  11. return smalltalk.withContext(function($ctx1) {
  12. return self}, function($ctx1) {$ctx1.fill(self,"clear",{},smalltalk.ConsoleTranscript)})},
  13. args: [],
  14. source: "clear\x0a\x09\x22no op\x22",
  15. messageSends: [],
  16. referencedClasses: []
  17. }),
  18. smalltalk.ConsoleTranscript);
  19. smalltalk.addMethod(
  20. smalltalk.method({
  21. selector: "cr",
  22. category: 'printing',
  23. fn: function (){
  24. var self=this;
  25. return smalltalk.withContext(function($ctx1) {
  26. return self}, function($ctx1) {$ctx1.fill(self,"cr",{},smalltalk.ConsoleTranscript)})},
  27. args: [],
  28. source: "cr\x0a\x09\x22no op\x22",
  29. messageSends: [],
  30. referencedClasses: []
  31. }),
  32. smalltalk.ConsoleTranscript);
  33. smalltalk.addMethod(
  34. smalltalk.method({
  35. selector: "open",
  36. category: 'actions',
  37. fn: function (){
  38. var self=this;
  39. return smalltalk.withContext(function($ctx1) {
  40. return self}, function($ctx1) {$ctx1.fill(self,"open",{},smalltalk.ConsoleTranscript)})},
  41. args: [],
  42. source: "open",
  43. messageSends: [],
  44. referencedClasses: []
  45. }),
  46. smalltalk.ConsoleTranscript);
  47. smalltalk.addMethod(
  48. smalltalk.method({
  49. selector: "show:",
  50. category: 'printing',
  51. fn: function (anObject){
  52. var self=this;
  53. return smalltalk.withContext(function($ctx1) {
  54. console.log(String(_st(anObject)._asString()));
  55. return self}, function($ctx1) {$ctx1.fill(self,"show:",{anObject:anObject},smalltalk.ConsoleTranscript)})},
  56. args: ["anObject"],
  57. source: "show: anObject\x0a\x22Smalltalk objects should have no trouble displaying themselves on the Transcript; Javascript objects don't know how, so must be wrapped in a JSObectProxy.\x22\x0a<console.log(String(_st(anObject)._asString()))>",
  58. messageSends: [],
  59. referencedClasses: []
  60. }),
  61. smalltalk.ConsoleTranscript);
  62. smalltalk.addMethod(
  63. smalltalk.method({
  64. selector: "initialize",
  65. category: 'initialization',
  66. fn: function (){
  67. var self=this;
  68. function $Transcript(){return smalltalk.Transcript||(typeof Transcript=="undefined"?nil:Transcript)}
  69. return smalltalk.withContext(function($ctx1) {
  70. _st($Transcript())._register_(self._new());
  71. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.ConsoleTranscript.klass)})},
  72. args: [],
  73. source: "initialize\x0a\x09Transcript register: self new",
  74. messageSends: ["register:", "new"],
  75. referencedClasses: ["Transcript"]
  76. }),
  77. smalltalk.ConsoleTranscript.klass);
  78. smalltalk.addClass('Transcript', smalltalk.Object, [], 'Kernel-Transcript');
  79. smalltalk.Transcript.comment="I am a facade for Transcript actions.\x0a\x0aI delegate actions to the currently registered transcript.\x0a\x0a## API\x0a\x0a Transcript \x0a show: 'hello world';\x0a cr;\x0a show: anObject.";
  80. smalltalk.Transcript.klass.iVarNames = ['current'];
  81. smalltalk.addMethod(
  82. smalltalk.method({
  83. selector: "clear",
  84. category: 'printing',
  85. fn: function (){
  86. var self=this;
  87. return smalltalk.withContext(function($ctx1) {
  88. _st(self._current())._clear();
  89. return self}, function($ctx1) {$ctx1.fill(self,"clear",{},smalltalk.Transcript.klass)})},
  90. args: [],
  91. source: "clear\x0a\x09self current clear",
  92. messageSends: ["clear", "current"],
  93. referencedClasses: []
  94. }),
  95. smalltalk.Transcript.klass);
  96. smalltalk.addMethod(
  97. smalltalk.method({
  98. selector: "cr",
  99. category: 'printing',
  100. fn: function (){
  101. var self=this;
  102. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  103. return smalltalk.withContext(function($ctx1) {
  104. _st(self._current())._show_(_st($String())._cr());
  105. return self}, function($ctx1) {$ctx1.fill(self,"cr",{},smalltalk.Transcript.klass)})},
  106. args: [],
  107. source: "cr\x0a\x09self current show: String cr",
  108. messageSends: ["show:", "cr", "current"],
  109. referencedClasses: ["String"]
  110. }),
  111. smalltalk.Transcript.klass);
  112. smalltalk.addMethod(
  113. smalltalk.method({
  114. selector: "current",
  115. category: 'instance creation',
  116. fn: function (){
  117. var self=this;
  118. return smalltalk.withContext(function($ctx1) {
  119. var $1;
  120. $1=self["@current"];
  121. return $1;
  122. }, function($ctx1) {$ctx1.fill(self,"current",{},smalltalk.Transcript.klass)})},
  123. args: [],
  124. source: "current\x0a\x09^current",
  125. messageSends: [],
  126. referencedClasses: []
  127. }),
  128. smalltalk.Transcript.klass);
  129. smalltalk.addMethod(
  130. smalltalk.method({
  131. selector: "inspect:",
  132. category: 'printing',
  133. fn: function (anObject){
  134. var self=this;
  135. return smalltalk.withContext(function($ctx1) {
  136. self._show_(anObject);
  137. return self}, function($ctx1) {$ctx1.fill(self,"inspect:",{anObject:anObject},smalltalk.Transcript.klass)})},
  138. args: ["anObject"],
  139. source: "inspect: anObject\x0a\x09self show: anObject",
  140. messageSends: ["show:"],
  141. referencedClasses: []
  142. }),
  143. smalltalk.Transcript.klass);
  144. smalltalk.addMethod(
  145. smalltalk.method({
  146. selector: "new",
  147. category: 'instance creation',
  148. fn: function (){
  149. var self=this;
  150. return smalltalk.withContext(function($ctx1) {
  151. self._shouldNotImplement();
  152. return self}, function($ctx1) {$ctx1.fill(self,"new",{},smalltalk.Transcript.klass)})},
  153. args: [],
  154. source: "new\x0a\x09self shouldNotImplement",
  155. messageSends: ["shouldNotImplement"],
  156. referencedClasses: []
  157. }),
  158. smalltalk.Transcript.klass);
  159. smalltalk.addMethod(
  160. smalltalk.method({
  161. selector: "open",
  162. category: 'instance creation',
  163. fn: function (){
  164. var self=this;
  165. return smalltalk.withContext(function($ctx1) {
  166. _st(self._current())._open();
  167. return self}, function($ctx1) {$ctx1.fill(self,"open",{},smalltalk.Transcript.klass)})},
  168. args: [],
  169. source: "open\x0a\x09self current open",
  170. messageSends: ["open", "current"],
  171. referencedClasses: []
  172. }),
  173. smalltalk.Transcript.klass);
  174. smalltalk.addMethod(
  175. smalltalk.method({
  176. selector: "register:",
  177. category: 'instance creation',
  178. fn: function (aTranscript){
  179. var self=this;
  180. return smalltalk.withContext(function($ctx1) {
  181. self["@current"]=aTranscript;
  182. return self}, function($ctx1) {$ctx1.fill(self,"register:",{aTranscript:aTranscript},smalltalk.Transcript.klass)})},
  183. args: ["aTranscript"],
  184. source: "register: aTranscript\x0a\x09current := aTranscript",
  185. messageSends: [],
  186. referencedClasses: []
  187. }),
  188. smalltalk.Transcript.klass);
  189. smalltalk.addMethod(
  190. smalltalk.method({
  191. selector: "show:",
  192. category: 'printing',
  193. fn: function (anObject){
  194. var self=this;
  195. return smalltalk.withContext(function($ctx1) {
  196. _st(self._current())._show_(anObject);
  197. return self}, function($ctx1) {$ctx1.fill(self,"show:",{anObject:anObject},smalltalk.Transcript.klass)})},
  198. args: ["anObject"],
  199. source: "show: anObject\x0a\x09self current show: anObject",
  200. messageSends: ["show:", "current"],
  201. referencedClasses: []
  202. }),
  203. smalltalk.Transcript.klass);
  204. });