Jelajahi Sumber

kernel: OrganizeBrik is a thing of a past.

Herbert Vojčík 7 tahun lalu
induk
melakukan
105f4f4c75

+ 5 - 0
API-CHANGES.txt

@@ -12,6 +12,10 @@
   + otganizeMethods
 + Behavior >>
   + basicOrganization
++ ClassOrganizer >>
+  + theClass
++ ClassOrganizer class >>
+  + on:
 + Compiler class >>
   + eval:
 + JavaScriptException >>
@@ -39,6 +43,7 @@
   + leaveOrganization
 + Trait >>
   + basicOrganization
+  + basicOrganization:
 + UndefinedObject >>
   + ==
 

+ 59 - 3
src/Kernel-Classes.js

@@ -235,6 +235,29 @@ messageSends: ["basicAt:"]
 }),
 $globals.Behavior);
 
+$core.addMethod(
+$core.method({
+selector: "basicOrganization:",
+protocol: "accessing",
+fn: function (aClassOrganizer){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return $self._basicAt_put_("organization",aClassOrganizer);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"basicOrganization:",{aClassOrganizer:aClassOrganizer},$globals.Behavior)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aClassOrganizer"],
+source: "basicOrganization: aClassOrganizer\x0a\x09^ self basicAt: 'organization' put:aClassOrganizer",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["basicAt:put:"]
+}),
+$globals.Behavior);
+
 $core.addMethod(
 $core.method({
 selector: "canUnderstand:",
@@ -2682,17 +2705,27 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
+var $1,$receiver;
+$1=$self._basicOrganization();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["basicOrganization"]=1;
+//>>excludeEnd("ctx");
+if(($receiver = $1) == null || $receiver.a$nil){
+$self._basicOrganization_($recv($globals.ClassOrganizer)._on_(self));
 return $self._basicOrganization();
+} else {
+return $1;
+}
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"organization",{},$globals.TBehaviorProvider)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "organization\x0a\x09^ self basicOrganization",
-referencedClasses: [],
+source: "organization\x0a\x09^ self basicOrganization ifNil: [\x0a\x09\x09self basicOrganization: (ClassOrganizer on: self).\x0a\x09\x09self basicOrganization ]",
+referencedClasses: ["ClassOrganizer"],
 //>>excludeEnd("ide");
-messageSends: ["basicOrganization"]
+messageSends: ["ifNil:", "basicOrganization", "basicOrganization:", "on:"]
 }),
 $globals.TBehaviorProvider);
 
@@ -3655,6 +3688,29 @@ messageSends: ["basicAt:"]
 }),
 $globals.Trait);
 
+$core.addMethod(
+$core.method({
+selector: "basicOrganization:",
+protocol: "accessing",
+fn: function (aClassOrganizer){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return $self._basicAt_put_("organization",aClassOrganizer);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"basicOrganization:",{aClassOrganizer:aClassOrganizer},$globals.Trait)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aClassOrganizer"],
+source: "basicOrganization: aClassOrganizer\x0a\x09^ self basicAt: 'organization' put: aClassOrganizer",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["basicAt:put:"]
+}),
+$globals.Trait);
+
 $core.addMethod(
 $core.method({
 selector: "classTag",

+ 11 - 1
src/Kernel-Classes.st

@@ -48,6 +48,10 @@ basicOrganization
 	^ self basicAt: 'organization'
 !
 
+basicOrganization: aClassOrganizer
+	^ self basicAt: 'organization' put:aClassOrganizer
+!
+
 instanceVariableNames
 	<inlineJS: 'return self.iVarNames'>
 !
@@ -654,7 +658,9 @@ methodsInProtocol: aString
 !
 
 organization
-	^ self basicOrganization
+	^ self basicOrganization ifNil: [
+		self basicOrganization: (ClassOrganizer on: self).
+		self basicOrganization ]
 !
 
 ownMethods
@@ -915,6 +921,10 @@ basicOrganization
 	^ self basicAt: 'organization'
 !
 
+basicOrganization: aClassOrganizer
+	^ self basicAt: 'organization' put: aClassOrganizer
+!
+
 classTag
 	^ 'trait'
 !

+ 82 - 0
src/Kernel-Infrastructure.js

@@ -907,6 +907,38 @@ messageSends: ["addElement:", "announce:", "current", "protocol:", "new", "theCl
 }),
 $globals.ClassOrganizer);
 
+$core.addMethod(
+$core.method({
+selector: "initialize",
+protocol: "initialization",
+fn: function (){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+(
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.supercall = true,
+//>>excludeEnd("ctx");
+($globals.ClassOrganizer.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.supercall = false;
+//>>excludeEnd("ctx");;
+$self._basicAt_put_("elements",[]);
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.ClassOrganizer)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "initialize\x0a\x09super initialize.\x0a\x09self basicAt: 'elements' put: #()",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["initialize", "basicAt:put:"]
+}),
+$globals.ClassOrganizer);
+
 $core.addMethod(
 $core.method({
 selector: "removeElement:",
@@ -969,6 +1001,56 @@ messageSends: []
 }),
 $globals.ClassOrganizer);
 
+$core.addMethod(
+$core.method({
+selector: "theClass:",
+protocol: "accessing",
+fn: function (aClass){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+self.theClass = aClass;
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"theClass:",{aClass:aClass},$globals.ClassOrganizer)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aClass"],
+source: "theClass: aClass\x0a\x09<inlineJS: 'self.theClass = aClass'>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.ClassOrganizer);
+
+
+$core.addMethod(
+$core.method({
+selector: "on:",
+protocol: "instance creation",
+fn: function (aClass){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+$1=$self._new();
+$recv($1)._theClass_(aClass);
+return $recv($1)._yourself();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"on:",{aClass:aClass},$globals.ClassOrganizer.a$cls)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aClass"],
+source: "on: aClass\x0a\x09^ self new\x0a\x09\x09theClass: aClass;\x0a\x09\x09yourself",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["theClass:", "new", "yourself"]
+}),
+$globals.ClassOrganizer.a$cls);
 
 
 $core.addClass("PackageOrganizer", $globals.Organizer, [], "Kernel-Infrastructure");

+ 19 - 0
src/Kernel-Infrastructure.st

@@ -279,6 +279,25 @@ removeElement: aString
 
 theClass
 	<inlineJS: 'return self.theClass'>
+!
+
+theClass: aClass
+	<inlineJS: 'self.theClass = aClass'>
+! !
+
+!ClassOrganizer methodsFor: 'initialization'!
+
+initialize
+	super initialize.
+	self basicAt: 'elements' put: #()
+! !
+
+!ClassOrganizer class methodsFor: 'instance creation'!
+
+on: aClass
+	^ self new
+		theClass: aClass;
+		yourself
 ! !
 
 Organizer subclass: #PackageOrganizer

+ 0 - 27
support/kernel-fundamentals.js

@@ -88,28 +88,6 @@ define(['./compatibility' /* TODO remove */], function () {
         this.Object = SmalltalkObject;
     }
 
-    OrganizeBrik.deps = ["arraySet", "root"];
-    function OrganizeBrik (brikz, st) {
-        var SmalltalkObject = brikz.root.Object;
-        var coreFns = brikz.root.coreFns;
-        var addElement = brikz.arraySet.addElement;
-
-        function SmalltalkOrganizer () {
-        }
-
-        function SmalltalkClassOrganizer () {
-            this.elements = [];
-        }
-
-        coreFns.Organizer = inherits(SmalltalkOrganizer, SmalltalkObject);
-        coreFns.ClassOrganizer = inherits(SmalltalkClassOrganizer, SmalltalkOrganizer);
-
-        this.setupClassOrganization = function (traitOrBehavior) {
-            traitOrBehavior.organization = new SmalltalkClassOrganizer();
-            traitOrBehavior.organization.theClass = traitOrBehavior;
-        };
-    }
-
     SelectorsBrik.deps = ["selectorConversion"];
     function SelectorsBrik (brikz, st) {
         var selectorSet = Object.create(null);
@@ -262,12 +240,8 @@ define(['./compatibility' /* TODO remove */], function () {
         };
     }
 
-    BehaviorProvidersBrik.deps = ["organize"];
     function BehaviorProvidersBrik (brikz, st) {
-        var setupClassOrganization = brikz.organize.setupClassOrganization;
-
         this.setupMethods = function (traitOrBehavior) {
-            setupClassOrganization(traitOrBehavior);
             traitOrBehavior.localMethods = Object.create(null);
             traitOrBehavior.methods = Object.create(null);
         };
@@ -378,7 +352,6 @@ define(['./compatibility' /* TODO remove */], function () {
         brikz.smalltalkGlobals = SmalltalkGlobalsBrik;
         brikz.root = RootBrik;
         brikz.arraySet = ArraySetBrik;
-        brikz.organize = OrganizeBrik;
         brikz.selectorConversion = SelectorConversionBrik;
         brikz.selectors = SelectorsBrik;
         brikz.packages = PackagesBrik;