mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-24 03:52:26 +01:00
Fix prefixing of dump messages from base.jsm.
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
sandbox.__proto__ = proto || modules;
|
sandbox.__proto__ = proto || modules;
|
||||||
return sandbox;
|
return sandbox;
|
||||||
}
|
}
|
||||||
const jsmodules = {};
|
const jsmodules = { dump: function dump_(arg) window.dump("dactyl: " + arg + "\n") };
|
||||||
const modules = {
|
const modules = {
|
||||||
__proto__: jsmodules,
|
__proto__: jsmodules,
|
||||||
get content() window.content,
|
get content() window.content,
|
||||||
|
|||||||
@@ -112,7 +112,19 @@ function defineModule(name, params) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defineModule.loadLog = [];
|
defineModule.loadLog = [];
|
||||||
Object.defineProperty(defineModule.loadLog, "push", { value: function (val) { dump(val + "\n"); this[this.length] = val; } });
|
Object.defineProperty(defineModule.loadLog, "push", {
|
||||||
|
value: function (val) { defineModule.dump(val + "\n"); this[this.length] = val; }
|
||||||
|
});
|
||||||
|
defineModule.dump = function dump_() {
|
||||||
|
let msg = Array.map(arguments, function (msg) {
|
||||||
|
if (loaded.util && typeof msg == "object")
|
||||||
|
msg = util.objectToString(msg);
|
||||||
|
return msg;
|
||||||
|
}).join(", ");
|
||||||
|
let name = loaded.services ? services.get("dactyl:").name : "dactyl";
|
||||||
|
dump(String.replace(msg, /\n?$/, "\n")
|
||||||
|
.replace(/^./gm, name + ": $&"));
|
||||||
|
}
|
||||||
defineModule.modules = [];
|
defineModule.modules = [];
|
||||||
defineModule.times = { all: 0 };
|
defineModule.times = { all: 0 };
|
||||||
defineModule.time = function time(major, minor, func, self) {
|
defineModule.time = function time(major, minor, func, self) {
|
||||||
@@ -130,9 +142,9 @@ defineModule.time = function time(major, minor, func, self) {
|
|||||||
|
|
||||||
function endModule() {
|
function endModule() {
|
||||||
defineModule.loadLog.push("endModule " + currentModule.NAME);
|
defineModule.loadLog.push("endModule " + currentModule.NAME);
|
||||||
loaded[currentModule.NAME] = 1;
|
|
||||||
for(let [, mod] in Iterator(use[currentModule.NAME] || []))
|
for(let [, mod] in Iterator(use[currentModule.NAME] || []))
|
||||||
require(mod, currentModule.NAME, "use");
|
require(mod, currentModule.NAME, "use");
|
||||||
|
loaded[currentModule.NAME] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function require(obj, name, from) {
|
function require(obj, name, from) {
|
||||||
@@ -141,11 +153,11 @@ function require(obj, name, from) {
|
|||||||
Cu.import("resource://dactyl/" + name + ".jsm", obj);
|
Cu.import("resource://dactyl/" + name + ".jsm", obj);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
dump("loading " + String.quote("resource://dactyl/" + name + ".jsm") + "\n");
|
defineModule.dump("loading " + String.quote("resource://dactyl/" + name + ".jsm") + "\n");
|
||||||
if (loaded.util)
|
if (loaded.util)
|
||||||
util.reportError(e);
|
util.reportError(e);
|
||||||
else
|
else
|
||||||
dump(" " + e.fileName + ":" + e.lineNumber + ": " + e +"\n");
|
defineModule.dump(" " + e.fileName + ":" + e.lineNumber + ": " + e +"\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,10 +177,10 @@ defineModule("base", {
|
|||||||
function Runnable(self, func, args) {
|
function Runnable(self, func, args) {
|
||||||
return {
|
return {
|
||||||
__proto__: Runnable.prototype,
|
__proto__: Runnable.prototype,
|
||||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIRunnable]),
|
|
||||||
run: function () { func.apply(self, args || []); }
|
run: function () { func.apply(self, args || []); }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Runnable.prototype.QueryInterface = XPCOMUtils.generateQI([Ci.nsIRunnable]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all of the top-level properties of an object, by
|
* Returns a list of all of the top-level properties of an object, by
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
// This work is licensed for reuse under an MIT license. Details are
|
// This work is licensed for reuse under an MIT license. Details are
|
||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
"use strict";
|
"use strict";
|
||||||
|
try {
|
||||||
Components.utils.import("resource://dactyl/base.jsm");
|
Components.utils.import("resource://dactyl/base.jsm");
|
||||||
defineModule("services", {
|
defineModule("services", {
|
||||||
exports: ["Services", "services"],
|
exports: ["Services", "services"],
|
||||||
@@ -136,6 +136,6 @@ const Services = Module("Services", {
|
|||||||
|
|
||||||
endModule();
|
endModule();
|
||||||
|
|
||||||
// catch(e){dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack);}
|
} catch(e){dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack);}
|
||||||
|
|
||||||
// vim: set fdm=marker sw=4 sts=4 et ft=javascript:
|
// vim: set fdm=marker sw=4 sts=4 et ft=javascript:
|
||||||
|
|||||||
@@ -231,15 +231,7 @@ const Util = Module("Util", {
|
|||||||
*
|
*
|
||||||
* @param {string|Object} msg The message to print.
|
* @param {string|Object} msg The message to print.
|
||||||
*/
|
*/
|
||||||
dump: function dump_() {
|
dump: defineModule.dump,
|
||||||
let msg = Array.map(arguments, function (msg) {
|
|
||||||
if (typeof msg == "object")
|
|
||||||
msg = util.objectToString(msg);
|
|
||||||
return msg;
|
|
||||||
}).join(", ");
|
|
||||||
msg = String.replace(msg, /\n?$/, "\n");
|
|
||||||
dump(msg.replace(/^./gm, services.get("dactyl:").name + ": $&"));
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dumps a stack trace to the console.
|
* Dumps a stack trace to the console.
|
||||||
|
|||||||
Reference in New Issue
Block a user