Browse Source

Adds Behavior >> includesBehavior:

Nicolas Petton 11 years ago
parent
commit
64ec40b7fc
3 changed files with 42 additions and 0 deletions
  1. 16 0
      js/Kernel-Classes.deploy.js
  2. 21 0
      js/Kernel-Classes.js
  3. 5 0
      st/Kernel-Classes.st

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

@@ -295,6 +295,22 @@ return "";
 messageSends: []}),
 smalltalk.Behavior);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "includesBehavior:",
+fn: function (aClass){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=_st(_st(self).__eq_eq(aClass))._or_((function(){
+return smalltalk.withContext(function($ctx2) {
+return _st(self)._inheritsFrom_(aClass);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"includesBehavior:",{aClass:aClass},smalltalk.Behavior)})},
+messageSends: ["or:", "inheritsFrom:", "=="]}),
+smalltalk.Behavior);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "includesSelector:",

+ 21 - 0
js/Kernel-Classes.js

@@ -381,6 +381,27 @@ referencedClasses: []
 }),
 smalltalk.Behavior);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "includesBehavior:",
+category: 'testing',
+fn: function (aClass){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=_st(_st(self).__eq_eq(aClass))._or_((function(){
+return smalltalk.withContext(function($ctx2) {
+return _st(self)._inheritsFrom_(aClass);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"includesBehavior:",{aClass:aClass},smalltalk.Behavior)})},
+args: ["aClass"],
+source: "includesBehavior: aClass\x0a\x09^ self == aClass or: [\x0a\x09\x09\x09self inheritsFrom: aClass ]",
+messageSends: ["or:", "inheritsFrom:", "=="],
+referencedClasses: []
+}),
+smalltalk.Behavior);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "includesSelector:",

+ 5 - 0
st/Kernel-Classes.st

@@ -271,6 +271,11 @@ canUnderstand: aSelector
 		self superclass notNil and: [self superclass canUnderstand: aSelector]]
 !
 
+includesBehavior: aClass
+	^ self == aClass or: [
+			self inheritsFrom: aClass ]
+!
+
 includesSelector: aString
 	^ self methodDictionary includesKey: aString
 !