-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
33 lines (26 loc) · 838 Bytes
/
main.cpp
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
29
30
31
32
33
#include <iostream>
#include <string>
#include <node.h> //
using namespace std;
using namespace v8; // Add the missing namespace for v8
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::Number;
using v8::Value;
namespace main {
string HelloWorld() {
return "hola mundo";
}
void method(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
string result = HelloWorld();
Local<String> returnValue = String::NewFromUtf8(isolate, result.c_str()).ToLocalChecked();
args.GetReturnValue().Set(returnValue);
}
void Initialize(Local<Object> exports) {
NODE_SET_METHOD(exports, "helloWorld", method);// Implementation of Initialize function
}
NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize);
}