From f400b57beddfe6b18c70538d31058e1d4daffecd Mon Sep 17 00:00:00 2001 From: Roy Wright Date: Tue, 26 Nov 2019 10:49:47 +0100 Subject: [PATCH] Correctly define copy assignment operators. --- napi-inl.h | 2 +- napi.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/napi-inl.h b/napi-inl.h index f72e1da..91c2e89 100644 --- a/napi-inl.h +++ b/napi-inl.h @@ -2120,7 +2120,7 @@ inline Error& Error::operator =(Error&& other) { inline Error::Error(const Error& other) : ObjectReference(other) { } -inline Error& Error::operator =(Error& other) { +inline Error& Error::operator =(const Error& other) { Reset(); _env = other.Env(); diff --git a/napi.h b/napi.h index 2fc9b10..fe1cd53 100644 --- a/napi.h +++ b/napi.h @@ -1108,7 +1108,7 @@ namespace Napi { // A reference can be moved but cannot be copied. Reference(Reference&& other); Reference& operator =(Reference&& other); - Reference& operator =(Reference&) = delete; + Reference& operator =(const Reference&) = delete; operator napi_ref() const; bool operator ==(const Reference &other) const; @@ -1153,7 +1153,7 @@ namespace Napi { ObjectReference& operator =(Reference&& other); ObjectReference(ObjectReference&& other); ObjectReference& operator =(ObjectReference&& other); - ObjectReference& operator =(ObjectReference&) = delete; + ObjectReference& operator =(const ObjectReference&) = delete; Napi::Value Get(const char* utf8name) const; Napi::Value Get(const std::string& utf8name) const; @@ -1191,7 +1191,7 @@ namespace Napi { FunctionReference(FunctionReference&& other); FunctionReference& operator =(FunctionReference&& other); FunctionReference(const FunctionReference&) = delete; - FunctionReference& operator =(FunctionReference&) = delete; + FunctionReference& operator =(const FunctionReference&) = delete; Napi::Value operator ()(const std::initializer_list& args) const; @@ -1333,7 +1333,7 @@ namespace Napi { Error(Error&& other); Error& operator =(Error&& other); Error(const Error&); - Error& operator =(Error&); + Error& operator =(const Error&); const std::string& Message() const NAPI_NOEXCEPT; void ThrowAsJavaScriptException() const; @@ -1806,7 +1806,7 @@ namespace Napi { AsyncContext(AsyncContext&& other); AsyncContext& operator =(AsyncContext&& other); AsyncContext(const AsyncContext&) = delete; - AsyncContext& operator =(AsyncContext&) = delete; + AsyncContext& operator =(const AsyncContext&) = delete; operator napi_async_context() const; @@ -1825,7 +1825,7 @@ namespace Napi { AsyncWorker(AsyncWorker&& other); AsyncWorker& operator =(AsyncWorker&& other); AsyncWorker(const AsyncWorker&) = delete; - AsyncWorker& operator =(AsyncWorker&) = delete; + AsyncWorker& operator =(const AsyncWorker&) = delete; operator napi_async_work() const;