-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJSEProcess.cpp
More file actions
44 lines (30 loc) · 1.08 KB
/
JSEProcess.cpp
File metadata and controls
44 lines (30 loc) · 1.08 KB
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
34
35
36
37
38
39
40
41
42
43
44
#include "JSE.h"
#include "JSEProcess.h"
using namespace v8;
namespace JSE {
QApplication *_JSEProcess_app;
JSEV8 *_JSEProcess_v8app;
void FuncQuit(const FunctionCallbackInfo<Value> &args)
{
_JSEProcess_v8app->exit();
_JSEProcess_app->exit();
}
void SetupProcessObject(JSEApplication *app, JSEV8 *v8app, Persistent<Object> &process, Isolate *isolate)
{
QStringList argv = app->arguments();
HandleScope scope(isolate);
Local<FunctionTemplate> process_template = FunctionTemplate::New(isolate);
process_template->SetClassName(String::NewFromUtf8(isolate, "process"));
Local<Object> objProcess = process_template->GetFunction()->NewInstance();
Local<Object> objArgv = Array::New(isolate, argv.size());
for (int i = 0; i < argv.size(); i++)
{
objArgv->Set(i, String::NewFromUtf8(isolate, argv[i].toUtf8().constData()));
}
objProcess->Set(String::NewFromUtf8(isolate, "argv"), objArgv);
_JSEProcess_app = app;
_JSEProcess_v8app = v8app;
JSE_SET_METHOD(objProcess, "quit", FuncQuit);
process.Reset(isolate, objProcess);
}
}