forked from saary/node.net
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSharpAddon.cpp
More file actions
41 lines (31 loc) · 932 Bytes
/
SharpAddon.cpp
File metadata and controls
41 lines (31 loc) · 932 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
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma comment(lib, "node")
#include <node.h>
#include <v8.h>
#include <string>
#include "SharpLibHelper.h"
using namespace node;
using namespace v8;
class SharpObject: ObjectWrap
{
private:
SharpLibHelper* _sharpLibHelper;
public:
static Persistent<FunctionTemplate> s_ct;
static void NODE_EXTERN Init(Handle<Object> target)
{
HandleScope scope;
target->Set(v8::String::NewSymbol("Sharp"), FunctionTemplate::New(SharpLibHelper::Instance)->GetFunction());
}
};
Persistent<FunctionTemplate> SharpObject::s_ct;
extern "C" {
void NODE_EXTERN init (Handle<Object> target)
{
SharpObject::Init(target);
// Load Assembly is a global method defined in SharpLibHelper.
// It attaches a hander to AssemblyLoad to search the active directory.
LoadAssembly();
}
// 'sharp' here is treated as a string within the macro
NODE_MODULE(sharp, init);
}