зеркало из https://github.com/mozilla/snowl.git
don't modify Object.prototype to avoid problems when enumerating properties of objects (since anything we add is enumerable); add Mixin.js module so inmixing stuff works
This commit is contained in:
Родитель
1eac5df561
Коммит
abd75c0fa4
|
@ -0,0 +1,68 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Snowl.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Myk Melez <myk@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
let EXPORTED_SYMBOLS = ["inmix"];
|
||||
|
||||
/**
|
||||
* Inmix attributes (properties, methods, getters/setters) from the source
|
||||
* object into the target object. Doesn't inmix attributes that already exist
|
||||
* in the target object (i.e. doesn't override existing attributes).
|
||||
*
|
||||
* FIXME: give the target object access in some way to the source's version
|
||||
* of attributes it overrides.
|
||||
*
|
||||
* @param target {Object} the object that receives attributes
|
||||
* @param source {Object} the object that provides attributes
|
||||
*/
|
||||
function inmix(target, source) {
|
||||
for (let attr in source) {
|
||||
// Don't inmix attributes that already exist in the target.
|
||||
if (attr in target)
|
||||
continue;
|
||||
|
||||
let getter = source.__lookupGetter__(attr);
|
||||
let setter = source.__lookupSetter__(attr);
|
||||
|
||||
if (getter || setter) {
|
||||
if (getter)
|
||||
target.__defineGetter__(attr, getter);
|
||||
if (setter)
|
||||
target.__defineSetter__(attr, setter);
|
||||
}
|
||||
else
|
||||
target[attr] = source[attr];
|
||||
}
|
||||
}
|
|
@ -46,8 +46,8 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|||
Cu.import("resource://gre/modules/ISO8601DateUtils.jsm");
|
||||
|
||||
// modules that are generic
|
||||
Cu.import("resource://snowl/modules/Compose.js");
|
||||
Cu.import("resource://snowl/modules/log4moz.js");
|
||||
Cu.import("resource://snowl/modules/Mixin.js");
|
||||
Cu.import("resource://snowl/modules/Observers.js");
|
||||
Cu.import("resource://snowl/modules/URI.js");
|
||||
|
||||
|
@ -64,8 +64,6 @@ Cu.import("resource://snowl/modules/service.js");
|
|||
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
|
||||
loader.loadSubScript("chrome://snowl/content/strands.js");
|
||||
|
||||
Object.prototype.acquire = acquire;
|
||||
|
||||
/**
|
||||
* Convert a string to an array of character codes.
|
||||
*
|
||||
|
@ -682,5 +680,5 @@ SnowlFeed.prototype = {
|
|||
|
||||
};
|
||||
|
||||
SnowlFeed.prototype.acquire(SnowlSource);
|
||||
inmix(SnowlFeed.prototype, SnowlSource);
|
||||
SnowlService.addAccountType(SnowlFeed);
|
||||
|
|
|
@ -46,8 +46,8 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|||
Cu.import("resource://gre/modules/ISO8601DateUtils.jsm");
|
||||
|
||||
// modules that are generic
|
||||
Cu.import("resource://snowl/modules/Compose.js");
|
||||
Cu.import("resource://snowl/modules/log4moz.js");
|
||||
Cu.import("resource://snowl/modules/Mixin.js");
|
||||
Cu.import("resource://snowl/modules/Observers.js");
|
||||
Cu.import("resource://snowl/modules/URI.js");
|
||||
|
||||
|
@ -65,8 +65,6 @@ Cu.import("resource://snowl/modules/service.js");
|
|||
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
|
||||
loader.loadSubScript("chrome://snowl/content/strands.js");
|
||||
|
||||
Object.prototype.acquire = acquire;
|
||||
|
||||
const TYPE = "SnowlTwitter";
|
||||
const NAME = "Twitter";
|
||||
const MACHINE_URI = URI.get("https://twitter.com");
|
||||
|
@ -157,6 +155,7 @@ SnowlTwitter.prototype = {
|
|||
|
||||
// refresh is defined elsewhere.
|
||||
|
||||
|
||||
//**************************************************************************//
|
||||
// SnowlTarget
|
||||
|
||||
|
@ -804,6 +803,6 @@ SnowlTwitter.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
SnowlTwitter.prototype.acquire(SnowlSource);
|
||||
SnowlTwitter.prototype.acquire(SnowlTarget);
|
||||
inmix(SnowlTwitter.prototype, SnowlSource);
|
||||
inmix(SnowlTwitter.prototype, SnowlTarget);
|
||||
SnowlService.addAccountType(SnowlTwitter);
|
||||
|
|
Загрузка…
Ссылка в новой задаче