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

Normalise use of "res" vs "ret" for return variables.

This commit is contained in:
Doug Kearns
2011-03-07 21:41:07 +11:00
parent 7bf3f40ab0
commit 1c4c5e5ad3
6 changed files with 46 additions and 47 deletions

View File

@@ -230,9 +230,9 @@ Runnable.prototype.QueryInterface = XPCOMUtils.generateQI([Ci.nsIRunnable]);
*/
function debuggerProperties(obj) {
if (loaded.services && services.debugger.isOn) {
let ret = {};
services.debugger.wrapValue(obj).getProperties(ret, {});
return ret.value;
let res = {};
services.debugger.wrapValue(obj).getProperties(res, {});
return res.value;
}
}
@@ -1487,20 +1487,20 @@ var array = Class("array", Array, {
* @returns {Array}
*/
uniq: function uniq(ary, unsorted) {
let ret = [];
let res = [];
if (unsorted) {
for (let item in values(ary))
if (ret.indexOf(item) == -1)
ret.push(item);
if (res.indexOf(item) == -1)
res.push(item);
}
else {
for (let [, item] in Iterator(ary.sort())) {
if (item != last || !ret.length)
ret.push(item);
if (item != last || !res.length)
res.push(item);
var last = item;
}
}
return ret;
return res;
},
/**

View File

@@ -180,8 +180,7 @@ var JavaScript = Module("javascript", {
this._top.statements.pop();
this._top = this._get(-2);
this._last = this._top.char;
let ret = this._stack.pop();
return ret;
return this._stack.pop();
},
_buildStack: function (filter) {

View File

@@ -872,54 +872,54 @@ var Options = Module("options", {
* @returns {Object} The parsed command object.
*/
parseOpt: function parseOpt(args, modifiers) {
let ret = {};
let res = {};
let matches, prefix, postfix;
[matches, prefix, ret.name, postfix, ret.valueGiven, ret.operator, ret.value] =
[matches, prefix, res.name, postfix, res.valueGiven, res.operator, res.value] =
args.match(/^\s*(no|inv)?([^=]+?)([?&!])?\s*(([-+^]?)=(.*))?\s*$/) || [];
ret.args = args;
ret.onlyNonDefault = false; // used for :set to print non-default options
res.args = args;
res.onlyNonDefault = false; // used for :set to print non-default options
if (!args) {
ret.name = "all";
ret.onlyNonDefault = true;
res.name = "all";
res.onlyNonDefault = true;
}
if (matches) {
ret.option = this.get(ret.name, ret.scope);
if (!ret.option && (ret.option = this.get(prefix + ret.name, ret.scope))) {
ret.name = prefix + ret.name;
res.option = this.get(res.name, res.scope);
if (!res.option && (res.option = this.get(prefix + res.name, res.scope))) {
res.name = prefix + res.name;
prefix = "";
}
}
ret.prefix = prefix;
ret.postfix = postfix;
res.prefix = prefix;
res.postfix = postfix;
ret.all = (ret.name == "all");
ret.get = (ret.all || postfix == "?" || (ret.option && ret.option.type != "boolean" && !ret.valueGiven));
ret.invert = (prefix == "inv" || postfix == "!");
ret.reset = (postfix == "&");
ret.unsetBoolean = (prefix == "no");
res.all = (res.name == "all");
res.get = (res.all || postfix == "?" || (res.option && res.option.type != "boolean" && !res.valueGiven));
res.invert = (prefix == "inv" || postfix == "!");
res.reset = (postfix == "&");
res.unsetBoolean = (prefix == "no");
ret.scope = modifiers && modifiers.scope;
res.scope = modifiers && modifiers.scope;
if (!ret.option)
return ret;
if (!res.option)
return res;
if (ret.value === undefined)
ret.value = "";
if (res.value === undefined)
res.value = "";
ret.optionValue = ret.option.get(ret.scope);
res.optionValue = res.option.get(res.scope);
try {
ret.values = ret.option.parse(ret.value);
res.values = res.option.parse(res.value);
}
catch (e) {
ret.error = e;
res.error = e;
}
return ret;
return res;
},
/**

View File

@@ -83,20 +83,20 @@ var ArrayStore = Class("ArrayStore", StoreBase, {
},
pop: function pop(value) {
var ret = this._object.pop();
var res = this._object.pop();
this.fireEvent("pop", this._object.length);
return ret;
return res;
},
truncate: function truncate(length, fromEnd) {
var ret = this._object.length;
var res = this._object.length;
if (this._object.length > length) {
if (fromEnd)
this._object.splice(0, this._object.length - length);
this._object.length = length;
this.fireEvent("truncate", length);
}
return ret;
return res;
},
// XXX: Awkward.

View File

@@ -90,19 +90,19 @@ var Template = Module("Template", {
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
if (iter.length) // FIXME: Kludge?
iter = array.iterValues(iter);
let ret = <></>;
let res = <></>;
let n = 0;
for each (let i in Iterator(iter)) {
let val = func(i, n);
if (val == undefined)
continue;
if (n++ && sep)
ret += sep;
res += sep;
if (interruptable && n % interruptable == 0)
util.threadYield(true, true);
ret += val;
res += val;
}
return ret;
return res;
},
bindings: {

View File

@@ -132,15 +132,15 @@ const Mail = Module("mail", {
/** @property {nsISmtpServer[]} The list of configured SMTP servers. */
get smtpServers() {
let servers = services.smtp.smtpServers;
let ret = [];
let res = [];
while (servers.hasMoreElements()) {
let server = servers.getNext();
if (server instanceof Ci.nsISmtpServer)
ret.push(server);
res.push(server);
}
return ret;
return res;
},
composeNewMail: function (args) {