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
5a78adc0
Commit
5a78adc0
authored
Apr 09, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented the "comparable" builtin.
parent
aeee9f57
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
9 deletions
+48
-9
basic.scss
basic.scss
+12
-1
context.cpp
context.cpp
+2
-1
functions.cpp
functions.cpp
+32
-5
functions.hpp
functions.hpp
+2
-2
No files found.
basic.scss
View file @
5a78adc0
...
@@ -73,7 +73,17 @@ div {
...
@@ -73,7 +73,17 @@ div {
c
:
unit
(
10boo
);
c
:
unit
(
10boo
);
d
:
unitless
(
20%
);
d
:
unitless
(
20%
);
e
:
unitless
(
123
);
e
:
unitless
(
123
);
/* comparable tests */
a
:
comparable
(
123em
,
123cm
);
b
:
comparable
(
123pt
,
123in
);
c
:
comparable
(
120
,
12pt
);
d
:
comparable
(
10px
,
12pt
);
e
:
comparable
(
10pc
,
12%
);
f
:
comparable
(
2em
,
50%
);
g
:
comparable
(
1
.5em
,
3ex
);
h
:
comparable
(
2em
,
24pt
);
i
:
comparable
(
16pt
,
.5cm
);
/* hsl tests */
a
:
hsl
(
23
,
100%
,
50%
);
a
:
hsl
(
23
,
100%
,
50%
);
b
:
hsl
(
120
,
100%
,
50%
);
b
:
hsl
(
120
,
100%
,
50%
);
}
}
\ No newline at end of file
context.cpp
View file @
5a78adc0
...
@@ -74,7 +74,7 @@ namespace Sass {
...
@@ -74,7 +74,7 @@ namespace Sass {
register_function
(
type_of_descriptor
,
type_of
);
register_function
(
type_of_descriptor
,
type_of
);
register_function
(
unit_descriptor
,
unit
);
register_function
(
unit_descriptor
,
unit
);
register_function
(
unitless_descriptor
,
unitless
);
register_function
(
unitless_descriptor
,
unitless
);
//
register_function(comparable_descriptor, comparable);
register_function
(
comparable_descriptor
,
comparable
);
}
}
}
}
\ No newline at end of file
functions.cpp
View file @
5a78adc0
...
@@ -394,7 +394,7 @@ namespace Sass {
...
@@ -394,7 +394,7 @@ namespace Sass {
extern
const
char
percent_str
[]
=
"%"
;
extern
const
char
percent_str
[]
=
"%"
;
Function_Descriptor
unit_descriptor
=
Function_Descriptor
unit_descriptor
=
{
"unit"
,
"$
value
"
,
0
};
{
"unit"
,
"$
number
"
,
0
};
Node
unit
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
)
{
Node
unit
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
)
{
Node
val
(
bindings
[
parameters
[
0
]]);
Node
val
(
bindings
[
parameters
[
0
]]);
Node
u
(
Node
::
string_constant
,
val
.
line_number
,
Token
::
make
());
Node
u
(
Node
::
string_constant
,
val
.
line_number
,
Token
::
make
());
...
@@ -420,7 +420,7 @@ namespace Sass {
...
@@ -420,7 +420,7 @@ namespace Sass {
extern
const
char
false_str
[]
=
"false"
;
extern
const
char
false_str
[]
=
"false"
;
Function_Descriptor
unitless_descriptor
=
Function_Descriptor
unitless_descriptor
=
{
"unitless"
,
"$
value
"
,
0
};
{
"unitless"
,
"$
number
"
,
0
};
Node
unitless
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
)
{
Node
unitless
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
)
{
Node
val
(
bindings
[
parameters
[
0
]]);
Node
val
(
bindings
[
parameters
[
0
]]);
Node
result
(
Node
::
string_constant
,
val
.
line_number
,
Token
::
make
());
Node
result
(
Node
::
string_constant
,
val
.
line_number
,
Token
::
make
());
...
@@ -441,9 +441,36 @@ namespace Sass {
...
@@ -441,9 +441,36 @@ namespace Sass {
return
result
;
return
result
;
}
}
Function_Descriptor
comparable_descriptor
=
{
"comparable"
,
"$number_1"
,
"$number_2"
,
0
};
Node
comparable
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
)
{
Node
n1
(
bindings
[
parameters
[
0
]]);
Node
n2
(
bindings
[
parameters
[
1
]]);
Node
::
Type
t1
=
n1
.
type
;
Node
::
Type
t2
=
n2
.
type
;
if
(
t1
==
Node
::
number
||
t2
==
Node
::
number
)
{
return
Node
(
Node
::
identifier
,
n1
.
line_number
,
Token
::
make
(
true_str
));
}
else
if
(
t1
==
Node
::
numeric_percentage
&&
t2
==
Node
::
numeric_percentage
)
{
return
Node
(
Node
::
identifier
,
n1
.
line_number
,
Token
::
make
(
true_str
));
}
else
if
(
t1
==
Node
::
numeric_dimension
&&
t2
==
Node
::
numeric_dimension
)
{
string
u1
(
Token
::
make
(
n1
.
content
.
dimension
.
unit
,
Prelexer
::
identifier
(
n1
.
content
.
dimension
.
unit
)).
to_string
());
string
u2
(
Token
::
make
(
n2
.
content
.
dimension
.
unit
,
Prelexer
::
identifier
(
n2
.
content
.
dimension
.
unit
)).
to_string
());
if
(
u1
==
"ex"
&&
u2
==
"ex"
||
u1
==
"em"
&&
u2
==
"em"
||
(
u1
==
"in"
||
u1
==
"cm"
||
u1
==
"mm"
||
u1
==
"pt"
||
u1
==
"pc"
)
&&
(
u2
==
"in"
||
u2
==
"cm"
||
u2
==
"mm"
||
u2
==
"pt"
||
u2
==
"pc"
))
{
return
Node
(
Node
::
identifier
,
n1
.
line_number
,
Token
::
make
(
true_str
));
}
else
{
return
Node
(
Node
::
identifier
,
n1
.
line_number
,
Token
::
make
(
false_str
));
}
}
else
{
return
Node
(
Node
::
identifier
,
n1
.
line_number
,
Token
::
make
(
false_str
));
}
}
...
...
functions.hpp
View file @
5a78adc0
...
@@ -145,8 +145,8 @@ namespace Sass {
...
@@ -145,8 +145,8 @@ namespace Sass {
extern
Function_Descriptor
unitless_descriptor
;
extern
Function_Descriptor
unitless_descriptor
;
Node
unitless
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
);
Node
unitless
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
);
//
extern Function_Descriptor comparable_descriptor;
extern
Function_Descriptor
comparable_descriptor
;
//
Node comparable(const vector<Token>& parameters, map<Token, Node>& bindings);
Node
comparable
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
);
}
}
...
...
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