Browse Source

Deprecate Object >> asJavaScriptSource.

Herby Vojčík 4 years ago
parent
commit
e23c809602
3 changed files with 58 additions and 3 deletions
  1. 5 1
      lang/API-CHANGES.txt
  2. 44 2
      lang/src/Kernel-Objects.js
  3. 9 0
      lang/src/Kernel-Objects.st

+ 5 - 1
lang/API-CHANGES.txt

@@ -3,14 +3,18 @@
 * Deprecate ClassBuilder >> addSubclass:named:instanceVariableNames:package:.
 * Deprecate ... >> migrateClassNamed:superclass:instanceVariableNames:package:.
 * Behavior >> instanceVariableNames aimed at only that. No visible change atm.
-* Deprecate Object >> asJavaScriptObject.
+* Deprecate Object >> asJavaScript{Object,Source}.
   * Hard to do generically if slots are added later.
 
 + Behavior >>
   + slots
++ Boolean >>
+  + asJavaScriptSource
 + ClassBuilder >>
   + addSubclass:named:slots:package:
   + migrateClassNamed:superclass:slots:package:
++ UndefinedObject >>
+  + asJavaScriptSource
 
 
 0.29.1:

+ 44 - 2
lang/src/Kernel-Objects.js

@@ -789,16 +789,17 @@ selector: "asJavaScriptSource",
 protocol: "converting",
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "asJavaScriptSource\x0a\x09^ self asString",
+source: "asJavaScriptSource\x0a\x09self deprecatedAPI: 'Implement domain-specific #asJavaScriptSource on your classes instead.'.\x0a\x09^ self asString",
 referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["asString"]
+messageSends: ["deprecatedAPI:", "asString"]
 }, function ($methodClass){ return function (){
 var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
+$self._deprecatedAPI_("Implement domain-specific #asJavaScriptSource on your classes instead.");
 return $self._asString();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"asJavaScriptSource",{})});
@@ -2013,6 +2014,29 @@ return self;
 }; }),
 $globals.Boolean);
 
+$core.addMethod(
+$core.method({
+selector: "asJavaScriptSource",
+protocol: "converting",
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "asJavaScriptSource\x0a\x09^ self asString",
+referencedClasses: [],
+//>>excludeEnd("ide");
+pragmas: [],
+messageSends: ["asString"]
+}, function ($methodClass){ return function (){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return $self._asString();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"asJavaScriptSource",{})});
+//>>excludeEnd("ctx");
+}; }),
+$globals.Boolean);
+
 $core.addMethod(
 $core.method({
 selector: "asString",
@@ -6913,6 +6937,24 @@ return null;
 }; }),
 $globals.UndefinedObject);
 
+$core.addMethod(
+$core.method({
+selector: "asJavaScriptSource",
+protocol: "converting",
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "asJavaScriptSource\x0a\x09^ 'null'",
+referencedClasses: [],
+//>>excludeEnd("ide");
+pragmas: [],
+messageSends: []
+}, function ($methodClass){ return function (){
+var self=this,$self=this;
+return "null";
+
+}; }),
+$globals.UndefinedObject);
+
 $core.addMethod(
 $core.method({
 selector: "deepCopy",

+ 9 - 0
lang/src/Kernel-Objects.st

@@ -302,6 +302,7 @@ asJavaScriptObject
 !
 
 asJavaScriptSource
+	self deprecatedAPI: 'Implement domain-specific #asJavaScriptSource on your classes instead.'.
 	^ self asString
 !
 
@@ -545,6 +546,10 @@ asJavaScriptObject
 	^ self
 !
 
+asJavaScriptSource
+	^ self asString
+!
+
 asString
 	<inlineJS: 'return self.toString()'>
 ! !
@@ -1594,6 +1599,10 @@ identityHash
 
 asJavaScriptObject
 	^ null
+!
+
+asJavaScriptSource
+	^ 'null'
 ! !
 
 !UndefinedObject methodsFor: 'copying'!