Browse Source

Deprecate #javascriptConstructor(:).

Use #javaScriptConstructor(:) instead.
Herby Vojčík 4 years ago
parent
commit
4655803e80
5 changed files with 89 additions and 22 deletions
  1. 9 0
      lang/API-CHANGES.txt
  2. 58 10
      lang/src/Kernel-Classes.js
  3. 14 4
      lang/src/Kernel-Classes.st
  4. 6 6
      lang/src/Kernel-Tests.js
  5. 2 2
      lang/src/Kernel-Tests.st

+ 9 - 0
lang/API-CHANGES.txt

@@ -1,3 +1,12 @@
+0.24.1:
+
+* Deprecate Behavior >> javascriptConstructor(:)
+
++ Behavior >>
+  + javaScriptConstructor
+  + javaScriptConstructor:
+
+
 0.23.2:
 
 + Platform class >>

+ 58 - 10
lang/src/Kernel-Classes.js

@@ -406,11 +406,11 @@ $globals.Behavior);
 
 $core.addMethod(
 $core.method({
-selector: "javascriptConstructor",
+selector: "javaScriptConstructor",
 protocol: "accessing",
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "javascriptConstructor\x0a\x09\x22Answer the JS constructor used to instantiate. See kernel-language.js\x22\x0a\x09\x0a\x09^ fn",
+source: "javaScriptConstructor\x0a\x09\x22Answer the JS constructor used to instantiate. See kernel-language.js\x22\x0a\x09\x0a\x09^ fn",
 referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
@@ -424,11 +424,11 @@ $globals.Behavior);
 
 $core.addMethod(
 $core.method({
-selector: "javascriptConstructor:",
+selector: "javaScriptConstructor:",
 protocol: "accessing",
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aJavaScriptFunction"],
-source: "javascriptConstructor: aJavaScriptFunction\x0a\x09\x22Set the JS constructor used to instantiate.\x0a\x09See the JS counter-part in boot.js `$core.setClassConstructor'\x22\x0a\x09\x0a\x09Smalltalk core setClassConstructor: self to: aJavaScriptFunction",
+source: "javaScriptConstructor: aJavaScriptFunction\x0a\x09\x22Set the JS constructor used to instantiate.\x0a\x09See the JS counter-part in boot.js `$core.setClassConstructor'\x22\x0a\x09\x0a\x09Smalltalk core setClassConstructor: self to: aJavaScriptFunction",
 referencedClasses: ["Smalltalk"],
 //>>excludeEnd("ide");
 pragmas: [],
@@ -441,6 +441,54 @@ return $core.withContext(function($ctx1) {
 $recv($recv($globals.Smalltalk)._core())._setClassConstructor_to_(self,aJavaScriptFunction);
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"javaScriptConstructor:",{aJavaScriptFunction:aJavaScriptFunction})});
+//>>excludeEnd("ctx");
+}; }),
+$globals.Behavior);
+
+$core.addMethod(
+$core.method({
+selector: "javascriptConstructor",
+protocol: "accessing",
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "javascriptConstructor\x0a\x09self deprecatedAPI: 'Use #javaScriptConstructor instead.'.\x0a\x09^ self javaScriptConstructor",
+referencedClasses: [],
+//>>excludeEnd("ide");
+pragmas: [],
+messageSends: ["deprecatedAPI:", "javaScriptConstructor"]
+}, function ($methodClass){ return function (){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+$self._deprecatedAPI_("Use #javaScriptConstructor instead.");
+return $self._javaScriptConstructor();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"javascriptConstructor",{})});
+//>>excludeEnd("ctx");
+}; }),
+$globals.Behavior);
+
+$core.addMethod(
+$core.method({
+selector: "javascriptConstructor:",
+protocol: "accessing",
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aJavaScriptFunction"],
+source: "javascriptConstructor: aJavaScriptFunction\x0a\x09self deprecatedAPI: 'Use #javaScriptConstructor: instead.'.\x0a\x09^ self javaScriptConstructor: aJavaScriptFunction",
+referencedClasses: [],
+//>>excludeEnd("ide");
+pragmas: [],
+messageSends: ["deprecatedAPI:", "javaScriptConstructor:"]
+}, function ($methodClass){ return function (aJavaScriptFunction){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+$self._deprecatedAPI_("Use #javaScriptConstructor: instead.");
+return $self._javaScriptConstructor_(aJavaScriptFunction);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"javascriptConstructor:",{aJavaScriptFunction:aJavaScriptFunction})});
 //>>excludeEnd("ctx");
 }; }),
@@ -527,17 +575,17 @@ selector: "prototype",
 protocol: "accessing",
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "prototype\x0a\x09^ self javascriptConstructor prototype",
+source: "prototype\x0a\x09^ self javaScriptConstructor prototype",
 referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["prototype", "javascriptConstructor"]
+messageSends: ["prototype", "javaScriptConstructor"]
 }, function ($methodClass){ return function (){
 var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-return $recv($self._javascriptConstructor())._prototype();
+return $recv($self._javaScriptConstructor())._prototype();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"prototype",{})});
 //>>excludeEnd("ctx");
@@ -849,17 +897,17 @@ selector: "provided",
 protocol: "converting",
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "provided\x0a\x09\x22Returns JS proxy that allows to access 'static API', as in\x0a\x09  Number provided EPSILON\x0a\x09that forwards to (wrapped JS) constructor function.\x22\x0a\x09\x0a\x09^ self javascriptConstructor provided",
+source: "provided\x0a\x09\x22Returns JS proxy that allows to access 'static API', as in\x0a\x09  Number provided EPSILON\x0a\x09that forwards to (wrapped JS) constructor function.\x22\x0a\x09\x0a\x09^ self javaScriptConstructor provided",
 referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["provided", "javascriptConstructor"]
+messageSends: ["provided", "javaScriptConstructor"]
 }, function ($methodClass){ return function (){
 var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-return $recv($self._javascriptConstructor())._provided();
+return $recv($self._javaScriptConstructor())._provided();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"provided",{})});
 //>>excludeEnd("ctx");

+ 14 - 4
lang/src/Kernel-Classes.st

@@ -56,19 +56,29 @@ instanceVariableNames
 	^ slots
 !
 
-javascriptConstructor
+javaScriptConstructor
 	"Answer the JS constructor used to instantiate. See kernel-language.js"
 	
 	^ fn
 !
 
-javascriptConstructor: aJavaScriptFunction
+javaScriptConstructor: aJavaScriptFunction
 	"Set the JS constructor used to instantiate.
 	See the JS counter-part in boot.js `$core.setClassConstructor'"
 	
 	Smalltalk core setClassConstructor: self to: aJavaScriptFunction
 !
 
+javascriptConstructor
+	self deprecatedAPI: 'Use #javaScriptConstructor instead.'.
+	^ self javaScriptConstructor
+!
+
+javascriptConstructor: aJavaScriptFunction
+	self deprecatedAPI: 'Use #javaScriptConstructor: instead.'.
+	^ self javaScriptConstructor: aJavaScriptFunction
+!
+
 lookupSelector: selector
 	"Look up the given selector in my methodDictionary.
 	Return the corresponding method if found.
@@ -86,7 +96,7 @@ lookupSelector: selector
 !
 
 prototype
-	^ self javascriptConstructor prototype
+	^ self javaScriptConstructor prototype
 !
 
 subclasses
@@ -206,7 +216,7 @@ provided
 	  Number provided EPSILON
 	that forwards to (wrapped JS) constructor function."
 	
-	^ self javascriptConstructor provided
+	^ self javaScriptConstructor provided
 ! !
 
 !Class methodsFor: 'enumerating'!

+ 6 - 6
lang/src/Kernel-Tests.js

@@ -2543,11 +2543,11 @@ selector: "testSetJavaScriptConstructor",
 protocol: "tests",
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testSetJavaScriptConstructor\x0a\x09| instance |\x0a\x09theClass := builder copyClass: ObjectMock named: 'ObjectMock2'.\x0a\x09theClass javascriptConstructor: self jsConstructor.\x0a\x09\x22part took from copy class test\x22\x0a\x09self assert: theClass superclass == ObjectMock superclass.\x0a\x09self assert: theClass instanceVariableNames == ObjectMock instanceVariableNames.\x0a\x09self assert: theClass name equals: 'ObjectMock2'.\x0a\x09self assert: theClass package == ObjectMock package.\x0a\x09self assert: theClass methodDictionary keys equals: ObjectMock methodDictionary keys.\x0a\x09\x22testing specific to late-coupled detached root class\x22\x0a\x09instance := theClass new.\x0a\x09self assert: instance class == theClass.\x0a\x09self assert: instance value equals: 4.\x0a\x09self shouldnt: [ instance foo: 9 ] raise: Error.\x0a\x09self assert: instance foo equals: 9",
+source: "testSetJavaScriptConstructor\x0a\x09| instance |\x0a\x09theClass := builder copyClass: ObjectMock named: 'ObjectMock2'.\x0a\x09theClass javaScriptConstructor: self jsConstructor.\x0a\x09\x22part took from copy class test\x22\x0a\x09self assert: theClass superclass == ObjectMock superclass.\x0a\x09self assert: theClass instanceVariableNames == ObjectMock instanceVariableNames.\x0a\x09self assert: theClass name equals: 'ObjectMock2'.\x0a\x09self assert: theClass package == ObjectMock package.\x0a\x09self assert: theClass methodDictionary keys equals: ObjectMock methodDictionary keys.\x0a\x09\x22testing specific to late-coupled detached root class\x22\x0a\x09instance := theClass new.\x0a\x09self assert: instance class == theClass.\x0a\x09self assert: instance value equals: 4.\x0a\x09self shouldnt: [ instance foo: 9 ] raise: Error.\x0a\x09self assert: instance foo equals: 9",
 referencedClasses: ["ObjectMock", "Error"],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["copyClass:named:", "javascriptConstructor:", "jsConstructor", "assert:", "==", "superclass", "instanceVariableNames", "assert:equals:", "name", "package", "keys", "methodDictionary", "new", "class", "value", "shouldnt:raise:", "foo:", "foo"]
+messageSends: ["copyClass:named:", "javaScriptConstructor:", "jsConstructor", "assert:", "==", "superclass", "instanceVariableNames", "assert:equals:", "name", "package", "keys", "methodDictionary", "new", "class", "value", "shouldnt:raise:", "foo:", "foo"]
 }, function ($methodClass){ return function (){
 var self=this,$self=this;
 var instance;
@@ -2556,7 +2556,7 @@ return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 var $2,$1,$4,$3,$6,$5,$8,$7;
 $self.theClass=$recv($self.builder)._copyClass_named_($globals.ObjectMock,"ObjectMock2");
-$recv($self.theClass)._javascriptConstructor_($self._jsConstructor());
+$recv($self.theClass)._javaScriptConstructor_($self._jsConstructor());
 $2=$recv($self.theClass)._superclass();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["superclass"]=1;
@@ -2662,11 +2662,11 @@ selector: "testTrickySetJavaScriptConstructor",
 protocol: "tests",
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testTrickySetJavaScriptConstructor\x0a\x09| instance |\x0a\x09theClass := builder copyClass: ObjectMock named: 'ObjectMock2'.\x0a\x09theClass javascriptConstructor: self trickyJsConstructor.\x0a\x09\x22part took from copy class test\x22\x0a\x09self assert: theClass superclass == ObjectMock superclass.\x0a\x09self assert: theClass instanceVariableNames == ObjectMock instanceVariableNames.\x0a\x09self assert: theClass name equals: 'ObjectMock2'.\x0a\x09self assert: theClass package == ObjectMock package.\x0a\x09self assert: theClass methodDictionary keys equals: ObjectMock methodDictionary keys.\x0a\x09\x22testing specific to late-coupled detached root class\x22\x0a\x09instance := theClass new.\x0a\x09self assert: instance class == theClass.\x0a\x09self assert: instance value equals: 4.\x0a\x09self shouldnt: [ instance foo: 9 ] raise: Error.\x0a\x09self assert: instance foo equals: 9",
+source: "testTrickySetJavaScriptConstructor\x0a\x09| instance |\x0a\x09theClass := builder copyClass: ObjectMock named: 'ObjectMock2'.\x0a\x09theClass javaScriptConstructor: self trickyJsConstructor.\x0a\x09\x22part took from copy class test\x22\x0a\x09self assert: theClass superclass == ObjectMock superclass.\x0a\x09self assert: theClass instanceVariableNames == ObjectMock instanceVariableNames.\x0a\x09self assert: theClass name equals: 'ObjectMock2'.\x0a\x09self assert: theClass package == ObjectMock package.\x0a\x09self assert: theClass methodDictionary keys equals: ObjectMock methodDictionary keys.\x0a\x09\x22testing specific to late-coupled detached root class\x22\x0a\x09instance := theClass new.\x0a\x09self assert: instance class == theClass.\x0a\x09self assert: instance value equals: 4.\x0a\x09self shouldnt: [ instance foo: 9 ] raise: Error.\x0a\x09self assert: instance foo equals: 9",
 referencedClasses: ["ObjectMock", "Error"],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["copyClass:named:", "javascriptConstructor:", "trickyJsConstructor", "assert:", "==", "superclass", "instanceVariableNames", "assert:equals:", "name", "package", "keys", "methodDictionary", "new", "class", "value", "shouldnt:raise:", "foo:", "foo"]
+messageSends: ["copyClass:named:", "javaScriptConstructor:", "trickyJsConstructor", "assert:", "==", "superclass", "instanceVariableNames", "assert:equals:", "name", "package", "keys", "methodDictionary", "new", "class", "value", "shouldnt:raise:", "foo:", "foo"]
 }, function ($methodClass){ return function (){
 var self=this,$self=this;
 var instance;
@@ -2675,7 +2675,7 @@ return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 var $2,$1,$4,$3,$6,$5,$8,$7;
 $self.theClass=$recv($self.builder)._copyClass_named_($globals.ObjectMock,"ObjectMock2");
-$recv($self.theClass)._javascriptConstructor_($self._trickyJsConstructor());
+$recv($self.theClass)._javaScriptConstructor_($self._trickyJsConstructor());
 $2=$recv($self.theClass)._superclass();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["superclass"]=1;

+ 2 - 2
lang/src/Kernel-Tests.st

@@ -508,7 +508,7 @@ testMetaclassSubclasses
 testSetJavaScriptConstructor
 	| instance |
 	theClass := builder copyClass: ObjectMock named: 'ObjectMock2'.
-	theClass javascriptConstructor: self jsConstructor.
+	theClass javaScriptConstructor: self jsConstructor.
 	"part took from copy class test"
 	self assert: theClass superclass == ObjectMock superclass.
 	self assert: theClass instanceVariableNames == ObjectMock instanceVariableNames.
@@ -530,7 +530,7 @@ testSlotsFromInstanceVariablesString
 testTrickySetJavaScriptConstructor
 	| instance |
 	theClass := builder copyClass: ObjectMock named: 'ObjectMock2'.
-	theClass javascriptConstructor: self trickyJsConstructor.
+	theClass javaScriptConstructor: self trickyJsConstructor.
 	"part took from copy class test"
 	self assert: theClass superclass == ObjectMock superclass.
 	self assert: theClass instanceVariableNames == ObjectMock instanceVariableNames.