Projekt

Obecné

Profil

Stáhnout (1.21 KB) Statistiky
| Větev: | Revize:
1
/*
2
** © 2014 by Philipp Dunkel <pip@pipobscure.com>
3
** Licensed under MIT License.
4
*/
5

    
6
void FSEvents::emitEvent(const char *path, UInt32 flags, UInt64 id) {
7
  Nan::HandleScope handle_scope;
8
  v8::Local<v8::Object> object = handle();
9
  v8::Local<v8::Value> key = Nan::New<v8::String>("handler").ToLocalChecked();
10
  Nan::Callback handler(Nan::To<v8::Function>(Nan::Get(object, key).ToLocalChecked()).ToLocalChecked());
11
  v8::Local<v8::Value> argv[] = {
12
    Nan::New<v8::String>(path).ToLocalChecked(),
13
    Nan::New<v8::Number>(flags),
14
    Nan::New<v8::Number>(id)
15
  };
16
  handler.Call(3, argv, &async_resource);
17
}
18

    
19
NAN_METHOD(FSEvents::New) {
20
  Nan::Utf8String path(info[0]);
21

    
22
  FSEvents *fse = new FSEvents(*path);
23
  fse->Wrap(info.This());
24
  Nan::Set(info.This(), Nan::New<v8::String>("handler").ToLocalChecked(), info[1]);
25

    
26
  info.GetReturnValue().Set(info.This());
27
}
28

    
29
NAN_METHOD(FSEvents::Stop) {
30
  FSEvents* fse = Nan::ObjectWrap::Unwrap<FSEvents>(info.This());
31

    
32
  fse->threadStop();
33
  fse->asyncStop();
34

    
35
  info.GetReturnValue().Set(info.This());
36
}
37

    
38
NAN_METHOD(FSEvents::Start) {
39
  FSEvents* fse = Nan::ObjectWrap::Unwrap<FSEvents>(info.This());
40
  fse->asyncStart();
41
  fse->threadStart();
42

    
43
  info.GetReturnValue().Set(info.This());
44
}
(3-3/5)