summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/CSS.cpp6
-rw-r--r--src/core/CSS.hpp9
-rw-r--r--src/core/Managed.cpp12
-rw-r--r--src/core/Managed.hpp2
-rw-r--r--src/core/Tokenizer.hpp2
5 files changed, 20 insertions, 11 deletions
diff --git a/src/core/CSS.cpp b/src/core/CSS.cpp
index c3900e8..d131fec 100644
--- a/src/core/CSS.cpp
+++ b/src/core/CSS.cpp
@@ -20,6 +20,12 @@
namespace ousia {
+void RuleSet::merge(Rooted<RuleSet> other){
+ for(auto& o : other->rules){
+ rules[o.first] = o.second;
+ }
+}
+
/*
* different versions of "getChildren".
*/
diff --git a/src/core/CSS.hpp b/src/core/CSS.hpp
index 4cf15be..aa701b5 100644
--- a/src/core/CSS.hpp
+++ b/src/core/CSS.hpp
@@ -85,10 +85,11 @@ public:
return rules;
}
- void merge(Rooted<RuleSet> other)
- {
- rules.insert(other->rules.begin(), other->rules.end());
- }
+ /**
+ * This implements an overriding "insert all" of all rules in the other
+ * RuleSet to the rules in this RuleSet.
+ */
+ void merge(Rooted<RuleSet> other);
};
/**
diff --git a/src/core/Managed.cpp b/src/core/Managed.cpp
index 8cbbb17..f3a68a3 100644
--- a/src/core/Managed.cpp
+++ b/src/core/Managed.cpp
@@ -101,7 +101,7 @@ void ObjectDescriptor::incrDegree(RefDir dir, Managed *o)
}
// Fetch a reference to either the input or the output reference map
- auto &m = dir == RefDir::in ? refIn : refOut;
+ auto &m = dir == RefDir::IN ? refIn : refOut;
// Insert a new entry or increment the corresponding reference counter
auto it = m.find(o);
@@ -128,7 +128,7 @@ bool ObjectDescriptor::decrDegree(RefDir dir, Managed *o, bool all)
}
// Fetch a reference to either the input or the output reference map
- auto &m = dir == RefDir::in ? refIn : refOut;
+ auto &m = dir == RefDir::IN ? refIn : refOut;
// Decrement corresponding reference counter, delete the entry if the
// reference counter reaches zero
@@ -187,11 +187,11 @@ void Manager::addRef(Managed *tar, Managed *src)
// Store the tar <- src reference
assert(dTar);
- dTar->incrDegree(RefDir::in, src);
+ dTar->incrDegree(RefDir::IN, src);
if (src) {
// Store the src -> tar reference
assert(dSrc);
- dSrc->incrDegree(RefDir::out, tar);
+ dSrc->incrDegree(RefDir::OUT, tar);
} else {
// We have just added a root reference, remove the element from the
// list of marked objects
@@ -207,11 +207,11 @@ void Manager::deleteRef(Managed *tar, Managed *src, bool all)
// Decrement the output degree of the source Managed first
if (dSrc) {
- dSrc->decrDegree(RefDir::out, tar, all);
+ dSrc->decrDegree(RefDir::OUT, tar, all);
}
// Decrement the input degree of the input Managed
- if (dTar && dTar->decrDegree(RefDir::in, src, all)) {
+ if (dTar && dTar->decrDegree(RefDir::IN, src, all)) {
// If the Managed has a zero in degree, it can be safely deleted, otherwise
// if it has no root reference, add it to the "marked" set which is
// subject to tracing garbage collection
diff --git a/src/core/Managed.hpp b/src/core/Managed.hpp
index 6199e33..25fa14b 100644
--- a/src/core/Managed.hpp
+++ b/src/core/Managed.hpp
@@ -45,7 +45,7 @@ class Owned;
* Enum used to specify the direction of a object reference (inbound or
* outbound).
*/
-enum class RefDir { in, out };
+enum class RefDir { IN, OUT };
/**
* The ObjectDescriptor struct is used by the Manager for reference counting and
diff --git a/src/core/Tokenizer.hpp b/src/core/Tokenizer.hpp
index 4aebf56..8f80150 100644
--- a/src/core/Tokenizer.hpp
+++ b/src/core/Tokenizer.hpp
@@ -225,6 +225,8 @@ public:
void consumePeek();
const BufferedCharReader &getInput() const { return input; }
+
+ BufferedCharReader &getInput() { return input; }
};
}