mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-10 21:54:12 +01:00
Cleanup.
This commit is contained in:
@@ -145,7 +145,7 @@ function defineModule(name, params, module) {
|
||||
defineModule.prefix += " ";
|
||||
|
||||
for (let [, mod] in Iterator(params.require || []))
|
||||
require(jsmodules, mod, null, name);
|
||||
require(module, mod, null, name);
|
||||
module.__proto__ = jsmodules;
|
||||
|
||||
module._lastModule = currentModule;
|
||||
@@ -210,6 +210,10 @@ function require(obj, name, from, targetName) {
|
||||
" into " + (targetName || obj.NAME || caller.filename + ":" + caller.lineNumber));
|
||||
|
||||
JSMLoader.load(name + ".jsm", obj);
|
||||
|
||||
if (!loaded[name] && obj != jsmodules)
|
||||
JSMLoader.load(name + ".jsm", jsmodules);
|
||||
|
||||
return obj;
|
||||
}
|
||||
catch (e) {
|
||||
@@ -235,6 +239,7 @@ defineModule("base", {
|
||||
}, this);
|
||||
|
||||
this.lazyRequire("messages", ["_", "Messages"]);
|
||||
this.lazyRequire("util", ["util"]);
|
||||
|
||||
/**
|
||||
* Returns a list of all of the top-level properties of an object, by
|
||||
@@ -627,9 +632,15 @@ function memoize(obj, key, getter) {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
|
||||
get: function g_replaceProperty() (
|
||||
Class.replaceProperty(this.instance || this, key, null),
|
||||
Class.replaceProperty(this.instance || this, key, getter.call(this, key))),
|
||||
get: function g_replaceProperty() {
|
||||
try {
|
||||
Class.replaceProperty(this.instance || this, key, null);
|
||||
return Class.replaceProperty(this.instance || this, key, getter.call(this, key));
|
||||
}
|
||||
catch (e) {
|
||||
util.reportError(e);
|
||||
}
|
||||
},
|
||||
|
||||
set: function s_replaceProperty(val)
|
||||
Class.replaceProperty(this.instance || this, key, val)
|
||||
@@ -881,8 +892,13 @@ Class.Memoize = function Memoize(getter, wait)
|
||||
else
|
||||
this.get = function replace() {
|
||||
let obj = this.instance || this;
|
||||
Class.replaceProperty(obj, key, null);
|
||||
return Class.replaceProperty(obj, key, getter.call(this, key));
|
||||
try {
|
||||
Class.replaceProperty(obj, key, null);
|
||||
return Class.replaceProperty(obj, key, getter.call(this, key));
|
||||
}
|
||||
catch (e) {
|
||||
util.reportError(e);
|
||||
}
|
||||
};
|
||||
|
||||
this.set = function replace(val) Class.replaceProperty(this.instance || this, val);
|
||||
|
||||
@@ -15,6 +15,8 @@ defineModule("io", {
|
||||
require: ["services"]
|
||||
}, this);
|
||||
|
||||
this.lazyRequire("config", ["config"]);
|
||||
|
||||
// TODO: why are we passing around strings rather than file objects?
|
||||
/**
|
||||
* Provides a basic interface to common system I/O operations.
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||
defineModule("storage", {
|
||||
exports: ["File", "Storage", "storage"],
|
||||
require: ["config", "services", "util"]
|
||||
require: ["services", "util"]
|
||||
}, this);
|
||||
|
||||
this.lazyRequire("config", ["config"]);
|
||||
this.lazyRequire("io", ["IO"]);
|
||||
|
||||
var win32 = /^win(32|nt)$/i.test(services.runtime.OS);
|
||||
@@ -17,12 +18,17 @@ var myObject = JSON.parse("{}").constructor;
|
||||
|
||||
function loadData(name, store, type) {
|
||||
try {
|
||||
let data = storage.infoPath.child(name).read();
|
||||
let result = JSON.parse(data);
|
||||
if (result instanceof type)
|
||||
return result;
|
||||
let file = storage.infoPath.child(name);
|
||||
if (file.exists()) {
|
||||
let data = file.read();
|
||||
let result = JSON.parse(data);
|
||||
if (result instanceof type)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
util.reportError(e);
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
|
||||
function saveData(obj) {
|
||||
|
||||
@@ -1476,7 +1476,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
return func.apply(self || this, Array.slice(arguments, 2));
|
||||
}
|
||||
catch (e) {
|
||||
util.reportError(e);
|
||||
this.reportError(e);
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user