зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1442599 - Part 1: Replace AutoScopedAssign with MakeScopeExit. r=jorendorff
--HG-- extra : rebase_source : 15f362a6976aedea503a983f14acfc6c626914f8
This commit is contained in:
Родитель
3b52a7becc
Коммит
9ed8b208a7
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "jsexn.h"
|
||||
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "mozilla/Sprintf.h"
|
||||
|
||||
#include <string.h>
|
||||
|
@ -667,7 +668,11 @@ js::ErrorToException(JSContext* cx, JSErrorReport* reportp,
|
|||
// Prevent infinite recursion.
|
||||
if (cx->generatingError)
|
||||
return;
|
||||
AutoScopedAssign<bool> asa(&cx->generatingError.ref(), true);
|
||||
|
||||
cx->generatingError = true;
|
||||
auto restore = mozilla::MakeScopeExit([cx] {
|
||||
cx->generatingError = false;
|
||||
});
|
||||
|
||||
// Create an exception object.
|
||||
RootedString messageStr(cx, reportp->newMessageString(cx));
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Compiler.h"
|
||||
#include "mozilla/GuardObjects.h"
|
||||
#include "mozilla/HashFunctions.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/PodOperations.h"
|
||||
|
@ -156,26 +155,6 @@ Max(T t1, T t2)
|
|||
return t1 > t2 ? t1 : t2;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
class MOZ_RAII AutoScopedAssign
|
||||
{
|
||||
public:
|
||||
AutoScopedAssign(T* addr, const T& value
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: addr_(addr), old(*addr_)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
*addr_ = value;
|
||||
}
|
||||
|
||||
~AutoScopedAssign() { *addr_ = old; }
|
||||
|
||||
private:
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
T* addr_;
|
||||
T old;
|
||||
};
|
||||
|
||||
template <typename T, typename U>
|
||||
static inline U
|
||||
ComputeByteAlignment(T bytes, U alignment)
|
||||
|
|
Загрузка…
Ссылка в новой задаче