node/test/addons/make-callback-domain-warning/binding.cc
Daniel Bevenius 53a5d87bec test: fix deprecation warning in binding.cc
Currently, the make-callback-domain-warning addon generates the
following warning:
../binding.cc:22:9:
warning: 'MakeCallback' is deprecated: Use MakeCallback(...,
      async_context) [-Wdeprecated-declarations]
  node::MakeCallback(isolate, recv, method, 0, nullptr);
        ^
../../../../src/node.h:172:50:
note: 'MakeCallback' has been explicitly marked
      deprecated here
                NODE_EXTERN v8::Local<v8::Value> MakeCallback(
                                                 ^
1 warning generated.

This commit fixes this warning.

PR-URL: https://github.com/nodejs/node/pull/18877
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
2018-02-22 06:25:58 +01:00

33 lines
728 B
C++

#include "node.h"
#include "v8.h"
#include <assert.h>
using v8::Function;
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::Value;
namespace {
void MakeCallback(const FunctionCallbackInfo<Value>& args) {
assert(args[0]->IsObject());
assert(args[1]->IsFunction());
Isolate* isolate = args.GetIsolate();
Local<Object> recv = args[0].As<Object>();
Local<Function> method = args[1].As<Function>();
node::MakeCallback(isolate, recv, method, 0, nullptr,
node::async_context{0, 0});
}
void Initialize(Local<Object> exports) {
NODE_SET_METHOD(exports, "makeCallback", MakeCallback);
}
} // namespace
NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)