Browse Source

Rename, move things around.

Herby Vojčík 4 years ago
parent
commit
5326d88750

+ 1 - 1
lang/API-CHANGES.txt

@@ -3,7 +3,7 @@
 * Deprecate Behavior >> javascriptConstructor(:)
 
 + Behavior >>
-  + alternateConstructorFromSelector:
+  + alternateConstructorViaSelector:
   + beJavaScriptSubclassOf:
   + javaScriptConstructor
   + javaScriptConstructor:

+ 5 - 35
lang/src/Kernel-Classes.js

@@ -187,12 +187,12 @@ $globals.Behavior);
 
 $core.addMethod(
 $core.method({
-selector: "alternateConstructorFromSelector:",
+selector: "alternateConstructorViaSelector:",
 protocol: "instance creation",
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aSelector"],
-source: "alternateConstructorFromSelector: aSelector\x0a\x09^ self\x0a\x09\x09javaScriptConstructorFor: self prototype\x0a\x09\x09initializingVia: (self >> aSelector) fn",
-referencedClasses: [],
+source: "alternateConstructorViaSelector: aSelector\x0a\x09^ BlockClosure\x0a\x09\x09javaScriptConstructorFor: self prototype\x0a\x09\x09initializingVia: (self >> aSelector) fn",
+referencedClasses: ["BlockClosure"],
 //>>excludeEnd("ide");
 pragmas: [],
 messageSends: ["javaScriptConstructorFor:initializingVia:", "prototype", "fn", ">>"]
@@ -201,9 +201,9 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-return $self._javaScriptConstructorFor_initializingVia_($self._prototype(),$recv($self.__gt_gt(aSelector))._fn());
+return $recv($globals.BlockClosure)._javaScriptConstructorFor_initializingVia_($self._prototype(),$recv($self.__gt_gt(aSelector))._fn());
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"alternateConstructorFromSelector:",{aSelector:aSelector})});
+}, function($ctx1) {$ctx1.fill(self,"alternateConstructorViaSelector:",{aSelector:aSelector})});
 //>>excludeEnd("ctx");
 }; }),
 $globals.Behavior);
@@ -494,36 +494,6 @@ return self;
 }; }),
 $globals.Behavior);
 
-$core.addMethod(
-$core.method({
-selector: "javaScriptConstructorFor:initializingVia:",
-protocol: "private",
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["aPrototype", "aMethodBlock"],
-source: "javaScriptConstructorFor: aPrototype initializingVia: aMethodBlock\x0a\x09<inlineJS: '\x0a\x09\x09function Ctr () {\x0a\x09\x09\x09aMethodBlock.apply(this, arguments);\x0a\x09\x09}\x0a\x09\x09Ctr.prototype = aPrototype;\x0a\x09\x09return Ctr;\x0a\x09'>",
-referencedClasses: [],
-//>>excludeEnd("ide");
-pragmas: [["inlineJS:", ["\x0a\x09\x09function Ctr () {\x0a\x09\x09\x09aMethodBlock.apply(this, arguments);\x0a\x09\x09}\x0a\x09\x09Ctr.prototype = aPrototype;\x0a\x09\x09return Ctr;\x0a\x09"]]],
-messageSends: []
-}, function ($methodClass){ return function (aPrototype,aMethodBlock){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-
-		function Ctr () {
-			aMethodBlock.apply(this, arguments);
-		}
-		Ctr.prototype = aPrototype;
-		return Ctr;
-	;
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"javaScriptConstructorFor:initializingVia:",{aPrototype:aPrototype,aMethodBlock:aMethodBlock})});
-//>>excludeEnd("ctx");
-}; }),
-$globals.Behavior);
-
 $core.addMethod(
 $core.method({
 selector: "javascriptConstructor",

+ 2 - 12
lang/src/Kernel-Classes.st

@@ -140,8 +140,8 @@ allSubclassesDo: aBlock
 
 !Behavior methodsFor: 'instance creation'!
 
-alternateConstructorFromSelector: aSelector
-	^ self
+alternateConstructorViaSelector: aSelector
+	^ BlockClosure
 		javaScriptConstructorFor: self prototype
 		initializingVia: (self >> aSelector) fn
 !
@@ -156,16 +156,6 @@ new
 
 !Behavior methodsFor: 'private'!
 
-javaScriptConstructorFor: aPrototype initializingVia: aMethodBlock
-	<inlineJS: '
-		function Ctr () {
-			aMethodBlock.apply(this, arguments);
-		}
-		Ctr.prototype = aPrototype;
-		return Ctr;
-	'>
-!
-
 makeJavaScriptConstructorSubclassOf: javaScriptClass
 	<inlineJS: '
 		Object.setPrototypeOf($self.fn.prototype, javaScriptClass.prototype);

+ 30 - 0
lang/src/Kernel-Methods.js

@@ -725,6 +725,36 @@ return self;
 $globals.BlockClosure);
 
 
+$core.addMethod(
+$core.method({
+selector: "javaScriptConstructorFor:initializingVia:",
+protocol: "instance creation",
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aPrototype", "aMethodBlock"],
+source: "javaScriptConstructorFor: aPrototype initializingVia: aMethodBlock\x0a\x09<inlineJS: '\x0a\x09\x09function Ctr () {\x0a\x09\x09\x09aMethodBlock.apply(this, arguments);\x0a\x09\x09}\x0a\x09\x09Ctr.prototype = aPrototype;\x0a\x09\x09return Ctr;\x0a\x09'>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+pragmas: [["inlineJS:", ["\x0a\x09\x09function Ctr () {\x0a\x09\x09\x09aMethodBlock.apply(this, arguments);\x0a\x09\x09}\x0a\x09\x09Ctr.prototype = aPrototype;\x0a\x09\x09return Ctr;\x0a\x09"]]],
+messageSends: []
+}, function ($methodClass){ return function (aPrototype,aMethodBlock){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+
+		function Ctr () {
+			aMethodBlock.apply(this, arguments);
+		}
+		Ctr.prototype = aPrototype;
+		return Ctr;
+	;
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"javaScriptConstructorFor:initializingVia:",{aPrototype:aPrototype,aMethodBlock:aMethodBlock})});
+//>>excludeEnd("ctx");
+}; }),
+$globals.BlockClosure.a$cls);
+
 
 $core.addClass("CompiledMethod", $globals.Object, ["args", "instantiateFn", "fn", "messageSends", "pragmas", "owner", "methodClass", "protocol", "referencedClasses", "selector", "source"], "Kernel-Methods");
 //>>excludeStart("ide", pragmas.excludeIdeData);

+ 12 - 0
lang/src/Kernel-Methods.st

@@ -200,6 +200,18 @@ valueWithTimeout: aNumber
 	'>
 ! !
 
+!BlockClosure class methodsFor: 'instance creation'!
+
+javaScriptConstructorFor: aPrototype initializingVia: aMethodBlock
+	<inlineJS: '
+		function Ctr () {
+			aMethodBlock.apply(this, arguments);
+		}
+		Ctr.prototype = aPrototype;
+		return Ctr;
+	'>
+! !
+
 Object subclass: #CompiledMethod
 	slots: {#args. #instantiateFn. #fn. #messageSends. #pragmas. #owner. #methodClass. #protocol. #referencedClasses. #selector. #source}
 	package: 'Kernel-Methods'!

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

@@ -2510,15 +2510,15 @@ $globals.ClassTest);
 
 $core.addMethod(
 $core.method({
-selector: "testAlternateConstructorFromSelector",
+selector: "testAlternateConstructorViaSelector",
 protocol: "tests",
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testAlternateConstructorFromSelector\x0a\x09| instance block |\x0a\x09block := ObjectMock alternateConstructorFromSelector: #foo:.\x0a\x0a\x09instance := block newValue: 4.\x0a\x09self assert: instance class == ObjectMock.\x0a\x09self assert: instance foo equals: 4.\x0a\x09self shouldnt: [ instance foo: 9 ] raise: Error.\x0a\x09self assert: instance foo equals: 9",
+source: "testAlternateConstructorViaSelector\x0a\x09| instance block |\x0a\x09block := ObjectMock alternateConstructorViaSelector: #foo:.\x0a\x0a\x09instance := block newValue: 4.\x0a\x09self assert: instance class == ObjectMock.\x0a\x09self assert: instance foo equals: 4.\x0a\x09self shouldnt: [ instance foo: 9 ] raise: Error.\x0a\x09self assert: instance foo equals: 9",
 referencedClasses: ["ObjectMock", "Error"],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["alternateConstructorFromSelector:", "newValue:", "assert:", "==", "class", "assert:equals:", "foo", "shouldnt:raise:", "foo:"]
+messageSends: ["alternateConstructorViaSelector:", "newValue:", "assert:", "==", "class", "assert:equals:", "foo", "shouldnt:raise:", "foo:"]
 }, function ($methodClass){ return function (){
 var self=this,$self=this;
 var instance,block;
@@ -2526,7 +2526,7 @@ var instance,block;
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 var $1;
-block=$recv($globals.ObjectMock)._alternateConstructorFromSelector_("foo:");
+block=$recv($globals.ObjectMock)._alternateConstructorViaSelector_("foo:");
 instance=$recv(block)._newValue_((4));
 $self._assert_($recv($recv(instance)._class()).__eq_eq($globals.ObjectMock));
 $1=$recv(instance)._foo();
@@ -2549,7 +2549,7 @@ return $recv(instance)._foo_((9));
 $self._assert_equals_($recv(instance)._foo(),(9));
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"testAlternateConstructorFromSelector",{instance:instance,block:block})});
+}, function($ctx1) {$ctx1.fill(self,"testAlternateConstructorViaSelector",{instance:instance,block:block})});
 //>>excludeEnd("ctx");
 }; }),
 $globals.ClassTest);

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

@@ -499,9 +499,9 @@ testAllSubclasses
 	self assert: Object allSubclasses equals: subclasses
 !
 
-testAlternateConstructorFromSelector
+testAlternateConstructorViaSelector
 	| instance block |
-	block := ObjectMock alternateConstructorFromSelector: #foo:.
+	block := ObjectMock alternateConstructorViaSelector: #foo:.
 
 	instance := block newValue: 4.
 	self assert: instance class == ObjectMock.