[gjs] lang: Remove old, unused wrapper API for ES5 API



commit 98578960a96e3d1c19b91e26de8bdeb2c67f9e58
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Jan 3 01:16:34 2014 -0500

    lang: Remove old, unused wrapper API for ES5 API
    
    Lang.defineAccessorProperty and Lang.seal are replaced by
    Object.defineProperty and Object.freeze.

 installed-tests/js/testLang.js |   15 -------------
 modules/lang.js                |   44 ----------------------------------------
 modules/overrides/Gio.js       |    7 +++--
 3 files changed, 4 insertions(+), 62 deletions(-)
---
diff --git a/installed-tests/js/testLang.js b/installed-tests/js/testLang.js
index b778c78..342a599 100644
--- a/installed-tests/js/testLang.js
+++ b/installed-tests/js/testLang.js
@@ -108,20 +108,5 @@ function testBind() {
     JSUnit.assertEquals("o3.args[4] in callback", 1138, o3.args[4]);
 }
 
-function testDefineAccessorProperty() {
-    var obj = {};
-    var storage = 42;
-
-    JSUnit.assertEquals(obj.foo, undefined);
-
-    Lang.defineAccessorProperty(obj, 'foo',
-                                function () { return storage; },
-                                function (val) { storage = val; });
-
-    JSUnit.assertEquals(obj.foo, 42);
-    obj.foo = 43;
-    JSUnit.assertEquals(obj.foo, 43);
-}
-
 JSUnit.gjstestRun(this, JSUnit.setUp, JSUnit.tearDown);
 
diff --git a/modules/lang.js b/modules/lang.js
index b88fe3c..73de257 100644
--- a/modules/lang.js
+++ b/modules/lang.js
@@ -59,23 +59,6 @@ function copyPublicProperties(source, dest) {
     }
 }
 
-function copyPropertiesNoOverwrite(source, dest) {
-    for (let property in source) {
-        if (!(property in dest)) {
-            _copyProperty(source, dest, property);
-        }
-    }
-}
-
-function removeNullProperties(obj) {
-    for (let property in obj) {
-        if (obj[property] == null)
-            delete obj[property];
-        else if (typeof(obj[property]) == 'object')
-            removeNullProperties(obj[property]);
-    }
-}
-
 /**
  * Binds obj to callback. Makes it possible to refer to "obj"
  * using this within the callback.
@@ -113,33 +96,6 @@ function bind(obj, callback) {
     };
 }
 
-function defineAccessorProperty(object, name, getter, setter) {
-    Object.defineProperty(object, name, { get: getter,
-                                         set: setter,
-                                         configurable: true,
-                                         enumerable: true });
-}
-
-function _deepFreeze(o) {
-    Object.freeze(o);
-
-    for (prop in o) {
-        if (!o.hasOwnProperty(prop) || !(typeof o === "object") || Object.isFrozen(o))
-            continue;
-
-        _deepFreeze(o[prop]);
-    }
-}
-
-// The name of this function is unfortunate, as it wraps
-// Object.freeze, not Object.seal
-function seal(object, deep) {
-    if (deep)
-        _deepFreeze(object);
-    else
-        Object.freeze(object);
-}
-
 // Class magic
 // Adapted from MooTools, MIT license
 // https://github.com/mootools/moootools-core
diff --git a/modules/overrides/Gio.js b/modules/overrides/Gio.js
index ec1b4b9..eac26c4 100644
--- a/modules/overrides/Gio.js
+++ b/modules/overrides/Gio.js
@@ -172,9 +172,10 @@ function _addDBusConvenience() {
     for (i = 0; i < properties.length; i++) {
         let name = properties[i].name;
         let signature = properties[i].signature;
-        Lang.defineAccessorProperty(this, name,
-                                    Lang.bind(this, _propertyGetter, name),
-                                    Lang.bind(this, _propertySetter, name, signature));
+        Object.defineProperty(this, name, { get: Lang.bind(this, _propertyGetter, name),
+                                            set: Lang.bind(this, _propertySetter, name, signature),
+                                            configurable: true,
+                                            enumerable: true });
     }
 }
 


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