Commit c9494525 by Marcin Cieslak

Change obj->XxxValue() to Nan::To<xxx>() in sass_types

parent a130dae8
...@@ -62,7 +62,7 @@ namespace SassTypes ...@@ -62,7 +62,7 @@ namespace SassTypes
return Nan::ThrowError(Nan::New("Expected one boolean argument").ToLocalChecked()); return Nan::ThrowError(Nan::New("Expected one boolean argument").ToLocalChecked());
} }
info.GetReturnValue().Set((get_singleton(info[0]->ToBoolean()->Value()).get_js_object())); info.GetReturnValue().Set(get_singleton(Nan::To<bool>(info[0]).FromJust()).get_js_object());
} }
} }
......
...@@ -15,7 +15,7 @@ namespace SassTypes ...@@ -15,7 +15,7 @@ namespace SassTypes
throw std::invalid_argument("Only argument should be an integer."); throw std::invalid_argument("Only argument should be an integer.");
} }
argb = raw_val[0]->ToInt32()->Value(); argb = Nan::To<int32_t>(raw_val[0]).FromJust();
a = (double)((argb >> 030) & 0xff) / 0xff; a = (double)((argb >> 030) & 0xff) / 0xff;
r = (double)((argb >> 020) & 0xff); r = (double)((argb >> 020) & 0xff);
g = (double)((argb >> 010) & 0xff); g = (double)((argb >> 010) & 0xff);
...@@ -27,7 +27,7 @@ namespace SassTypes ...@@ -27,7 +27,7 @@ namespace SassTypes
throw std::invalid_argument("Constructor arguments should be numbers exclusively."); throw std::invalid_argument("Constructor arguments should be numbers exclusively.");
} }
a = raw_val[3]->ToNumber()->Value(); a = Nan::To<double>(raw_val[3]).FromJust();
// fall through vvv // fall through vvv
case 3: case 3:
...@@ -35,9 +35,9 @@ namespace SassTypes ...@@ -35,9 +35,9 @@ namespace SassTypes
throw std::invalid_argument("Constructor arguments should be numbers exclusively."); throw std::invalid_argument("Constructor arguments should be numbers exclusively.");
} }
r = raw_val[0]->ToNumber()->Value(); r = Nan::To<double>(raw_val[0]).FromJust();
g = raw_val[1]->ToNumber()->Value(); g = Nan::To<double>(raw_val[1]).FromJust();
b = raw_val[2]->ToNumber()->Value(); b = Nan::To<double>(raw_val[2]).FromJust();
break; break;
case 0: case 0:
...@@ -86,7 +86,7 @@ namespace SassTypes ...@@ -86,7 +86,7 @@ namespace SassTypes
return Nan::ThrowError(Nan::New("Supplied value should be a number").ToLocalChecked()); return Nan::ThrowError(Nan::New("Supplied value should be a number").ToLocalChecked());
} }
sass_color_set_r(unwrap(info.This())->value, info[0]->ToNumber()->Value()); sass_color_set_r(unwrap(info.This())->value, Nan::To<double>(info[0]).FromJust());
} }
NAN_METHOD(Color::SetG) { NAN_METHOD(Color::SetG) {
...@@ -98,7 +98,7 @@ namespace SassTypes ...@@ -98,7 +98,7 @@ namespace SassTypes
return Nan::ThrowError(Nan::New("Supplied value should be a number").ToLocalChecked()); return Nan::ThrowError(Nan::New("Supplied value should be a number").ToLocalChecked());
} }
sass_color_set_g(unwrap(info.This())->value, info[0]->ToNumber()->Value()); sass_color_set_g(unwrap(info.This())->value, Nan::To<double>(info[0]).FromJust());
} }
NAN_METHOD(Color::SetB) { NAN_METHOD(Color::SetB) {
...@@ -110,7 +110,7 @@ namespace SassTypes ...@@ -110,7 +110,7 @@ namespace SassTypes
return Nan::ThrowError(Nan::New("Supplied value should be a number").ToLocalChecked()); return Nan::ThrowError(Nan::New("Supplied value should be a number").ToLocalChecked());
} }
sass_color_set_b(unwrap(info.This())->value, info[0]->ToNumber()->Value()); sass_color_set_b(unwrap(info.This())->value, Nan::To<double>(info[0]).FromJust());
} }
NAN_METHOD(Color::SetA) { NAN_METHOD(Color::SetA) {
...@@ -122,6 +122,6 @@ namespace SassTypes ...@@ -122,6 +122,6 @@ namespace SassTypes
return Nan::ThrowError(Nan::New("Supplied value should be a number").ToLocalChecked()); return Nan::ThrowError(Nan::New("Supplied value should be a number").ToLocalChecked());
} }
sass_color_set_a(unwrap(info.This())->value, info[0]->ToNumber()->Value()); sass_color_set_a(unwrap(info.This())->value, Nan::To<double>(info[0]).FromJust());
} }
} }
...@@ -14,14 +14,14 @@ namespace SassTypes ...@@ -14,14 +14,14 @@ namespace SassTypes
throw std::invalid_argument("First argument should be an integer."); throw std::invalid_argument("First argument should be an integer.");
} }
length = raw_val[0]->ToInt32()->Value(); length = Nan::To<uint32_t>(raw_val[0]).FromJust();
if (raw_val.size() >= 2) { if (raw_val.size() >= 2) {
if (!raw_val[1]->IsBoolean()) { if (!raw_val[1]->IsBoolean()) {
throw std::invalid_argument("Second argument should be a boolean."); throw std::invalid_argument("Second argument should be a boolean.");
} }
comma = raw_val[1]->ToBoolean()->Value(); comma = Nan::To<bool>(raw_val[1]).FromJust();
} }
} }
...@@ -47,14 +47,14 @@ namespace SassTypes ...@@ -47,14 +47,14 @@ namespace SassTypes
} }
Sass_Value* list = unwrap(info.This())->value; Sass_Value* list = unwrap(info.This())->value;
size_t index = info[0]->ToInt32()->Value(); size_t index = Nan::To<uint32_t>(info[0]).FromJust();
if (index >= sass_list_get_length(list)) { if (index >= sass_list_get_length(list)) {
return Nan::ThrowError(Nan::New("Out of bound index").ToLocalChecked()); return Nan::ThrowError(Nan::New("Out of bound index").ToLocalChecked());
} }
info.GetReturnValue().Set(Factory::create(sass_list_get_value(list, info[0]->ToInt32()->Value()))->get_js_object()); info.GetReturnValue().Set(Factory::create(sass_list_get_value(list, Nan::To<uint32_t>(info[0]).FromJust()))->get_js_object());
} }
NAN_METHOD(List::SetValue) { NAN_METHOD(List::SetValue) {
...@@ -71,7 +71,7 @@ namespace SassTypes ...@@ -71,7 +71,7 @@ namespace SassTypes
} }
Value* sass_value = Factory::unwrap(info[1]); Value* sass_value = Factory::unwrap(info[1]);
sass_list_set_value(unwrap(info.This())->value, info[0]->ToInt32()->Value(), sass_value->get_sass_value()); sass_list_set_value(unwrap(info.This())->value, Nan::To<uint32_t>(info[0]).FromJust(), sass_value->get_sass_value());
} }
NAN_METHOD(List::GetSeparator) { NAN_METHOD(List::GetSeparator) {
...@@ -87,7 +87,7 @@ namespace SassTypes ...@@ -87,7 +87,7 @@ namespace SassTypes
return Nan::ThrowError(Nan::New("Supplied value should be a boolean").ToLocalChecked()); return Nan::ThrowError(Nan::New("Supplied value should be a boolean").ToLocalChecked());
} }
sass_list_set_separator(unwrap(info.This())->value, info[0]->ToBoolean()->Value() ? SASS_COMMA : SASS_SPACE); sass_list_set_separator(unwrap(info.This())->value, Nan::To<bool>(info[0]).FromJust() ? SASS_COMMA : SASS_SPACE);
} }
NAN_METHOD(List::GetLength) { NAN_METHOD(List::GetLength) {
......
...@@ -13,7 +13,7 @@ namespace SassTypes ...@@ -13,7 +13,7 @@ namespace SassTypes
throw std::invalid_argument("First argument should be an integer."); throw std::invalid_argument("First argument should be an integer.");
} }
length = raw_val[0]->ToInt32()->Value(); length = Nan::To<uint32_t>(raw_val[0]).FromJust();
} }
return sass_make_map(length); return sass_make_map(length);
...@@ -38,14 +38,14 @@ namespace SassTypes ...@@ -38,14 +38,14 @@ namespace SassTypes
} }
Sass_Value* map = unwrap(info.This())->value; Sass_Value* map = unwrap(info.This())->value;
size_t index = info[0]->ToInt32()->Value(); size_t index = Nan::To<uint32_t>(info[0]).FromJust();
if (index >= sass_map_get_length(map)) { if (index >= sass_map_get_length(map)) {
return Nan::ThrowError(Nan::New("Out of bound index").ToLocalChecked()); return Nan::ThrowError(Nan::New("Out of bound index").ToLocalChecked());
} }
info.GetReturnValue().Set(Factory::create(sass_map_get_value(map, info[0]->ToInt32()->Value()))->get_js_object()); info.GetReturnValue().Set(Factory::create(sass_map_get_value(map, Nan::To<uint32_t>(info[0]).FromJust()))->get_js_object());
} }
NAN_METHOD(Map::SetValue) { NAN_METHOD(Map::SetValue) {
...@@ -62,7 +62,7 @@ namespace SassTypes ...@@ -62,7 +62,7 @@ namespace SassTypes
} }
Value* sass_value = Factory::unwrap(info[1]); Value* sass_value = Factory::unwrap(info[1]);
sass_map_set_value(unwrap(info.This())->value, info[0]->ToInt32()->Value(), sass_value->get_sass_value()); sass_map_set_value(unwrap(info.This())->value, Nan::To<uint32_t>(info[0]).FromJust(), sass_value->get_sass_value());
} }
NAN_METHOD(Map::GetKey) { NAN_METHOD(Map::GetKey) {
...@@ -76,14 +76,14 @@ namespace SassTypes ...@@ -76,14 +76,14 @@ namespace SassTypes
} }
Sass_Value* map = unwrap(info.This())->value; Sass_Value* map = unwrap(info.This())->value;
size_t index = info[0]->ToInt32()->Value(); size_t index = Nan::To<uint32_t>(info[0]).FromJust();
if (index >= sass_map_get_length(map)) { if (index >= sass_map_get_length(map)) {
return Nan::ThrowError(Nan::New("Out of bound index").ToLocalChecked()); return Nan::ThrowError(Nan::New("Out of bound index").ToLocalChecked());
} }
info.GetReturnValue().Set(Factory::create(sass_map_get_key(map, info[0]->ToInt32()->Value()))->get_js_object()); info.GetReturnValue().Set(Factory::create(sass_map_get_key(map, Nan::To<uint32_t>(info[0]).FromJust()))->get_js_object());
} }
NAN_METHOD(Map::SetKey) { NAN_METHOD(Map::SetKey) {
...@@ -100,7 +100,7 @@ namespace SassTypes ...@@ -100,7 +100,7 @@ namespace SassTypes
} }
Value* sass_value = Factory::unwrap(info[1]); Value* sass_value = Factory::unwrap(info[1]);
sass_map_set_key(unwrap(info.This())->value, info[0]->ToInt32()->Value(), sass_value->get_sass_value()); sass_map_set_key(unwrap(info.This())->value, Nan::To<uint32_t>(info[0]).FromJust(), sass_value->get_sass_value());
} }
NAN_METHOD(Map::GetLength) { NAN_METHOD(Map::GetLength) {
......
...@@ -15,7 +15,7 @@ namespace SassTypes ...@@ -15,7 +15,7 @@ namespace SassTypes
throw std::invalid_argument("First argument should be a number."); throw std::invalid_argument("First argument should be a number.");
} }
value = raw_val[0]->ToNumber()->Value(); value = Nan::To<double>(raw_val[0]).FromJust();
if (raw_val.size() >= 2) { if (raw_val.size() >= 2) {
if (!raw_val[1]->IsString()) { if (!raw_val[1]->IsString()) {
...@@ -54,7 +54,7 @@ namespace SassTypes ...@@ -54,7 +54,7 @@ namespace SassTypes
return Nan::ThrowError(Nan::New("Supplied value should be a number").ToLocalChecked()); return Nan::ThrowError(Nan::New("Supplied value should be a number").ToLocalChecked());
} }
sass_number_set_value(unwrap(info.This())->value, info[0]->ToNumber()->Value()); sass_number_set_value(unwrap(info.This())->value, Nan::To<double>(info[0]).FromJust());
} }
NAN_METHOD(Number::SetUnit) { NAN_METHOD(Number::SetUnit) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment