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
2bb0012d
Commit
2bb0012d
authored
Sep 11, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converting the numeric functions.
parent
a597ae8c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
12 deletions
+17
-12
functions.cpp
functions.cpp
+17
-12
No files found.
functions.cpp
View file @
2bb0012d
...
@@ -689,21 +689,19 @@ namespace Sass {
...
@@ -689,21 +689,19 @@ namespace Sass {
extern
Signature
percentage_sig
=
"percentage($value)"
;
extern
Signature
percentage_sig
=
"percentage($value)"
;
Node
percentage
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
percentage
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
orig
(
bindings
[
parameter_names
[
0
].
token
()]);
Node
orig
(
arg
(
percentage_sig
,
path
,
line
,
parameter_names
,
bindings
,
0
,
Node
::
number
));
if
(
orig
.
type
()
!=
Node
::
number
)
{
throw_eval_error
(
"argument to percentage must be a unitless number"
,
orig
.
path
(),
orig
.
line
());
}
return
new_Node
(
path
,
line
,
orig
.
numeric_value
()
*
100
,
Node
::
numeric_percentage
);
return
new_Node
(
path
,
line
,
orig
.
numeric_value
()
*
100
,
Node
::
numeric_percentage
);
}
}
extern
Signature
round_sig
=
"round($value)"
;
extern
Signature
round_sig
=
"round($value)"
;
Node
round
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
round
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
orig
(
bindings
[
parameter_names
[
0
].
token
()]
);
Node
orig
(
arg
(
round_sig
,
path
,
line
,
parameter_names
,
bindings
,
0
,
Node
::
numeric
)
);
switch
(
orig
.
type
())
switch
(
orig
.
type
())
{
{
case
Node
:
:
numeric_dimension
:
{
case
Node
:
:
numeric_dimension
:
{
return
new_Node
(
path
,
line
,
return
new_Node
(
path
,
line
,
std
::
floor
(
orig
.
numeric_value
()
+
0.5
),
orig
.
unit
());
std
::
floor
(
orig
.
numeric_value
()
+
0.5
),
orig
.
unit
());
}
break
;
}
break
;
case
Node
:
:
number
:
{
case
Node
:
:
number
:
{
...
@@ -718,6 +716,7 @@ namespace Sass {
...
@@ -718,6 +716,7 @@ namespace Sass {
}
break
;
}
break
;
default:
{
default:
{
// unreachable
throw_eval_error
(
"argument to round must be numeric"
,
path
,
line
);
throw_eval_error
(
"argument to round must be numeric"
,
path
,
line
);
}
break
;
}
break
;
}
}
...
@@ -727,12 +726,13 @@ namespace Sass {
...
@@ -727,12 +726,13 @@ namespace Sass {
extern
Signature
ceil_sig
=
"ceil($value)"
;
extern
Signature
ceil_sig
=
"ceil($value)"
;
Node
ceil
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
ceil
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
orig
(
bindings
[
parameter_names
[
0
].
token
()]
);
Node
orig
(
arg
(
ceil_sig
,
path
,
line
,
parameter_names
,
bindings
,
0
,
Node
::
numeric
)
);
switch
(
orig
.
type
())
switch
(
orig
.
type
())
{
{
case
Node
:
:
numeric_dimension
:
{
case
Node
:
:
numeric_dimension
:
{
return
new_Node
(
path
,
line
,
return
new_Node
(
path
,
line
,
std
::
ceil
(
orig
.
numeric_value
()),
orig
.
unit
());
std
::
ceil
(
orig
.
numeric_value
()),
orig
.
unit
());
}
break
;
}
break
;
case
Node
:
:
number
:
{
case
Node
:
:
number
:
{
...
@@ -747,6 +747,7 @@ namespace Sass {
...
@@ -747,6 +747,7 @@ namespace Sass {
}
break
;
}
break
;
default:
{
default:
{
// unreachable
throw_eval_error
(
"argument to ceil must be numeric"
,
path
,
line
);
throw_eval_error
(
"argument to ceil must be numeric"
,
path
,
line
);
}
break
;
}
break
;
}
}
...
@@ -756,12 +757,13 @@ namespace Sass {
...
@@ -756,12 +757,13 @@ namespace Sass {
extern
Signature
floor_sig
=
"floor($value)"
;
extern
Signature
floor_sig
=
"floor($value)"
;
Node
floor
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
floor
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
orig
(
bindings
[
parameter_names
[
0
].
token
()]
);
Node
orig
(
arg
(
floor_sig
,
path
,
line
,
parameter_names
,
bindings
,
0
,
Node
::
numeric
)
);
switch
(
orig
.
type
())
switch
(
orig
.
type
())
{
{
case
Node
:
:
numeric_dimension
:
{
case
Node
:
:
numeric_dimension
:
{
return
new_Node
(
path
,
line
,
return
new_Node
(
path
,
line
,
std
::
floor
(
orig
.
numeric_value
()),
orig
.
unit
());
std
::
floor
(
orig
.
numeric_value
()),
orig
.
unit
());
}
break
;
}
break
;
case
Node
:
:
number
:
{
case
Node
:
:
number
:
{
...
@@ -776,6 +778,7 @@ namespace Sass {
...
@@ -776,6 +778,7 @@ namespace Sass {
}
break
;
}
break
;
default:
{
default:
{
// unreachable
throw_eval_error
(
"argument to floor must be numeric"
,
path
,
line
);
throw_eval_error
(
"argument to floor must be numeric"
,
path
,
line
);
}
break
;
}
break
;
}
}
...
@@ -785,12 +788,13 @@ namespace Sass {
...
@@ -785,12 +788,13 @@ namespace Sass {
extern
Signature
abs_sig
=
"abs($value)"
;
extern
Signature
abs_sig
=
"abs($value)"
;
Node
abs
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
abs
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
orig
(
bindings
[
parameter_names
[
0
].
token
()]
);
Node
orig
(
arg
(
abs_sig
,
path
,
line
,
parameter_names
,
bindings
,
0
,
Node
::
numeric
)
);
switch
(
orig
.
type
())
switch
(
orig
.
type
())
{
{
case
Node
:
:
numeric_dimension
:
{
case
Node
:
:
numeric_dimension
:
{
return
new_Node
(
path
,
line
,
return
new_Node
(
path
,
line
,
std
::
abs
(
orig
.
numeric_value
()),
orig
.
unit
());
std
::
abs
(
orig
.
numeric_value
()),
orig
.
unit
());
}
break
;
}
break
;
case
Node
:
:
number
:
{
case
Node
:
:
number
:
{
...
@@ -805,6 +809,7 @@ namespace Sass {
...
@@ -805,6 +809,7 @@ namespace Sass {
}
break
;
}
break
;
default:
{
default:
{
// unreachable
throw_eval_error
(
"argument to abs must be numeric"
,
path
,
line
);
throw_eval_error
(
"argument to abs must be numeric"
,
path
,
line
);
}
break
;
}
break
;
}
}
...
...
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