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
83a92d81
Commit
83a92d81
authored
May 01, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Putting the node type-tag enum back inside the Node class.
parent
4808d322
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
31 deletions
+31
-31
node.cpp
node.cpp
+5
-5
node.hpp
node.hpp
+16
-16
node_factory.cpp
node_factory.cpp
+6
-6
node_factory.hpp
node_factory.hpp
+3
-3
test_node_factory.cpp
test_node_factory.cpp
+1
-1
No files found.
node.cpp
View file @
83a92d81
...
...
@@ -177,10 +177,10 @@ namespace Sass {
{
switch
(
type
)
{
case
number
:
case
numeric_percentage
:
case
Node
:
:
number
:
case
Node
:
:
numeric_percentage
:
return
value
.
numeric
;
case
numeric_dimension
:
case
Node
:
:
numeric_dimension
:
return
value
.
dimension
.
numeric
;
default
:
break
;
...
...
@@ -193,11 +193,11 @@ namespace Sass {
{
switch
(
type
)
{
case
numeric_percentage
:
{
case
Node
:
:
numeric_percentage
:
{
return
"
\"
%
\"
"
;
}
break
;
case
numeric_dimension
:
{
case
Node
:
:
numeric_dimension
:
{
string
result
(
"
\"
"
);
result
+=
value
.
dimension
.
unit
.
to_string
();
result
+=
"
\"
"
;
...
...
node.hpp
View file @
83a92d81
...
...
@@ -6,7 +6,18 @@
namespace
Sass
{
using
namespace
std
;
enum
Node_Type
{
struct
Node_Impl
;
class
Node
{
private
:
friend
class
Node_Factory
;
Node_Impl
*
ip_
;
// private constructors; must use a Node_Factory
Node
();
Node
(
Node_Impl
*
ip
);
// : ip_(ip) { }
public
:
enum
Type
{
none
,
flags
,
comment
,
...
...
@@ -90,18 +101,7 @@ namespace Sass {
assignment
};
struct
Node_Impl
;
class
Node
{
private
:
friend
class
Node_Factory
;
Node_Impl
*
ip_
;
// private constructors; must use a Node_Factory
Node
();
Node
(
Node_Impl
*
ip
);
// : ip_(ip) { }
public
:
Node_Type
type
();
// { return ip_->type; }
Type
type
();
// { return ip_->type; }
bool
has_children
();
// { return ip_->has_children; }
bool
has_statements
();
// { return ip_->has_statements; }
...
...
@@ -197,7 +197,7 @@ namespace Sass {
string
*
file_name
;
size_t
line_number
;
Node
_
Type
type
;
Node
::
Type
type
;
bool
has_children
;
bool
has_statements
;
...
...
@@ -219,7 +219,7 @@ namespace Sass {
// bool boolean_value();
bool
is_numeric
()
{
return
type
>=
number
&&
type
<=
numeric_dimension
;
}
{
return
type
>=
Node
::
number
&&
type
<=
Node
::
numeric_dimension
;
}
size_t
size
()
{
return
children
.
size
();
}
...
...
@@ -252,7 +252,7 @@ namespace Sass {
inline
Node
::
Node
(
Node_Impl
*
ip
)
:
ip_
(
ip
)
{
}
inline
Node
_Type
Node
::
type
()
{
return
ip_
->
type
;
}
inline
Node
::
Type
Node
::
type
()
{
return
ip_
->
type
;
}
inline
bool
Node
::
has_children
()
{
return
ip_
->
has_children
;
}
inline
bool
Node
::
has_statements
()
{
return
ip_
->
has_statements
;
}
...
...
node_factory.cpp
View file @
83a92d81
...
...
@@ -2,7 +2,7 @@
namespace
Sass
{
Node_Impl
*
Node_Factory
::
alloc_Node_Impl
(
Node
_
Type
type
,
string
*
file
,
size_t
line
)
Node_Impl
*
Node_Factory
::
alloc_Node_Impl
(
Node
::
Type
type
,
string
*
file
,
size_t
line
)
{
Node_Impl
*
ip
=
new
Node_Impl
();
ip
->
type
=
type
;
...
...
@@ -12,14 +12,14 @@ namespace Sass {
return
ip
;
}
Node
Node_Factory
::
node
(
Node
_
Type
type
,
string
*
file
,
size_t
line
,
const
Token
&
t
)
Node
Node_Factory
::
node
(
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
::
node
(
Node
::
Type
type
,
string
*
file
,
size_t
line
,
size_t
size
)
{
Node_Impl
*
ip
=
alloc_Node_Impl
(
type
,
file
,
line
);
ip
->
has_children
=
true
;
...
...
@@ -29,14 +29,14 @@ namespace Sass {
Node
Node_Factory
::
node
(
string
*
file
,
size_t
line
,
double
v
)
{
Node_Impl
*
ip
=
alloc_Node_Impl
(
number
,
file
,
line
);
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_Impl
*
ip
=
alloc_Node_Impl
(
numeric_dimension
,
file
,
line
);
Node_Impl
*
ip
=
alloc_Node_Impl
(
Node
::
numeric_dimension
,
file
,
line
);
ip
->
value
.
dimension
.
numeric
=
v
;
ip
->
value
.
dimension
.
unit
=
t
;
return
Node
(
ip
);
...
...
@@ -44,7 +44,7 @@ namespace Sass {
Node
Node_Factory
::
node
(
string
*
file
,
size_t
line
,
double
r
,
double
g
,
double
b
,
double
a
)
{
Node
color
(
node
(
numeric_color
,
file
,
line
,
4
));
Node
color
(
node
(
Node
::
numeric_color
,
file
,
line
,
4
));
color
<<
node
(
file
,
line
,
r
)
<<
node
(
file
,
line
,
g
)
<<
node
(
file
,
line
,
b
)
...
...
node_factory.hpp
View file @
83a92d81
...
...
@@ -12,10 +12,10 @@ namespace Sass {
class
Node_Factory
{
vector
<
Node_Impl
*>
pool_
;
Node_Impl
*
alloc_Node_Impl
(
Node
_
Type
type
,
string
*
file
,
size_t
line
);
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
(
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
);
...
...
test_node_factory.cpp
View file @
83a92d81
...
...
@@ -16,7 +16,7 @@ int main()
Node_Factory
make
=
Node_Factory
();
Node
interior
(
make
.
node
(
block
,
0
,
0
,
3
));
Node
interior
(
make
.
node
(
Node
::
block
,
0
,
0
,
3
));
cout
<<
interior
.
size
()
<<
endl
;
cout
<<
interior
.
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