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
11aeaa6a
Commit
11aeaa6a
authored
May 15, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improving the interface and correcting some behavior.
parent
6a8b096a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
25 deletions
+29
-25
node.hpp
node.hpp
+7
-4
node_factory.cpp
node_factory.cpp
+10
-11
node_factory.hpp
node_factory.hpp
+6
-5
test_node_factory.cpp
test_node_factory.cpp
+6
-5
No files found.
node.hpp
View file @
11aeaa6a
...
...
@@ -198,7 +198,7 @@ namespace Sass {
vector
<
Node
>
children
;
string
*
file_name
;
size_t
line_number
;
size_t
line_number
;
Node
::
Type
type
;
...
...
@@ -216,6 +216,9 @@ namespace Sass {
size_t
size
()
{
return
children
.
size
();
}
bool
empty
()
{
return
children
.
empty
();
}
Node
&
at
(
size_t
i
)
{
return
children
.
at
(
i
);
}
...
...
@@ -224,10 +227,10 @@ namespace Sass {
{
return
children
.
back
();
}
void
push_back
(
const
Node
&
n
)
{
children
.
push_back
(
n
);
}
{
children
.
push_back
(
n
);
has_children
=
true
;
}
void
pop_back
()
{
children
.
pop_back
();
}
{
children
.
pop_back
();
if
(
empty
())
has_children
=
false
;
}
bool
boolean_value
()
{
return
value
.
boolean
;
}
...
...
@@ -239,7 +242,7 @@ namespace Sass {
// ------------------------------------------------------------------------
// Node method implementations
// -- in the header
so they can be easily
declared inline
// -- in the header
file so they can easily be
declared inline
// -- outside of their class definition to get the right declaration order
// ------------------------------------------------------------------------
...
...
node_factory.cpp
View file @
11aeaa6a
...
...
@@ -12,29 +12,28 @@ namespace Sass {
return
ip
;
}
Node
Node_Factory
::
node
(
Node
::
Type
type
,
string
*
file
,
size_t
line
,
const
Token
&
t
)
Node
Node_Factory
::
operator
()
(
Node
::
Type
type
,
string
*
file
,
size_t
line
,
const
Token
&
t
)
{
Node_Impl
*
ip
=
alloc_Node_Impl
(
type
,
file
,
line
);
ip
->
value
.
token
=
t
;
return
Node
(
ip
);
}
Node
Node_Factory
::
node
(
Node
::
Type
type
,
string
*
file
,
size_t
line
,
size_t
size
)
Node
Node_Factory
::
operator
()
(
Node
::
Type
type
,
string
*
file
,
size_t
line
,
size_t
size
)
{
Node_Impl
*
ip
=
alloc_Node_Impl
(
type
,
file
,
line
);
ip
->
has_children
=
true
;
ip
->
children
.
reserve
(
size
);
return
Node
(
ip
);
}
Node
Node_Factory
::
node
(
string
*
file
,
size_t
line
,
double
v
)
Node
Node_Factory
::
operator
()
(
string
*
file
,
size_t
line
,
double
v
)
{
Node_Impl
*
ip
=
alloc_Node_Impl
(
Node
::
number
,
file
,
line
);
ip
->
value
.
numeric
=
v
;
return
Node
(
ip
);
}
Node
Node_Factory
::
node
(
string
*
file
,
size_t
line
,
double
v
,
const
Token
&
t
)
Node
Node_Factory
::
operator
()
(
string
*
file
,
size_t
line
,
double
v
,
const
Token
&
t
)
{
Node_Impl
*
ip
=
alloc_Node_Impl
(
Node
::
numeric_dimension
,
file
,
line
);
ip
->
value
.
dimension
.
numeric
=
v
;
...
...
@@ -42,13 +41,13 @@ namespace Sass {
return
Node
(
ip
);
}
Node
Node_Factory
::
node
(
string
*
file
,
size_t
line
,
double
r
,
double
g
,
double
b
,
double
a
)
Node
Node_Factory
::
operator
()
(
string
*
file
,
size_t
line
,
double
r
,
double
g
,
double
b
,
double
a
)
{
Node
color
(
node
(
Node
::
numeric_color
,
file
,
line
,
4
));
color
<<
node
(
file
,
line
,
r
)
<<
node
(
file
,
line
,
g
)
<<
node
(
file
,
line
,
b
)
<<
node
(
file
,
line
,
a
);
Node
color
(
(
*
this
)
(
Node
::
numeric_color
,
file
,
line
,
4
));
color
<<
(
*
this
)
(
file
,
line
,
r
)
<<
(
*
this
)
(
file
,
line
,
g
)
<<
(
*
this
)
(
file
,
line
,
b
)
<<
(
*
this
)
(
file
,
line
,
a
);
return
color
;
}
...
...
node_factory.hpp
View file @
11aeaa6a
...
...
@@ -14,11 +14,11 @@ namespace Sass {
vector
<
Node_Impl
*>
pool_
;
Node_Impl
*
alloc_Node_Impl
(
Node
::
Type
type
,
string
*
file
,
size_t
line
);
public
:
Node
node
(
Node
::
Type
type
,
string
*
file
,
size_t
line
,
const
Token
&
t
);
Node
node
(
Node
::
Type
type
,
string
*
file
,
size_t
line
,
size_t
size
);
Node
node
(
string
*
file
,
size_t
line
,
double
v
);
Node
node
(
string
*
file
,
size_t
line
,
double
v
,
const
Token
&
t
);
Node
node
(
string
*
file
,
size_t
line
,
double
r
,
double
g
,
double
b
,
double
a
=
1.0
);
Node
operator
()
(
Node
::
Type
type
,
string
*
file
,
size_t
line
,
const
Token
&
t
);
Node
operator
()
(
Node
::
Type
type
,
string
*
file
,
size_t
line
,
size_t
size
);
Node
operator
()
(
string
*
file
,
size_t
line
,
double
v
);
Node
operator
()
(
string
*
file
,
size_t
line
,
double
v
,
const
Token
&
t
);
Node
operator
()
(
string
*
file
,
size_t
line
,
double
r
,
double
g
,
double
b
,
double
a
=
1.0
);
};
}
\ No newline at end of file
test_node_factory.cpp
View file @
11aeaa6a
...
...
@@ -11,20 +11,21 @@ int main()
using
namespace
Sass
;
using
namespace
std
;
cout
<<
sizeof
(
Node_Impl
*
)
<<
endl
;
cout
<<
sizeof
(
Node
)
<<
endl
;
cout
<<
sizeof
(
Node_Impl
)
<<
endl
<<
endl
;
Node_Factory
mak
e
=
Node_Factory
();
Node_Factory
new_Nod
e
=
Node_Factory
();
Node
interior
(
make
.
n
ode
(
Node
::
block
,
0
,
0
,
3
));
Node
interior
(
new_N
ode
(
Node
::
block
,
0
,
0
,
3
));
cout
<<
interior
.
size
()
<<
endl
;
cout
<<
interior
.
has_children
()
<<
endl
;
cout
<<
interior
.
should_eval
()
<<
endl
<<
endl
;
Node
num
(
make
.
n
ode
(
0
,
0
,
255
,
123
,
32
));
Node
num2
(
make
.
n
ode
(
0
,
0
,
255
,
123
,
32
));
Node
num3
(
make
.
n
ode
(
0
,
0
,
255
,
122
,
20
,
.75
));
Node
num
(
new_N
ode
(
0
,
0
,
255
,
123
,
32
));
Node
num2
(
new_N
ode
(
0
,
0
,
255
,
123
,
32
));
Node
num3
(
new_N
ode
(
0
,
0
,
255
,
122
,
20
,
.75
));
cout
<<
num
.
size
()
<<
endl
;
cout
<<
num
.
has_children
()
<<
endl
;
...
...
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