1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 23:17:59 +01:00

[bootstrap] Add code to manually reload stale cached modules on rehash.

--HG--
branch : bootstrapped
This commit is contained in:
Kris Maglione
2010-12-25 08:54:33 -05:00
parent 53786141e1
commit a759ab3606
14 changed files with 122 additions and 78 deletions

18
common/bootstrap.js vendored
View File

@@ -16,7 +16,7 @@ const resourceProto = Services.io.getProtocolHandler("resource")
.QueryInterface(Ci.nsIResProtocolHandler); .QueryInterface(Ci.nsIResProtocolHandler);
const categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager); const categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
const manager = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); const manager = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
const storage = Cc["@mozilla.org/fuel/application;1"].getService(Ci.fuelIApplication); const storage = Cc["@mozilla.org/fuel/application;1"].getService(Ci.fuelIApplication).storage;
function httpGet(url) { function httpGet(url) {
let xmlhttp = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest); let xmlhttp = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
@@ -41,6 +41,7 @@ let addon = null;
let basePath = null; let basePath = null;
let components = {}; let components = {};
let getURI = null; let getURI = null;
var JSMLoader = storage.get("dactyl.JSMLoader", { get load() Cu.import });
function startup(data, reason) { function startup(data, reason) {
dump("dactyl: bootstrap: startup " + reasonToString(reason) + "\n"); dump("dactyl: bootstrap: startup " + reasonToString(reason) + "\n");
@@ -87,12 +88,12 @@ FactoryProxy.prototype = {
}, },
unregister: function () { unregister: function () {
dump("dactyl: bootstrap: unregister: " + this.classID + " " + this.contractID + "\n"); dump("dactyl: bootstrap: unregister: " + this.classID + " " + this.contractID + "\n");
manager.unregisterFactory(this.classID, manager.unregisterFactory(this.classID, this);
this);
}, },
get module() { get module() {
Object.defineProperty(this, "module", { value: {}, enumerable: true }); Object.defineProperty(this, "module", { value: {}, enumerable: true });
Cu.import(this.url, this.module); JSMLoader.load(this.url, this.module);
JSMLoader.registerGlobal(this.url, this.module.NSGetFactory);
return this.module; return this.module;
}, },
createInstance: function (iids) { createInstance: function (iids) {
@@ -138,7 +139,6 @@ function init() {
break; break;
case "contract": case "contract":
components[fields[2]].contractID = fields[1]; components[fields[2]].contractID = fields[1];
components[fields[2]].register();
break; break;
case "resource": case "resource":
@@ -146,11 +146,13 @@ function init() {
} }
} }
Cc["@dactyl.googlecode.com/base/xpc-interface-shim"].createInstance()
Services.obs.notifyObservers(null, "dactyl-rehash", null); Services.obs.notifyObservers(null, "dactyl-rehash", null);
Cu.import("resource://dactyl/base.jsm"); JSMLoader.load("resource://dactyl/base.jsm", global);
for each (let component in components)
component.register();
require(global, "prefs"); require(global, "prefs");
require(global, "services"); require(global, "services");

View File

@@ -4,14 +4,14 @@
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
"use strict"; "use strict";
const Ci = Components.interfaces, Cc = Components.classes; var Ci = Components.interfaces, Cc = Components.classes;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
const prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService) var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService)
.getBranch("extensions.dactyl."); .getBranch("extensions.dactyl.");
const appName = prefs.getComplexValue("appName", Ci.nsISupportsString).data; var appName = prefs.getComplexValue("appName", Ci.nsISupportsString).data;
const name = prefs.getComplexValue("name", Ci.nsISupportsString).data; var name = prefs.getComplexValue("name", Ci.nsISupportsString).data;
function CommandLineHandler() { function CommandLineHandler() {
this.wrappedJSObject = this; this.wrappedJSObject = this;
@@ -45,9 +45,9 @@ CommandLineHandler.prototype = {
}; };
if (XPCOMUtils.generateNSGetFactory) if (XPCOMUtils.generateNSGetFactory)
const NSGetFactory = XPCOMUtils.generateNSGetFactory([CommandLineHandler]); var NSGetFactory = XPCOMUtils.generateNSGetFactory([CommandLineHandler]);
else else
const NSGetModule = XPCOMUtils.generateNSGetModule([CommandLineHandler]); var NSGetModule = XPCOMUtils.generateNSGetModule([CommandLineHandler]);
var EXPORTED_SYMBOLS = ["NSGetFactory"]; var EXPORTED_SYMBOLS = ["NSGetFactory"];
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -12,16 +12,16 @@
* By Kris Maglione, ideas from Ed Anuff's nsChromeExtensionHandler. * By Kris Maglione, ideas from Ed Anuff's nsChromeExtensionHandler.
*/ */
const NAME = "protocols"; var NAME = "protocols";
const global = this; var global = this;
const Cc = Components.classes; var Cc = Components.classes;
const Ci = Components.interfaces; var Ci = Components.interfaces;
const Cu = Components.utils; var Cu = Components.utils;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
const ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
const systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrincipal); var systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrincipal);
function dataURL(type, data) "data:" + (type || "application/xml;encoding=UTF-8") + "," + escape(data); function dataURL(type, data) "data:" + (type || "application/xml;encoding=UTF-8") + "," + escape(data);
function makeChannel(url, orig) { function makeChannel(url, orig) {
@@ -204,9 +204,9 @@ Shim.prototype = {
}; };
if (XPCOMUtils.generateNSGetFactory) if (XPCOMUtils.generateNSGetFactory)
const NSGetFactory = XPCOMUtils.generateNSGetFactory([AboutHandler, ChromeData, Dactyl, Shim]); var NSGetFactory = XPCOMUtils.generateNSGetFactory([AboutHandler, ChromeData, Dactyl, Shim]);
else else
const NSGetModule = XPCOMUtils.generateNSGetModule([AboutHandler, ChromeData, Dactyl, Shim]); var NSGetModule = XPCOMUtils.generateNSGetModule([AboutHandler, ChromeData, Dactyl, Shim]);
var EXPORTED_SYMBOLS = ["NSGetFactory"]; var EXPORTED_SYMBOLS = ["NSGetFactory"];
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -4,10 +4,49 @@
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
"use strict"; "use strict";
const Cc = Components.classes; if (!JSMLoader)
const Ci = Components.interfaces; var JSMLoader = {
const Cr = Components.results; builtin: Components.utils.Sandbox(this),
const Cu = Components.utils; globals: {},
stale: {},
load: function load(url, target) {
dump("dactyl: load: " + url + "\n");
if (this.stale[url]) {
delete this.stale[url];
dump("dactyl: load stale\n");
let global = this.globals[url];
for each (let prop in Object.getOwnPropertyNames(global))
try {
if (!set.has(this.builtin, prop) && global[prop] != this && global[prop] != set)
delete global[prop]
}
catch (e) {}
Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader)
.loadSubScript(url, this.globals[url]);
dump("dactyl: load reloaded: " + url + "\n");
}
Components.utils.import(url, target);
},
purge: function purge() {
for (let [url, global] in Iterator(this.globals))
this.stale[url] = true;
},
registerGlobal: function registerGlobal(uri, obj) {
if (Cu.getGlobalForObject)
this.globals[uri] = Cu.getGlobalForObject(obj);
}
};
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
var Cu = Components.utils;
Cc["@mozilla.org/fuel/application;1"].getService(Ci.fuelIApplication)
.storage.set("dactyl.JSMLoader", JSMLoader);
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm");
try { try {
@@ -98,7 +137,8 @@ let loaded = {};
let currentModule; let currentModule;
function defineModule(name, params) { function defineModule(name, params) {
let module = Cu.getGlobalForObject ? Cu.getGlobalForObject(params) : params.__parent__; let module = Cu.getGlobalForObject ? Cu.getGlobalForObject(params) : params.__parent__;
defineModule.globals.push(module); JSMLoader.registerGlobal(Components.stack.caller.filename, module);
module.NAME = name; module.NAME = name;
module.EXPORTED_SYMBOLS = params.exports || []; module.EXPORTED_SYMBOLS = params.exports || [];
defineModule.loadLog.push("defineModule " + name); defineModule.loadLog.push("defineModule " + name);
@@ -115,7 +155,6 @@ function defineModule(name, params) {
currentModule = module; currentModule = module;
} }
defineModule.globals = [];
defineModule.loadLog = []; defineModule.loadLog = [];
Object.defineProperty(defineModule.loadLog, "push", { Object.defineProperty(defineModule.loadLog, "push", {
value: function (val) { defineModule.dump(val + "\n"); this[this.length] = val; } value: function (val) { defineModule.dump(val + "\n"); this[this.length] = val; }
@@ -162,7 +201,7 @@ function endModule() {
function require(obj, name, from) { function require(obj, name, from) {
try { try {
defineModule.loadLog.push((from || "require") + ": loading " + name + " into " + obj.NAME); defineModule.loadLog.push((from || "require") + ": loading " + name + " into " + obj.NAME);
Cu.import("resource://dactyl/" + name + ".jsm", obj); JSMLoader.load("resource://dactyl/" + name + ".jsm", obj);
} }
catch (e) { catch (e) {
defineModule.dump("loading " + String.quote("resource://dactyl/" + name + ".jsm") + "\n"); defineModule.dump("loading " + String.quote("resource://dactyl/" + name + ".jsm") + "\n");
@@ -176,7 +215,7 @@ function require(obj, name, from) {
defineModule("base", { defineModule("base", {
// sed -n 's/^(const|function) ([a-zA-Z0-9_]+).*/ "\2",/p' base.jsm | sort | fmt // sed -n 's/^(const|function) ([a-zA-Z0-9_]+).*/ "\2",/p' base.jsm | sort | fmt
exports: [ exports: [
"ErrorBase", "Cc", "Ci", "Class", "Cr", "Cu", "Module", "Object", "Runnable", "ErrorBase", "Cc", "Ci", "Class", "Cr", "Cu", "Module", "JSMLoader", "Object", "Runnable",
"Struct", "StructBase", "Timer", "UTF8", "XPCOM", "XPCOMUtils", "array", "Struct", "StructBase", "Timer", "UTF8", "XPCOM", "XPCOMUtils", "array",
"call", "callable", "ctypes", "curry", "debuggerProperties", "defineModule", "call", "callable", "ctypes", "curry", "debuggerProperties", "defineModule",
"deprecated", "endModule", "forEach", "isArray", "isGenerator", "deprecated", "endModule", "forEach", "isArray", "isGenerator",
@@ -478,7 +517,7 @@ function isSubclass(targ, src) {
* @param {object|string|[object|string]} src The types to check targ against. * @param {object|string|[object|string]} src The types to check targ against.
* @returns {boolean} * @returns {boolean}
*/ */
const isinstance_types = { var isinstance_types = {
boolean: Boolean, boolean: Boolean,
string: String, string: String,
function: Function, function: Function,
@@ -513,7 +552,7 @@ function isObject(obj) typeof obj === "object" && obj != null || obj instanceof
* any window, frame, namespace, or execution context, which * any window, frame, namespace, or execution context, which
* is not the case when using (obj instanceof Array). * is not the case when using (obj instanceof Array).
*/ */
const isArray = var isArray =
Array.isArray Array.isArray
// This is bloody stupid. // This is bloody stupid.
? function isArray(val) Array.isArray(val) || val && val.constructor && val.constructor.name === "Array" ? function isArray(val) Array.isArray(val) || val && val.constructor && val.constructor.name === "Array"
@@ -617,7 +656,7 @@ sandbox.__proto__ = this;
* is prepended to its arguments. * is prepended to its arguments.
*/ */
// Hack to get around lack of access to caller in strict mode. // Hack to get around lack of access to caller in strict mode.
const withCallerGlobal = Cu.evalInSandbox(<![CDATA[ var withCallerGlobal = Cu.evalInSandbox(<![CDATA[
(function withCallerGlobal(fn) (function withCallerGlobal(fn)
function withCallerGlobal_wrapped() function withCallerGlobal_wrapped()
fn.apply(this, fn.apply(this,
@@ -860,7 +899,7 @@ function XPCOM(interfaces, superClass) {
/** /**
* An abstract base class for classes that wish to inherit from Error. * An abstract base class for classes that wish to inherit from Error.
*/ */
const ErrorBase = Class("ErrorBase", Error, { var ErrorBase = Class("ErrorBase", Error, {
level: 2, level: 2,
init: function (message, level) { init: function (message, level) {
level = level || 0; level = level || 0;
@@ -980,7 +1019,7 @@ let StructBase = Class("StructBase", Array, {
} }
}); });
const Timer = Class("Timer", { var Timer = Class("Timer", {
init: function (minInterval, maxInterval, callback) { init: function (minInterval, maxInterval, callback) {
this._timer = services.Timer(); this._timer = services.Timer();
this.callback = callback; this.callback = callback;
@@ -1056,7 +1095,7 @@ function octal(decimal) parseInt(decimal, 8);
/** /**
* Array utility methods. * Array utility methods.
*/ */
const array = Class("array", Array, { var array = Class("array", Array, {
init: function (ary) { init: function (ary) {
if (isinstance(ary, ["Iterator", "Generator"]) || "__iterator__" in ary) if (isinstance(ary, ["Iterator", "Generator"]) || "__iterator__" in ary)
ary = [k for (k in ary)]; ary = [k for (k in ary)];

View File

@@ -10,8 +10,8 @@ defineModule("bookmarkcache", {
require: ["services", "storage", "util"] require: ["services", "storage", "util"]
}); });
const Bookmark = Struct("url", "title", "icon", "post", "keyword", "tags", "id"); var Bookmark = Struct("url", "title", "icon", "post", "keyword", "tags", "id");
const Keyword = Struct("keyword", "title", "icon", "url"); var Keyword = Struct("keyword", "title", "icon", "url");
Bookmark.defaultValue("icon", function () BookmarkCache.getFavicon(this.url)); Bookmark.defaultValue("icon", function () BookmarkCache.getFavicon(this.url));
Bookmark.setter = function (key, func) this.prototype.__defineSetter__(key, func); Bookmark.setter = function (key, func) this.prototype.__defineSetter__(key, func);
Bookmark.prototype.__defineGetter__("extra", function () [ Bookmark.prototype.__defineGetter__("extra", function () [
@@ -33,9 +33,9 @@ Bookmark.setter("tags", function (val) {
services.tagging.tagURI(this.uri, val); services.tagging.tagURI(this.uri, val);
}); });
const name = "bookmark-cache"; var name = "bookmark-cache";
const BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), { var BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), {
POST: "bookmarkProperties/POSTData", POST: "bookmarkProperties/POSTData",
init: function init() { init: function init() {

View File

@@ -11,7 +11,7 @@ defineModule("highlight", {
use: ["template", "util"] use: ["template", "util"]
}); });
const Highlight = Struct("class", "selector", "sites", var Highlight = Struct("class", "selector", "sites",
"default", "value", "agent", "default", "value", "agent",
"base", "baseClass", "style"); "base", "baseClass", "style");
Highlight.liveProperty = function (name, prop) { Highlight.liveProperty = function (name, prop) {
@@ -52,7 +52,7 @@ Highlight.prototype.toString = function ()
* *
* @author Kris Maglione <maglione.k@gmail.com> * @author Kris Maglione <maglione.k@gmail.com>
*/ */
const Highlights = Module("Highlight", { var Highlights = Module("Highlight", {
init: function () { init: function () {
this.highlight = {}; this.highlight = {};
this.loaded = {}; this.loaded = {};

View File

@@ -14,7 +14,7 @@ defineModule("overlay", {
* @class ModuleBase * @class ModuleBase
* The base class for all modules. * The base class for all modules.
*/ */
const ModuleBase = Class("ModuleBase", { var ModuleBase = Class("ModuleBase", {
/** /**
* @property {[string]} A list of module prerequisites which * @property {[string]} A list of module prerequisites which
* must be initialized before this module is loaded. * must be initialized before this module is loaded.
@@ -24,7 +24,7 @@ const ModuleBase = Class("ModuleBase", {
toString: function () "[module " + this.constructor.className + "]" toString: function () "[module " + this.constructor.className + "]"
}); });
const Overlay = Module("Overlay", { var Overlay = Module("Overlay", {
init: function () { init: function () {
util.overlayWindow("chrome://browser/content/browser.xul", function (window) ({ util.overlayWindow("chrome://browser/content/browser.xul", function (window) ({
init: function (document) { init: function (document) {

View File

@@ -13,7 +13,7 @@ defineModule("prefs", {
use: ["template"] use: ["template"]
}); });
const Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), { var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
SAVED: "extensions.dactyl.saved.", SAVED: "extensions.dactyl.saved.",
RESTORE: "extensions.dactyl.restore.", RESTORE: "extensions.dactyl.restore.",

View File

@@ -24,7 +24,7 @@ let tmp = {};
services.subscriptLoader.loadSubScript("chrome://browser/content/sanitize.js", tmp); services.subscriptLoader.loadSubScript("chrome://browser/content/sanitize.js", tmp);
tmp.Sanitizer.prototype.__proto__ = Class.prototype; tmp.Sanitizer.prototype.__proto__ = Class.prototype;
const Range = Struct("min", "max"); var Range = Struct("min", "max");
Range.prototype.contains = function (date) Range.prototype.contains = function (date)
date == null || (this.min == null || date >= this.min) && (this.max == null || date <= this.max); date == null || (this.min == null || date >= this.min) && (this.max == null || date <= this.max);
Range.prototype.__defineGetter__("isEternity", function () this.max == null && this.min == null); Range.prototype.__defineGetter__("isEternity", function () this.max == null && this.min == null);
@@ -33,7 +33,7 @@ Range.prototype.__defineGetter__("native", function ()
this.isEternity ? null : [range.min || 0, range.max == null ? Number.MAX_VALUE : range.max]); this.isEternity ? null : [range.min || 0, range.max == null ? Number.MAX_VALUE : range.max]);
const Item = Class("Item", { var Item = Class("Item", {
init: function (name) { init: function (name) {
this.name = name; this.name = name;
}, },
@@ -55,7 +55,7 @@ const Item = Class("Item", {
SHUTDOWN_BRANCH: "privacy.clearOnShutdown." SHUTDOWN_BRANCH: "privacy.clearOnShutdown."
}); });
const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference], tmp.Sanitizer), { var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference], tmp.Sanitizer), {
sessionStart: Date.now() * 1000, sessionStart: Date.now() * 1000,
init: function () { init: function () {

View File

@@ -14,7 +14,7 @@ defineModule("services", {
/** /**
* A lazily-instantiated XPCOM class and service cache. * A lazily-instantiated XPCOM class and service cache.
*/ */
const Services = Module("Services", { var Services = Module("Services", {
init: function () { init: function () {
this.classes = {}; this.classes = {};
this.services = {}; this.services = {};

View File

@@ -7,14 +7,14 @@
if (this.XPCSafeJSObjectWrapper == null) if (this.XPCSafeJSObjectWrapper == null)
this.XPCSafeJSObjectWrapper = XPCNativeWrapper; this.XPCSafeJSObjectWrapper = XPCNativeWrapper;
const myObject = Object; var myObject = Object;
Components.utils.import("resource://dactyl/base.jsm"); Components.utils.import("resource://dactyl/base.jsm");
defineModule("storage", { defineModule("storage", {
exports: ["File", "storage"], exports: ["File", "storage"],
require: ["services", "util"] require: ["services", "util"]
}); });
const win32 = /^win(32|nt)$/i.test(services.runtime.OS); var win32 = /^win(32|nt)$/i.test(services.runtime.OS);
function loadData(name, store, type) { function loadData(name, store, type) {
try { try {
@@ -33,7 +33,7 @@ function saveData(obj) {
storage.infoPath.child(obj.name).write(obj.serial); storage.infoPath.child(obj.name).write(obj.serial);
} }
const StoreBase = Class("StoreBase", { var StoreBase = Class("StoreBase", {
OPTIONS: ["privateData", "replacer"], OPTIONS: ["privateData", "replacer"],
fireEvent: function (event, arg) { storage.fireEvent(this.name, event, arg); }, fireEvent: function (event, arg) { storage.fireEvent(this.name, event, arg); },
@@ -61,7 +61,7 @@ const StoreBase = Class("StoreBase", {
save: function () { saveData(this); }, save: function () { saveData(this); },
}); });
const ArrayStore = Class("ArrayStore", StoreBase, { var ArrayStore = Class("ArrayStore", StoreBase, {
_constructor: Array, _constructor: Array,
get length() this._object.length, get length() this._object.length,
@@ -107,7 +107,7 @@ const ArrayStore = Class("ArrayStore", StoreBase, {
__iterator__: function () Iterator(this._object), __iterator__: function () Iterator(this._object),
}); });
const ObjectStore = Class("ObjectStore", StoreBase, { var ObjectStore = Class("ObjectStore", StoreBase, {
_constructor: myObject, _constructor: myObject,
clear: function () { clear: function () {
@@ -142,7 +142,7 @@ const ObjectStore = Class("ObjectStore", StoreBase, {
__iterator__: function () Iterator(this._object), __iterator__: function () Iterator(this._object),
}); });
const Storage = Module("Storage", { var Storage = Module("Storage", {
alwaysReload: {}, alwaysReload: {},
init: function () { init: function () {
@@ -269,7 +269,7 @@ const Storage = Module("Storage", {
* @param {boolean} checkPWD Whether to allow expansion relative to the * @param {boolean} checkPWD Whether to allow expansion relative to the
* current directory. @default true * current directory. @default true
*/ */
const File = Class("File", { var File = Class("File", {
init: function (path, checkPWD) { init: function (path, checkPWD) {
let file = services.File(); let file = services.File();

View File

@@ -12,11 +12,11 @@ defineModule("styles", {
}); });
function cssUri(css) "chrome-data:text/css," + encodeURI(css); function cssUri(css) "chrome-data:text/css," + encodeURI(css);
const namespace = "@namespace html " + XHTML.uri.quote() + ";\n" + var namespace = "@namespace html " + XHTML.uri.quote() + ";\n" +
"@namespace xul " + XUL.uri.quote() + ";\n" + "@namespace xul " + XUL.uri.quote() + ";\n" +
"@namespace dactyl " + NS.uri.quote() + ";\n"; "@namespace dactyl " + NS.uri.quote() + ";\n";
const Sheet = Struct("name", "id", "sites", "css", "hive", "agent"); var Sheet = Struct("name", "id", "sites", "css", "hive", "agent");
Sheet.liveProperty = function (name) { Sheet.liveProperty = function (name) {
let i = this.prototype.members[name]; let i = this.prototype.members[name];
this.prototype.__defineGetter__(name, function () this[i]); this.prototype.__defineGetter__(name, function () this[i]);
@@ -73,7 +73,7 @@ update(Sheet.prototype, {
} }
}); });
const Hive = Class("Hive", { var Hive = Class("Hive", {
init: function () { init: function () {
this.sheets = []; this.sheets = [];
this.names = {}; this.names = {};
@@ -212,7 +212,7 @@ const Hive = Class("Hive", {
* *
* @author Kris Maglione <maglione.k@gmail.com> * @author Kris Maglione <maglione.k@gmail.com>
*/ */
const Styles = Module("Styles", { var Styles = Module("Styles", {
init: function () { init: function () {
this._id = 0; this._id = 0;
this.user = Hive(); this.user = Hive();

View File

@@ -13,7 +13,7 @@ defineModule("template", {
default xml namespace = XHTML; default xml namespace = XHTML;
const Template = Module("Template", { var Template = Module("Template", {
add: function add(a, b) a + b, add: function add(a, b) a + b,
join: function join(c) function (a, b) a + c + b, join: function join(c) function (a, b) a + c + b,

View File

@@ -15,10 +15,10 @@ defineModule("util", {
use: ["highlight", "storage", "template"] use: ["highlight", "storage", "template"]
}); });
const XBL = Namespace("xbl", "http://www.mozilla.org/xbl"); var XBL = Namespace("xbl", "http://www.mozilla.org/xbl");
const XHTML = Namespace("html", "http://www.w3.org/1999/xhtml"); var XHTML = Namespace("html", "http://www.w3.org/1999/xhtml");
const XUL = Namespace("xul", "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); var XUL = Namespace("xul", "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
const NS = Namespace("dactyl", "http://vimperator.org/namespaces/liberator"); var NS = Namespace("dactyl", "http://vimperator.org/namespaces/liberator");
default xml namespace = XHTML; default xml namespace = XHTML;
memoize(this, "Commands", function () { memoize(this, "Commands", function () {
@@ -28,7 +28,7 @@ memoize(this, "Commands", function () {
return obj.Commands; return obj.Commands;
}); });
const FailedAssertion = Class("FailedAssertion", ErrorBase); var FailedAssertion = Class("FailedAssertion", ErrorBase);
function wrapCallback(fn) function wrapCallback(fn)
fn.wrapper = function wrappedCallback () { fn.wrapper = function wrappedCallback () {
@@ -41,7 +41,7 @@ function wrapCallback(fn)
} }
} }
const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), { var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
init: function () { init: function () {
this.Array = array; this.Array = array;
@@ -920,6 +920,9 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
services.observer.removeObserver(this, "dactyl-rehash"); services.observer.removeObserver(this, "dactyl-rehash");
util.dump("dactyl: util: observe: dactyl-rehash"); util.dump("dactyl: util: observe: dactyl-rehash");
if (true)
JSMLoader.purge();
else
for (let module in values(defineModule.modules)) { for (let module in values(defineModule.modules)) {
util.dump("dactyl: util: init(" + module + ")"); util.dump("dactyl: util: init(" + module + ")");
if (module.reinit) if (module.reinit)
@@ -1427,7 +1430,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
* Math utility methods. * Math utility methods.
* @singleton * @singleton
*/ */
const GlobalMath = Math; var GlobalMath = Math;
var Math = update(Object.create(GlobalMath), { var Math = update(Object.create(GlobalMath), {
/** /**
* Returns the specified *value* constrained to the range *min* - *max*. * Returns the specified *value* constrained to the range *min* - *max*.