-// Copyright (c) 2010-2013 Kris Maglione <maglione.k@gmail.com>
+// Copyright (c) 2010-2014 Kris Maglione <maglione.k@gmail.com>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
delete this[hive];
if (reason != "shutdown")
- this.children.splice(0).forEach(this.contexts.closure.removeGroup);
+ this.children.splice(0).forEach(this.contexts.bound.removeGroup);
},
destroy: function destroy(reason) {
for (let hive in values(this.hives))
util.trapErrors("destroy", hive);
if (reason != "shutdown")
- this.children.splice(0).forEach(this.contexts.closure.removeGroup);
+ this.children.splice(0).forEach(this.contexts.bound.removeGroup);
},
argsExtra: function argsExtra() ({}),
}, {
compileFilter: function (patterns, default_=false) {
function siteFilter(uri)
- let (match = array.nth(siteFilter.filters, f => f(uri), 0))
- match ? match.result : default_;
+ let (match = siteFilter.filters.find(f => f(uri)))
+ match ? match.result
+ : default_;
return update(siteFilter, {
toString: function () this.filters.join(","),
completer: function (context) modules.completion.group(context)
});
- memoize(modules, "userContext", () => contexts.Context(modules.io.getRCFile("~", true), contexts.user, [modules, true]));
- memoize(modules, "_userContext", () => contexts.Context(modules.io.getRCFile("~", true), contexts.user, [modules.userContext]));
+ memoize(modules, "userContext", () => contexts.Context(modules.io.getRCFile("~", true), contexts.user, [modules, false]));
+ memoize(modules, "_userContext", () => modules.userContext);
},
cleanup: function () {
- for each (let hive in this.groupList.slice())
+ for (let hive of this.groupList.slice())
util.trapErrors("cleanup", hive, "shutdown");
},
destroy: function () {
- for each (let hive in values(this.groupList.slice()))
+ for (let hive of values(this.groupList.slice()))
util.trapErrors("destroy", hive, "shutdown");
- for (let [name, plugin] in iter(this.modules.plugins.contexts))
+ for each (let plugin in this.modules.plugins.contexts) {
if (plugin && "onUnload" in plugin && callable(plugin.onUnload))
util.trapErrors("onUnload", plugin);
+
+ if (isinstance(plugin, ["Sandbox"]))
+ util.trapErrors("nukeSandbox", Cu, plugin);
+ }
},
signals: {
{ _hive: { value: name } })));
memoize(contexts.groupsProto, name,
- function () [group[name] for (group in values(this.groups)) if (Set.has(group, name))]);
+ function () [group[name]
+ for (group in values(this.groups))
+ if (hasOwnProperty(group, name))]);
},
get toStringParams() [this.name, this.Hive]
Context: function Context(file, group, args) {
const { contexts, io, newContext, plugins, userContext } = this.modules;
- let isPlugin = array.nth(io.getRuntimeDirectories("plugins"),
- dir => dir.contains(file, true),
- 0);
- let isRuntime = array.nth(io.getRuntimeDirectories(""),
- dir => dir.contains(file, true),
- 0);
+ let isPlugin = io.getRuntimeDirectories("plugins")
+ .find(dir => dir.contains(file, true));
+ let isRuntime = io.getRuntimeDirectories("")
+ .find(dir => dir.contains(file, true));
let name = isPlugin ? file.getRelativeDescriptor(isPlugin).replace(File.PATH_SEP, "-")
: file.leafName;
let id = util.camelCase(name.replace(/\.[^.]*$/, ""));
let contextPath = file.path;
- let self = Set.has(plugins, contextPath) && plugins.contexts[contextPath];
+ let self = hasOwnProperty(plugins, contextPath) && plugins.contexts[contextPath];
if (!self && isPlugin && false)
- self = Set.has(plugins, id) && plugins[id];
+ self = hasOwnProperty(plugins, id) && plugins[id];
if (self) {
- if (Set.has(self, "onUnload"))
+ if (hasOwnProperty(self, "onUnload"))
util.trapErrors("onUnload", self);
}
else {
if (uri instanceof Ci.nsIFileURL)
var file = File(uri.file);
- let isPlugin = array.nth(io.getRuntimeDirectories("plugins"),
- dir => dir.contains(file, true),
- 0);
+ let isPlugin = io.getRuntimeDirectories("plugins")
+ .find(dir => dir.contains(file, true));
let name = isPlugin && file && file.getRelativeDescriptor(isPlugin)
.replace(File.PATH_SEP, "-");
let id = util.camelCase(name.replace(/\.[^.]*$/, ""));
- let self = Set.has(this.pluginModules, canonical) && this.pluginModules[canonical];
+ let self = hasOwnProperty(this.pluginModules, canonical) && this.pluginModules[canonical];
if (!self) {
self = Object.create(jsmodules);
delete contexts.pluginModules[canonical];
}
- for each (let { plugins } in overlay.modules)
+ for (let { plugins } of overlay.modules)
if (plugins[this.NAME] == this)
delete plugins[this.name];
})
initializedGroups: function (hive)
let (need = hive ? [hive] : Object.keys(this.hives))
- this.groupList.filter(group => need.some(Set.has(group))),
+ this.groupList.filter(group => need.some(hasOwnProperty.bind(null, group))),
addGroup: function addGroup(name, description, filter, persist, replace) {
let group = this.getGroup(name);
getGroup: function getGroup(name, hive) {
if (name === "default")
var group = this.context && this.context.context && this.context.context.GROUP;
- else if (Set.has(this.groupMap, name))
+ else if (hasOwnProperty(this.groupMap, name))
group = this.groupMap[name];
if (group && hive)
getDocs: function getDocs(context) {
try {
- if (isinstance(context, ["Sandbox"])) {
- let info = "INFO" in context && Cu.evalInSandbox("this.INFO instanceof XML ? INFO.toXMLString() : this.INFO", context);
- return /^</.test(info) ? XML(info) : info;
- }
if (DOM.isJSONXML(context.INFO))
return context.INFO;
- if (typeof context.INFO == "xml" && config.haveGecko(null, "14.*"))
- return context.INFO;
}
catch (e) {}
return null;
util.assert(!group.builtin ||
!["-description", "-locations", "-nopersist"]
- .some(Set.has(args.explicitOpts)),
+ .some(hasOwnProperty.bind(null, args.explicitOpts)),
_("group.cantModifyBuiltin"));
},
{