Browse Source

cleaner fix for issue #143. See comments on https://github.com/amber-smalltalk/amber/commit/97cc25cba063722aeb75cab7b293fd74ffe1feb3

Nicolas Petton 10 years ago
parent
commit
1d3ea8649b
4 changed files with 17 additions and 69 deletions
  1. 6 45
      js/Importer-Exporter.js
  2. 4 7
      js/Kernel-Classes.js
  3. 6 15
      st/Importer-Exporter.st
  4. 1 2
      st/Kernel-Classes.st

+ 6 - 45
js/Importer-Exporter.js

@@ -440,27 +440,6 @@ referencedClasses: ["OrderedCollection", "Package", "Smalltalk", "Dictionary", "
 }),
 smalltalk.ChunkExporter);
 
-smalltalk.addMethod(
-smalltalk.method({
-selector: "methodsOfCategory:",
-category: 'accessing',
-fn: function (aCategory){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-var $1;
-$1=_st(_st(aCategory)._methods())._sorted_((function(a,b){
-return smalltalk.withContext(function($ctx2) {
-return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
-}, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,1)})}));
-return $1;
-}, function($ctx1) {$ctx1.fill(self,"methodsOfCategory:",{aCategory:aCategory},smalltalk.ChunkExporter)})},
-args: ["aCategory"],
-source: "methodsOfCategory: aCategory\x0a\x09\x22Issue #143: sort methods alphabetically\x22\x0a\x0a\x09^(aCategory methods) sorted: [ :a :b | a selector <= b selector ]",
-messageSends: ["sorted:", "methods", "<=", "selector"],
-referencedClasses: []
-}),
-smalltalk.ChunkExporter);
-
 smalltalk.addMethod(
 smalltalk.method({
 selector: "ownCategoriesOfClass:",
@@ -1036,12 +1015,15 @@ fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 var $1;
-$1=_st(self._theClass())._methodsInProtocol_(self._name());
+$1=_st(_st(self._theClass())._methodsInProtocol_(self._name()))._sorted_((function(a,b){
+return smalltalk.withContext(function($ctx2) {
+return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
+}, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,1)})}));
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"methods",{},smalltalk.ExportMethodProtocol)})},
 args: [],
-source: "methods\x0a\x09^ self theClass methodsInProtocol: self name",
-messageSends: ["methodsInProtocol:", "theClass", "name"],
+source: "methods\x0a\x09^ (self theClass methodsInProtocol: self name)\x0a\x09\x09sorted: [ :a :b | a selector <= b selector ]",
+messageSends: ["sorted:", "methodsInProtocol:", "theClass", "name", "<=", "selector"],
 referencedClasses: []
 }),
 smalltalk.ExportMethodProtocol);
@@ -1080,27 +1062,6 @@ referencedClasses: []
 }),
 smalltalk.ExportMethodProtocol);
 
-smalltalk.addMethod(
-smalltalk.method({
-selector: "sortedMethods",
-category: 'accessing',
-fn: function (){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-var $1;
-$1=_st(self._methods())._sorted_((function(a,b){
-return smalltalk.withContext(function($ctx2) {
-return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
-}, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,1)})}));
-return $1;
-}, function($ctx1) {$ctx1.fill(self,"sortedMethods",{},smalltalk.ExportMethodProtocol)})},
-args: [],
-source: "sortedMethods\x0a\x09^ self methods sorted: [ :a :b | a selector <= b selector ]",
-messageSends: ["sorted:", "methods", "<=", "selector"],
-referencedClasses: []
-}),
-smalltalk.ExportMethodProtocol);
-
 smalltalk.addMethod(
 smalltalk.method({
 selector: "theClass",

+ 4 - 7
js/Kernel-Classes.js

@@ -677,18 +677,15 @@ fn: function (aString){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 var $1;
-$1=_st(_st(_st(self._methodDictionary())._values())._select_((function(each){
+$1=_st(_st(self._methodDictionary())._values())._select_((function(each){
 return smalltalk.withContext(function($ctx2) {
 return _st(_st(each)._protocol()).__eq(aString);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})))._sorted_((function(a,b){
-return smalltalk.withContext(function($ctx2) {
-return _st(_st(a)._selector()).__lt_eq(_st(b)._selector());
-}, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,2)})}));
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"methodsInProtocol:",{aString:aString},smalltalk.Behavior)})},
 args: ["aString"],
-source: "methodsInProtocol: aString\x0a\x09^ (self methodDictionary values select: [ :each | each protocol = aString ])\x0a\x09\x09\x09sorted: [ :a :b | a selector <= b selector ]",
-messageSends: ["sorted:", "select:", "values", "methodDictionary", "=", "protocol", "<=", "selector"],
+source: "methodsInProtocol: aString\x0a\x09^ self methodDictionary values select: [ :each | each protocol = aString ]",
+messageSends: ["select:", "values", "methodDictionary", "=", "protocol"],
 referencedClasses: []
 }),
 smalltalk.Behavior);

+ 6 - 15
st/Importer-Exporter.st

@@ -89,12 +89,6 @@ extensionCategoriesOfPackage: aPackage
 	^result
 !
 
-methodsOfCategory: aCategory
-	"Issue #143: sort methods alphabetically"
-
-	^(aCategory methods) sorted: [ :a :b | a selector <= b selector ]
-!
-
 ownCategoriesOfClass: aClass
 	"Answer the protocols of aClass that are not package extensions"
 	
@@ -470,7 +464,8 @@ I am used when exporting a package.!
 !ExportMethodProtocol methodsFor: 'accessing'!
 
 methods
-	^ self theClass methodsInProtocol: self name
+	^ (self theClass methodsInProtocol: self name)
+		sorted: [ :a :b | a selector <= b selector ]
 !
 
 name
@@ -481,10 +476,6 @@ name: aString
 	name := aString
 !
 
-sortedMethods
-	^ self methods sorted: [ :a :b | a selector <= b selector ]
-!
-
 theClass
 	^theClass
 !
@@ -716,13 +707,13 @@ classRegisteredFor: aString
 	^ registry at: aString
 !
 
+defaultType
+	^ AmdPackageTransport type
+!
+
 type
 	"Override in subclasses"
 	^ nil
-!
-
-defaultType
-	^ AmdPackageTransport type
 ! !
 
 !PackageTransport class methodsFor: 'initialization'!

+ 1 - 2
st/Kernel-Classes.st

@@ -145,8 +145,7 @@ methodsFor: aString stamp: aStamp
 !
 
 methodsInProtocol: aString
-	^ (self methodDictionary values select: [ :each | each protocol = aString ])
-			sorted: [ :a :b | a selector <= b selector ]
+	^ self methodDictionary values select: [ :each | each protocol = aString ]
 !
 
 name