diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 1ea54a8d..fe375905 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -25,16 +25,16 @@ const FailedAssertion = Class("FailedAssertion", Error, { } }); -deprecated.seen = { "chrome://dactyl/content/javascript.js": true }; -function deprecated(reason, fn) +function deprecated(reason, fn) update( function deprecatedMethod() { let frame = Components.stack.caller; - if (!set.add(deprecated.seen, frame.filename)) + if (!set.add(deprecatedMethod.seen, frame.filename)) dactyl.echoerr(frame.filename + ":" + frame.lineNumber + ": " + (this.className || this.constructor.className) + "." + fn.name + " is deprecated: " + reason); return fn.apply(this, arguments); - } + }, + { seen: { "chrome://dactyl/content/javascript.js": true } }); const Dactyl = Module("dactyl", { init: function () { diff --git a/common/content/io.js b/common/content/io.js index 6660ecac..efab3aa7 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -345,13 +345,15 @@ lookup: dactyl.helpInitialized = false; } catch (e) { - if (isString(e)) - e = { message: e }; - let err = new Error(); - for (let [k, v] in Iterator(e)) - err[k] = v; - err.echoerr = <>{file.path}:{e.lineNumber}: {e}; - throw err; + if (e.fileName) + try { + e.fileName = e.fileName.replace(/^(chrome|resource):.*? -> /, ""); + if (e.fileName == uri.spec) + e.fileName = filename; + e.echoerr = <>{e.fileName}:{e.lineNumber}: {e} + } + catch (e) {} + throw e; } } else if (/\.css$/.test(filename)) diff --git a/common/content/javascript.js b/common/content/javascript.js index c5c6cd19..c0d30380 100644 --- a/common/content/javascript.js +++ b/common/content/javascript.js @@ -358,8 +358,6 @@ const JavaScript = Module("javascript", { } let args = { - completer: compl, - anchored: true, filter: last == null ? key : string, last: last, prefix: last != null ? key : "" @@ -369,39 +367,42 @@ const JavaScript = Module("javascript", { // TODO: Make this a generic completion helper function. for (let [, obj] in Iterator(objects)) this.context.fork(obj[1], this._top.offset, this, this._fill, - update({}, args, { + update({ obj: obj[0], - name: obj[1] - })); + name: obj[1], + anchored: true, + completer: compl + }, args)); if (orig) return; for (let [, obj] in Iterator(objects)) this.context.fork(obj[1] + "/prototypes", this._top.offset, this, this._fill, - update({}, args, { + update({ obj: obj[0], name: obj[1] + " (prototypes)", + anchored: true, completer: function (a, b) compl(a, b, true) - })); + }, args)); for (let [, obj] in Iterator(objects)) this.context.fork(obj[1] + "/substrings", this._top.offset, this, this._fill, - update({}, args, { + update({ obj: obj[0], name: obj[1] + " (substrings)", anchored: false, completer: compl - })); + }, args)); for (let [, obj] in Iterator(objects)) this.context.fork(obj[1] + "/prototypes/substrings", this._top.offset, this, this._fill, - update({}, args, { + update({ obj: obj[0], name: obj[1] + " (prototype substrings)", anchored: false, completer: function (a, b) compl(a, b, true) - })); + }, args)); }, _getKey: function () { diff --git a/common/modules/base.jsm b/common/modules/base.jsm index 33635641..9b360ba8 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -10,6 +10,11 @@ const Cr = Components.results; const Cu = Components.utils; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +try { + var ctypes; + Components.utils.import("resource://gre/modules/ctypes.jsm"); +} +catch (e) {} let objproto = Object.prototype; let hasOwnProperty = objproto.hasOwnProperty; @@ -149,7 +154,7 @@ defineModule("base", { exports: [ "Cc", "Ci", "Class", "Cr", "Cu", "Module", "Object", "Runnable", "Struct", "StructBase", "Timer", "UTF8", "XPCOM", "XPCOMUtils", "array", - "call", "callable", "curry", "debuggerProperties", "defineModule", + "call", "callable", "ctypes", "curry", "debuggerProperties", "defineModule", "endModule", "forEach", "isArray", "isGenerator", "isinstance", "isObject", "isString", "isSubclass", "iter", "iterAll", "keys", "memoize", "properties", "requiresMainThread", "set", "update", "values" @@ -356,6 +361,20 @@ set.remove = function (set, key) { * @returns {Generator} */ function iter(obj) { + if (ctypes && obj instanceof ctypes.CData) { + while (obj.constructor instanceof ctypes.PointerType) + obj = obj.contents; + if (obj.constructor instanceof ctypes.ArrayType) + return array.iterItems(obj); + if (obj.constructor instanceof ctypes.StructType) + return (function () { + for (let prop in values(obj.constructor.fields)) + let ([name, type] = Iterator(prop).next()) { + yield [name, obj[name]]; + } + })(); + obj = {}; + } if (isinstance(obj, [Ci.nsIDOMHTMLCollection, Ci.nsIDOMNodeList])) return array.iterItems(obj); if (obj instanceof Ci.nsIDOMNamedNodeMap)