-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd.cpp
More file actions
28 lines (22 loc) · 678 Bytes
/
add.cpp
File metadata and controls
28 lines (22 loc) · 678 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <node.h>
#include "add.h"
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Value;
using v8::Number;
using v8::Exception;
void add(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
// Perform the operation
Local<Number> num = Number::New(isolate, Add(args[0].As<Number>()->Value(), args[1].As<Number>()->Value()));
// Set the return value (using the passed in
// FunctionCallbackInfo<Value>&)
args.GetReturnValue().Set(num);
}
void Initialize(Local<Object> exports) {
NODE_SET_METHOD(exports, "add", add);
}
NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)