зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1441988 - Simplify AutoVector definitions by making this a template r=sfink
This commit is contained in:
Родитель
8b9f1c68b9
Коммит
a9547048d9
|
@ -23,10 +23,6 @@ class nsICycleCollectorListener;
|
|||
class nsScriptNameSpaceManager;
|
||||
class nsIDocShell;
|
||||
|
||||
namespace JS {
|
||||
class AutoValueVector;
|
||||
} // namespace JS
|
||||
|
||||
namespace mozilla {
|
||||
template <class> class Maybe;
|
||||
struct CycleCollectorResults;
|
||||
|
|
|
@ -40,8 +40,6 @@ extern JS_FRIEND_DATA(const js::Class* const) FunctionClassPtr;
|
|||
|
||||
namespace JS {
|
||||
|
||||
class AutoIdVector;
|
||||
|
||||
/**
|
||||
* The answer to a successful query as to whether an object is an Array per
|
||||
* ES6's internal |IsArray| operation (as exposed by |Array.isArray|).
|
||||
|
|
|
@ -99,14 +99,14 @@ class GCVector
|
|||
return vector.infallibleAppend(aBegin, aLength);
|
||||
}
|
||||
|
||||
template<typename U, size_t O, class BP>
|
||||
MOZ_MUST_USE bool appendAll(const mozilla::Vector<U, O, BP>& aU) { return vector.appendAll(aU); }
|
||||
template<typename U, size_t O, class BP>
|
||||
MOZ_MUST_USE bool appendAll(const GCVector<U, O, BP>& aU) {
|
||||
return vector.append(aU.begin(), aU.length());
|
||||
template<typename U>
|
||||
MOZ_MUST_USE bool appendAll(const U& aU) {
|
||||
return vector.append(aU.begin(), aU.end());
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool appendN(const T& val, size_t count) { return vector.appendN(val, count); }
|
||||
MOZ_MUST_USE bool appendN(const T& val, size_t count) {
|
||||
return vector.appendN(val, count);
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
MOZ_MUST_USE bool append(const U* aBegin, const U* aEnd) {
|
||||
|
@ -219,10 +219,8 @@ class MutableWrappedPtrOperations<JS::GCVector<T, Capacity, AllocPolicy>, Wrappe
|
|||
MOZ_MUST_USE bool emplaceBack(Args&&... aArgs) {
|
||||
return vec().emplaceBack(mozilla::Forward<Args...>(aArgs...));
|
||||
}
|
||||
template<typename U, size_t O, class BP>
|
||||
MOZ_MUST_USE bool appendAll(const mozilla::Vector<U, O, BP>& aU) { return vec().appendAll(aU); }
|
||||
template<typename U, size_t O, class BP>
|
||||
MOZ_MUST_USE bool appendAll(const JS::GCVector<U, O, BP>& aU) { return vec().appendAll(aU); }
|
||||
template<typename U>
|
||||
MOZ_MUST_USE bool appendAll(const U& aU) { return vec().appendAll(aU); }
|
||||
MOZ_MUST_USE bool appendN(const T& aT, size_t aN) { return vec().appendN(aT, aN); }
|
||||
template<typename U>
|
||||
MOZ_MUST_USE bool append(const U* aBegin, const U* aEnd) {
|
||||
|
@ -253,4 +251,17 @@ class MutableWrappedPtrOperations<JS::GCVector<T, Capacity, AllocPolicy>, Wrappe
|
|||
|
||||
} // namespace js
|
||||
|
||||
namespace JS {
|
||||
|
||||
// An automatically rooted vector for stack use.
|
||||
template <typename T>
|
||||
class AutoVector : public Rooted<GCVector<T, 8>> {
|
||||
using Vec = GCVector<T, 8>;
|
||||
using Base = Rooted<Vec>;
|
||||
public:
|
||||
explicit AutoVector(JSContext* cx) : Base(cx, Vec(cx)) {}
|
||||
};
|
||||
|
||||
} // namespace JS
|
||||
|
||||
#endif // js_GCVector_h
|
||||
|
|
|
@ -30,9 +30,9 @@ class TwoByteCharsZ;
|
|||
class UTF8Chars;
|
||||
class UTF8CharsZ;
|
||||
|
||||
class AutoValueVector;
|
||||
class AutoIdVector;
|
||||
class AutoObjectVector;
|
||||
using AutoValueVector = AutoVector<Value>;
|
||||
using AutoIdVector = AutoVector<jsid>;
|
||||
using AutoObjectVector = AutoVector<JSObject*>;
|
||||
|
||||
using ValueVector = JS::GCVector<JS::Value>;
|
||||
using IdVector = JS::GCVector<jsid>;
|
||||
|
|
|
@ -102,29 +102,6 @@ class MOZ_RAII AutoValueArray : public AutoGCRooter
|
|||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoValueVector : public Rooted<GCVector<Value, 8>> {
|
||||
using Vec = GCVector<Value, 8>;
|
||||
using Base = Rooted<Vec>;
|
||||
public:
|
||||
explicit AutoValueVector(JSContext* cx) : Base(cx, Vec(cx)) {}
|
||||
};
|
||||
|
||||
class AutoIdVector : public Rooted<GCVector<jsid, 8>> {
|
||||
using Vec = GCVector<jsid, 8>;
|
||||
using Base = Rooted<Vec>;
|
||||
public:
|
||||
explicit AutoIdVector(JSContext* cx) : Base(cx, Vec(cx)) {}
|
||||
|
||||
bool appendAll(const AutoIdVector& other) { return this->Base::appendAll(other.get()); }
|
||||
};
|
||||
|
||||
class AutoObjectVector : public Rooted<GCVector<JSObject*, 8>> {
|
||||
using Vec = GCVector<JSObject*, 8>;
|
||||
using Base = Rooted<Vec>;
|
||||
public:
|
||||
explicit AutoObjectVector(JSContext* cx) : Base(cx, Vec(cx)) {}
|
||||
};
|
||||
|
||||
using ValueVector = JS::GCVector<JS::Value>;
|
||||
using IdVector = JS::GCVector<jsid>;
|
||||
using ScriptVector = JS::GCVector<JSScript*>;
|
||||
|
|
|
@ -29,7 +29,11 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
class AutoIdVector;
|
||||
template <typename T> class AutoVector;
|
||||
using AutoIdVector = AutoVector<jsid>;
|
||||
using AutoValueVector = AutoVector<Value>;
|
||||
using AutoObjectVector = AutoVector<JSObject*>;
|
||||
|
||||
class CallArgs;
|
||||
|
||||
class JS_FRIEND_API(CompileOptions);
|
||||
|
|
|
@ -12,10 +12,6 @@
|
|||
#include "js/CallNonGenericMethod.h"
|
||||
#include "js/Wrapper.h"
|
||||
|
||||
namespace JS {
|
||||
class AutoIdVector;
|
||||
} // namespace JS
|
||||
|
||||
namespace xpc {
|
||||
|
||||
template <typename Base, typename Policy>
|
||||
|
|
Загрузка…
Ссылка в новой задаче