浏览代码

TBehaviorDefaults.

To be able to send certain specialized messages
to any kind of behaviour.
Herbert Vojčík 7 年之前
父节点
当前提交
ff9994249d
共有 2 个文件被更改,包括 104 次插入93 次删除
  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);
 $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.addMethod(
 $core.method({
 $core.method({
 selector: "basicAddCompiledMethod:",
 selector: "basicAddCompiledMethod:",
@@ -849,24 +813,6 @@ messageSends: []
 }),
 }),
 $globals.BehaviorBody);
 $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.addMethod(
 $core.method({
 $core.method({
 selector: "theMetaClass",
 selector: "theMetaClass",
@@ -1012,24 +958,6 @@ messageSends: ["ifNotEmpty:", "traitComposition", "streamContents:", "write:", "
 }),
 }),
 $globals.BehaviorBody);
 $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");
 $core.addClass("Behavior", $globals.BehaviorBody, [], "Kernel-Classes");
@@ -3636,6 +3564,80 @@ messageSends: ["theClass:", "new", "level:", "getNodesFrom:", "yourself"]
 $globals.ClassSorterNode.klass);
 $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");
 $core.addTrait("TMasterBehavior", "Kernel-Classes");
 //>>excludeStart("ide", pragmas.excludeIdeData);
 //>>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.";
 $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);
 $globals.TraitTransformation.klass);
 
 
+$core.setTraitComposition([{trait: $globals.TBehaviorDefaults}], $globals.Behavior);
 $core.setTraitComposition([{trait: $globals.TMasterBehavior}], $globals.Class);
 $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.addMethod(
 $core.method({
 $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
 	^ self methodAt: aString
 !
 !
 
 
-allInstanceVariableNames
-	"Default for non-classes; to be able to send #allInstanceVariableNames to any class / trait."
-	^ #()
-!
-
 definition
 definition
 	self subclassResponsibility
 	self subclassResponsibility
 !
 !
@@ -108,11 +103,6 @@ selectors
 	^ self methodDictionary keys
 	^ self methodDictionary keys
 !
 !
 
 
-superclass
-	"Default for non-classes; to be able to send #superclass to any class / trait."
-	^ nil
-!
-
 theMetaClass
 theMetaClass
 	self subclassResponsibility
 	self subclassResponsibility
 !
 !
@@ -133,11 +123,6 @@ traitCompositionDefinition
 				do: [ :each | str write: each definition ]
 				do: [ :each | str write: each definition ]
 				separatedBy: [ str write: '. ' ].
 				separatedBy: [ str write: '. ' ].
 			str write: '}' ] ]
 			str write: '}' ] ]
-!
-
-traitUsers
-	"Default for non-traits; to be able to send #traitUsers to any class / trait"
-	^ #()
 ! !
 ! !
 
 
 !BehaviorBody methodsFor: 'compiling'!
 !BehaviorBody methodsFor: 'compiling'!
@@ -201,10 +186,6 @@ setTraitComposition: aTraitComposition
 
 
 !BehaviorBody methodsFor: 'enumerating'!
 !BehaviorBody methodsFor: 'enumerating'!
 
 
-allSubclassesDo: aBlock
-	"Default for non-classes; to be able to send #allSubclassesDo: to any class / trait."
-!
-
 protocolsDo: aBlock
 protocolsDo: aBlock
 	"Execute aBlock for each method protocol with
 	"Execute aBlock for each method protocol with
 	its collection of methods in the sort order of protocol name."
 	its collection of methods in the sort order of protocol name."
@@ -916,6 +897,32 @@ on: aClass classes: aCollection level: anInteger
 		yourself
 		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
 Trait named: #TMasterBehavior
 	package: 'Kernel-Classes'!
 	package: 'Kernel-Classes'!
 !TMasterBehavior commentStamp!
 !TMasterBehavior commentStamp!
@@ -1110,8 +1117,9 @@ on: aTrait
 	^ super new trait: aTrait; yourself
 	^ super new trait: aTrait; yourself
 ! !
 ! !
 
 
+Behavior setTraitComposition: {TBehaviorDefaults} asTraitComposition!
 Class setTraitComposition: {TMasterBehavior} asTraitComposition!
 Class setTraitComposition: {TMasterBehavior} asTraitComposition!
-Trait setTraitComposition: {TMasterBehavior} asTraitComposition!
+Trait setTraitComposition: {TBehaviorDefaults. TMasterBehavior} asTraitComposition!
 ! !
 ! !
 
 
 !Array methodsFor: '*Kernel-Classes'!
 !Array methodsFor: '*Kernel-Classes'!