Platform-Node.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. define("amber_core/Platform-Node", ["amber/boot", "amber_core/Kernel-Objects"], function($boot){"use strict";
  2. var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
  3. $core.addPackage('Platform-Node');
  4. $core.packages["Platform-Node"].innerEval = function (expr) { return eval(expr); };
  5. $core.packages["Platform-Node"].transport = {"type":"amd","amdNamespace":"amber_core"};
  6. $core.addClass('NodePlatform', $globals.Object, [], 'Platform-Node');
  7. //>>excludeStart("ide", pragmas.excludeIdeData);
  8. $globals.NodePlatform.comment="I am `Platform` service implementation for node-like environment.";
  9. //>>excludeEnd("ide");
  10. $core.addMethod(
  11. $core.method({
  12. selector: "globals",
  13. protocol: 'accessing',
  14. fn: function (){
  15. var self=this;
  16. return global;
  17. },
  18. //>>excludeStart("ide", pragmas.excludeIdeData);
  19. args: [],
  20. source: "globals\x0a\x09^ global",
  21. referencedClasses: [],
  22. //>>excludeEnd("ide");
  23. messageSends: []
  24. }),
  25. $globals.NodePlatform);
  26. $core.addMethod(
  27. $core.method({
  28. selector: "newXhr",
  29. protocol: 'accessing',
  30. fn: function (){
  31. var self=this;
  32. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  33. return $core.withContext(function($ctx1) {
  34. //>>excludeEnd("ctx");
  35. var $receiver;
  36. if(($receiver = $globals.XMLHttpRequest) == null || $receiver.isNil){
  37. self._error_("XMLHttpRequest not available.");
  38. } else {
  39. return $recv($globals.XMLHttpRequest)._new();
  40. };
  41. return self;
  42. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  43. }, function($ctx1) {$ctx1.fill(self,"newXhr",{},$globals.NodePlatform)});
  44. //>>excludeEnd("ctx");
  45. },
  46. //>>excludeStart("ide", pragmas.excludeIdeData);
  47. args: [],
  48. source: "newXhr\x0a\x09XMLHttpRequest\x0a\x09\x09ifNotNil: [ ^ XMLHttpRequest new ]\x0a\x09\x09ifNil: [ self error: 'XMLHttpRequest not available.' ]",
  49. referencedClasses: ["XMLHttpRequest"],
  50. //>>excludeEnd("ide");
  51. messageSends: ["ifNotNil:ifNil:", "new", "error:"]
  52. }),
  53. $globals.NodePlatform);
  54. $core.addMethod(
  55. $core.method({
  56. selector: "initialize",
  57. protocol: 'testing',
  58. fn: function (){
  59. var self=this;
  60. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  61. return $core.withContext(function($ctx1) {
  62. //>>excludeEnd("ctx");
  63. var $1;
  64. $1=self._isFeasible();
  65. if($core.assert($1)){
  66. $recv($globals.Platform)._registerIfNone_(self._new());
  67. };
  68. return self;
  69. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  70. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.NodePlatform.klass)});
  71. //>>excludeEnd("ctx");
  72. },
  73. //>>excludeStart("ide", pragmas.excludeIdeData);
  74. args: [],
  75. source: "initialize\x0a\x09self isFeasible ifTrue: [ Platform registerIfNone: self new ]",
  76. referencedClasses: ["Platform"],
  77. //>>excludeEnd("ide");
  78. messageSends: ["ifTrue:", "isFeasible", "registerIfNone:", "new"]
  79. }),
  80. $globals.NodePlatform.klass);
  81. $core.addMethod(
  82. $core.method({
  83. selector: "isFeasible",
  84. protocol: 'testing',
  85. fn: function (){
  86. var self=this;
  87. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  88. return $core.withContext(function($ctx1) {
  89. //>>excludeEnd("ctx");
  90. return typeof global !== "undefined";
  91. return self;
  92. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  93. }, function($ctx1) {$ctx1.fill(self,"isFeasible",{},$globals.NodePlatform.klass)});
  94. //>>excludeEnd("ctx");
  95. },
  96. //>>excludeStart("ide", pragmas.excludeIdeData);
  97. args: [],
  98. source: "isFeasible\x0a<return typeof global !== \x22undefined\x22>",
  99. referencedClasses: [],
  100. //>>excludeEnd("ide");
  101. messageSends: []
  102. }),
  103. $globals.NodePlatform.klass);
  104. });