Browse Source

adds Behavior >> ownMethods

Nicolas Petton 11 years ago
parent
commit
b85076c509
3 changed files with 62 additions and 0 deletions
  1. 28 0
      js/Kernel-Classes.deploy.js
  2. 25 0
      js/Kernel-Classes.js
  3. 9 0
      st/Kernel-Classes.st

+ 28 - 0
js/Kernel-Classes.deploy.js

@@ -302,6 +302,17 @@ return $1;
 messageSends: ["install:forClass:category:", "new"]}),
 smalltalk.Behavior);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "constructor",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+return self.fn;
+return self}, function($ctx1) {$ctx1.fill(self,"constructor",{},smalltalk.Behavior)})},
+messageSends: []}),
+smalltalk.Behavior);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "definition",
@@ -544,6 +555,23 @@ return $1;
 messageSends: ["basicAt:"]}),
 smalltalk.Behavior);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "ownMethods",
+fn: function (){
+var self=this;
+function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=_st(self._ownProtocols())._inject_into_(_st($OrderedCollection())._new(),(function(acc,each){
+return smalltalk.withContext(function($ctx2) {
+return _st(acc).__comma(self._methodsInProtocol_(each));
+}, function($ctx2) {$ctx2.fillBlock({acc:acc,each:each},$ctx1)})}));
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"ownMethods",{},smalltalk.Behavior)})},
+messageSends: ["inject:into:", "new", ",", "methodsInProtocol:", "ownProtocols"]}),
+smalltalk.Behavior);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "ownProtocols",

+ 25 - 0
js/Kernel-Classes.js

@@ -710,6 +710,31 @@ referencedClasses: []
 }),
 smalltalk.Behavior);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "ownMethods",
+category: 'accessing',
+fn: function (){
+var self=this;
+function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=_st(_st(self._ownProtocols())._inject_into_(_st($OrderedCollection())._new(),(function(acc,each){
+return smalltalk.withContext(function($ctx2) {
+return _st(acc).__comma(self._methodsInProtocol_(each));
+}, function($ctx2) {$ctx2.fillBlock({acc:acc,each:each},$ctx1)})})))._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)})}));
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"ownMethods",{},smalltalk.Behavior)})},
+args: [],
+source: "ownMethods\x0a\x09\x22Answer the methods of the receiver that are not package extensions\x22\x0a\x0a\x09^ (self ownProtocols \x0a\x09\x09inject: OrderedCollection new\x0a\x09\x09into: [ :acc :each | acc, (self methodsInProtocol: each) ])\x0a\x09\x09\x09sorted: [ :a :b | a selector <= b selector ]",
+messageSends: ["sorted:", "<=", "selector", "inject:into:", "new", ",", "methodsInProtocol:", "ownProtocols"],
+referencedClasses: ["OrderedCollection"]
+}),
+smalltalk.Behavior);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "ownProtocols",

+ 9 - 0
st/Kernel-Classes.st

@@ -143,6 +143,15 @@ organization
 	^ self basicAt: 'organization'
 !
 
+ownMethods
+	"Answer the methods of the receiver that are not package extensions"
+
+	^ (self ownProtocols 
+		inject: OrderedCollection new
+		into: [ :acc :each | acc, (self methodsInProtocol: each) ])
+			sorted: [ :a :b | a selector <= b selector ]
+!
+
 ownProtocols
 	"Answer the protocols of the receiver that are not package extensions"