1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-14 18:35:47 +01:00

[bootstrap] Merge default.

--HG--
branch : bootstrapped
This commit is contained in:
Kris Maglione
2010-12-25 06:58:27 -05:00
4 changed files with 48 additions and 26 deletions

View File

@@ -8,11 +8,7 @@
/** @scope modules */ /** @scope modules */
let ValueError = Class("ValueError", Error, { let ValueError = Class("ValueError", ErrorBase);
init: function (message) {
update(this, Error(message));
}
});
// do NOT create instances of this class yourself, use the helper method // do NOT create instances of this class yourself, use the helper method
// options.add() instead // options.add() instead

View File

@@ -176,7 +176,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: [
"Cc", "Ci", "Class", "Cr", "Cu", "Module", "Object", "Runnable", "ErrorBase", "Cc", "Ci", "Class", "Cr", "Cu", "Module", "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",
@@ -857,6 +857,26 @@ function XPCOM(interfaces, superClass) {
return res; return res;
} }
/**
* An abstract base class for classes that wish to inherit from Error.
*/
const ErrorBase = Class("ErrorBase", Error, {
level: 2,
init: function (message, level) {
level = level || 0;
update(this, Error(message))
this.message = message;
let frame = Components.stack;
for (let i = 0; i < this.level + level; i++) {
frame = frame.caller;
this.stack = this.stack.replace(/^.*\n/, "");
}
this.fileName = frame.filename;
this.lineNumber = frame.lineNumber;
}
});
/** /**
* Constructs a new Module class and instantiates an instance into the current * Constructs a new Module class and instantiates an instance into the current
* module global object. * module global object.

View File

@@ -356,17 +356,39 @@ const Styles = Module("Styles", {
}, { }, {
commands: function (dactyl, modules, window) { commands: function (dactyl, modules, window) {
const commands = modules.commands; const commands = modules.commands;
const queue = [];
const timer = Timer(10, 10, function () {
let args = queue.shift()
let [filter, css] = args;
if ("-append" in args) {
let sheet = styles.user.get(args["-name"]);
if (sheet) {
filter = sheet.sites.concat(filter).join(",");
css = sheet.css + " " + css;
}
}
styles.user.add(args["-name"], filter, css, args["-agent"]);
if (queue.length)
timer.tell();
});
commands.add(["sty[le]"], commands.add(["sty[le]"],
"Add or list user styles", "Add or list user styles",
function (args) { function (args) {
let [filter, css] = args; let [filter, css] = args;
let name = args["-name"];
if (!css) { if (css) {
queue.push(args);
timer.tell(args);
}
else {
let list = styles.user.sheets.slice() let list = styles.user.sheets.slice()
.sort(function (a, b) a.name && b.name ? String.localeCompare(a.name, b.name) .sort(function (a, b) a.name && b.name ? String.localeCompare(a.name, b.name)
: !!b.name - !!a.name || a.id - b.id); : !!b.name - !!a.name || a.id - b.id);
let uris = util.visibleURIs(window.content); let uris = util.visibleURIs(window.content);
let name = args["-name"];
modules.commandline.commandOutput( modules.commandline.commandOutput(
template.tabular(["", "Name", "Filter", "CSS"], template.tabular(["", "Name", "Filter", "CSS"],
["min-width: 1em; text-align: center; color: red; font-weight: bold;", ["min-width: 1em; text-align: center; color: red; font-weight: bold;",
@@ -379,17 +401,6 @@ const Styles = Module("Styles", {
for (sheet in values(list)) for (sheet in values(list))
if ((!filter || sheet.sites.indexOf(filter) >= 0) && (!name || sheet.name == name))))); if ((!filter || sheet.sites.indexOf(filter) >= 0) && (!name || sheet.name == name)))));
} }
else {
if ("-append" in args) {
let sheet = styles.user.get(name);
if (sheet) {
filter = sheet.sites.concat(filter).join(",");
css = sheet.css + " " + css;
}
}
styles.user.add(name, filter, css, args["-agent"]);
}
}, },
{ {
bang: true, bang: true,

View File

@@ -28,12 +28,7 @@ memoize(this, "Commands", function () {
return obj.Commands; return obj.Commands;
}); });
const FailedAssertion = Class("FailedAssertion", Error, { const FailedAssertion = Class("FailedAssertion", ErrorBase);
init: function (message) {
update(this, Error(message))
this.message = message;
}
});
function wrapCallback(fn) function wrapCallback(fn)
fn.wrapper = function wrappedCallback () { fn.wrapper = function wrappedCallback () {
@@ -126,7 +121,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
*/ */
assert: function (condition, message) { assert: function (condition, message) {
if (!condition) if (!condition)
throw FailedAssertion(message); throw FailedAssertion(message, 1);
}, },
get chromePackages() { get chromePackages() {