diff --git a/.appveyor.yml b/.appveyor.yml index 58dcd550a..19e209b96 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -4,9 +4,9 @@ image: platform: x64 environment: matrix: + - nodejs_version: "10" - nodejs_version: "8" - nodejs_version: "6" - - nodejs_version: "4" install: - ps: Install-Product node $env:nodejs_version $env:platform diff --git a/binding.gyp b/binding.gyp index 257fcc510..236109412 100644 --- a/binding.gyp +++ b/binding.gyp @@ -100,6 +100,19 @@ 'src/include', "ToObject(), &g_log_info); + eventpolicy_from_jsobject(&policy, info[0].As(), &g_log_info); as_event_loop* loop; as_error err; @@ -76,7 +76,7 @@ NAN_METHOD(setDefaultLogging) { Nan::HandleScope(); if (info[0]->IsObject()){ - if (log_from_jsobject(&g_log_info, info[0]->ToObject()) == AS_NODE_PARAM_OK) { + if (log_from_jsobject(&g_log_info, info[0].As()) == AS_NODE_PARAM_OK) { if (g_log_info.level < 0) { // common logging does not support log level "OFF" as_log_set_level(AS_LOG_LEVEL_ERROR); diff --git a/src/main/async.cc b/src/main/async.cc index 150823044..e3763e3d6 100644 --- a/src/main/async.cc +++ b/src/main/async.cc @@ -155,7 +155,7 @@ bool async_scan_listener(as_error* err, as_record* record, void* udata, as_event bool continue_scan = true; if (result->IsBoolean()) { - continue_scan = result->ToBoolean()->Value(); + continue_scan = Nan::To(result).FromJust(); as_v8_debug(log, "Async scan callback returned: %s", continue_scan ? "true" : "false"); } return continue_scan; diff --git a/src/main/client.cc b/src/main/client.cc index 593b6da53..124c0e5b4 100644 --- a/src/main/client.cc +++ b/src/main/client.cc @@ -64,18 +64,16 @@ NAN_METHOD(AerospikeClient::New) as_config config; as_config_init(&config); - if (info[0]->IsObject()) { - Local v8_log_info = info[0]->ToObject()->Get(Nan::New("log").ToLocalChecked()) ; - if (v8_log_info->IsObject()) { - log_from_jsobject(client->log, v8_log_info->ToObject()); - } + Local v8Config = info[0].As(); + + Local v8LogInfo = v8Config->Get(Nan::New("log").ToLocalChecked()) ; + if (v8LogInfo->IsObject()) { + log_from_jsobject(client->log, v8LogInfo.As()); } - if (info[0]->IsObject()) { - int result = config_from_jsobject(&config, info[0]->ToObject(), client->log); - if (result != AS_NODE_PARAM_OK) { - Nan::ThrowError("Invalid client configuration"); - } + int result = config_from_jsobject(&config, v8Config, client->log); + if (result != AS_NODE_PARAM_OK) { + Nan::ThrowError("Invalid client configuration"); } aerospike_init(client->as, &config); @@ -159,8 +157,8 @@ NAN_METHOD(AerospikeClient::AddSeedHost) TYPE_CHECK_REQ(info[0], IsString, "hostname must be a string"); TYPE_CHECK_REQ(info[1], IsNumber, "port must be a number"); - Nan::Utf8String hostname(info[0]->ToString()); - uint16_t port = (uint16_t) info[1]->ToInteger()->Value(); + Nan::Utf8String hostname(info[0].As()); + uint16_t port = (uint16_t) Nan::To(info[1]).FromJust(); as_cluster_add_seed(client->as->cluster, *hostname, NULL, port); } @@ -176,8 +174,8 @@ NAN_METHOD(AerospikeClient::RemoveSeedHost) TYPE_CHECK_REQ(info[0], IsString, "hostname must be a string"); TYPE_CHECK_REQ(info[1], IsNumber, "port must be a number"); - Nan::Utf8String hostname(info[0]->ToString()); - uint16_t port = (uint16_t) info[1]->ToInteger()->Value(); + Nan::Utf8String hostname(info[0].As()); + uint16_t port = (uint16_t) Nan::To(info[1]).FromJust(); as_cluster_remove_seed(client->as->cluster, *hostname, port); } @@ -186,7 +184,7 @@ NAN_METHOD(AerospikeClient::SetLogLevel) { AerospikeClient* client = Nan::ObjectWrap::Unwrap(info.Holder()); if (info[0]->IsObject()) { - log_from_jsobject(client->log, info[0]->ToObject()); + log_from_jsobject(client->log, info[0].As()); } info.GetReturnValue().Set(info.Holder()); } diff --git a/src/main/commands/apply_async.cc b/src/main/commands/apply_async.cc index 8c61db2ce..ddda10506 100644 --- a/src/main/commands/apply_async.cc +++ b/src/main/commands/apply_async.cc @@ -46,19 +46,19 @@ NAN_METHOD(AerospikeClient::ApplyAsync) char* udf_module = NULL; char* udf_function = NULL; - if (key_from_jsobject(&key, info[0]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (key_from_jsobject(&key, info[0].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Key object invalid"); goto Cleanup; } key_initalized = true; - if (udfargs_from_jsobject(&udf_module, &udf_function, &udf_args, info[1]->ToObject(), log) != AS_NODE_PARAM_OK ) { + if (udfargs_from_jsobject(&udf_module, &udf_function, &udf_args, info[1].As(), log) != AS_NODE_PARAM_OK ) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "UDF args object invalid"); goto Cleanup; } if (info[2]->IsObject()) { - if (applypolicy_from_jsobject(&policy, info[2]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (applypolicy_from_jsobject(&policy, info[2].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Policy object invalid"); goto Cleanup; } diff --git a/src/main/commands/batch_exists.cc b/src/main/commands/batch_exists.cc index afa404160..de68f7d97 100644 --- a/src/main/commands/batch_exists.cc +++ b/src/main/commands/batch_exists.cc @@ -93,7 +93,7 @@ prepare(const Nan::FunctionCallbackInfo &info) if (info[1]->IsObject()) { cmd->policy = (as_policy_batch*) cf_malloc(sizeof(as_policy_batch)); - if (batchpolicy_from_jsobject(cmd->policy, info[1]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (batchpolicy_from_jsobject(cmd->policy, info[1].As(), log) != AS_NODE_PARAM_OK) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Batch policy parameter invalid"); } } diff --git a/src/main/commands/batch_get.cc b/src/main/commands/batch_get.cc index 02a2efa8c..2d17b61bf 100644 --- a/src/main/commands/batch_get.cc +++ b/src/main/commands/batch_get.cc @@ -94,7 +94,7 @@ prepare(const Nan::FunctionCallbackInfo &info) if (info[1]->IsObject() ) { cmd->policy = (as_policy_batch*) cf_malloc(sizeof(as_policy_batch)); - if (batchpolicy_from_jsobject(cmd->policy, info[1]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (batchpolicy_from_jsobject(cmd->policy, info[1].As(), log) != AS_NODE_PARAM_OK) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Batch policy parameter invalid"); } } diff --git a/src/main/commands/batch_read_async.cc b/src/main/commands/batch_read_async.cc index 1ac8e41eb..b25341a93 100644 --- a/src/main/commands/batch_read_async.cc +++ b/src/main/commands/batch_read_async.cc @@ -44,7 +44,7 @@ NAN_METHOD(AerospikeClient::BatchReadAsync) } if (info[1]->IsObject()) { - if (batchpolicy_from_jsobject(&policy, info[1]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (batchpolicy_from_jsobject(&policy, info[1].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Policy object invalid"); free_batch_records(records); goto Cleanup; diff --git a/src/main/commands/batch_select.cc b/src/main/commands/batch_select.cc index ba82db41c..9d50ee393 100644 --- a/src/main/commands/batch_select.cc +++ b/src/main/commands/batch_select.cc @@ -105,7 +105,7 @@ prepare(const Nan::FunctionCallbackInfo &info) if (info[2]->IsObject() ) { cmd->policy = (as_policy_batch*) cf_malloc(sizeof(as_policy_batch)); - if (batchpolicy_from_jsobject(cmd->policy, info[2]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (batchpolicy_from_jsobject(cmd->policy, info[2].As(), log) != AS_NODE_PARAM_OK) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Batch policy parameter invalid"); } } diff --git a/src/main/commands/exists_async.cc b/src/main/commands/exists_async.cc index 59755901a..c73446863 100644 --- a/src/main/commands/exists_async.cc +++ b/src/main/commands/exists_async.cc @@ -39,14 +39,14 @@ NAN_METHOD(AerospikeClient::ExistsAsync) as_policy_read* p_policy = NULL; as_status status; - if (key_from_jsobject(&key, info[0]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (key_from_jsobject(&key, info[0].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Key object invalid"); goto Cleanup; } key_initalized = true; if (info[1]->IsObject()) { - if (readpolicy_from_jsobject(&policy, info[1]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (readpolicy_from_jsobject(&policy, info[1].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Policy object invalid"); goto Cleanup; } diff --git a/src/main/commands/get_async.cc b/src/main/commands/get_async.cc index 98644522c..f80dfbddb 100644 --- a/src/main/commands/get_async.cc +++ b/src/main/commands/get_async.cc @@ -39,14 +39,14 @@ NAN_METHOD(AerospikeClient::GetAsync) as_policy_read* p_policy = NULL; as_status status = AEROSPIKE_ERR; - if (key_from_jsobject(&key, info[0]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (key_from_jsobject(&key, info[0].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Key object invalid"); goto Cleanup; } key_initalized = true; if (info[1]->IsObject()) { - if (readpolicy_from_jsobject(&policy, info[1]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (readpolicy_from_jsobject(&policy, info[1].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Policy object invalid"); goto Cleanup; } diff --git a/src/main/commands/index_create.cc b/src/main/commands/index_create.cc index 0f6fb7fbb..f9bea71bb 100644 --- a/src/main/commands/index_create.cc +++ b/src/main/commands/index_create.cc @@ -57,27 +57,27 @@ prepare(const Nan::FunctionCallbackInfo &info) IndexCreateCommand* cmd = new IndexCreateCommand(client, info[7].As()); LogInfo* log = client->log; - if (as_strlcpy(cmd->ns, *Nan::Utf8String(info[0]->ToString()), AS_NAMESPACE_MAX_SIZE) > AS_NAMESPACE_MAX_SIZE) { + if (as_strlcpy(cmd->ns, *Nan::Utf8String(info[0].As()), AS_NAMESPACE_MAX_SIZE) > AS_NAMESPACE_MAX_SIZE) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Namespace exceeds max. length (%d)", AS_NAMESPACE_MAX_SIZE); } if (info[1]->IsString()) { - if (as_strlcpy(cmd->set, *Nan::Utf8String(info[1]->ToString()), AS_SET_MAX_SIZE) > AS_SET_MAX_SIZE) { + if (as_strlcpy(cmd->set, *Nan::Utf8String(info[1].As()), AS_SET_MAX_SIZE) > AS_SET_MAX_SIZE) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Set exceeds max. length (%d)", AS_SET_MAX_SIZE); } } - if (as_strlcpy(cmd->bin, *Nan::Utf8String(info[2]->ToString()), AS_BIN_NAME_MAX_LEN) > AS_BIN_NAME_MAX_LEN) { + if (as_strlcpy(cmd->bin, *Nan::Utf8String(info[2].As()), AS_BIN_NAME_MAX_LEN) > AS_BIN_NAME_MAX_LEN) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Bin name exceeds max. length (%d)", AS_BIN_NAME_MAX_LEN); } - cmd->index = strdup(*Nan::Utf8String(info[3]->ToString())); - cmd->itype = (as_index_type) info[4]->ToInteger()->Value(); - cmd->dtype = (as_index_datatype) info[5]->ToInteger()->Value(); + cmd->index = strdup(*Nan::Utf8String(info[3].As())); + cmd->itype = (as_index_type) Nan::To(info[4]).FromJust(); + cmd->dtype = (as_index_datatype) Nan::To(info[5]).FromJust(); if (info[6]->IsObject()) { cmd->policy = (as_policy_info*) cf_malloc(sizeof(as_policy_info)); - if (infopolicy_from_jsobject(cmd->policy, info[6]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (infopolicy_from_jsobject(cmd->policy, info[6].As(), log) != AS_NODE_PARAM_OK) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Policy parameter is invalid"); } } diff --git a/src/main/commands/index_remove.cc b/src/main/commands/index_remove.cc index ac2d55846..a4111efff 100644 --- a/src/main/commands/index_remove.cc +++ b/src/main/commands/index_remove.cc @@ -53,15 +53,15 @@ prepare(const Nan::FunctionCallbackInfo &info) IndexRemoveCommand* cmd = new IndexRemoveCommand(client, info[3].As()); LogInfo* log = cmd->log = client->log; - if (as_strlcpy(cmd->ns, *Nan::Utf8String(info[0]->ToString()), AS_NAMESPACE_MAX_SIZE) > AS_NAMESPACE_MAX_SIZE) { + if (as_strlcpy(cmd->ns, *Nan::Utf8String(info[0].As()), AS_NAMESPACE_MAX_SIZE) > AS_NAMESPACE_MAX_SIZE) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Namespace exceeds max. length (%d)", AS_NAMESPACE_MAX_SIZE); } - cmd->index = strdup(*Nan::Utf8String(info[1]->ToString())); + cmd->index = strdup(*Nan::Utf8String(info[1].As())); if (info[2]->IsObject()) { cmd->policy = (as_policy_info*)cf_malloc(sizeof(as_policy_info)); - if(infopolicy_from_jsobject(cmd->policy, info[2]->ToObject(), log) != AS_NODE_PARAM_OK) { + if(infopolicy_from_jsobject(cmd->policy, info[2].As(), log) != AS_NODE_PARAM_OK) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Policy parameter is invalid"); } } diff --git a/src/main/commands/info.cc b/src/main/commands/info.cc index 069a19bdc..52cf6e1a0 100644 --- a/src/main/commands/info.cc +++ b/src/main/commands/info.cc @@ -60,7 +60,7 @@ prepare(const Nan::FunctionCallbackInfo &info) if (info[0]->IsString()) { cmd->request = (char*) cf_malloc(MAX_INFO_REQUEST_LEN); - size_t reqlen = as_strlcpy(cmd->request, *Nan::Utf8String(info[0]->ToString()), MAX_INFO_REQUEST_LEN); + size_t reqlen = as_strlcpy(cmd->request, *Nan::Utf8String(info[0].As()), MAX_INFO_REQUEST_LEN); if (reqlen > MAX_INFO_REQUEST_LEN) { as_v8_info(log, "Info request exceeds max. length (%zu > %i): \"%s...\"", reqlen, MAX_INFO_REQUEST_LEN, cmd->request); return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Info request exceeds max. length"); @@ -70,14 +70,14 @@ prepare(const Nan::FunctionCallbackInfo &info) } if (info[1]->IsObject()) { - if (host_from_jsobject(info[1]->ToObject(), &cmd->addr, &cmd->port, log) != AS_NODE_PARAM_OK) { + if (host_from_jsobject(info[1].As(), &cmd->addr, &cmd->port, log) != AS_NODE_PARAM_OK) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Host parameter is invalid"); } } if (info[2]->IsObject()) { cmd->policy = (as_policy_info*) cf_malloc(sizeof(as_policy_info)); - if (infopolicy_from_jsobject(cmd->policy, info[2]->ToObject(), log) != AS_NODE_PARAM_OK ) { + if (infopolicy_from_jsobject(cmd->policy, info[2].As(), log) != AS_NODE_PARAM_OK ) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Policy parameter is invalid"); } } diff --git a/src/main/commands/info_foreach.cc b/src/main/commands/info_foreach.cc index 827fd9ac7..042761258 100644 --- a/src/main/commands/info_foreach.cc +++ b/src/main/commands/info_foreach.cc @@ -95,7 +95,7 @@ prepare(const Nan::FunctionCallbackInfo &info) if (info[0]->IsString()) { cmd->request = (char*) malloc(INFO_REQUEST_LEN); - if (as_strlcpy(cmd->request, *Nan::Utf8String(info[0]->ToString()), INFO_REQUEST_LEN) > INFO_REQUEST_LEN) { + if (as_strlcpy(cmd->request, *Nan::Utf8String(info[0].As()), INFO_REQUEST_LEN) > INFO_REQUEST_LEN) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Info request exceeds max. length (%d)", INFO_REQUEST_LEN); } } else { @@ -104,7 +104,7 @@ prepare(const Nan::FunctionCallbackInfo &info) if (info[1]->IsObject()) { cmd->policy = (as_policy_info*) cf_malloc(sizeof(as_policy_info)); - if (infopolicy_from_jsobject(cmd->policy, info[1]->ToObject(), log) != AS_NODE_PARAM_OK ) { + if (infopolicy_from_jsobject(cmd->policy, info[1].As(), log) != AS_NODE_PARAM_OK ) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Policy parameter is invalid"); } } diff --git a/src/main/commands/job_info.cc b/src/main/commands/job_info.cc index f0efcbbd7..0518a3a7b 100644 --- a/src/main/commands/job_info.cc +++ b/src/main/commands/job_info.cc @@ -54,12 +54,12 @@ prepare(const Nan::FunctionCallbackInfo &info) JobInfoCommand* cmd = new JobInfoCommand(client, info[3].As()); LogInfo* log = client->log; - cmd->job_id = info[0]->ToInteger()->Value(); - cmd->module = strdup(*Nan::Utf8String(info[1]->ToString())); + cmd->job_id = Nan::To(info[0]).FromJust(); + cmd->module = strdup(*Nan::Utf8String(info[1].As())); if (info[2]->IsObject()) { cmd->policy = (as_policy_info*) cf_malloc(sizeof(as_policy_info)); - if (infopolicy_from_jsobject(cmd->policy, info[2]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (infopolicy_from_jsobject(cmd->policy, info[2].As(), log) != AS_NODE_PARAM_OK) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Policy parameter is invalid"); } } diff --git a/src/main/commands/operate_async.cc b/src/main/commands/operate_async.cc index 938367eb2..79854648d 100644 --- a/src/main/commands/operate_async.cc +++ b/src/main/commands/operate_async.cc @@ -44,7 +44,7 @@ NAN_METHOD(AerospikeClient::OperateAsync) as_policy_operate* p_policy = NULL; as_status status; - if (key_from_jsobject(&key, info[0]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (key_from_jsobject(&key, info[0].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Key object invalid"); goto Cleanup; } @@ -57,13 +57,13 @@ NAN_METHOD(AerospikeClient::OperateAsync) operations_initalized = true; if (info[2]->IsObject()) { - Local metadata = info[2]->ToObject(); + Local metadata = info[2].As(); setTTL(metadata, &operations.ttl, log); setGeneration(metadata, &operations.gen, log); } if (info[3]->IsObject()) { - if (operatepolicy_from_jsobject(&policy, info[3]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (operatepolicy_from_jsobject(&policy, info[3].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Policy object invalid"); goto Cleanup; } diff --git a/src/main/commands/put_async.cc b/src/main/commands/put_async.cc index 1910ec557..a46c35fa4 100644 --- a/src/main/commands/put_async.cc +++ b/src/main/commands/put_async.cc @@ -43,27 +43,27 @@ NAN_METHOD(AerospikeClient::PutAsync) as_policy_write* p_policy = NULL; as_status status; - if (key_from_jsobject(&key, info[0]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (key_from_jsobject(&key, info[0].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Key object invalid"); goto Cleanup; } key_initalized = true; - if (recordbins_from_jsobject(&record, info[1]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (recordbins_from_jsobject(&record, info[1].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Record object invalid"); goto Cleanup; } record_initalized = true; if (info[2]->IsObject()) { - if (recordmeta_from_jsobject(&record, info[2]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (recordmeta_from_jsobject(&record, info[2].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Meta object invalid"); goto Cleanup; } } if (info[3]->IsObject()) { - if (writepolicy_from_jsobject(&policy, info[3]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (writepolicy_from_jsobject(&policy, info[3].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Policy object invalid"); goto Cleanup; } diff --git a/src/main/commands/query_apply.cc b/src/main/commands/query_apply.cc index 15ba649b5..d165af2ff 100644 --- a/src/main/commands/query_apply.cc +++ b/src/main/commands/query_apply.cc @@ -69,7 +69,7 @@ prepare(const Nan::FunctionCallbackInfo &info) if (info[3]->IsObject()) { cmd->policy = (as_policy_query*) cf_malloc(sizeof(as_policy_query)); - if (querypolicy_from_jsobject(cmd->policy, info[3]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (querypolicy_from_jsobject(cmd->policy, info[3].As(), log) != AS_NODE_PARAM_OK) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Policy parameter is invalid"); } } diff --git a/src/main/commands/query_async.cc b/src/main/commands/query_async.cc index 6a7497c0b..86f146b62 100644 --- a/src/main/commands/query_async.cc +++ b/src/main/commands/query_async.cc @@ -52,7 +52,7 @@ NAN_METHOD(AerospikeClient::QueryAsync) setup_query(&query, info[0], info[1], info[2], log); if (info[3]->IsObject()) { - if (querypolicy_from_jsobject(&policy, info[3]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (querypolicy_from_jsobject(&policy, info[3].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Policy object invalid"); goto Cleanup; } diff --git a/src/main/commands/query_background.cc b/src/main/commands/query_background.cc index 635f5e447..1919c823b 100644 --- a/src/main/commands/query_background.cc +++ b/src/main/commands/query_background.cc @@ -58,13 +58,13 @@ prepare(const Nan::FunctionCallbackInfo &info) if (info[3]->IsObject()) { cmd->policy = (as_policy_write*) cf_malloc(sizeof(as_policy_write)); - if (writepolicy_from_jsobject(cmd->policy, info[3]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (writepolicy_from_jsobject(cmd->policy, info[3].As(), log) != AS_NODE_PARAM_OK) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Policy parameter is invalid"); } } if (info[4]->IsNumber()) { - cmd->query_id = info[4]->ToInteger()->Value(); + cmd->query_id = Nan::To(info[4]).FromJust(); as_v8_info(log, "Using query ID %lli for background query.", cmd->query_id); } diff --git a/src/main/commands/query_foreach.cc b/src/main/commands/query_foreach.cc index d27d064a1..5aebe93fd 100644 --- a/src/main/commands/query_foreach.cc +++ b/src/main/commands/query_foreach.cc @@ -155,7 +155,7 @@ prepare(const Nan::FunctionCallbackInfo &info) if (info[3]->IsObject()) { cmd->policy = (as_policy_query*) cf_malloc(sizeof(as_policy_query)); - if (querypolicy_from_jsobject(cmd->policy, info[3]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (querypolicy_from_jsobject(cmd->policy, info[3].As(), log) != AS_NODE_PARAM_OK) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Policy parameter is invalid"); } } diff --git a/src/main/commands/remove_async.cc b/src/main/commands/remove_async.cc index 8630c5e41..e47d53294 100644 --- a/src/main/commands/remove_async.cc +++ b/src/main/commands/remove_async.cc @@ -39,14 +39,14 @@ NAN_METHOD(AerospikeClient::RemoveAsync) as_policy_remove* p_policy = NULL; as_status status; - if (key_from_jsobject(&key, info[0]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (key_from_jsobject(&key, info[0].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Key object invalid"); goto Cleanup; } key_initalized = true; if (info[1]->IsObject()) { - if (removepolicy_from_jsobject(&policy, info[1]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (removepolicy_from_jsobject(&policy, info[1].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Policy object invalid"); goto Cleanup; } diff --git a/src/main/commands/scan_async.cc b/src/main/commands/scan_async.cc index 31e50153e..a28b2adf7 100644 --- a/src/main/commands/scan_async.cc +++ b/src/main/commands/scan_async.cc @@ -54,7 +54,7 @@ NAN_METHOD(AerospikeClient::ScanAsync) setup_scan(&scan, info[0], info[1], info[2], log); if (info[3]->IsObject()) { - if (scanpolicy_from_jsobject(&policy, info[3]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (scanpolicy_from_jsobject(&policy, info[3].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Policy object invalid"); goto Cleanup; } @@ -62,7 +62,7 @@ NAN_METHOD(AerospikeClient::ScanAsync) } if (info[4]->IsNumber()) { - scan_id = info[4]->ToInteger()->Value(); + scan_id = Nan::To(info[4]).FromJust(); as_v8_info(log, "Using scan ID %lli for async scan.", scan_id); } diff --git a/src/main/commands/scan_background.cc b/src/main/commands/scan_background.cc index 33149bbaf..5b4e0b145 100644 --- a/src/main/commands/scan_background.cc +++ b/src/main/commands/scan_background.cc @@ -58,13 +58,13 @@ prepare(const Nan::FunctionCallbackInfo &info) if (info[3]->IsObject()) { cmd->policy = (as_policy_scan*) cf_malloc(sizeof(as_policy_scan)); - if (scanpolicy_from_jsobject(cmd->policy, info[3]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (scanpolicy_from_jsobject(cmd->policy, info[3].As(), log) != AS_NODE_PARAM_OK) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Policy parameter is invalid"); } } if (info[4]->IsNumber()) { - cmd->scan_id = info[4]->ToInteger()->Value(); + cmd->scan_id = Nan::To(info[4]).FromJust(); as_v8_info(log, "Using scan ID %lli for background scan.", cmd->scan_id); } diff --git a/src/main/commands/select_async.cc b/src/main/commands/select_async.cc index 55645c1fa..f61b4e14f 100644 --- a/src/main/commands/select_async.cc +++ b/src/main/commands/select_async.cc @@ -42,7 +42,7 @@ NAN_METHOD(AerospikeClient::SelectAsync) as_policy_read* p_policy = NULL; as_status status; - if (key_from_jsobject(&key, info[0]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (key_from_jsobject(&key, info[0].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Key object invalid"); goto Cleanup; } @@ -54,7 +54,7 @@ NAN_METHOD(AerospikeClient::SelectAsync) } if (info[2]->IsObject()) { - if (readpolicy_from_jsobject(&policy, info[2]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (readpolicy_from_jsobject(&policy, info[2].As(), log) != AS_NODE_PARAM_OK) { CmdErrorCallback(cmd, AEROSPIKE_ERR_PARAM, "Policy object invalid"); goto Cleanup; } diff --git a/src/main/commands/truncate.cc b/src/main/commands/truncate.cc index e95d96985..434fa4779 100644 --- a/src/main/commands/truncate.cc +++ b/src/main/commands/truncate.cc @@ -50,23 +50,23 @@ prepare(const Nan::FunctionCallbackInfo &info) TruncateCommand* cmd = new TruncateCommand(client, info[4].As()); LogInfo* log = client->log; - if (as_strlcpy(cmd->ns, *Nan::Utf8String(info[0]->ToString()), AS_NAMESPACE_MAX_SIZE) > AS_NAMESPACE_MAX_SIZE) { + if (as_strlcpy(cmd->ns, *Nan::Utf8String(info[0].As()), AS_NAMESPACE_MAX_SIZE) > AS_NAMESPACE_MAX_SIZE) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Namespace exceeds max. length (%d)", AS_NAMESPACE_MAX_SIZE); } if (info[1]->IsString()) { - if (as_strlcpy(cmd->set, *Nan::Utf8String(info[1]->ToString()), AS_SET_MAX_SIZE) > AS_SET_MAX_SIZE) { + if (as_strlcpy(cmd->set, *Nan::Utf8String(info[1].As()), AS_SET_MAX_SIZE) > AS_SET_MAX_SIZE) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Set exceeds max. length (%d)", AS_SET_MAX_SIZE); } } if (info[2]->IsNumber()) { - cmd->before_nanos = (uint64_t) info[2]->ToInteger()->Value(); + cmd->before_nanos = (uint64_t) Nan::To(info[2]).FromJust(); } if (info[3]->IsObject()) { cmd->policy = (as_policy_info*) cf_malloc(sizeof(as_policy_info)); - if (infopolicy_from_jsobject(cmd->policy, info[3]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (infopolicy_from_jsobject(cmd->policy, info[3].As(), log) != AS_NODE_PARAM_OK) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Policy parameter is invalid"); } } diff --git a/src/main/commands/udf_register.cc b/src/main/commands/udf_register.cc index 38e82a661..0388ce803 100644 --- a/src/main/commands/udf_register.cc +++ b/src/main/commands/udf_register.cc @@ -59,7 +59,7 @@ prepare(const Nan::FunctionCallbackInfo &info) UdfRegisterCommand* cmd = new UdfRegisterCommand(client, info[3].As()); LogInfo* log = client->log; - char* filepath = strdup(*Nan::Utf8String(info[0]->ToString())); + char* filepath = strdup(*Nan::Utf8String(info[0].As())); FILE * file = fopen(filepath, "r"); if (!file) { CmdSetError(cmd, AEROSPIKE_ERR, "Cannot open file: %s", filepath); @@ -121,14 +121,14 @@ prepare(const Nan::FunctionCallbackInfo &info) as_bytes_init_wrap(&cmd->content, file_content, size, true); if (info[1]->IsNumber()) { - cmd->type = (as_udf_type) info[1]->IntegerValue(); + cmd->type = (as_udf_type) Nan::To(info[1]).FromJust(); } else { cmd->type = AS_UDF_TYPE_LUA; } if (info[2]->IsObject()) { cmd->policy = (as_policy_info*) cf_malloc(sizeof(as_policy_info)); - if (infopolicy_from_jsobject(cmd->policy, info[2]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (infopolicy_from_jsobject(cmd->policy, info[2].As(), log) != AS_NODE_PARAM_OK) { CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Policy parameter is invalid"); if (filepath != NULL) cf_free(filepath); return cmd; diff --git a/src/main/commands/udf_remove.cc b/src/main/commands/udf_remove.cc index ddf10af01..3bd222dfd 100644 --- a/src/main/commands/udf_remove.cc +++ b/src/main/commands/udf_remove.cc @@ -52,11 +52,11 @@ prepare(const Nan::FunctionCallbackInfo &info) UdfRemoveCommand* cmd = new UdfRemoveCommand(client, info[2].As()); LogInfo* log = client->log; - cmd->module = strdup(*Nan::Utf8String(info[0]->ToString())); + cmd->module = strdup(*Nan::Utf8String(info[0].As())); if (info[1]->IsObject()) { cmd->policy = (as_policy_info*) cf_malloc(sizeof(as_policy_info)); - if (infopolicy_from_jsobject(cmd->policy, info[1]->ToObject(), log) != AS_NODE_PARAM_OK) { + if (infopolicy_from_jsobject(cmd->policy, info[1].As(), log) != AS_NODE_PARAM_OK) { return CmdSetError(cmd, AEROSPIKE_ERR_PARAM, "Policy parameter is invalid"); } } diff --git a/src/main/config.cc b/src/main/config.cc index c4d53f763..7ccc4fb67 100644 --- a/src/main/config.cc +++ b/src/main/config.cc @@ -68,13 +68,13 @@ int config_from_jsobject(as_config* config, Local configObj, const LogIn } else if (maybe_hosts->IsArray()) { Local host_list = Local::Cast(maybe_hosts); for (uint32_t i = 0; i < host_list->Length(); i++) { - Local host = host_list->Get(i)->ToObject(); + Local host = host_list->Get(i).As(); Local maybe_addr = host->Get(Nan::New("addr").ToLocalChecked()); Local maybe_port = host->Get(Nan::New("port").ToLocalChecked()); uint16_t port = default_port; if (maybe_port->IsNumber()) { - port = (uint16_t) maybe_port->IntegerValue(); + port = (uint16_t) Nan::To(maybe_port).FromJust(); } else if (maybe_port->IsUndefined()) { // use default value } else { @@ -100,68 +100,68 @@ int config_from_jsobject(as_config* config, Local configObj, const LogIn } if (policies_val->IsObject()) { - Local policies_obj = policies_val->ToObject(); + Local policies_obj = policies_val.As(); as_policies *policies = &config->policies; Local policy_val = policies_obj->Get(Nan::New("apply").ToLocalChecked()); if (policy_val->IsObject()) { - if ((rc = applypolicy_from_jsobject(&policies->apply, policy_val->ToObject(), log)) != AS_NODE_PARAM_OK) { + if ((rc = applypolicy_from_jsobject(&policies->apply, policy_val.As(), log)) != AS_NODE_PARAM_OK) { goto Cleanup; } } policy_val = policies_obj->Get(Nan::New("batch").ToLocalChecked()); if (policy_val->IsObject()) { - if ((rc = batchpolicy_from_jsobject(&policies->batch, policy_val->ToObject(), log)) != AS_NODE_PARAM_OK) { + if ((rc = batchpolicy_from_jsobject(&policies->batch, policy_val.As(), log)) != AS_NODE_PARAM_OK) { goto Cleanup; } } policy_val = policies_obj->Get(Nan::New("info").ToLocalChecked()); if (policy_val->IsObject()) { - if ((rc = infopolicy_from_jsobject(&policies->info, policy_val->ToObject(), log)) != AS_NODE_PARAM_OK) { + if ((rc = infopolicy_from_jsobject(&policies->info, policy_val.As(), log)) != AS_NODE_PARAM_OK) { goto Cleanup; } } policy_val = policies_obj->Get(Nan::New("operate").ToLocalChecked()); if (policy_val->IsObject()) { - if ((rc = operatepolicy_from_jsobject(&policies->operate, policy_val->ToObject(), log)) != AS_NODE_PARAM_OK) { + if ((rc = operatepolicy_from_jsobject(&policies->operate, policy_val.As(), log)) != AS_NODE_PARAM_OK) { goto Cleanup; } } policy_val = policies_obj->Get(Nan::New("read").ToLocalChecked()); if (policy_val->IsObject()) { - if ((rc = readpolicy_from_jsobject(&policies->read, policy_val->ToObject(), log)) != AS_NODE_PARAM_OK) { + if ((rc = readpolicy_from_jsobject(&policies->read, policy_val.As(), log)) != AS_NODE_PARAM_OK) { goto Cleanup; } } policy_val = policies_obj->Get(Nan::New("remove").ToLocalChecked()); if (policy_val->IsObject()) { - if ((rc = removepolicy_from_jsobject(&policies->remove, policy_val->ToObject(), log)) != AS_NODE_PARAM_OK) { + if ((rc = removepolicy_from_jsobject(&policies->remove, policy_val.As(), log)) != AS_NODE_PARAM_OK) { goto Cleanup; } } policy_val = policies_obj->Get(Nan::New("scan").ToLocalChecked()); if (policy_val->IsObject()) { - if ((rc = scanpolicy_from_jsobject(&policies->scan, policy_val->ToObject(), log)) != AS_NODE_PARAM_OK) { + if ((rc = scanpolicy_from_jsobject(&policies->scan, policy_val.As(), log)) != AS_NODE_PARAM_OK) { goto Cleanup; } } policy_val = policies_obj->Get(Nan::New("query").ToLocalChecked()); if (policy_val->IsObject()) { - if ((rc = querypolicy_from_jsobject(&policies->query, policy_val->ToObject(), log)) != AS_NODE_PARAM_OK) { + if ((rc = querypolicy_from_jsobject(&policies->query, policy_val.As(), log)) != AS_NODE_PARAM_OK) { goto Cleanup; } } policy_val = policies_obj->Get(Nan::New("write").ToLocalChecked()); if (policy_val->IsObject()) { - if ((rc = writepolicy_from_jsobject(&policies->write, policy_val->ToObject(), log)) != AS_NODE_PARAM_OK) { + if ((rc = writepolicy_from_jsobject(&policies->write, policy_val.As(), log)) != AS_NODE_PARAM_OK) { goto Cleanup; } } @@ -171,7 +171,7 @@ int config_from_jsobject(as_config* config, Local configObj, const LogIn // If modlua path is passed in config object, set those values here if (configObj->Has(Nan::New("modlua").ToLocalChecked())) { - Local modlua = configObj->Get(Nan::New("modlua").ToLocalChecked())->ToObject(); + Local modlua = configObj->Get(Nan::New("modlua").ToLocalChecked()).As(); if ((rc = get_optional_string_property(&user_path, &defined, modlua, "userPath", log)) != AS_NODE_PARAM_OK) { goto Cleanup; } else if (defined) { @@ -196,7 +196,7 @@ int config_from_jsobject(as_config* config, Local configObj, const LogIn } if (configObj->Has(Nan::New("sharedMemory").ToLocalChecked())) { - Local shmConfigObj = configObj->Get(Nan::New("sharedMemory").ToLocalChecked())->ToObject(); + Local shmConfigObj = configObj->Get(Nan::New("sharedMemory").ToLocalChecked()).As(); config->use_shm = true; if ((rc = get_optional_bool_property(&config->use_shm, NULL, shmConfigObj, "enable", log)) != AS_NODE_PARAM_OK) { goto Cleanup; diff --git a/src/main/operations.cc b/src/main/operations.cc index 1a5411dda..28af1d69e 100644 --- a/src/main/operations.cc +++ b/src/main/operations.cc @@ -44,12 +44,12 @@ int get_optional_list_policy(as_list_policy* policy, bool* has_policy, Local policy_obj = maybe_policy_obj->ToObject(); + Local policy_obj = maybe_policy_obj.As(); as_list_order order; Local value = policy_obj->Get(Nan::New("order").ToLocalChecked()); if (value->IsNumber()) { - order = (as_list_order) value->IntegerValue(); + order = (as_list_order) Nan::To(value).FromJust(); } else if (value->IsUndefined()) { order = AS_LIST_UNORDERED; } else { @@ -60,7 +60,7 @@ int get_optional_list_policy(as_list_policy* policy, bool* has_policy, LocalGet(Nan::New("writeFlags").ToLocalChecked()); if (value->IsNumber()) { - write_flags = (as_list_write_flags) value->IntegerValue(); + write_flags = (as_list_write_flags) Nan::To(value).FromJust(); } else if (value->IsUndefined()) { write_flags = AS_LIST_WRITE_DEFAULT; } else { @@ -78,7 +78,7 @@ int get_list_return_type(as_list_return_type* return_type, Local obj, Lo Nan::HandleScope scope; Local value = obj->Get(Nan::New("returnType").ToLocalChecked()); if (value->IsNumber()) { - (*return_type) = (as_list_return_type) value->IntegerValue(); + (*return_type) = (as_list_return_type) Nan::To(value).FromJust(); } else if (value->IsUndefined()) { (*return_type) = AS_LIST_RETURN_NONE; } else { @@ -112,7 +112,7 @@ int get_map_policy(as_map_policy* policy, Local obj, LogInfo* log) as_v8_error(log, "Type error: policy should be an Object"); return AS_NODE_PARAM_ERR; } - Local policy_obj = maybe_policy_obj->ToObject(); + Local policy_obj = maybe_policy_obj.As(); as_map_order order = AS_MAP_UNORDERED; bool order_set = false; @@ -147,7 +147,7 @@ int get_map_return_type(as_map_return_type* return_type, Local obj, LogI Nan::HandleScope scope; Local value = obj->Get(Nan::New("returnType").ToLocalChecked()); if (value->IsNumber()) { - (*return_type) = (as_map_return_type) value->IntegerValue(); + (*return_type) = (as_map_return_type) Nan::To(value).FromJust(); } else if (value->IsUndefined()) { (*return_type) = AS_MAP_RETURN_NONE; } else { @@ -174,7 +174,7 @@ int add_write_op(as_operations* ops, Local obj, LogInfo* log) rc = AS_NODE_PARAM_ERR; } } else if (v8val->IsNumber()) { - int64_t val = v8val->IntegerValue(); + int64_t val = Nan::To(v8val).FromJust(); as_v8_debug(log, "bin=%s, value=%i", binName, val); if (!as_operations_add_write_int64(ops, binName, val)) { rc = AS_NODE_PARAM_ERR; @@ -188,7 +188,7 @@ int add_write_op(as_operations* ops, Local obj, LogInfo* log) } else if (node::Buffer::HasInstance(v8val)) { int len ; uint8_t* data ; - if ((rc = extract_blob_from_jsobject(&data, &len, v8val->ToObject(), log)) == AS_NODE_PARAM_OK) { + if ((rc = extract_blob_from_jsobject(&data, &len, v8val.As(), log)) == AS_NODE_PARAM_OK) { as_v8_debug(log, "bin=%s, value=, len=%i", binName, len); if (!as_operations_add_write_rawp(ops, binName, data, len, true)) { rc = AS_NODE_PARAM_ERR; @@ -266,7 +266,7 @@ int add_incr_op(as_operations* ops, Local obj, LogInfo* log) if (binName != NULL) free (binName); return AS_NODE_PARAM_OK; } else if (v8val->IsNumber()) { - int64_t binValue = v8val->IntegerValue(); + int64_t binValue = Nan::To(v8val).FromJust(); as_v8_debug(log, "bin=%s, value=%i", binName, binValue); as_operations_add_incr(ops, binName, binValue); if (binName != NULL) free (binName); @@ -294,7 +294,7 @@ int add_prepend_op(as_operations* ops, Local obj, LogInfo* log) if (binName) free(binName); return AS_NODE_PARAM_OK; } else if (v8val->IsObject()) { - Local binObj = v8val->ToObject(); + Local binObj = v8val.As(); int len; uint8_t* data; if (extract_blob_from_jsobject(&data, &len, binObj, log) != AS_NODE_PARAM_OK) { @@ -327,7 +327,7 @@ int add_append_op(as_operations* ops, Local obj, LogInfo* log) if (binName) free(binName); return AS_NODE_PARAM_OK; } else if (v8val->IsObject()) { - Local binObj = v8val->ToObject(); + Local binObj = v8val.As(); int len ; uint8_t* data ; if (extract_blob_from_jsobject(&data, &len, binObj, log) != AS_NODE_PARAM_OK) { @@ -1402,7 +1402,7 @@ int add_map_put_items_op(as_operations* ops, Local obj, LogInfo* log) as_v8_error(log, "Type error: items property should be an Object"); return AS_NODE_PARAM_ERR; } - if (map_from_jsobject(&items, v8items->ToObject(), log) != AS_NODE_PARAM_OK) { + if (map_from_jsobject(&items, v8items.As(), log) != AS_NODE_PARAM_OK) { as_v8_error(log, "Type error: items property should be an Object"); return AS_NODE_PARAM_ERR; } @@ -2351,7 +2351,7 @@ int operations_from_jsarray(as_operations* ops, Local arr, LogInfo* log) int result = AS_NODE_PARAM_OK; int64_t op; for (uint32_t i = 0; i < capacity; i++) { - Local obj = arr->Get(i)->ToObject(); + Local obj = arr->Get(i).As(); setTTL(obj, &ops->ttl, log); result = get_int64_property(&op, obj, "op", log); if (result == AS_NODE_PARAM_OK) { diff --git a/src/main/predexp.cc b/src/main/predexp.cc index 1f8095e7b..28dda3092 100644 --- a/src/main/predexp.cc +++ b/src/main/predexp.cc @@ -92,7 +92,7 @@ const predex_table_entry predex_table[] = { as_predexp_base* convert_predexp(Local predexp) { - int code = (int) predexp->Get(Nan::New("code").ToLocalChecked())->ToObject()->IntegerValue(); + int code = Nan::To(predexp->Get(Nan::New("code").ToLocalChecked())).FromJust(); const predex_table_entry *entry = &predex_table[code]; if (!entry) { return NULL; @@ -111,13 +111,13 @@ convert_predexp(Local predexp) return res; } case INT32_ARG: - return entry->conv.fint32((int32_t) arg->IntegerValue()); + return entry->conv.fint32(Nan::To(arg).FromJust()); case INT64_ARG: - return entry->conv.fint64(arg->IntegerValue()); + return entry->conv.fint64(Nan::To(arg).FromJust()); case UINT16_ARG: - return entry->conv.fuint16((uint16_t) arg->IntegerValue()); + return entry->conv.fuint16(Nan::To(arg).FromJust()); case UINT32_ARG: - return entry->conv.fuint32((uint32_t) arg->IntegerValue()); + return entry->conv.fuint32(Nan::To(arg).FromJust()); default: return NULL; } diff --git a/src/main/query.cc b/src/main/query.cc index bce87421d..9f020c7b8 100644 --- a/src/main/query.cc +++ b/src/main/query.cc @@ -53,7 +53,7 @@ void setup_query(as_query* query, Local ns, Local set, LocalIsObject()) { return; } - Local options = maybe_options->ToObject(); + Local options = maybe_options.As(); Local filters_val = options->Get(Nan::New("filters").ToLocalChecked()); TYPE_CHECK_OPT(filters_val, IsArray, "filters must be an array"); @@ -63,16 +63,16 @@ void setup_query(as_query* query, Local ns, Local set, Local filter = filters->Get(i)->ToObject(); + Local filter = filters->Get(i).As(); Local bin = filter->Get(Nan::New("bin").ToLocalChecked()); if (!bin->IsString()) { as_v8_error(log, "Bin value must be string"); Nan::ThrowError("Bin value is not a string"); } const char* bin_name = *Nan::Utf8String(bin); - as_predicate_type predicate = (as_predicate_type) filter->Get(Nan::New("predicate").ToLocalChecked())->ToObject()->IntegerValue(); - as_index_type type = (as_index_type) filter->Get(Nan::New("type").ToLocalChecked())->ToObject()->IntegerValue(); - as_index_datatype datatype = (as_index_datatype) filter->Get(Nan::New("datatype").ToLocalChecked())->ToObject()->IntegerValue(); + as_predicate_type predicate = (as_predicate_type) Nan::To(filter->Get(Nan::New("predicate").ToLocalChecked())).FromJust(); + as_index_type type = (as_index_type) Nan::To(filter->Get(Nan::New("type").ToLocalChecked())).FromJust(); + as_index_datatype datatype = (as_index_datatype) Nan::To(filter->Get(Nan::New("datatype").ToLocalChecked())).FromJust(); as_v8_debug(log, "Building filter on predicate type %d, index type %d, data type %d, bin name '%s'", predicate, type, datatype, bin_name); switch(predicate) { case AS_PREDICATE_RANGE: @@ -81,8 +81,8 @@ void setup_query(as_query* query, Local ns, Local set, Local v8min = filter->Get(Nan::New("min").ToLocalChecked()); Local v8max = filter->Get(Nan::New("max").ToLocalChecked()); if (v8min->IsNumber() && v8max->IsNumber()) { - const int64_t min = v8min->IntegerValue(); - const int64_t max = v8max->IntegerValue(); + const int64_t min = Nan::To(v8min).FromJust(); + const int64_t max = Nan::To(v8max).FromJust(); as_query_where(query, bin_name, predicate, type, datatype, min, max); as_v8_debug(log, "Integer range predicate from %llu to %llu", min, max); } else { @@ -106,7 +106,7 @@ void setup_query(as_query* query, Local ns, Local set, Local value = filter->Get(Nan::New("val").ToLocalChecked()); if (value->IsNumber()) { - const int64_t val = value->IntegerValue(); + const int64_t val = Nan::To(value).FromJust(); as_query_where(query, bin_name, predicate, type, datatype, val); as_v8_debug(log, "Integer equality predicate %d", val); } else { @@ -137,7 +137,7 @@ void setup_query(as_query* query, Local ns, Local set, Local 0) { as_query_predexp_init(query, size); for (int i = 0; i < size; i++) { - Local predexpObj = predexp_ary->Get(i)->ToObject(); + Local predexpObj = predexp_ary->Get(i).As(); as_predexp_base* predexp = convert_predexp(predexpObj); as_query_predexp_add(query, predexp); } @@ -165,7 +165,7 @@ void setup_query(as_query* query, Local ns, Local set, Local nobins = options->Get(Nan::New("nobins").ToLocalChecked()); TYPE_CHECK_OPT(nobins, IsBoolean, "nobins must be a boolean"); if (nobins->IsBoolean()) { - query->no_bins = nobins->ToBoolean()->Value(); + query->no_bins = Nan::To(nobins).FromJust(); } Local udf = options->Get(Nan::New("udf").ToLocalChecked()); @@ -176,7 +176,7 @@ void setup_query(as_query* query, Local ns, Local set, LocalToObject(), log); + int status = udfargs_from_jsobject(&filename, &funcname, &arglist, udf.As(), log); if (status != 0) { as_v8_error(log, "Parsing UDF arguments for query object failed"); Nan::ThrowTypeError("Error in parsing the UDF parameters"); diff --git a/src/main/scan.cc b/src/main/scan.cc index c2bc64c8d..d4d1867c4 100644 --- a/src/main/scan.cc +++ b/src/main/scan.cc @@ -52,7 +52,7 @@ void setup_scan(as_scan* scan, Local ns, Local set, Local m if (!maybe_options->IsObject()) { return; } - Local options = maybe_options->ToObject(); + Local options = maybe_options.As(); Local selected = options->Get(Nan::New("selected").ToLocalChecked()); TYPE_CHECK_OPT(selected, IsArray, "selected must be an array"); @@ -75,25 +75,25 @@ void setup_scan(as_scan* scan, Local ns, Local set, Local m Local nobins = options->Get(Nan::New("nobins").ToLocalChecked()); TYPE_CHECK_OPT(nobins, IsBoolean, "nobins must be a boolean"); if (nobins->IsBoolean()) { - as_scan_set_nobins(scan, nobins->ToBoolean()->Value()); + as_scan_set_nobins(scan, Nan::To(nobins).FromJust()); } Local concurrent = options->Get(Nan::New("concurrent").ToLocalChecked()); TYPE_CHECK_OPT(concurrent, IsBoolean, "concurrent must be a boolean"); if (concurrent->IsBoolean()) { - as_scan_set_concurrent(scan, concurrent->ToBoolean()->Value()); + as_scan_set_concurrent(scan, Nan::To(concurrent).FromJust()); } Local percent = options->Get(Nan::New("percent").ToLocalChecked()); TYPE_CHECK_OPT(percent, IsNumber, "percent must be a number"); if (percent->IsNumber()) { - as_scan_set_percent(scan, (uint8_t) percent->IntegerValue()); + as_scan_set_percent(scan, (uint8_t) Nan::To(percent).FromJust()); } Local priority = options->Get(Nan::New("priority").ToLocalChecked()); TYPE_CHECK_OPT(priority, IsNumber, "prioriy must be a number"); if (priority->IsNumber()) { - as_scan_set_priority(scan, (as_scan_priority) priority->IntegerValue()); + as_scan_set_priority(scan, (as_scan_priority) Nan::To(priority).FromJust()); } Local udf = options->Get(Nan::New("udf").ToLocalChecked()); @@ -104,7 +104,7 @@ void setup_scan(as_scan* scan, Local ns, Local set, Local m char* filename = module; char* funcname = func; as_list* arglist = NULL; - int status = udfargs_from_jsobject(&filename, &funcname, &arglist, udf->ToObject(), log); + int status = udfargs_from_jsobject(&filename, &funcname, &arglist, udf.As(), log); if (status != 0) { as_v8_error(log, "Parsing UDF arguments for scan object failed"); Nan::ThrowTypeError("Error in parsing the UDF parameters"); diff --git a/src/main/util/conversions.cc b/src/main/util/conversions.cc index 04969f010..04971fef5 100644 --- a/src/main/util/conversions.cc +++ b/src/main/util/conversions.cc @@ -100,7 +100,7 @@ int get_int_property(int* intp, Local obj, char const* prop, const LogIn as_v8_error(log, "Type error: %s property should be integer", prop); return AS_NODE_PARAM_ERR; } - (*intp) = (int) value->IntegerValue(); + (*intp) = Nan::To(value).FromJust(); as_v8_detail(log, "%s => (int) %d", prop, *intp); return AS_NODE_PARAM_OK; } @@ -111,7 +111,7 @@ int get_optional_int_property(int* intp, bool* defined, Local obj, char Local value = obj->Get(Nan::New(prop).ToLocalChecked()); if (value->IsNumber()) { if (defined != NULL) (*defined) = true; - (*intp) = (int) value->IntegerValue(); + (*intp) = Nan::To(value).FromJust(); as_v8_detail(log, "%s => (int) %d", prop, *intp); } else if (value->IsUndefined() || value->IsNull()) { if (defined != NULL) (*defined) = false; @@ -130,7 +130,7 @@ int get_int64_property(int64_t* intp, Local obj, char const* prop, const as_v8_error(log, "Type error: %s property should be integer", prop); return AS_NODE_PARAM_ERR; } - (*intp) = value->IntegerValue(); + (*intp) = Nan::To(value).FromJust(); as_v8_detail(log, "%s => (int64) %d", prop, *intp); return AS_NODE_PARAM_OK; } @@ -141,7 +141,7 @@ int get_optional_int64_property(int64_t* intp, bool* defined, Local obj, Local value = obj->Get(Nan::New(prop).ToLocalChecked()); if (value->IsNumber()) { if (defined != NULL) (*defined) = true; - (*intp) = value->IntegerValue(); + (*intp) = Nan::To(value).FromJust(); as_v8_detail(log, "%s => (int64) %d", prop, *intp); } else if (value->IsUndefined() || value->IsNull()) { if (defined != NULL) (*defined) = false; @@ -157,9 +157,9 @@ int get_optional_int32_property(int32_t* intp, bool* defined, Local obj, { Nan::HandleScope scope; Local value = obj->Get(Nan::New(prop).ToLocalChecked()); - if (value->IsInt32()) { + if (value->IsNumber()) { if (defined != NULL) (*defined) = true; - (*intp) = value->Int32Value(); + (*intp) = Nan::To(value).FromJust(); as_v8_detail(log, "%s => (uint32) %d", prop, *intp); } else if (value->IsUndefined() || value->IsNull()) { if (defined != NULL) (*defined) = false; @@ -175,9 +175,9 @@ int get_optional_uint32_property(uint32_t* intp, bool* defined, Local ob { Nan::HandleScope scope; Local value = obj->Get(Nan::New(prop).ToLocalChecked()); - if (value->IsUint32()) { + if (value->IsNumber()) { if (defined != NULL) (*defined) = true; - (*intp) = value->Uint32Value(); + (*intp) = Nan::To(value).FromJust(); as_v8_detail(log, "%s => (uint32) %d", prop, *intp); } else if (value->IsUndefined() || value->IsNull()) { if (defined != NULL) (*defined) = false; @@ -195,7 +195,7 @@ int get_optional_bool_property(bool* boolp, bool* defined, Local obj, ch Local value = obj->Get(Nan::New(prop).ToLocalChecked()); if (value->IsBoolean()) { if (defined != NULL) (*defined) = true; - (*boolp) = value->BooleanValue(); + (*boolp) = Nan::To(value).FromJust(); as_v8_detail(log, "%s => (bool) %d", prop, *boolp); } else if (value->IsUndefined() || value->IsNull()) { if (defined != NULL) (*defined) = false; @@ -249,7 +249,7 @@ int host_from_jsobject(Local obj, char** addr, uint16_t* port, const Log Local addrVal = obj->Get(Nan::New("addr").ToLocalChecked()); if ( addrVal->IsString() ) { *addr = (char*) malloc (HOST_ADDRESS_SIZE); - strcpy(*addr, *Nan::Utf8String(addrVal->ToString())); + strcpy(*addr, *Nan::Utf8String(addrVal.As())); as_v8_detail(log, "host addr : %s", (*addr)); } else { @@ -260,7 +260,7 @@ int host_from_jsobject(Local obj, char** addr, uint16_t* port, const Log if ( obj->Has(Nan::New("port").ToLocalChecked()) ){ Local portVal = obj->Get(Nan::New("port").ToLocalChecked()); if ( portVal->IsNumber() ) { - *port = (uint16_t) portVal->IntegerValue(); + *port = (uint16_t) Nan::To(portVal).FromJust(); } else { return AS_NODE_PARAM_ERR; @@ -277,13 +277,13 @@ int log_from_jsobject(LogInfo* log, Local obj) FILE* fd = log->fd; if (obj->IsObject()) { - Local v8_log = obj->ToObject(); + Local v8_log = obj.As(); // `level` is optional if (v8_log->Has(Nan::New("level").ToLocalChecked())) { Local v8_log_level = v8_log->Get(Nan::New("level").ToLocalChecked()); if (v8_log_level->IsNumber()){ - level = (as_log_level) v8_log_level->IntegerValue(); + level = (as_log_level) Nan::To(v8_log_level).FromJust(); } else if (v8_log_level->IsNull() || v8_log_level->IsUndefined()){ // `null` and `undefined` imply the value should not change. } else { @@ -296,7 +296,7 @@ int log_from_jsobject(LogInfo* log, Local obj) if (rc == AS_NODE_PARAM_OK && v8_log->Has(Nan::New("file").ToLocalChecked())) { Local v8_file = obj->Get(Nan::New("file").ToLocalChecked()); if (v8_file->IsNumber()) { - int fildes = (int) v8_file->IntegerValue(); + int fildes = Nan::To(v8_file).FromJust(); #if !defined(_MSC_VER) fd = fdopen(fildes, "a"); #else @@ -781,7 +781,7 @@ int extract_blob_from_jsobject(uint8_t** data, int* len, Local obj, cons bool instanceof(Local value, const char * type) { if (value->IsObject()) { - Local ctor_name = value->ToObject()->GetConstructorName(); + Local ctor_name = value.As()->GetConstructorName(); Nan::Utf8String cn(ctor_name); return 0 == strncmp(*cn, type, strlen(type)); } else { @@ -805,8 +805,8 @@ bool instanceof(Local value, const char * type) bool is_double_value(Local value) { if (value->IsNumber()) { - int64_t i = value->IntegerValue(); - double d = value->NumberValue(); + int64_t i = Nan::To(value).FromJust(); + double d = Nan::To(value).FromJust(); return d != (double)i; } return instanceof(value, DoubleType); @@ -815,9 +815,9 @@ bool is_double_value(Local value) double double_value(Local value) { if (instanceof(value, DoubleType)) { - value = value->ToObject()->Get(Nan::New("Double").ToLocalChecked()); + value = value.As()->Get(Nan::New("Double").ToLocalChecked()); } - return (double) value->NumberValue(); + return Nan::To(value).FromJust(); } bool is_geojson_value(Local value) @@ -827,7 +827,7 @@ bool is_geojson_value(Local value) char* geojson_as_string(Local value) { - Local strval = value->ToObject()->Get(Nan::New("str").ToLocalChecked()); + Local strval = value.As()->Get(Nan::New("str").ToLocalChecked()); return strdup(*Nan::Utf8String(strval)); } @@ -854,7 +854,7 @@ int list_from_jsarray(as_list** list, Local array, const LogInfo* log) int map_from_jsobject(as_map** map, Local obj, const LogInfo* log) { - const Local props = obj->ToObject()->GetOwnPropertyNames(); + const Local props = obj.As()->GetOwnPropertyNames(); const uint32_t capacity = props->Length(); as_v8_detail(log, "Creating new as_hashmap with capacity %d", capacity); as_hashmap* hashmap = as_hashmap_new(capacity); @@ -889,19 +889,21 @@ int asval_from_jsvalue(as_val** value, Local v8value, const LogInfo* log) as_v8_detail(log, "Object passed is undefined"); *value = (as_val*) &as_nil; } else if (v8value->IsBoolean()) { - *value = (as_val*) as_boolean_new(v8value->BooleanValue()); + *value = (as_val*) as_boolean_new(Nan::To(v8value).FromJust()); } else if (v8value->IsString()) { *value = (as_val*) as_string_new(strdup(*Nan::Utf8String(v8value)), true); - } else if (v8value->IsInt32() || v8value->IsUint32()) { - *value = (as_val*) as_integer_new(v8value->IntegerValue()); + } else if (v8value->IsInt32()) { + *value = (as_val*) as_integer_new(Nan::To(v8value).FromJust()); + } else if (v8value->IsUint32()) { + *value = (as_val*) as_integer_new(Nan::To(v8value).FromJust()); } else if (is_double_value(v8value)) { *value = (as_val*) as_double_new(double_value(v8value)); } else if (v8value->IsNumber()) { - *value = (as_val*) as_integer_new(v8value->IntegerValue()); + *value = (as_val*) as_integer_new(Nan::To(v8value).FromJust()); } else if (node::Buffer::HasInstance(v8value)) { int size; uint8_t* data; - if (extract_blob_from_jsobject(&data, &size, v8value->ToObject(), log) != AS_NODE_PARAM_OK) { + if (extract_blob_from_jsobject(&data, &size, v8value.As(), log) != AS_NODE_PARAM_OK) { as_v8_error(log, "Extractingb blob from a js object failed"); return AS_NODE_PARAM_ERR; } @@ -914,7 +916,7 @@ int asval_from_jsvalue(as_val** value, Local v8value, const LogInfo* log) char* jsonstr = geojson_as_string(v8value); *value = (as_val*) as_geojson_new(jsonstr, true); } else { // generic object - treat as map - if (map_from_jsobject((as_map**) value, v8value->ToObject(), log) != AS_NODE_PARAM_OK) { + if (map_from_jsobject((as_map**) value, v8value.As(), log) != AS_NODE_PARAM_OK) { return AS_NODE_PARAM_ERR; } } @@ -1030,7 +1032,7 @@ int setTTL(Local obj, uint32_t* ttl, const LogInfo* log) as_v8_detail(log, "Setting ttl from JS object"); Local v8ttl = obj->Get(Nan::New("ttl").ToLocalChecked()) ; if (v8ttl->IsNumber()) { - (*ttl) = (uint32_t) v8ttl->IntegerValue(); + (*ttl) = Nan::To(v8ttl).FromJust(); as_v8_detail(log, "TTL: %d", (*ttl)); } else if (v8ttl->IsNull() || v8ttl->IsUndefined()) { // noop - ttl may not be specified @@ -1047,7 +1049,7 @@ int setGeneration(Local obj, uint16_t* generation, const LogInfo* log) if (obj->Has(Nan::New("gen").ToLocalChecked()) ) { Local v8gen = obj->Get(Nan::New("gen").ToLocalChecked()); if (v8gen->IsNumber()) { - (*generation) = (uint16_t) v8gen->IntegerValue(); + (*generation) = (uint16_t) Nan::To(v8gen).FromJust(); as_v8_detail(log, "Generation: %d", (*generation)); } else if (v8gen->IsNull() || v8gen->IsUndefined()) { // noop - gen may not be specified @@ -1201,12 +1203,12 @@ int key_from_jsobject(as_key* key, Local obj, const LogInfo* log) as_v8_error(log, "Invalid key value: double - only string, integer and Buffer are supported"); return AS_NODE_PARAM_ERR; } else if (val_obj->IsNumber()) { - int64_t value = val_obj->IntegerValue(); + int64_t value = Nan::To(val_obj).FromJust(); as_key_init_int64(key, ns, set, value); as_v8_detail(log, "key.key = %d", value); has_value = true; } else if (val_obj->IsObject()) { - Local obj = val_obj->ToObject(); + Local obj = val_obj.As(); int size ; uint8_t* data ; if (extract_blob_from_jsobject(&data, &size, obj, log) != AS_NODE_PARAM_OK) { @@ -1238,7 +1240,7 @@ int key_from_jsobject(as_key* key, Local obj, const LogInfo* log) } else { Local digest_value = obj->Get(Nan::New("digest").ToLocalChecked()); if (digest_value->IsObject()) { - Local digest_obj = digest_value->ToObject(); + Local digest_obj = digest_value.As(); int size; uint8_t* data; if (extract_blob_from_jsobject(&data, &size, digest_obj, log) != AS_NODE_PARAM_OK) { @@ -1271,7 +1273,7 @@ int batch_from_jsarray(as_batch* batch, Local arr, const LogInfo* log) uint32_t len = arr->Length(); as_batch_init(batch, len); for (uint32_t i = 0; i < len; i++) { - Local key = arr->Get(i)->ToObject(); + Local key = arr->Get(i).As(); if (key_from_jsobject(as_batch_keyat(batch, i), key, log) != AS_NODE_PARAM_OK) { as_v8_error(log, "Parsing batch key [%d] failed", i); return AS_NODE_PARAM_ERR; @@ -1287,9 +1289,9 @@ int batch_read_records_from_jsarray(as_batch_read_records** records, Local obj = arr->Get(i)->ToObject(); + Local obj = arr->Get(i).As(); - Local key = obj->Get(Nan::New("key").ToLocalChecked())->ToObject(); + Local key = obj->Get(Nan::New("key").ToLocalChecked()).As(); if (key_from_jsobject(&record->key, key, log) != AS_NODE_PARAM_OK) { as_v8_error(log, "Parsing batch keys failed"); return AS_NODE_PARAM_ERR; @@ -1309,7 +1311,7 @@ int batch_read_records_from_jsarray(as_batch_read_records** records, Local maybe_read_all_bins = obj->Get(Nan::New("read_all_bins").ToLocalChecked()); if (maybe_read_all_bins->IsBoolean()) { - record->read_all_bins = maybe_read_all_bins->ToBoolean()->Value(); + record->read_all_bins = Nan::To(maybe_read_all_bins).FromJust(); } } return AS_NODE_PARAM_OK; @@ -1363,7 +1365,7 @@ int udfargs_from_jsobject(char** filename, char** funcname, as_list** args, Loca if (obj->Has(Nan::New("module").ToLocalChecked())) { Local module = obj->Get(Nan::New("module").ToLocalChecked()); if (module->IsString()) { - size_t size = module->ToString()->Length() + 1; + size_t size = module.As()->Length() + 1; if (*filename == NULL) { *filename = (char*) cf_malloc(sizeof(char) * size); } @@ -1385,7 +1387,7 @@ int udfargs_from_jsobject(char** filename, char** funcname, as_list** args, Loca if (obj->Has(Nan::New("funcname").ToLocalChecked())) { Local v8_funcname = obj->Get(Nan::New("funcname").ToLocalChecked()); if (v8_funcname->IsString()) { - size_t size = v8_funcname->ToString()->Length() + 1; + size_t size = v8_funcname.As()->Length() + 1; if (*funcname == NULL) { *funcname = (char*) cf_malloc(sizeof(char) * size); }