[Pkg-mozext-commits] [requestpolicy] 213/257: Revert "[ref] Rules[Symbol.iterator]"
David Prévot
taffit at moszumanska.debian.org
Thu Jan 28 03:20:14 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit 4a77494efdfd07398de248156375f42ca0cddb16
Author: Martin Kimmerle <dev at 256k.de>
Date: Tue Dec 15 16:00:22 2015 +0100
Revert "[ref] Rules[Symbol.iterator]"
This reverts commit 36ad2b979c939227ece962dc0e24b37f1c475bb4.
---
src/content/lib/ruleset.jsm | 58 ++++++++++++++++++++++++++++++++++-----------
1 file changed, 44 insertions(+), 14 deletions(-)
diff --git a/src/content/lib/ruleset.jsm b/src/content/lib/ruleset.jsm
index 49fe2f0..b659165 100644
--- a/src/content/lib/ruleset.jsm
+++ b/src/content/lib/ruleset.jsm
@@ -30,6 +30,8 @@ this.EXPORTED_SYMBOLS = [
"RawRuleset"
];
+/* global Iterator */
+
let {ScriptLoader: {importModule}} = Cu.import(
"chrome://rpcontinued/content/lib/script-loader.jsm", {});
let {Logger} = importModule("lib/logger");
@@ -476,6 +478,22 @@ RawRuleset.prototype = {
};
//==============================================================================
+// RuleIterator
+//==============================================================================
+
+// FIXME: Again apply commit 36ad2b9 "[ref] Rules[Symbol.iterator]"
+// as soon as Pale Moon supports Symbol.iterator.
+
+function RuleIterator(rules) {
+ this._rulesIterator = new Iterator(rules);
+}
+
+RuleIterator.prototype.next = function() {
+ // The default Iterator over arrays returns a tuple of [index, item].
+ return this._rulesIterator.next()[1];
+};
+
+//==============================================================================
// Rules
//==============================================================================
@@ -503,29 +521,41 @@ Rules.prototype = {
return this._rules.length === 0;
},
- [Symbol.iterator]: function*() {
- yield* this._rules;
+ // FIXME: Again apply commit 36ad2b9 "[ref] Rules[Symbol.iterator]"
+ // as soon as Pale Moon supports Symbol.iterator.
+ /* jshint -W103 */
+ __iterator__: function() {
+ return new RuleIterator(this._rules);
},
+ /* jshint +W103 */
get: function(scheme, port) {
let rule = new Rule(scheme, port);
- for (let existingRule of this._rules) {
- if (existingRule.isEqual(rule)) {
- return existingRule;
+ for (let i = 0; ; i++) {
+ let item = this._rules[i];
+ if (!item) {
+ break;
+ }
+ if (item.isEqual(rule)) {
+ return item;
}
}
return null;
},
add: function(scheme, port) {
- let newRule = new Rule(scheme, port);
- for (let existingRule of this._rules) {
- if (existingRule.isEqual(newRule)) {
- return existingRule;
+ let rule = new Rule(scheme, port);
+ for (let i = 0; ; i++) {
+ let item = this._rules[i];
+ if (!item) {
+ break;
+ }
+ if (item.isEqual(rule)) {
+ return item;
}
}
- this._rules.push(newRule);
- return newRule;
+ this._rules.push(rule);
+ return rule;
}
};
@@ -945,7 +975,7 @@ Ruleset.prototype = {
// First, check for rules for each part of the origin host.
originouterloop: for (let entry of this.getHostMatches(originHost)) {
//dprint(entry);
- for (let rule of entry.rules) {
+ for (let rule in entry.rules) {
//dprint("Checking rule: " + rule);
let ruleMatchedOrigin = rule.isMatch(origin);
@@ -979,7 +1009,7 @@ Ruleset.prototype = {
//dprint("There are origin-to-destination rules using this origin rule.");
for (let destEntry of rule.destinations.getHostMatches(destHost)) {
//dprint(destEntry);
- for (let destRule of destEntry.rules) {
+ for (let destRule in destEntry.rules) {
//dprint("Checking rule: " + rule);
if (destRule.allowDestination && destRule.isMatch(dest)) {
//dprint("ALLOW origin-to-dest by rule origin " + entry + " " + rule + " to dest " + destEntry + " " + destRule);
@@ -1029,7 +1059,7 @@ Ruleset.prototype = {
// Last, check for rules for each part of the destination host.
destouterloop: for (let entry of this.getHostMatches(destHost)) {
//dprint(entry);
- for (let rule of entry.rules) {
+ for (let rule in entry.rules) {
//dprint("Checking rule: " + rule);
if (rule.allowDestination && rule.isMatch(dest)) {
//dprint("ALLOW dest by rule " + entry + " " + rule);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git
More information about the Pkg-mozext-commits
mailing list