48
48
if (!node::Buffer::HasInstance(obj))
49
49
ret = WALLY_EINVAL;
50
50
else {
51
- mBuffer = obj->ToObject();
51
+ mBuffer = obj->ToObject(Nan::GetCurrentContext()).ToLocalChecked( );
52
52
if (IsValid(mBuffer)) {
53
53
mData = (unsigned char*) node::Buffer::Data(mBuffer);
54
54
mLength = node::Buffer::Length(mBuffer);
62
62
{
63
63
if (ret != WALLY_OK)
64
64
return; // Do nothing, caller will already throw
65
- const v8 ::MaybeLocal<v8::Object> local = Nan::NewBuffer(len);
65
+ const Nan ::MaybeLocal<v8::Object> local = Nan::NewBuffer(len);
66
66
if (local.ToLocal(&mBuffer)) {
67
67
mData = (unsigned char*) node::Buffer::Data(mBuffer);
68
68
mLength = len;
86
86
if (!IsValid(obj) || !obj->IsArray())
87
87
ret = WALLY_EINVAL;
88
88
else {
89
- mArray = obj->ToObject();
89
+ mArray = obj->ToObject(Nan::GetCurrentContext()).ToLocalChecked( );
90
90
if (!IsValid(mArray))
91
91
ret = WALLY_EINVAL;
92
92
}
@@ -269,7 +269,7 @@ def _generate_nan(funcname, f):
269
269
' const size_t len = arr%s.get().Length();' % i ,
270
270
' be64array%s.reserve(len);' % i ,
271
271
' for (size_t i = 0; i < len && ret == WALLY_OK; ++i)' ,
272
- ' be64array%s.push_back(LocalUInt64(arr%s.get().Get(i ), ret).mValue);' % (i , i ),
272
+ ' be64array%s.push_back(LocalUInt64(arr%s.get().Get(Nan::GetCurrentContext(), i).ToLocalChecked( ), ret).mValue);' % (i , i ),
273
273
'}' ,
274
274
])
275
275
postprocessing .extend ([
@@ -287,7 +287,7 @@ def _generate_nan(funcname, f):
287
287
postprocessing .extend ([
288
288
'v8::Local<v8::String> str_res;' ,
289
289
'if (ret == WALLY_OK) {' ,
290
- ' str_res = v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), result_ptr);' ,
290
+ ' str_res = v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), result_ptr, v8::NewStringType::kNormal).ToLocalChecked( );' ,
291
291
' wally_free_string(result_ptr);' ,
292
292
' if (!IsValid(str_res))' ,
293
293
' ret = WALLY_ENOMEM;' ,
@@ -317,7 +317,8 @@ def _generate_nan(funcname, f):
317
317
if num_outs > 1 :
318
318
postprocessing .extend ([
319
319
'if (ret == WALLY_OK)' ,
320
- ' res->Set(%s, res%s);' % (cur_out , i ),
320
+ ' if (!res->Set(Nan::GetCurrentContext(), %s, res%s).FromMaybe(false))' % (cur_out , i ),
321
+ ' ret = WALLY_ERROR;' ,
321
322
])
322
323
cur_out += 1
323
324
else :
@@ -333,16 +334,18 @@ def _generate_nan(funcname, f):
333
334
postprocessing .extend ([
334
335
'if (ret == WALLY_OK) {' ,
335
336
' *be64%s = cpu_to_be64(*be64%s);' % (i , i ),
336
- ' res->Set(%s, res%s);' % (cur_out , i ),
337
+ ' if (!res->Set(Nan::GetCurrentContext(), %s, res%s).FromMaybe(false)) ' % (cur_out , i ),
338
+ ' ret = WALLY_ERROR;' ,
337
339
'}' ,
338
340
])
339
341
cur_out += 1
340
342
elif arg == 'bip32_in' :
341
343
input_args .append ((
342
344
'ext_key* inkey;'
343
- 'unsigned char* inbuf = (unsigned char*) node::Buffer::Data(info[%s]->ToObject());'
344
- 'bip32_key_unserialize_alloc(inbuf, node::Buffer::Length(info[%s]->ToObject()), &inkey);'
345
- ) % (i , i ))
345
+ 'const LocalObject buf = info[%s]->ToObject(Nan::GetCurrentContext()).ToLocalChecked();'
346
+ 'unsigned char* inbuf = (unsigned char*) node::Buffer::Data(buf);'
347
+ 'bip32_key_unserialize_alloc(inbuf, node::Buffer::Length(buf), &inkey);'
348
+ ) % (i ))
346
349
args .append ('inkey' )
347
350
postprocessing .append ('bip32_key_free(inkey);' )
348
351
elif arg in ['bip32_pub_out' , 'bip32_priv_out' ]:
0 commit comments