[gjs] lang: Remove use of __{define,lookup}{Getter,Setter}__



commit 3c6c3e0ec3ec345cb6c417d80cbe3956c46c54b6
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Jan 9 01:25:15 2013 -0500

    lang: Remove use of __{define,lookup}{Getter,Setter}__
    
    Upstream is planning to remove all four of these methods -- they're
    implementable in ECMAScript 5, along with more, so simply use those
    instead of the SpiderMonkey special-cases.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=691996

 modules/lang.js |   31 ++++++-------------------------
 1 files changed, 6 insertions(+), 25 deletions(-)
---
diff --git a/modules/lang.js b/modules/lang.js
index 9e5c6c4..9703add 100644
--- a/modules/lang.js
+++ b/modules/lang.js
@@ -32,20 +32,8 @@ function countProperties(obj) {
 }
 
 function _copyProperty(source, dest, property) {
-    let getterFunc = source.__lookupGetter__(property);
-    let setterFunc = source.__lookupSetter__(property);
-
-    if (getterFunc) {
-        dest.__defineGetter__(property, getterFunc);
-    }
-
-    if (setterFunc) {
-        dest.__defineSetter__(property, setterFunc);
-    }
-
-    if (!setterFunc && !getterFunc) {
-        dest[property] = source[property];
-    }
+    let desc = Object.getOwnPropertyDescriptor(source, property);
+    Object.defineProperty(dest, property, desc);
 }
 
 function copyProperties(source, dest) {
@@ -118,17 +106,10 @@ function bind(obj, callback) {
 }
 
 function defineAccessorProperty(object, name, getter, setter) {
-    if (Object.defineProperty) { // ECMAScript 5
-	Object.defineProperty(object, name, { get: getter,
-					      set: setter,
-					      configurable: true,
-					      enumerable: true });
-	return;
-    }
-
-    // fallback to deprecated way
-    object.__defineGetter__(name, getter);
-    object.__defineSetter__(name, setter);
+    Object.defineProperty(object, name, { get: getter,
+					  set: setter,
+					  configurable: true,
+					  enumerable: true });
 }
 
 // Class magic



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]