2929
3030extern " C" {
3131 #include " c/bsdiff/bsdiff.h"
32- #include " c/bspatch/bspatch.h"
32+ #include " c/bspatch/bspatch.h"
3333}
3434
3535namespace bsdpNode {
3636 using namespace v8 ;
3737
38- void diff (const FunctionCallbackInfo<Value>& args)
38+ void diff (const FunctionCallbackInfo<Value>& args)
3939 {
40- Isolate* isolate = args.GetIsolate ();
41-
42- if (args.Length () < 4 || !args[0 ]->IsString () || !args[1 ]->IsString () || !args[2 ]->IsString ())
40+ if (args.Length () < 4 || !args[0 ]->IsString () || !args[1 ]->IsString () || !args[2 ]->IsString ())
4341 {
44- isolate-> ThrowException ( Exception::Error ( String::NewFromUtf8 (isolate, " Invalid arguments." )) );
42+ Nan::ThrowError ( " Invalid arguments." );
4543 return ;
4644 }
47-
45+
4846 Nan::Callback *callback = new Nan::Callback (args[3 ].As <v8::Function>());
4947
5048 Nan::Utf8String param0 (args[0 ]);
51- std::string oldfile = std::string (*param0);
49+ std::string oldfile = std::string (*param0);
5250
5351 Nan::Utf8String param1 (args[1 ]);
54- std::string newfile = std::string (*param1);
52+ std::string newfile = std::string (*param1);
5553
5654 Nan::Utf8String param2 (args[2 ]);
57- std::string patchfile = std::string (*param2);
55+ std::string patchfile = std::string (*param2);
5856
5957 DiffWorkerCallback* wc = new DiffWorkerCallback (callback, oldfile, newfile, patchfile);
6058 Nan::AsyncQueueWorker (wc);
6159 }
6260
63- void diffSync (const FunctionCallbackInfo<Value>& args)
61+ void diffSync (const FunctionCallbackInfo<Value>& args)
6462 {
6563 Isolate* isolate = args.GetIsolate ();
6664 HandleScope scope (isolate);
67-
68- if (!args[0 ]->IsString () || !args[1 ]->IsString () || !args[2 ]->IsString ())
65+
66+ if (!args[0 ]->IsString () || !args[1 ]->IsString () || !args[2 ]->IsString ())
6967 {
70- isolate-> ThrowException ( Exception::Error ( String::NewFromUtf8 (isolate, " Invalid arguments." )) );
68+ Nan::ThrowError ( " Invalid arguments." );
7169 return ;
7270 }
73-
71+
7472 Nan::Utf8String oldfile (args[0 ]);
7573 Nan::Utf8String newfile (args[1 ]);
7674 Nan::Utf8String patchfile (args[2 ]);
@@ -79,59 +77,57 @@ namespace bsdpNode {
7977 char error[1024 ];
8078 memset (error, 0 , sizeof error);
8179
82- int ret = bsdiff (error, *oldfile, *newfile, *patchfile, nullptr , nullptr );
80+ int ret = bsdiff (error, *oldfile, *newfile, *patchfile, nullptr , nullptr );
8381
84- if (ret != 0 )
85- isolate-> ThrowException ( Exception::Error ( String::NewFromUtf8 (isolate, error)));
82+ if (ret != 0 )
83+ Nan::ThrowError ( error);
8684 }
8785
88- void patch (const FunctionCallbackInfo<Value>& args)
86+ void patch (const FunctionCallbackInfo<Value>& args)
8987 {
90- Isolate* isolate = args.GetIsolate ();
91-
92- if (args.Length () < 4 || !args[0 ]->IsString () || !args[1 ]->IsString () || !args[2 ]->IsString ())
88+ if (args.Length () < 4 || !args[0 ]->IsString () || !args[1 ]->IsString () || !args[2 ]->IsString ())
9389 {
94- isolate-> ThrowException ( Exception::Error ( String::NewFromUtf8 (isolate, " Invalid arguments." )) );
90+ Nan::ThrowError ( " Invalid arguments." );
9591 return ;
9692 }
97-
93+
9894 Nan::Callback *callback = new Nan::Callback (args[3 ].As <v8::Function>());
9995
10096 Nan::Utf8String param0 (args[0 ]);
101- std::string oldfile = std::string (*param0);
97+ std::string oldfile = std::string (*param0);
10298
10399 Nan::Utf8String param1 (args[1 ]);
104- std::string newfile = std::string (*param1);
100+ std::string newfile = std::string (*param1);
105101
106102 Nan::Utf8String param2 (args[2 ]);
107- std::string patchfile = std::string (*param2);
103+ std::string patchfile = std::string (*param2);
108104
109105 PatchWorkerCallback* wc = new PatchWorkerCallback (callback, oldfile, newfile, patchfile);
110106 Nan::AsyncQueueWorker (wc);
111107 }
112108
113- void patchSync (const FunctionCallbackInfo<Value>& args)
109+ void patchSync (const FunctionCallbackInfo<Value>& args)
114110 {
115111 Isolate* isolate = args.GetIsolate ();
116112 HandleScope scope (isolate);
117113
118- if (!args[0 ]->IsString () || !args[1 ]->IsString () || !args[2 ]->IsString ())
114+ if (!args[0 ]->IsString () || !args[1 ]->IsString () || !args[2 ]->IsString ())
119115 {
120- isolate-> ThrowException ( Exception::Error ( String::NewFromUtf8 (isolate, " Invalid arguments." )) );
116+ Nan::ThrowError ( " Invalid arguments." );
121117 return ;
122118 }
123-
119+
124120 Nan::Utf8String oldfile (args[0 ]);
125121 Nan::Utf8String newfile (args[1 ]);
126122 Nan::Utf8String patchfile (args[2 ]);
127123
128124 char error[1024 ];
129125 memset (error, 0 , sizeof error);
130126
131- int ret = bspatch (error, *oldfile, *newfile, *patchfile, nullptr , nullptr );
127+ int ret = bspatch (error, *oldfile, *newfile, *patchfile, nullptr , nullptr );
132128
133129 if (ret != 0 )
134- isolate-> ThrowException ( Exception::Error ( String::NewFromUtf8 (isolate, error)));
130+ Nan::ThrowError ( error);
135131 }
136132
137133 void init (Local<Object> exports, Local<Object> module ) {
@@ -143,4 +139,4 @@ namespace bsdpNode {
143139 }
144140
145141 NODE_MODULE (bsdp, init)
146- }
142+ }
0 commit comments