-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclipperinit.cc
51 lines (43 loc) · 1.43 KB
/
clipperinit.cc
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
45
46
47
48
49
50
51
#include <node.h>
#include <v8.h>
#include <vector>
#include "lib/ClipperWrap.hpp"
using namespace std;
using namespace v8;
using namespace ClipperLib;
Handle<Value> Begin(const Arguments& args) {
HandleScope scope;
return scope.Close(ClipperWrap::NewInstance(args));
}
Handle<Value> Area(const Arguments& args) {
HandleScope scope;
return scope.Close(compute_area(args));
}
Handle<Value> Clean(const Arguments& args) {
HandleScope scope;
return scope.Close(clean(args));
}
Handle<Value> Orientation(const Arguments& args) {
HandleScope scope;
return scope.Close(orientation(args));
}
Handle<Value> Simplify(const Arguments& args) {
HandleScope scope;
return scope.Close(simplify(args));
}
extern "C" {
static void init(Handle<Object> exports) {
ClipperWrap::Init();
exports->Set(String::NewSymbol("begin"),
FunctionTemplate::New(Begin)->GetFunction());
exports->Set(String::NewSymbol("area"),
FunctionTemplate::New(Area)->GetFunction());
exports->Set(String::NewSymbol("clean"),
FunctionTemplate::New(Clean)->GetFunction());
exports->Set(String::NewSymbol("orientation"),
FunctionTemplate::New(Orientation)->GetFunction());
exports->Set(String::NewSymbol("simplify"),
FunctionTemplate::New(Simplify)->GetFunction());
}
NODE_MODULE(clipper, init)
}