mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-03 19:05:47 +01:00
Add array indexing to macro-string processing. Checkin Minefield crash workaround that was supposed to have been checked in yesterday.
This commit is contained in:
@@ -77,6 +77,13 @@
|
||||
the form of <tt><e-<a>name</a>></tt>, its value is never shown but may be
|
||||
used to test whether the given parameter is empty.
|
||||
</p>
|
||||
<p>
|
||||
Array elements, such as in the the <tt><args></tt> parameter
|
||||
of <ex>:command</ex> macros, may be accessed by appending
|
||||
<tt>[<a>n</a>]</tt>, where <a>n</a> is the one-based array
|
||||
index, to the macro name. The first argument of a command is
|
||||
therefore accessed with <tt><args[1]<</tt>.
|
||||
</p>
|
||||
<p>
|
||||
Any substring enclosed by <em><tt><{</tt></em> and <em><tt>}></tt></em>
|
||||
is automatically elided if any of the contained macros aren't currently
|
||||
|
||||
@@ -716,18 +716,28 @@ function Class() {
|
||||
if (callable(args[0]))
|
||||
superclass = args.shift();
|
||||
|
||||
var Constructor = eval(String.replace(<![CDATA[
|
||||
(function constructor(PARAMS) {
|
||||
if (loaded.util && util.haveGecko("6.0a1")) // Bug 657418.
|
||||
var Constructor = function Constructor() {
|
||||
var self = Object.create(Constructor.prototype, {
|
||||
constructor: { value: Constructor },
|
||||
});
|
||||
self.instance = self;
|
||||
var res = self.init.apply(self, arguments);
|
||||
return res !== undefined ? res : self;
|
||||
})]]>,
|
||||
"constructor", (name || superclass.className).replace(/\W/g, "_"))
|
||||
.replace("PARAMS", /^function .*?\((.*?)\)/.exec(args[0] && args[0].init || Class.prototype.init)[1]
|
||||
.replace(/\b(self|res|Constructor)\b/g, "$1_")));
|
||||
};
|
||||
else
|
||||
var Constructor = eval(String.replace(<![CDATA[
|
||||
(function constructor(PARAMS) {
|
||||
var self = Object.create(Constructor.prototype, {
|
||||
constructor: { value: Constructor },
|
||||
});
|
||||
self.instance = self;
|
||||
var res = self.init.apply(self, arguments);
|
||||
return res !== undefined ? res : self;
|
||||
})]]>,
|
||||
"constructor", (name || superclass.className).replace(/\W/g, "_"))
|
||||
.replace("PARAMS", /^function .*?\((.*?)\)/.exec(args[0] && args[0].init || Class.prototype.init)[1]
|
||||
.replace(/\b(self|res|Constructor)\b/g, "$1_")));
|
||||
|
||||
Constructor.className = name || superclass.className || superclass.name;
|
||||
|
||||
|
||||
@@ -356,14 +356,14 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
([^]*?) // 1
|
||||
(?:
|
||||
(<\{) | // 2
|
||||
(< ((?:[a-z]-)?[a-z-]+?) >) | // 3 4
|
||||
(\}>) // 5
|
||||
(< ((?:[a-z]-)?[a-z-]+?) (?:\[([0-9]+)\])? >) | // 3 4 5
|
||||
(\}>) // 6
|
||||
)
|
||||
]]>, "gixy");
|
||||
macro = String(macro);
|
||||
let end = 0;
|
||||
for (let match in re.iterate(macro)) {
|
||||
let [, prefix, open, full, macro, close] = match;
|
||||
let [, prefix, open, full, macro, idx, close] = match;
|
||||
end += match[0].length;
|
||||
|
||||
if (prefix)
|
||||
@@ -390,9 +390,17 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
if (set.has(defaults, name))
|
||||
stack.top.elements.push(quote(defaults[name]));
|
||||
else {
|
||||
stack.top.elements.push(update(
|
||||
function (obj) obj[name] != null ? quote(obj[name]) : set.has(obj, name) ? "" : unknown(full),
|
||||
{ test: function (obj) obj[name] != null && obj[name] !== false && (!flags.e || obj[name] != "") }));
|
||||
if (idx) {
|
||||
idx = Number(idx) - 1;
|
||||
stack.top.elements.push(update(
|
||||
function (obj) obj[name] != null && idx in obj[name] ? quote(obj[name][idx]) : set.has(obj, name) ? "" : unknown(full),
|
||||
{ test: function (obj) obj[name] != null && idx in obj[name] && obj[name][idx] !== false && (!flags.e || obj[name][idx] != "") }));
|
||||
}
|
||||
else {
|
||||
stack.top.elements.push(update(
|
||||
function (obj) obj[name] != null ? quote(obj[name]) : set.has(obj, name) ? "" : unknown(full),
|
||||
{ test: function (obj) obj[name] != null && obj[name] !== false && (!flags.e || obj[name] != "") }));
|
||||
}
|
||||
|
||||
for (let elem in array.iterValues(stack))
|
||||
elem.seen[name] = true;
|
||||
@@ -1252,7 +1260,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
delete desc.writable;
|
||||
desc.get = function get() value;
|
||||
desc.set = function set(val) {
|
||||
if (String(val).indexOf(sentinel) < 0)
|
||||
if (!callable(val) || Function.prototype.toString(val).indexOf(sentinel) < 0)
|
||||
Class.replaceProperty(this, k, val);
|
||||
else {
|
||||
let package_ = util.newURI(util.fixURI(Components.stack.caller.filename)).host;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<Description
|
||||
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
|
||||
em:minVersion="3.6"
|
||||
em:maxVersion="6.*"/>
|
||||
em:maxVersion="7.*"/>
|
||||
</em:targetApplication>
|
||||
</Description>
|
||||
</RDF>
|
||||
|
||||
Reference in New Issue
Block a user