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
4f2b3015
Commit
4f2b3015
authored
Sep 24, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Overloading the 'compact' function so that it behaves correctly with odd combinations of arguments.
parent
0411ea70
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
31 deletions
+43
-31
context.cpp
context.cpp
+14
-1
functions.cpp
functions.cpp
+23
-27
functions.hpp
functions.hpp
+6
-3
No files found.
context.cpp
View file @
4f2b3015
...
...
@@ -152,7 +152,20 @@ namespace Sass {
register_function
(
nth_sig
,
nth
);
register_function
(
join_sig
,
join
);
register_function
(
append_sig
,
append
);
register_function
(
compact_sig
,
compact
);
register_overload_stub
(
"compact"
);
register_function
(
compact_1_sig
,
compact_1
,
1
);
register_function
(
compact_n_sig
,
compact_n
,
0
);
register_function
(
compact_n_sig
,
compact_n
,
2
);
register_function
(
compact_n_sig
,
compact_n
,
3
);
register_function
(
compact_n_sig
,
compact_n
,
4
);
register_function
(
compact_n_sig
,
compact_n
,
5
);
register_function
(
compact_n_sig
,
compact_n
,
6
);
register_function
(
compact_n_sig
,
compact_n
,
7
);
register_function
(
compact_n_sig
,
compact_n
,
8
);
register_function
(
compact_n_sig
,
compact_n
,
9
);
register_function
(
compact_n_sig
,
compact_n
,
10
);
register_function
(
compact_n_sig
,
compact_n
,
11
);
register_function
(
compact_n_sig
,
compact_n
,
12
);
// Introspection Functions
register_function
(
type_of_sig
,
type_of
);
register_function
(
unit_sig
,
unit
);
...
...
functions.cpp
View file @
4f2b3015
...
...
@@ -1002,35 +1002,31 @@ namespace Sass {
return
new_list
;
}
extern
Signature
compact_sig
=
"compact($arg1: false, $arg2: false, $arg3: false, $arg4: false, $arg5: false, $arg6: false, $arg7: false, $arg8: false, $arg9: false, $arg10: false, $arg11: false, $arg12: false)"
;
Node
compact
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
first_arg
(
bindings
[
parameter_names
[
0
].
token
()]);
Node
rest_args
(
new_Node
(
Node
::
comma_list
,
path
,
line
,
0
));
for
(
size_t
i
=
1
,
S
=
bindings
.
current_frame
.
size
();
i
<
S
;
++
i
)
{
Node
the_arg
(
bindings
[
parameter_names
[
i
].
token
()]);
if
(
!
the_arg
.
is_false
())
rest_args
<<
new_Node
(
path
,
line
,
the_arg
);
}
if
(
rest_args
.
size
()
>
0
)
{
Node
result
(
new_Node
(
Node
::
comma_list
,
path
,
line
,
rest_args
.
size
()
+
(
first_arg
.
is_false
()
?
0
:
1
)));
if
(
!
first_arg
.
is_false
())
result
<<
new_Node
(
path
,
line
,
first_arg
);
result
+=
rest_args
;
return
result
;
}
else
{
Node
::
Type
first_type
=
first_arg
.
type
();
if
(
first_type
==
Node
::
space_list
||
first_type
==
Node
::
comma_list
)
{
Node
result
(
new_Node
(
first_type
,
path
,
line
,
0
));
for
(
size_t
i
=
0
,
S
=
first_arg
.
size
();
i
<
S
;
++
i
)
{
if
(
!
first_arg
[
i
].
is_false
())
result
<<
new_Node
(
path
,
line
,
first_arg
[
i
]);
}
return
result
;
}
else
{
return
new_Node
(
path
,
line
,
first_arg
);
extern
Signature
compact_1_sig
=
"compact($arg1)"
;
Node
compact_1
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
the_arg
(
bindings
[
parameter_names
[
0
].
token
()]);
if
(
the_arg
.
type
()
==
Node
::
comma_list
||
the_arg
.
type
()
==
Node
::
space_list
)
{
Node
non_nils
(
new_Node
(
the_arg
.
type
(),
path
,
line
,
0
));
for
(
size_t
i
=
0
,
S
=
the_arg
.
size
();
i
<
S
;
++
i
)
{
Node
elt
(
the_arg
[
i
]);
if
(
!
elt
.
is_false
())
non_nils
<<
new_Node
(
path
,
line
,
elt
);
}
return
non_nils
.
size
()
>
0
?
non_nils
:
new_Node
(
Node
::
nil
,
path
,
line
,
0
);
}
// unreachable
return
Node
();
return
new_Node
(
path
,
line
,
the_arg
);
}
extern
Signature
compact_n_sig
=
"compact($arg1: false, $arg2: false, $arg3: false, $arg4: false, $arg5: false, $arg6: false, $arg7: false, $arg8: false, $arg9: false, $arg10: false, $arg11: false, $arg12: false)"
;
Node
compact_n
(
const
Node
parameter_names
,
Environment
&
bindings
,
Node_Factory
&
new_Node
,
string
&
path
,
size_t
line
)
{
Node
non_nils
(
new_Node
(
Node
::
comma_list
,
path
,
line
,
0
));
for
(
size_t
i
=
0
,
S
=
bindings
.
current_frame
.
size
();
i
<
S
;
++
i
)
{
Node
the_arg
(
bindings
[
parameter_names
[
i
].
token
()]);
if
(
!
the_arg
.
is_false
())
non_nils
<<
new_Node
(
path
,
line
,
the_arg
);
}
return
non_nils
.
size
()
>
0
?
non_nils
:
new_Node
(
Node
::
nil
,
path
,
line
,
0
);
}
////////////////////////////////////////////////////////////////////////
...
...
functions.hpp
View file @
4f2b3015
...
...
@@ -193,9 +193,12 @@ namespace Sass {
extern
Signature
append_sig
;
Node
append
(
const
Node
,
Environment
&
,
Node_Factory
&
,
string
&
path
,
size_t
line
);
extern
Signature
compact_sig
;
Node
compact
(
const
Node
,
Environment
&
,
Node_Factory
&
,
string
&
path
,
size_t
line
);
extern
Signature
compact_1_sig
;
Node
compact_1
(
const
Node
,
Environment
&
,
Node_Factory
&
,
string
&
path
,
size_t
line
);
extern
Signature
compact_n_sig
;
Node
compact_n
(
const
Node
,
Environment
&
,
Node_Factory
&
,
string
&
path
,
size_t
line
);
// Introspection Functions /////////////////////////////////////////////
extern
Signature
type_of_sig
;
...
...
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