src: implement special member functions for classes in env.h

The classes in env.h were not adhering to the rule of five.
As per the rule of five, if a class implements any of five
special member functions, it must implement all the
five special member functions for enabling the compiler for
better optimization.

Refs: https://en.cppreference.com/w/cpp/language/rule_of_three

PR-URL: https://github.com/nodejs/node/pull/28579
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
GauthamBanasandra 2019-07-06 20:09:13 +05:30 committed by Rich Trott
parent b851469855
commit 7e69bcef1a

View File

@ -484,6 +484,8 @@ class IsolateData : public MemoryRetainer {
inline v8::Isolate* isolate() const; inline v8::Isolate* isolate() const;
IsolateData(const IsolateData&) = delete; IsolateData(const IsolateData&) = delete;
IsolateData& operator=(const IsolateData&) = delete; IsolateData& operator=(const IsolateData&) = delete;
IsolateData(IsolateData&&) = delete;
IsolateData& operator=(IsolateData&&) = delete;
private: private:
void DeserializeProperties(const std::vector<size_t>* indexes); void DeserializeProperties(const std::vector<size_t>* indexes);
@ -574,6 +576,12 @@ class AsyncRequest : public MemoryRetainer {
public: public:
AsyncRequest() = default; AsyncRequest() = default;
~AsyncRequest(); ~AsyncRequest();
AsyncRequest(const AsyncRequest&) = delete;
AsyncRequest& operator=(const AsyncRequest&) = delete;
AsyncRequest(AsyncRequest&&) = delete;
AsyncRequest& operator=(AsyncRequest&&) = delete;
void Install(Environment* env, void* data, uv_async_cb target); void Install(Environment* env, void* data, uv_async_cb target);
void Uninstall(); void Uninstall();
void Stop(); void Stop();
@ -658,6 +666,9 @@ class AsyncHooks : public MemoryRetainer {
AsyncHooks(const AsyncHooks&) = delete; AsyncHooks(const AsyncHooks&) = delete;
AsyncHooks& operator=(const AsyncHooks&) = delete; AsyncHooks& operator=(const AsyncHooks&) = delete;
AsyncHooks(AsyncHooks&&) = delete;
AsyncHooks& operator=(AsyncHooks&&) = delete;
~AsyncHooks() = default;
// Used to set the kDefaultTriggerAsyncId in a scope. This is instead of // Used to set the kDefaultTriggerAsyncId in a scope. This is instead of
// passing the trigger_async_id along with other constructor arguments. // passing the trigger_async_id along with other constructor arguments.
@ -672,6 +683,9 @@ class AsyncHooks : public MemoryRetainer {
DefaultTriggerAsyncIdScope(const DefaultTriggerAsyncIdScope&) = delete; DefaultTriggerAsyncIdScope(const DefaultTriggerAsyncIdScope&) = delete;
DefaultTriggerAsyncIdScope& operator=(const DefaultTriggerAsyncIdScope&) = DefaultTriggerAsyncIdScope& operator=(const DefaultTriggerAsyncIdScope&) =
delete; delete;
DefaultTriggerAsyncIdScope(DefaultTriggerAsyncIdScope&&) = delete;
DefaultTriggerAsyncIdScope& operator=(DefaultTriggerAsyncIdScope&&) =
delete;
private: private:
AsyncHooks* async_hooks_; AsyncHooks* async_hooks_;
@ -701,6 +715,8 @@ class AsyncCallbackScope {
~AsyncCallbackScope(); ~AsyncCallbackScope();
AsyncCallbackScope(const AsyncCallbackScope&) = delete; AsyncCallbackScope(const AsyncCallbackScope&) = delete;
AsyncCallbackScope& operator=(const AsyncCallbackScope&) = delete; AsyncCallbackScope& operator=(const AsyncCallbackScope&) = delete;
AsyncCallbackScope(AsyncCallbackScope&&) = delete;
AsyncCallbackScope& operator=(AsyncCallbackScope&&) = delete;
private: private:
Environment* env_; Environment* env_;
@ -719,6 +735,9 @@ class ImmediateInfo : public MemoryRetainer {
ImmediateInfo(const ImmediateInfo&) = delete; ImmediateInfo(const ImmediateInfo&) = delete;
ImmediateInfo& operator=(const ImmediateInfo&) = delete; ImmediateInfo& operator=(const ImmediateInfo&) = delete;
ImmediateInfo(ImmediateInfo&&) = delete;
ImmediateInfo& operator=(ImmediateInfo&&) = delete;
~ImmediateInfo() = default;
SET_MEMORY_INFO_NAME(ImmediateInfo) SET_MEMORY_INFO_NAME(ImmediateInfo)
SET_SELF_SIZE(ImmediateInfo) SET_SELF_SIZE(ImmediateInfo)
@ -745,6 +764,9 @@ class TickInfo : public MemoryRetainer {
TickInfo(const TickInfo&) = delete; TickInfo(const TickInfo&) = delete;
TickInfo& operator=(const TickInfo&) = delete; TickInfo& operator=(const TickInfo&) = delete;
TickInfo(TickInfo&&) = delete;
TickInfo& operator=(TickInfo&&) = delete;
~TickInfo() = default;
private: private:
friend class Environment; // So we can call the constructor. friend class Environment; // So we can call the constructor.
@ -779,6 +801,12 @@ class ShouldNotAbortOnUncaughtScope {
explicit inline ShouldNotAbortOnUncaughtScope(Environment* env); explicit inline ShouldNotAbortOnUncaughtScope(Environment* env);
inline void Close(); inline void Close();
inline ~ShouldNotAbortOnUncaughtScope(); inline ~ShouldNotAbortOnUncaughtScope();
ShouldNotAbortOnUncaughtScope(const ShouldNotAbortOnUncaughtScope&) = delete;
ShouldNotAbortOnUncaughtScope& operator=(
const ShouldNotAbortOnUncaughtScope&) = delete;
ShouldNotAbortOnUncaughtScope(ShouldNotAbortOnUncaughtScope&&) = delete;
ShouldNotAbortOnUncaughtScope& operator=(ShouldNotAbortOnUncaughtScope&&) =
delete;
private: private:
Environment* env_; Environment* env_;
@ -818,6 +846,8 @@ class Environment : public MemoryRetainer {
public: public:
Environment(const Environment&) = delete; Environment(const Environment&) = delete;
Environment& operator=(const Environment&) = delete; Environment& operator=(const Environment&) = delete;
Environment(Environment&&) = delete;
Environment& operator=(Environment&&) = delete;
SET_MEMORY_INFO_NAME(Environment) SET_MEMORY_INFO_NAME(Environment)