mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-19 01:08:18 +03:00
AK: Rename ValueRestorer => ScopedValueRollback.
Qt had a pretty good name for this concept, so let's steal it. :^)
This commit is contained in:
parent
03b9f6b7f8
commit
9fb2a65716
Notes:
sideshowbarker
2024-07-19 13:03:36 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/9fb2a657167
@ -3,7 +3,7 @@
|
|||||||
#include <AK/kstdio.h>
|
#include <AK/kstdio.h>
|
||||||
|
|
||||||
#ifdef USERLAND
|
#ifdef USERLAND
|
||||||
#include <AK/ValueRestorer.h>
|
#include <AK/ScopedValueRollback.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef USERLAND
|
#ifdef USERLAND
|
||||||
ValueRestorer<int> m_errno_restorer;
|
ScopedValueRollback<int> m_errno_restorer;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,15 +3,15 @@
|
|||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class ValueRestorer {
|
class ScopedValueRollback {
|
||||||
public:
|
public:
|
||||||
ValueRestorer(T& variable)
|
ScopedValueRollback(T& variable)
|
||||||
: m_variable(variable)
|
: m_variable(variable)
|
||||||
, m_saved_value(variable)
|
, m_saved_value(variable)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~ValueRestorer()
|
~ScopedValueRollback()
|
||||||
{
|
{
|
||||||
m_variable = m_saved_value;
|
m_variable = m_saved_value;
|
||||||
}
|
}
|
||||||
@ -23,4 +23,4 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using AK::ValueRestorer;
|
using AK::ScopedValueRollback;
|
@ -1,6 +1,6 @@
|
|||||||
#include <AK/PrintfImplementation.h>
|
#include <AK/PrintfImplementation.h>
|
||||||
|
#include <AK/ScopedValueRollback.h>
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
#include <AK/ValueRestorer.h>
|
|
||||||
#include <Kernel/Syscall.h>
|
#include <Kernel/Syscall.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -510,7 +510,7 @@ FILE* popen(const char* command, const char* type)
|
|||||||
|
|
||||||
int rc = pipe(pipe_fds);
|
int rc = pipe(pipe_fds);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
ValueRestorer restorer(errno);
|
ScopedValueRollback rollback(errno);
|
||||||
perror("pipe");
|
perror("pipe");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user