Browse Source

Object>>deprecated

Nicolas Petton 13 years ago
parent
commit
e3e7028a1c
3 changed files with 34 additions and 0 deletions
  1. 11 0
      js/Kernel.deploy.js
  2. 16 0
      js/Kernel.js
  3. 7 0
      st/Kernel.st

+ 11 - 0
js/Kernel.deploy.js

@@ -548,6 +548,17 @@ return self;}
 }),
 smalltalk.Object);
 
+smalltalk.addMethod(
+'_deprecated_',
+smalltalk.method({
+selector: 'deprecated:',
+fn: function (aString){
+var self=this;
+smalltalk.send((typeof console == 'undefined' ? nil : console), "_warn_", [aString]);
+return self;}
+}),
+smalltalk.Object);
+
 
 smalltalk.addMethod(
 '_initialize',

+ 16 - 0
js/Kernel.js

@@ -788,6 +788,22 @@ referencedClasses: []
 }),
 smalltalk.Object);
 
+smalltalk.addMethod(
+unescape('_deprecated_'),
+smalltalk.method({
+selector: unescape('deprecated%3A'),
+category: 'error handling',
+fn: function (aString){
+var self=this;
+smalltalk.send((typeof console == 'undefined' ? nil : console), "_warn_", [aString]);
+return self;},
+args: ["aString"],
+source: unescape('deprecated%3A%20aString%0A%09%22Just%20a%20simple%20way%20to%20deprecate%20methods.%0A%09%23deprecated%20is%20in%20the%20%27error%20handling%27%20protocol%20even%20if%20it%20doesn%27t%20throw%20an%20error%2C%0A%09but%20it%20would%20in%20the%20future.%22%0A%09console%20warn%3A%20aString'),
+messageSends: ["warn:"],
+referencedClasses: []
+}),
+smalltalk.Object);
+
 
 smalltalk.addMethod(
 unescape('_initialize'),

+ 7 - 0
st/Kernel.st

@@ -140,6 +140,13 @@ doesNotUnderstand: aMessage
 
 halt
 	self error: 'Halt encountered'
+!
+
+deprecated: aString
+	"Just a simple way to deprecate methods.
+	#deprecated is in the 'error handling' protocol even if it doesn't throw an error,
+	but it would in the future."
+	console warn: aString
 ! !
 
 !Object methodsFor: 'initialization'!