Browse Source

AnnouncementSubscription use #valuable: instead of #block: (deprecated)

Nicolas Petton 11 years ago
parent
commit
7182ee27f1
4 changed files with 148 additions and 36 deletions
  1. 1 0
      API-CHANGES.txt
  2. 50 11
      js/Kernel-Announcements.deploy.js
  3. 71 17
      js/Kernel-Announcements.js
  4. 26 8
      st/Kernel-Announcements.st

+ 1 - 0
API-CHANGES.txt

@@ -1,5 +1,6 @@
 0.11.0:
 
+* AnnouncementSubscription use #valuable: instead of #block: (deprecated)
 * AbstractCodeGenerator inherits from Object, not NodeVisitor
 * Object>>printString
 * replace >>printString with >>printOn:

+ 50 - 11
js/Kernel-Announcements.deploy.js

@@ -1,5 +1,5 @@
 smalltalk.addPackage('Kernel-Announcements');
-smalltalk.addClass('AnnouncementSubscription', smalltalk.Object, ['block', 'announcementClass'], 'Kernel-Announcements');
+smalltalk.addClass('AnnouncementSubscription', smalltalk.Object, ['valuable', 'announcementClass'], 'Kernel-Announcements');
 smalltalk.addMethod(
 smalltalk.method({
 selector: "announcementClass",
@@ -31,21 +31,23 @@ fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 var $1;
-$1=self["@block"];
+_st(self)._deprecatedAPI();
+$1=_st(self)._valuable();
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"block",{},smalltalk.AnnouncementSubscription)})},
-messageSends: []}),
+messageSends: ["deprecatedAPI", "valuable"]}),
 smalltalk.AnnouncementSubscription);
 
 smalltalk.addMethod(
 smalltalk.method({
 selector: "block:",
-fn: function (aBlock){
+fn: function (aValuable){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-self["@block"]=aBlock;
-return self}, function($ctx1) {$ctx1.fill(self,"block:",{aBlock:aBlock},smalltalk.AnnouncementSubscription)})},
-messageSends: []}),
+_st(self)._deprecatedAPI();
+_st(self)._valuable_(aValuable);
+return self}, function($ctx1) {$ctx1.fill(self,"block:",{aValuable:aValuable},smalltalk.AnnouncementSubscription)})},
+messageSends: ["deprecatedAPI", "valuable:"]}),
 smalltalk.AnnouncementSubscription);
 
 smalltalk.addMethod(
@@ -57,10 +59,10 @@ return smalltalk.withContext(function($ctx1) {
 var $1;
 $1=_st(self)._handlesAnnouncement_(anAnnouncement);
 if(smalltalk.assert($1)){
-_st(_st(self)._block())._value_(anAnnouncement);
+_st(_st(self)._valuable())._value_(anAnnouncement);
 };
 return self}, function($ctx1) {$ctx1.fill(self,"deliver:",{anAnnouncement:anAnnouncement},smalltalk.AnnouncementSubscription)})},
-messageSends: ["ifTrue:", "value:", "block", "handlesAnnouncement:"]}),
+messageSends: ["ifTrue:", "value:", "valuable", "handlesAnnouncement:"]}),
 smalltalk.AnnouncementSubscription);
 
 smalltalk.addMethod(
@@ -84,6 +86,43 @@ return $1;
 messageSends: ["ifNil:ifNotNil:", "includesBehavior:", "at:", "name", "theNonMetaClass", "class", "current", "announcementClass"]}),
 smalltalk.AnnouncementSubscription);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "receiver",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=_st(_st(self)._valuable())._receiver();
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"receiver",{},smalltalk.AnnouncementSubscription)})},
+messageSends: ["receiver", "valuable"]}),
+smalltalk.AnnouncementSubscription);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "valuable",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=self["@valuable"];
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"valuable",{},smalltalk.AnnouncementSubscription)})},
+messageSends: []}),
+smalltalk.AnnouncementSubscription);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "valuable:",
+fn: function (aValuable){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+self["@valuable"]=aValuable;
+return self}, function($ctx1) {$ctx1.fill(self,"valuable:",{aValuable:aValuable},smalltalk.AnnouncementSubscription)})},
+messageSends: []}),
+smalltalk.AnnouncementSubscription);
+
 
 
 smalltalk.addClass('Announcer', smalltalk.Object, ['registry', 'subscriptions'], 'Kernel-Announcements');
@@ -123,12 +162,12 @@ function $AnnouncementSubscription(){return smalltalk.AnnouncementSubscription||
 return smalltalk.withContext(function($ctx1) { 
 var $1,$2;
 $1=_st($AnnouncementSubscription())._new();
-_st($1)._block_(aBlock);
+_st($1)._valuable_(aBlock);
 _st($1)._announcementClass_(aClass);
 $2=_st($1)._yourself();
 _st(self["@subscriptions"])._add_($2);
 return self}, function($ctx1) {$ctx1.fill(self,"on:do:",{aClass:aClass,aBlock:aBlock},smalltalk.Announcer)})},
-messageSends: ["add:", "block:", "new", "announcementClass:", "yourself"]}),
+messageSends: ["add:", "valuable:", "new", "announcementClass:", "yourself"]}),
 smalltalk.Announcer);
 
 

+ 71 - 17
js/Kernel-Announcements.js

@@ -1,5 +1,5 @@
 smalltalk.addPackage('Kernel-Announcements');
-smalltalk.addClass('AnnouncementSubscription', smalltalk.Object, ['block', 'announcementClass'], 'Kernel-Announcements');
+smalltalk.addClass('AnnouncementSubscription', smalltalk.Object, ['valuable', 'announcementClass'], 'Kernel-Announcements');
 smalltalk.AnnouncementSubscription.comment="The subscription is a single entry in a subscription registry of an `Announcer`.\x0aSeveral subscriptions by the same object is possible."
 smalltalk.addMethod(
 smalltalk.method({
@@ -43,12 +43,13 @@ fn: function (){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 var $1;
-$1=self["@block"];
+_st(self)._deprecatedAPI();
+$1=_st(self)._valuable();
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"block",{},smalltalk.AnnouncementSubscription)})},
 args: [],
-source: "block\x0a\x09^block",
-messageSends: [],
+source: "block\x0a\x09\x22Use #valuable instead\x22\x0a\x09\x0a\x09self deprecatedAPI.\x0a\x09^ self valuable",
+messageSends: ["deprecatedAPI", "valuable"],
 referencedClasses: []
 }),
 smalltalk.AnnouncementSubscription);
@@ -57,14 +58,15 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "block:",
 category: 'accessing',
-fn: function (aBlock){
+fn: function (aValuable){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-self["@block"]=aBlock;
-return self}, function($ctx1) {$ctx1.fill(self,"block:",{aBlock:aBlock},smalltalk.AnnouncementSubscription)})},
-args: ["aBlock"],
-source: "block: aBlock\x0a\x09block := aBlock",
-messageSends: [],
+_st(self)._deprecatedAPI();
+_st(self)._valuable_(aValuable);
+return self}, function($ctx1) {$ctx1.fill(self,"block:",{aValuable:aValuable},smalltalk.AnnouncementSubscription)})},
+args: ["aValuable"],
+source: "block: aValuable\x0a\x09\x22Use #valuable instead\x22\x0a\x09\x0a\x09self deprecatedAPI.\x0a\x09self valuable: aValuable",
+messageSends: ["deprecatedAPI", "valuable:"],
 referencedClasses: []
 }),
 smalltalk.AnnouncementSubscription);
@@ -79,12 +81,12 @@ return smalltalk.withContext(function($ctx1) {
 var $1;
 $1=_st(self)._handlesAnnouncement_(anAnnouncement);
 if(smalltalk.assert($1)){
-_st(_st(self)._block())._value_(anAnnouncement);
+_st(_st(self)._valuable())._value_(anAnnouncement);
 };
 return self}, function($ctx1) {$ctx1.fill(self,"deliver:",{anAnnouncement:anAnnouncement},smalltalk.AnnouncementSubscription)})},
 args: ["anAnnouncement"],
-source: "deliver: anAnnouncement\x0a\x09(self handlesAnnouncement: anAnnouncement)\x0a\x09\x09ifTrue: [self block value: anAnnouncement]",
-messageSends: ["ifTrue:", "value:", "block", "handlesAnnouncement:"],
+source: "deliver: anAnnouncement\x0a\x09(self handlesAnnouncement: anAnnouncement)\x0a\x09\x09ifTrue: [self valuable value: anAnnouncement]",
+messageSends: ["ifTrue:", "value:", "valuable", "handlesAnnouncement:"],
 referencedClasses: []
 }),
 smalltalk.AnnouncementSubscription);
@@ -115,6 +117,58 @@ referencedClasses: ["Smalltalk"]
 }),
 smalltalk.AnnouncementSubscription);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "receiver",
+category: 'accessing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=_st(_st(self)._valuable())._receiver();
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"receiver",{},smalltalk.AnnouncementSubscription)})},
+args: [],
+source: "receiver\x0a\x09^ self valuable receiver",
+messageSends: ["receiver", "valuable"],
+referencedClasses: []
+}),
+smalltalk.AnnouncementSubscription);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "valuable",
+category: 'accessing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=self["@valuable"];
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"valuable",{},smalltalk.AnnouncementSubscription)})},
+args: [],
+source: "valuable\x0a\x09^ valuable",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.AnnouncementSubscription);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "valuable:",
+category: 'accessing',
+fn: function (aValuable){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+self["@valuable"]=aValuable;
+return self}, function($ctx1) {$ctx1.fill(self,"valuable:",{aValuable:aValuable},smalltalk.AnnouncementSubscription)})},
+args: ["aValuable"],
+source: "valuable: aValuable\x0a\x09valuable := aValuable",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.AnnouncementSubscription);
+
 
 
 smalltalk.addClass('Announcer', smalltalk.Object, ['registry', 'subscriptions'], 'Kernel-Announcements');
@@ -132,7 +186,7 @@ return _st(each)._deliver_(anAnnouncement);
 }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
 return self}, function($ctx1) {$ctx1.fill(self,"announce:",{anAnnouncement:anAnnouncement},smalltalk.Announcer)})},
 args: ["anAnnouncement"],
-source: "announce: anAnnouncement\x0a\x09subscriptions do: [:each |\x0a\x09\x09each deliver: anAnnouncement]",
+source: "announce: anAnnouncement\x0a\x09subscriptions do: [ :each |\x0a\x09\x09each deliver: anAnnouncement ]",
 messageSends: ["do:", "deliver:"],
 referencedClasses: []
 }),
@@ -166,14 +220,14 @@ function $AnnouncementSubscription(){return smalltalk.AnnouncementSubscription||
 return smalltalk.withContext(function($ctx1) { 
 var $1,$2;
 $1=_st($AnnouncementSubscription())._new();
-_st($1)._block_(aBlock);
+_st($1)._valuable_(aBlock);
 _st($1)._announcementClass_(aClass);
 $2=_st($1)._yourself();
 _st(self["@subscriptions"])._add_($2);
 return self}, function($ctx1) {$ctx1.fill(self,"on:do:",{aClass:aClass,aBlock:aBlock},smalltalk.Announcer)})},
 args: ["aClass", "aBlock"],
-source: "on: aClass do: aBlock\x0a\x09subscriptions add: (AnnouncementSubscription new\x0a\x09\x09block: aBlock;\x0a\x09\x09announcementClass: aClass;\x0a\x09\x09yourself)",
-messageSends: ["add:", "block:", "new", "announcementClass:", "yourself"],
+source: "on: aClass do: aBlock\x0a\x09subscriptions add: (AnnouncementSubscription new\x0a\x09\x09valuable: aBlock;\x0a\x09\x09announcementClass: aClass;\x0a\x09\x09yourself)",
+messageSends: ["add:", "valuable:", "new", "announcementClass:", "yourself"],
 referencedClasses: ["AnnouncementSubscription"]
 }),
 smalltalk.Announcer);

+ 26 - 8
st/Kernel-Announcements.st

@@ -1,6 +1,6 @@
 Smalltalk current createPackage: 'Kernel-Announcements'!
 Object subclass: #AnnouncementSubscription
-	instanceVariableNames: 'block announcementClass'
+	instanceVariableNames: 'valuable announcementClass'
 	package: 'Kernel-Announcements'!
 !AnnouncementSubscription commentStamp!
 The subscription is a single entry in a subscription registry of an `Announcer`.
@@ -17,18 +17,36 @@ announcementClass: aClass
 !
 
 block
-	^block
+	"Use #valuable instead"
+	
+	self deprecatedAPI.
+	^ self valuable
+!
+
+block: aValuable
+	"Use #valuable instead"
+	
+	self deprecatedAPI.
+	self valuable: aValuable
+!
+
+receiver
+	^ self valuable receiver
+!
+
+valuable
+	^ valuable
 !
 
-block: aBlock
-	block := aBlock
+valuable: aValuable
+	valuable := aValuable
 ! !
 
 !AnnouncementSubscription methodsFor: 'announcing'!
 
 deliver: anAnnouncement
 	(self handlesAnnouncement: anAnnouncement)
-		ifTrue: [self block value: anAnnouncement]
+		ifTrue: [self valuable value: anAnnouncement]
 !
 
 handlesAnnouncement: anAnnouncement
@@ -52,8 +70,8 @@ Use `#on:do:` to register subscriptions.!
 !Announcer methodsFor: 'announcing'!
 
 announce: anAnnouncement
-	subscriptions do: [:each |
-		each deliver: anAnnouncement]
+	subscriptions do: [ :each |
+		each deliver: anAnnouncement ]
 ! !
 
 !Announcer methodsFor: 'initialization'!
@@ -67,7 +85,7 @@ initialize
 
 on: aClass do: aBlock
 	subscriptions add: (AnnouncementSubscription new
-		block: aBlock;
+		valuable: aBlock;
 		announcementClass: aClass;
 		yourself)
 ! !