summaryrefslogtreecommitdiff
path: root/js/public/Value.h
diff options
context:
space:
mode:
Diffstat (limited to 'js/public/Value.h')
-rw-r--r--js/public/Value.h52
1 files changed, 15 insertions, 37 deletions
diff --git a/js/public/Value.h b/js/public/Value.h
index 087d178ef..c645f0773 100644
--- a/js/public/Value.h
+++ b/js/public/Value.h
@@ -1340,20 +1340,18 @@ struct BarrierMethods<JS::Value>
}
};
-template <class Outer> class MutableValueOperations;
+template <class Wrapper> class MutableValueOperations;
/**
* A class designed for CRTP use in implementing the non-mutating parts of the
- * Value interface in Value-like classes. Outer must be a class inheriting
- * ValueOperations<Outer> with a visible get() method returning a const
- * reference to the Value abstracted by Outer.
+ * Value interface in Value-like classes. Wrapper must be a class inheriting
+ * ValueOperations<Wrapper> with a visible get() method returning a const
+ * reference to the Value abstracted by Wrapper.
*/
-template <class Outer>
-class ValueOperations
+template <class Wrapper>
+class WrappedPtrOperations<JS::Value, Wrapper>
{
- friend class MutableValueOperations<Outer>;
-
- const JS::Value& value() const { return static_cast<const Outer*>(this)->get(); }
+ const JS::Value& value() const { return static_cast<const Wrapper*>(this)->get(); }
public:
bool isUndefined() const { return value().isUndefined(); }
@@ -1398,17 +1396,17 @@ class ValueOperations
/**
* A class designed for CRTP use in implementing all the mutating parts of the
- * Value interface in Value-like classes. Outer must be a class inheriting
- * MutableValueOperations<Outer> with visible get() methods returning const and
- * non-const references to the Value abstracted by Outer.
+ * Value interface in Value-like classes. Wrapper must be a class inheriting
+ * MutableWrappedPtrOperations<Wrapper> with visible get() methods returning const and
+ * non-const references to the Value abstracted by Wrapper.
*/
-template <class Outer>
-class MutableValueOperations : public ValueOperations<Outer>
+template <class Wrapper>
+class MutableWrappedPtrOperations<JS::Value, Wrapper> : public WrappedPtrOperations<JS::Value, Wrapper>
{
protected:
void set(const JS::Value& v) {
// Call Outer::set to trigger any barriers.
- static_cast<Outer*>(this)->set(v);
+ static_cast<Wrapper*>(this)->set(v);
}
public:
@@ -1434,13 +1432,9 @@ class MutableValueOperations : public ValueOperations<Outer>
* Augment the generic Heap<T> interface when T = Value with
* type-querying, value-extracting, and mutating operations.
*/
-template <>
-class HeapBase<JS::Value> : public MutableValueOperations<JS::Heap<JS::Value> >
+template <typename Wrapper>
+class HeapBase<JS::Value, Wrapper> : public MutableWrappedPtrOperations<JS::Value, Wrapper>
{
- typedef JS::Heap<JS::Value> Outer;
-
- friend class ValueOperations<Outer>;
-
public:
void setNumber(uint32_t ui) {
if (ui > JSVAL_INT_MAX) {
@@ -1460,22 +1454,6 @@ class HeapBase<JS::Value> : public MutableValueOperations<JS::Heap<JS::Value> >
}
};
-template <>
-class HandleBase<JS::Value> : public ValueOperations<JS::Handle<JS::Value> >
-{};
-
-template <>
-class MutableHandleBase<JS::Value> : public MutableValueOperations<JS::MutableHandle<JS::Value> >
-{};
-
-template <>
-class RootedBase<JS::Value> : public MutableValueOperations<JS::Rooted<JS::Value> >
-{};
-
-template <>
-class PersistentRootedBase<JS::Value> : public MutableValueOperations<JS::PersistentRooted<JS::Value>>
-{};
-
/*
* If the Value is a GC pointer type, convert to that type and call |f| with
* the pointer. If the Value is not a GC type, calls F::defaultValue.