Browse Source

TBehaviorDefaults.

To be able to send certain specialized messages
to any kind of behaviour.
Herbert Vojčík 7 years ago
parent
commit
ff9994249d
2 changed files with 104 additions and 93 deletions
  1. 76 73
      src/Kernel-Classes.js
  2. 28 20
      src/Kernel-Classes.st

+ 76 - 73
src/Kernel-Classes.js

@@ -105,42 +105,6 @@ messageSends: ["at:ifAbsent:", "methodDictionary", "selector", "ifFalse:", "incl
 }),
 $globals.BehaviorBody);
 
-$core.addMethod(
-$core.method({
-selector: "allInstanceVariableNames",
-protocol: "accessing",
-fn: function (){
-var self=this;
-return [];
-
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: [],
-source: "allInstanceVariableNames\x0a\x09\x22Default for non-classes; to be able to send #allInstanceVariableNames to any class / trait.\x22\x0a\x09^ #()",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: []
-}),
-$globals.BehaviorBody);
-
-$core.addMethod(
-$core.method({
-selector: "allSubclassesDo:",
-protocol: "enumerating",
-fn: function (aBlock){
-var self=this;
-return self;
-
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["aBlock"],
-source: "allSubclassesDo: aBlock\x0a\x09\x22Default for non-classes; to be able to send #allSubclassesDo: to any class / trait.\x22",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: []
-}),
-$globals.BehaviorBody);
-
 $core.addMethod(
 $core.method({
 selector: "basicAddCompiledMethod:",
@@ -849,24 +813,6 @@ messageSends: []
 }),
 $globals.BehaviorBody);
 
-$core.addMethod(
-$core.method({
-selector: "superclass",
-protocol: "accessing",
-fn: function (){
-var self=this;
-return nil;
-
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: [],
-source: "superclass\x0a\x09\x22Default for non-classes; to be able to send #superclass to any class / trait.\x22\x0a\x09^ nil",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: []
-}),
-$globals.BehaviorBody);
-
 $core.addMethod(
 $core.method({
 selector: "theMetaClass",
@@ -1012,24 +958,6 @@ messageSends: ["ifNotEmpty:", "traitComposition", "streamContents:", "write:", "
 }),
 $globals.BehaviorBody);
 
-$core.addMethod(
-$core.method({
-selector: "traitUsers",
-protocol: "accessing",
-fn: function (){
-var self=this;
-return [];
-
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: [],
-source: "traitUsers\x0a\x09\x22Default for non-traits; to be able to send #traitUsers to any class / trait\x22\x0a\x09^ #()",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: []
-}),
-$globals.BehaviorBody);
-
 
 
 $core.addClass("Behavior", $globals.BehaviorBody, [], "Kernel-Classes");
@@ -3636,6 +3564,80 @@ messageSends: ["theClass:", "new", "level:", "getNodesFrom:", "yourself"]
 $globals.ClassSorterNode.klass);
 
 
+$core.addTrait("TBehaviorDefaults", "Kernel-Classes");
+$core.addMethod(
+$core.method({
+selector: "allInstanceVariableNames",
+protocol: "accessing",
+fn: function (){
+var self=this;
+return [];
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "allInstanceVariableNames\x0a\x09\x22Default for non-classes; to be able to send #allInstanceVariableNames to any class / trait.\x22\x0a\x09^ #()",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.TBehaviorDefaults);
+
+$core.addMethod(
+$core.method({
+selector: "allSubclassesDo:",
+protocol: "enumerating",
+fn: function (aBlock){
+var self=this;
+return self;
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aBlock"],
+source: "allSubclassesDo: aBlock\x0a\x09\x22Default for non-classes; to be able to send #allSubclassesDo: to any class / trait.\x22",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.TBehaviorDefaults);
+
+$core.addMethod(
+$core.method({
+selector: "superclass",
+protocol: "accessing",
+fn: function (){
+var self=this;
+return nil;
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "superclass\x0a\x09\x22Default for non-classes; to be able to send #superclass to any class / trait.\x22\x0a\x09^ nil",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.TBehaviorDefaults);
+
+$core.addMethod(
+$core.method({
+selector: "traitUsers",
+protocol: "accessing",
+fn: function (){
+var self=this;
+return [];
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "traitUsers\x0a\x09\x22Default for non-traits; to be able to send #traitUsers to any class / trait\x22\x0a\x09^ #()",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.TBehaviorDefaults);
+
+
 $core.addTrait("TMasterBehavior", "Kernel-Classes");
 //>>excludeStart("ide", pragmas.excludeIdeData);
 $globals.TMasterBehavior.comment="I am the behavior on the instance-side of the browser.\x0a\x0aI define things like package, category, name, comment etc.\x0aas opposed to derived behaviors (metaclass, class trait, ...)\x0athat relate to me.";
@@ -4468,8 +4470,9 @@ messageSends: ["trait:", "new", "yourself"]
 }),
 $globals.TraitTransformation.klass);
 
+$core.setTraitComposition([{trait: $globals.TBehaviorDefaults}], $globals.Behavior);
 $core.setTraitComposition([{trait: $globals.TMasterBehavior}], $globals.Class);
-$core.setTraitComposition([{trait: $globals.TMasterBehavior}], $globals.Trait);
+$core.setTraitComposition([{trait: $globals.TBehaviorDefaults}, {trait: $globals.TMasterBehavior}], $globals.Trait);
 
 $core.addMethod(
 $core.method({

+ 28 - 20
src/Kernel-Classes.st

@@ -15,11 +15,6 @@ I also provides methods for compiling methods and examining the method dictionar
 	^ self methodAt: aString
 !
 
-allInstanceVariableNames
-	"Default for non-classes; to be able to send #allInstanceVariableNames to any class / trait."
-	^ #()
-!
-
 definition
 	self subclassResponsibility
 !
@@ -108,11 +103,6 @@ selectors
 	^ self methodDictionary keys
 !
 
-superclass
-	"Default for non-classes; to be able to send #superclass to any class / trait."
-	^ nil
-!
-
 theMetaClass
 	self subclassResponsibility
 !
@@ -133,11 +123,6 @@ traitCompositionDefinition
 				do: [ :each | str write: each definition ]
 				separatedBy: [ str write: '. ' ].
 			str write: '}' ] ]
-!
-
-traitUsers
-	"Default for non-traits; to be able to send #traitUsers to any class / trait"
-	^ #()
 ! !
 
 !BehaviorBody methodsFor: 'compiling'!
@@ -201,10 +186,6 @@ setTraitComposition: aTraitComposition
 
 !BehaviorBody methodsFor: 'enumerating'!
 
-allSubclassesDo: aBlock
-	"Default for non-classes; to be able to send #allSubclassesDo: to any class / trait."
-!
-
 protocolsDo: aBlock
 	"Execute aBlock for each method protocol with
 	its collection of methods in the sort order of protocol name."
@@ -916,6 +897,32 @@ on: aClass classes: aCollection level: anInteger
 		yourself
 ! !
 
+Trait named: #TBehaviorDefaults
+	package: 'Kernel-Classes'!
+
+!TBehaviorDefaults methodsFor: 'accessing'!
+
+allInstanceVariableNames
+	"Default for non-classes; to be able to send #allInstanceVariableNames to any class / trait."
+	^ #()
+!
+
+superclass
+	"Default for non-classes; to be able to send #superclass to any class / trait."
+	^ nil
+!
+
+traitUsers
+	"Default for non-traits; to be able to send #traitUsers to any class / trait"
+	^ #()
+! !
+
+!TBehaviorDefaults methodsFor: 'enumerating'!
+
+allSubclassesDo: aBlock
+	"Default for non-classes; to be able to send #allSubclassesDo: to any class / trait."
+! !
+
 Trait named: #TMasterBehavior
 	package: 'Kernel-Classes'!
 !TMasterBehavior commentStamp!
@@ -1110,8 +1117,9 @@ on: aTrait
 	^ super new trait: aTrait; yourself
 ! !
 
+Behavior setTraitComposition: {TBehaviorDefaults} asTraitComposition!
 Class setTraitComposition: {TMasterBehavior} asTraitComposition!
-Trait setTraitComposition: {TMasterBehavior} asTraitComposition!
+Trait setTraitComposition: {TBehaviorDefaults. TMasterBehavior} asTraitComposition!
 ! !
 
 !Array methodsFor: '*Kernel-Classes'!