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
755d6b51
Commit
755d6b51
authored
Apr 06, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented "type-of".
parent
a7550399
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
7 deletions
+71
-7
basic.scss
basic.scss
+4
-0
context.cpp
context.cpp
+6
-0
functions.cpp
functions.cpp
+47
-7
functions.hpp
functions.hpp
+14
-0
No files found.
basic.scss
View file @
755d6b51
...
...
@@ -63,4 +63,8 @@ div {
f
:
join
((
1
,
2
,
3
)
,
());
g
:
join
(()
,
(
1
,
2
,
3
));
h
:
hello
join
(()
,
()
,
auto
);
a
:
type-of
(
false
);
b
:
type-of
(
"true"
);
c
:
type-of
(
a
b
c
);
}
context.cpp
View file @
755d6b51
...
...
@@ -62,6 +62,11 @@ namespace Sass {
register_function
(
nth_descriptor
,
nth
);
register_function
(
join_2_descriptor
,
join_2
);
register_function
(
join_3_descriptor
,
join_3
);
// Introspection Functions
register_function
(
type_of_descriptor
,
type_of
);
// register_function(unit_descriptor, unit);
// register_function(unitless_descriptor, unitless);
// register_function(comparable_descriptor, comparable);
}
}
\ No newline at end of file
functions.cpp
View file @
755d6b51
...
...
@@ -220,6 +220,7 @@ namespace Sass {
}
// List Functions //////////////////////////////////////////////////////
Function_Descriptor
length_descriptor
=
{
"length"
,
"$list"
,
0
};
Node
length
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
)
{
...
...
@@ -291,13 +292,52 @@ namespace Sass {
return
join_impl
(
parameters
,
bindings
,
true
);
}
// Introspection Functions /////////////////////////////////////////////
extern
const
char
number_name
[]
=
"number"
;
extern
const
char
string_name
[]
=
"string"
;
extern
const
char
bool_name
[]
=
"bool"
;
extern
const
char
color_name
[]
=
"color"
;
extern
const
char
list_name
[]
=
"list"
;
Function_Descriptor
type_of_descriptor
=
{
"type-of"
,
"$value"
,
0
};
Node
type_of
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
)
{
Node
val
(
bindings
[
parameters
[
0
]]);
Node
type
(
Node
::
string_constant
,
val
.
line_number
,
Token
::
make
());
type
.
unquoted
=
true
;
switch
(
val
.
type
)
{
case
Node
:
:
number
:
case
Node
:
:
numeric_dimension
:
case
Node
:
:
numeric_percentage
:
type
.
content
.
token
=
Token
::
make
(
number_name
);
break
;
case
Node
:
:
identifier
:
{
string
text
(
val
.
content
.
token
.
to_string
());
if
(
text
==
"true"
||
text
==
"false"
)
{
type
.
content
.
token
=
Token
::
make
(
bool_name
);
}
else
{
type
.
content
.
token
=
Token
::
make
(
string_name
);
}
}
break
;
case
Node
:
:
string_constant
:
type
.
content
.
token
=
Token
::
make
(
string_name
);
break
;
case
Node
:
:
numeric_color
:
type
.
content
.
token
=
Token
::
make
(
color_name
);
break
;
case
Node
:
:
comma_list
:
case
Node
:
:
space_list
:
case
Node
:
:
nil
:
type
.
content
.
token
=
Token
::
make
(
list_name
);
break
;
default:
type
.
content
.
token
=
Token
::
make
(
string_name
);
}
return
type
;
}
...
...
functions.hpp
View file @
755d6b51
...
...
@@ -128,6 +128,20 @@ namespace Sass {
extern
Function_Descriptor
join_3_descriptor
;
Node
join_3
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
);
// Introspection Functions /////////////////////////////////////////////
extern
Function_Descriptor
type_of_descriptor
;
Node
type_of
(
const
vector
<
Token
>&
parameters
,
map
<
Token
,
Node
>&
bindings
);
// extern Function_Descriptor unit_descriptor;
// Node unit(const vector<Token>& parameters, map<Token, Node>& bindings);
//
// extern Function_Descriptor unitless_descriptor;
// Node unitless(const vector<Token>& parameters, map<Token, Node>& bindings);
//
// extern Function_Descriptor comparable_descriptor;
// 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