Browse Source

KernelObjects: add JSObjectProxy>>value

return contents of the 'value' attribute if it exists
otherwise return the result of Object>>value
Manfred Kroehnert 12 years ago
parent
commit
57ebfa0b0e
3 changed files with 58 additions and 0 deletions
  1. 22 0
      js/Kernel-Objects.deploy.js
  2. 27 0
      js/Kernel-Objects.js
  3. 9 0
      st/Kernel-Objects.st

+ 22 - 0
js/Kernel-Objects.deploy.js

@@ -1597,6 +1597,28 @@ return $1;
 }),
 smalltalk.JSObjectProxy);
 
+smalltalk.addMethod(
+"_value",
+smalltalk.method({
+selector: "value",
+fn: function (){
+var self=this;
+var attribute;
+return smalltalk.withContext(function($ctx1) { 
var $1,$2;
+attribute=_st(self)._at_("value");
+$1=attribute;
+if(($receiver = $1) == nil || $receiver == undefined){
+attribute=smalltalk.Object.fn.prototype._value.apply(_st(self), []);
+attribute;
+} else {
+$1;
+};
+$2=attribute;
+return $2;
+}, function($ctx1) {$ctx1.fill(self,"value",{attribute:attribute}, smalltalk.JSObjectProxy)})}
+}),
+smalltalk.JSObjectProxy);
+
 
 smalltalk.addMethod(
 "_on_",

+ 27 - 0
js/Kernel-Objects.js

@@ -2231,6 +2231,33 @@ referencedClasses: []
 }),
 smalltalk.JSObjectProxy);
 
+smalltalk.addMethod(
+"_value",
+smalltalk.method({
+selector: "value",
+category: 'accessing',
+fn: function (){
+var self=this;
+var attribute;
+return smalltalk.withContext(function($ctx1) { 
var $1,$2;
+attribute=_st(self)._at_("value");
+$1=attribute;
+if(($receiver = $1) == nil || $receiver == undefined){
+attribute=smalltalk.Object.fn.prototype._value.apply(_st(self), []);
+attribute;
+} else {
+$1;
+};
+$2=attribute;
+return $2;
+}, function($ctx1) {$ctx1.fill(self,"value",{attribute:attribute}, smalltalk.JSObjectProxy)})},
+args: [],
+source: "value\x0a\x09\x22if attribute 'value' exists on the JS object return it,\x0a    otherwise return the result of Object>>value.\x22\x0a\x09| attribute |\x0a\x09attribute := self at: 'value'.\x0a\x09attribute ifNil: [attribute := super value].\x0a    ^attribute",
+messageSends: ["at:", "ifNil:", "value"],
+referencedClasses: []
+}),
+smalltalk.JSObjectProxy);
+
 
 smalltalk.addMethod(
 "_on_",

+ 9 - 0
st/Kernel-Objects.st

@@ -682,6 +682,15 @@ jsObject
 
 jsObject: aJSObject
 	jsObject := aJSObject
+!
+
+value
+	"if attribute 'value' exists on the JS object return it,
+    otherwise return the result of Object>>value."
+	| attribute |
+	attribute := self at: 'value'.
+	attribute ifNil: [attribute := super value].
+    ^attribute
 ! !
 
 !JSObjectProxy methodsFor: 'enumerating'!