Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
08f11892
Commit
08f11892
authored
Dec 27, 2015
by
Michael Mifsud
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1309 from saper/less-red-tape-throw
Less V8 bureaucracy for Nan::ThrowTypeError
parents
7128b45e
cc1810b3
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
38 additions
and
38 deletions
+38
-38
boolean.cpp
src/sass_types/boolean.cpp
+2
-2
color.cpp
src/sass_types/color.cpp
+8
-8
factory.cpp
src/sass_types/factory.cpp
+1
-1
list.cpp
src/sass_types/list.cpp
+8
-8
map.cpp
src/sass_types/map.cpp
+12
-12
null.cpp
src/sass_types/null.cpp
+1
-1
number.cpp
src/sass_types/number.cpp
+4
-4
string.cpp
src/sass_types/string.cpp
+2
-2
No files found.
src/sass_types/boolean.cpp
View file @
08f11892
...
...
@@ -54,12 +54,12 @@ namespace SassTypes
if
(
info
.
IsConstructCall
())
{
if
(
constructor_locked
)
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Cannot instantiate SassBoolean"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Cannot instantiate SassBoolean"
);
}
}
else
{
if
(
info
.
Length
()
!=
1
||
!
info
[
0
]
->
IsBoolean
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Expected one boolean argument"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Expected one boolean argument"
);
}
info
.
GetReturnValue
().
Set
(
get_singleton
(
Nan
::
To
<
bool
>
(
info
[
0
]).
FromJust
()).
get_js_object
());
...
...
src/sass_types/color.cpp
View file @
08f11892
...
...
@@ -79,11 +79,11 @@ namespace SassTypes
NAN_METHOD
(
Color
::
SetR
)
{
if
(
info
.
Length
()
!=
1
)
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Expected just one argument"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Expected just one argument"
);
}
if
(
!
info
[
0
]
->
IsNumber
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied value should be a number"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied value should be a number"
);
}
sass_color_set_r
(
unwrap
(
info
.
This
())
->
value
,
Nan
::
To
<
double
>
(
info
[
0
]).
FromJust
());
...
...
@@ -91,11 +91,11 @@ namespace SassTypes
NAN_METHOD
(
Color
::
SetG
)
{
if
(
info
.
Length
()
!=
1
)
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Expected just one argument"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Expected just one argument"
);
}
if
(
!
info
[
0
]
->
IsNumber
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied value should be a number"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied value should be a number"
);
}
sass_color_set_g
(
unwrap
(
info
.
This
())
->
value
,
Nan
::
To
<
double
>
(
info
[
0
]).
FromJust
());
...
...
@@ -103,11 +103,11 @@ namespace SassTypes
NAN_METHOD
(
Color
::
SetB
)
{
if
(
info
.
Length
()
!=
1
)
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Expected just one argument"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Expected just one argument"
);
}
if
(
!
info
[
0
]
->
IsNumber
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied value should be a number"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied value should be a number"
);
}
sass_color_set_b
(
unwrap
(
info
.
This
())
->
value
,
Nan
::
To
<
double
>
(
info
[
0
]).
FromJust
());
...
...
@@ -115,11 +115,11 @@ namespace SassTypes
NAN_METHOD
(
Color
::
SetA
)
{
if
(
info
.
Length
()
!=
1
)
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Expected just one argument"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Expected just one argument"
);
}
if
(
!
info
[
0
]
->
IsNumber
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied value should be a number"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied value should be a number"
);
}
sass_color_set_a
(
unwrap
(
info
.
This
())
->
value
,
Nan
::
To
<
double
>
(
info
[
0
]).
FromJust
());
...
...
src/sass_types/factory.cpp
View file @
08f11892
...
...
@@ -40,7 +40,7 @@ namespace SassTypes
default
:
const
char
*
msg
=
"Unknown type encountered."
;
Nan
::
ThrowTypeError
(
Nan
::
New
<
v8
::
String
>
(
msg
).
ToLocalChecked
()
);
Nan
::
ThrowTypeError
(
msg
);
return
new
Error
(
sass_make_error
(
msg
));
}
}
...
...
src/sass_types/list.cpp
View file @
08f11892
...
...
@@ -39,11 +39,11 @@ namespace SassTypes
NAN_METHOD
(
List
::
GetValue
)
{
if
(
info
.
Length
()
!=
1
)
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Expected just one argument"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Expected just one argument"
);
}
if
(
!
info
[
0
]
->
IsNumber
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied index should be an integer"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied index should be an integer"
);
}
Sass_Value
*
list
=
unwrap
(
info
.
This
())
->
value
;
...
...
@@ -59,22 +59,22 @@ namespace SassTypes
NAN_METHOD
(
List
::
SetValue
)
{
if
(
info
.
Length
()
!=
2
)
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Expected two arguments"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Expected two arguments"
);
}
if
(
!
info
[
0
]
->
IsNumber
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied index should be an integer"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied index should be an integer"
);
}
if
(
!
info
[
1
]
->
IsObject
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied value should be a SassValue object"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied value should be a SassValue object"
);
}
Value
*
sass_value
=
Factory
::
unwrap
(
info
[
1
]);
if
(
sass_value
)
{
sass_list_set_value
(
unwrap
(
info
.
This
())
->
value
,
Nan
::
To
<
uint32_t
>
(
info
[
0
]).
FromJust
(),
sass_value
->
get_sass_value
());
}
else
{
Nan
::
ThrowTypeError
(
Nan
::
New
<
v8
::
String
>
(
"A SassValue is expected as the list item"
).
ToLocalChecked
()
);
Nan
::
ThrowTypeError
(
"A SassValue is expected as the list item"
);
}
}
...
...
@@ -84,11 +84,11 @@ namespace SassTypes
NAN_METHOD
(
List
::
SetSeparator
)
{
if
(
info
.
Length
()
!=
1
)
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Expected just one argument"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Expected just one argument"
);
}
if
(
!
info
[
0
]
->
IsBoolean
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied value should be a boolean"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied value should be a boolean"
);
}
sass_list_set_separator
(
unwrap
(
info
.
This
())
->
value
,
Nan
::
To
<
bool
>
(
info
[
0
]).
FromJust
()
?
SASS_COMMA
:
SASS_SPACE
);
...
...
src/sass_types/map.cpp
View file @
08f11892
...
...
@@ -30,11 +30,11 @@ namespace SassTypes
NAN_METHOD
(
Map
::
GetValue
)
{
if
(
info
.
Length
()
!=
1
)
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Expected just one argument"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Expected just one argument"
);
}
if
(
!
info
[
0
]
->
IsNumber
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied index should be an integer"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied index should be an integer"
);
}
Sass_Value
*
map
=
unwrap
(
info
.
This
())
->
value
;
...
...
@@ -50,33 +50,33 @@ namespace SassTypes
NAN_METHOD
(
Map
::
SetValue
)
{
if
(
info
.
Length
()
!=
2
)
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Expected two arguments"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Expected two arguments"
);
}
if
(
!
info
[
0
]
->
IsNumber
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied index should be an integer"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied index should be an integer"
);
}
if
(
!
info
[
1
]
->
IsObject
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied value should be a SassValue object"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied value should be a SassValue object"
);
}
Value
*
sass_value
=
Factory
::
unwrap
(
info
[
1
]);
if
(
sass_value
)
{
sass_map_set_value
(
unwrap
(
info
.
This
())
->
value
,
Nan
::
To
<
uint32_t
>
(
info
[
0
]).
FromJust
(),
sass_value
->
get_sass_value
());
}
else
{
Nan
::
ThrowTypeError
(
Nan
::
New
<
v8
::
String
>
(
"A SassValue is expected as a map value"
).
ToLocalChecked
()
);
Nan
::
ThrowTypeError
(
"A SassValue is expected as a map value"
);
}
}
NAN_METHOD
(
Map
::
GetKey
)
{
if
(
info
.
Length
()
!=
1
)
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Expected just one argument"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Expected just one argument"
);
}
if
(
!
info
[
0
]
->
IsNumber
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied index should be an integer"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied index should be an integer"
);
}
Sass_Value
*
map
=
unwrap
(
info
.
This
())
->
value
;
...
...
@@ -92,22 +92,22 @@ namespace SassTypes
NAN_METHOD
(
Map
::
SetKey
)
{
if
(
info
.
Length
()
!=
2
)
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Expected two arguments"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Expected two arguments"
);
}
if
(
!
info
[
0
]
->
IsNumber
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied index should be an integer"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied index should be an integer"
);
}
if
(
!
info
[
1
]
->
IsObject
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied value should be a SassValue object"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied value should be a SassValue object"
);
}
Value
*
sass_value
=
Factory
::
unwrap
(
info
[
1
]);
if
(
sass_value
)
{
sass_map_set_key
(
unwrap
(
info
.
This
())
->
value
,
Nan
::
To
<
uint32_t
>
(
info
[
0
]).
FromJust
(),
sass_value
->
get_sass_value
());
}
else
{
Nan
::
ThrowTypeError
(
Nan
::
New
<
v8
::
String
>
(
"A SassValue is expected as a map key"
).
ToLocalChecked
()
);
Nan
::
ThrowTypeError
(
"A SassValue is expected as a map key"
);
}
}
...
...
src/sass_types/null.cpp
View file @
08f11892
...
...
@@ -49,7 +49,7 @@ namespace SassTypes
if
(
info
.
IsConstructCall
())
{
if
(
constructor_locked
)
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Cannot instantiate SassNull"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Cannot instantiate SassNull"
);
}
}
else
{
...
...
src/sass_types/number.cpp
View file @
08f11892
...
...
@@ -47,11 +47,11 @@ namespace SassTypes
NAN_METHOD
(
Number
::
SetValue
)
{
if
(
info
.
Length
()
!=
1
)
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Expected just one argument"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Expected just one argument"
);
}
if
(
!
info
[
0
]
->
IsNumber
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied value should be a number"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied value should be a number"
);
}
sass_number_set_value
(
unwrap
(
info
.
This
())
->
value
,
Nan
::
To
<
double
>
(
info
[
0
]).
FromJust
());
...
...
@@ -59,11 +59,11 @@ namespace SassTypes
NAN_METHOD
(
Number
::
SetUnit
)
{
if
(
info
.
Length
()
!=
1
)
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Expected just one argument"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Expected just one argument"
);
}
if
(
!
info
[
0
]
->
IsString
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied value should be a string"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied value should be a string"
);
}
sass_number_set_unit
(
unwrap
(
info
.
This
())
->
value
,
create_string
(
info
[
0
]));
...
...
src/sass_types/string.cpp
View file @
08f11892
...
...
@@ -31,11 +31,11 @@ namespace SassTypes
NAN_METHOD
(
String
::
SetValue
)
{
if
(
info
.
Length
()
!=
1
)
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Expected just one argument"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Expected just one argument"
);
}
if
(
!
info
[
0
]
->
IsString
())
{
return
Nan
::
ThrowTypeError
(
Nan
::
New
(
"Supplied value should be a string"
).
ToLocalChecked
()
);
return
Nan
::
ThrowTypeError
(
"Supplied value should be a string"
);
}
sass_string_set_value
(
unwrap
(
info
.
This
())
->
value
,
create_string
(
info
[
0
]));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment