Browse Source

PlatformInterface existsGlobal: -> Smalltalk existsJsGlobal:

Herbert Vojčík 9 years ago
parent
commit
26a9c7f045

+ 3 - 0
API-CHANGES.txt

@@ -3,6 +3,7 @@
 * InterfacingObject >> ajax: deprecated
 * PlatformInterface class >> ajax: deprecated
 * PlatformInterface class >> alert:/confirm:/prompt:[default:] deprecated
+* PlatformInterface class >> existsGlobal: deprecated
 * Class BrowserInterface removed
 * Class Terminal, BrowserTerminal added
 
@@ -15,6 +16,8 @@
   + confirm:
   + prompt:
   + prompt:default:
+SmalltalkImage >>
+  + existsJsGlobal:
 
 - PlatformInterface class >>
   - initialize

+ 32 - 0
src/Kernel-Infrastructure.js

@@ -2879,6 +2879,38 @@ messageSends: []
 }),
 $globals.SmalltalkImage);
 
+$core.addMethod(
+$core.method({
+selector: "existsJsGlobal:",
+protocol: 'testing',
+fn: function (aString){
+var self=this;
+function $PlatformInterface(){return $globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+$1=$recv($recv($PlatformInterface())._globals())._at_ifPresent_ifAbsent_(aString,(function(){
+return true;
+
+}),(function(){
+return false;
+
+}));
+return $1;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"existsJsGlobal:",{aString:aString},$globals.SmalltalkImage)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aString"],
+source: "existsJsGlobal: aString\x0a\x09^ PlatformInterface globals \x0a\x09\x09at: aString \x0a\x09\x09ifPresent: [ true ] \x0a\x09\x09ifAbsent: [ false ]",
+referencedClasses: ["PlatformInterface"],
+//>>excludeEnd("ide");
+messageSends: ["at:ifPresent:ifAbsent:", "globals"]
+}),
+$globals.SmalltalkImage);
+
 $core.addMethod(
 $core.method({
 selector: "globalJsVariables",

+ 7 - 0
src/Kernel-Infrastructure.st

@@ -900,6 +900,13 @@ deletePackage: packageName
 
 !SmalltalkImage methodsFor: 'testing'!
 
+existsJsGlobal: aString
+	^ PlatformInterface globals 
+		at: aString 
+		ifPresent: [ true ] 
+		ifAbsent: [ false ]
+!
+
 isSmalltalkObject: anObject
 	"Consider anObject a Smalltalk object if it has a 'klass' property.
 	Note that this may be unaccurate"

+ 5 - 5
src/Kernel-Methods.js

@@ -3043,12 +3043,12 @@ selector: "exists:",
 protocol: 'testing',
 fn: function (aString){
 var self=this;
-function $PlatformInterface(){return $globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
+function $Smalltalk(){return $globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 var $1;
-$1=$recv($PlatformInterface())._existsGlobal_(aString);
+$1=$recv($Smalltalk())._existsJsGlobal_(aString);
 return $1;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"exists:",{aString:aString},$globals.NativeFunction.klass)});
@@ -3056,10 +3056,10 @@ return $1;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aString"],
-source: "exists: aString\x0a\x09^ PlatformInterface existsGlobal: aString",
-referencedClasses: ["PlatformInterface"],
+source: "exists: aString\x0a\x09^ Smalltalk existsJsGlobal: aString",
+referencedClasses: ["Smalltalk"],
 //>>excludeEnd("ide");
-messageSends: ["existsGlobal:"]
+messageSends: ["existsJsGlobal:"]
 }),
 $globals.NativeFunction.klass);
 

+ 1 - 1
src/Kernel-Methods.st

@@ -885,7 +885,7 @@ methodOf: nativeFunc this: thisObject valueWithArgs: args
 !NativeFunction class methodsFor: 'testing'!
 
 exists: aString
-	^ PlatformInterface existsGlobal: aString
+	^ Smalltalk existsJsGlobal: aString
 ! !
 
 Object subclass: #Timeout

+ 4 - 3
src/Platform-Services.js

@@ -1508,7 +1508,7 @@ $globals.NullProgressHandler.klass);
 
 $core.addClass('PlatformInterface', $globals.Object, [], 'Platform-Services');
 //>>excludeStart("ide", pragmas.excludeIdeData);
-$globals.PlatformInterface.comment="I am single entry point to underlying platform.\x0a\x0a## API\x0a\x0a- `PlatformInterface newXhr` returns new instance of `XMLHttpRequest`. This should be polyfilled for platforms where it does not exists, so it is always present.\x0a\x0a- `PlatformInterface globals` returns JS global object.\x0a- `PlatformInterface existsGlobal: aString` tests is a global named `aString` exists.";
+$globals.PlatformInterface.comment="I am single entry point to underlying platform.\x0a\x0a## API\x0a\x0a- `PlatformInterface newXhr` returns new instance of `XMLHttpRequest`. This should be polyfilled for platforms where it does not exists, so it is always present.\x0a\x0a- `PlatformInterface globals` returns JS global object.";
 //>>excludeEnd("ide");
 
 $core.addMethod(
@@ -1607,6 +1607,7 @@ function $PlatformInterface(){return $globals.PlatformInterface||(typeof Platfor
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 var $1;
+self._deprecatedAPI_("Use Smalltalk existsJsGlobal:");
 $1=$recv($recv($PlatformInterface())._globals())._at_ifPresent_ifAbsent_(aString,(function(){
 return true;
 
@@ -1621,10 +1622,10 @@ return $1;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aString"],
-source: "existsGlobal: aString\x0a\x09^ PlatformInterface globals \x0a\x09\x09at: aString \x0a\x09\x09ifPresent: [ true ] \x0a\x09\x09ifAbsent: [ false ]",
+source: "existsGlobal: aString\x0a\x09self deprecatedAPI: 'Use Smalltalk existsJsGlobal:'.\x0a\x09^ PlatformInterface globals \x0a\x09\x09at: aString \x0a\x09\x09ifPresent: [ true ] \x0a\x09\x09ifAbsent: [ false ]",
 referencedClasses: ["PlatformInterface"],
 //>>excludeEnd("ide");
-messageSends: ["at:ifPresent:ifAbsent:", "globals"]
+messageSends: ["deprecatedAPI:", "at:ifPresent:ifAbsent:", "globals"]
 }),
 $globals.PlatformInterface.klass);
 

+ 2 - 2
src/Platform-Services.st

@@ -352,8 +352,7 @@ I am single entry point to underlying platform.
 
 - `PlatformInterface newXhr` returns new instance of `XMLHttpRequest`. This should be polyfilled for platforms where it does not exists, so it is always present.
 
-- `PlatformInterface globals` returns JS global object.
-- `PlatformInterface existsGlobal: aString` tests is a global named `aString` exists.!
+- `PlatformInterface globals` returns JS global object.!
 
 !PlatformInterface class methodsFor: 'accessing'!
 
@@ -381,6 +380,7 @@ confirm: aString
 !
 
 existsGlobal: aString
+	self deprecatedAPI: 'Use Smalltalk existsJsGlobal:'.
 	^ PlatformInterface globals 
 		at: aString 
 		ifPresent: [ true ]