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
98f66158
Commit
98f66158
authored
Mar 05, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Workin' on the node struct.
parent
483fab5c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
38 deletions
+65
-38
node.cpp
node.cpp
+12
-8
node.hpp
node.hpp
+53
-30
No files found.
node.cpp
View file @
98f66158
...
@@ -92,31 +92,35 @@ namespace Sass {
...
@@ -92,31 +92,35 @@ namespace Sass {
string
indentation
(
2
*
depth
,
' '
);
string
indentation
(
2
*
depth
,
' '
);
bool
has_rules
,
has_nested_rulesets
;
bool
has_rules
,
has_nested_rulesets
;
if
(
type
==
ruleset
)
{
if
(
type
==
ruleset
)
{
has_rules
=
!
((
*
children
)[
1
].
children
->
empty
());
// has_rules = !((*children)[1].children->empty());
has_nested_rulesets
=
!
((
*
children
)[
1
].
opt_children
->
empty
());
has_rules
=
!
(
children
->
at
(
1
).
children
->
empty
());
// has_nested_rulesets = !((*children)[1].opt_children->empty());
has_nested_rulesets
=
!
(
children
->
at
(
1
).
opt_children
->
empty
());
}
}
switch
(
type
)
{
switch
(
type
)
{
case
ruleset
:
case
ruleset
:
if
(
has_rules
)
{
if
(
has_rules
)
{
buf
<<
indentation
;
buf
<<
indentation
;
(
*
children
)[
0
].
emit_nested_css
(
buf
,
prefix
,
depth
);
// selector
// (*children)[0].emit_nested_css(buf, prefix, depth); // selector
children
->
at
(
0
).
emit_nested_css
(
buf
,
prefix
,
depth
);
// selector
buf
<<
" {"
;
buf
<<
" {"
;
for
(
int
i
=
0
;
i
<
(
*
children
)[
1
].
children
->
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
(
*
children
)[
1
].
children
->
size
();
++
i
)
{
(
*
(
*
children
)[
1
].
children
)[
i
].
emit_nested_css
(
buf
,
""
,
depth
+
1
);
// rules
// (*(*children)[1].children)[i].emit_nested_css(buf, "", depth + 1); // rules
children
->
at
(
1
).
children
->
at
(
i
).
emit_nested_css
(
buf
,
""
,
depth
+
1
);
// rules
}
}
buf
<<
" }"
<<
endl
;
buf
<<
" }"
<<
endl
;
}
}
if
(
has_nested_rulesets
)
{
if
(
has_nested_rulesets
)
{
for
(
int
i
=
0
;
i
<
(
*
children
)[
1
]
.
opt_children
->
size
();
++
i
)
{
// do each nested ruleset
for
(
int
i
=
0
;
i
<
children
->
at
(
1
)
.
opt_children
->
size
();
++
i
)
{
// do each nested ruleset
(
*
(
*
children
)[
1
].
opt_children
)[
i
]
.
emit_nested_css
(
buf
,
prefix
+
(
prefix
.
empty
()
?
""
:
" "
)
+
string
((
*
children
)[
0
].
token
),
depth
+
(
has_rules
?
1
:
0
));
children
->
at
(
1
).
opt_children
->
at
(
i
)
.
emit_nested_css
(
buf
,
prefix
+
(
prefix
.
empty
()
?
""
:
" "
)
+
string
((
*
children
)[
0
].
token
),
depth
+
(
has_rules
?
1
:
0
));
}
}
}
}
if
(
depth
==
0
&&
prefix
.
empty
())
buf
<<
endl
;
if
(
depth
==
0
&&
prefix
.
empty
())
buf
<<
endl
;
break
;
break
;
case
rule
:
case
rule
:
buf
<<
endl
<<
indentation
;
buf
<<
endl
<<
indentation
;
(
*
children
)[
0
]
.
emit_nested_css
(
buf
,
""
,
depth
);
// property
children
->
at
(
0
)
.
emit_nested_css
(
buf
,
""
,
depth
);
// property
(
*
children
)[
1
]
.
emit_nested_css
(
buf
,
""
,
depth
);
// values
children
->
at
(
1
)
.
emit_nested_css
(
buf
,
""
,
depth
);
// values
buf
<<
";"
;
buf
<<
";"
;
break
;
break
;
case
property
:
case
property
:
...
...
node.hpp
View file @
98f66158
...
@@ -42,44 +42,66 @@ namespace Sass {
...
@@ -42,44 +42,66 @@ namespace Sass {
void
emit_expanded_css
(
stringstream
&
buf
,
const
string
&
prefix
);
void
emit_expanded_css
(
stringstream
&
buf
,
const
string
&
prefix
);
};
};
// struct Node {
struct
Node
{
// enum Type {
enum
Type
{
// nil,
nil
,
// comment,
comment
,
// ruleset,
ruleset
,
// selector_group,
selector_group
,
// selector,
selector
,
// simple_selector_sequence,
simple_selector_sequence
,
// type_selector,
type_selector
,
// class_selector,
class_selector
,
// id_selector,
id_selector
,
// attribute_selector,
attribute_selector
,
// clauses,
clauses
,
// rule,
rule
,
// property,
property
,
// values,
values
,
// value
value
// };
};
//
// size_t line_number;
// mutable vector<Node>* children;
// Token token;
// Type type;
// bool has_rules;
// bool has_rules;
// bool has_rulesets;
// bool has_rulesets;
// Type type;
// bool has_nested_properties;
// Token token;
// vector<Node>* children;
//
//
// Node(const Node& n)
// Node(const Node& n)
// : has_rules(n.has_rules), has_rulesets(n.has_rulesets),
// : line_number(n.line_number),
// type(n.type), token(n.token), children(n.children)
// children(n.children),
// { n.children = 0; } // No joint custody.
// token(n.token),
// Node(Type type_)
// type(n.type),
// : has_rules(false), has_rulesets(false),
// has_rules(n.has_rules),
// type(type_), token(Token()), children(0)
// has_rulesets(n.has_rulesets),
// has_nested_properties(n.has_nested_properties)
// { n.release(); } // No joint custody.
//
// Node(size_t line_number, Type type, size_t length = 0)
// : line_number(line_number),
// children(new vector<Node>),
// token(Token()),
// type(type),
// has_rules(false),
// has_rulesets(false),
// has_nested_properties(false)
// { children->reserve(length); }
//
// Node(size_t line_number, Type type, Token& token)
// : line_number(line_number),
// children(0),
// token(token),
// type(type),
// has_rules(false),
// has_rulesets(false),
// has_nested_properties(false)
// { }
// { }
// Node(Type type_, size_t size);
// Node(Type type_, Token& token_);
//
//
// Node& operator=(const Node& node);
// Node& operator=(const Node& node);
// Node& operator+=(const Node& node);
// Node& operator+=(const Node& node);
// Node& operator<<(const Node& node);
// Node& operator<<(const Node& node);
// void release() const { children = 0; }
// };
// };
}
}
\ No newline at end of file
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