From b3609d33b6069eb04b52724b5963fc9cceb47b8d Mon Sep 17 00:00:00 2001 From: Tim Rach Date: Tue, 5 Nov 2019 12:26:08 +0100 Subject: [PATCH] Fix return type and declaration of setter callback Return type should be void and second function argument of type Napi::Value should be present. See typedef: https://github.com/nodejs/node-addon-api/blob/295e560f5554c87d0a9dde6b73942ebd85fddb9d/napi.h#L1623 --- doc/class_property_descriptor.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/class_property_descriptor.md b/doc/class_property_descriptor.md index ae2d27e27..bb492de7d 100644 --- a/doc/class_property_descriptor.md +++ b/doc/class_property_descriptor.md @@ -20,7 +20,7 @@ class Example : public Napi::ObjectWrap { static Napi::FunctionReference constructor; double _value; Napi::Value GetValue(const Napi::CallbackInfo &info); - Napi::Value SetValue(const Napi::CallbackInfo &info); + void SetValue(const Napi::CallbackInfo &info, const Napi::Value &value); }; Napi::Object Example::Init(Napi::Env env, Napi::Object exports) { @@ -52,12 +52,11 @@ Napi::Value Example::GetValue(const Napi::CallbackInfo &info) { return Napi::Number::New(env, this->_value); } -Napi::Value Example::SetValue(const Napi::CallbackInfo &info, const Napi::Value &value) { +void Example::SetValue(const Napi::CallbackInfo &info, const Napi::Value &value) { Napi::Env env = info.Env(); // ... Napi::Number arg = value.As(); this->_value = arg.DoubleValue(); - return this->GetValue(info); } // Initialize native add-on