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
6e2de911
Commit
6e2de911
authored
May 01, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More work on the node refactor.
parent
885b0e50
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
180 additions
and
6 deletions
+180
-6
node_factory.cpp
node_factory.cpp
+57
-0
node_factory.hpp
node_factory.hpp
+25
-0
node_impl.cpp
node_impl.cpp
+2
-2
node_impl.hpp
node_impl.hpp
+1
-1
node_pimpl.cpp
node_pimpl.cpp
+2
-0
node_pimpl.hpp
node_pimpl.hpp
+3
-3
node_type.hpp
node_type.hpp
+90
-0
No files found.
node_factory.cpp
0 → 100644
View file @
6e2de911
#include "node_factory.hpp"
#include "node_impl.hpp"
namespace
Sass
{
Node_Impl
*
Node_Factory
::
alloc_Node_Impl
(
Node_Type
type
,
string
*
file
,
size_t
line
)
{
Node_Impl
*
ip
=
new
Node_Impl
();
ip
->
type
=
type
;
ip
->
file_name
=
file
;
ip
->
line_number
=
line
;
pool_
.
push_back
(
ip
);
return
ip
;
}
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_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_Impl
*
ip
=
alloc_Node_Impl
(
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
);
ip
->
value
.
dimension
.
numeric
=
v
;
ip
->
value
.
dimension
.
unit
=
t
;
return
Node
(
ip
);
}
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
));
color
<<
node
(
file
,
line
,
r
)
<<
node
(
file
,
line
,
g
)
<<
node
(
file
,
line
,
b
)
<<
node
(
file
,
line
,
a
);
return
color
;
}
}
\ No newline at end of file
node_factory.hpp
0 → 100644
View file @
6e2de911
#include <vector>
#ifndef SASS_NODE_INCLUDED
#include "node_pimpl.hpp"
#endif
namespace
Sass
{
using
namespace
std
;
struct
Token
;
struct
Node_Impl
;
class
Node_Factory
{
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
);
};
}
\ No newline at end of file
node_impl.cpp
View file @
6e2de911
...
...
@@ -152,7 +152,7 @@ namespace Sass {
// ------------------------------------------------------------------------
inline
bool
Node_Impl
::
is_numeric
()
{
return
type
>=
number
&&
type
<=
numeric_
color
;
}
{
return
type
>=
number
&&
type
<=
numeric_
dimension
;
}
inline
size_t
Node_Impl
::
size
()
{
return
children
.
size
();
}
...
...
@@ -180,7 +180,7 @@ namespace Sass {
case
numeric_percentage
:
return
value
.
numeric
;
case
numeric_dimension
:
return
value
.
dimension
.
numeric
_value
;
return
value
.
dimension
.
numeric
;
default
:
break
;
// throw an exception?
...
...
node_impl.hpp
View file @
6e2de911
...
...
@@ -34,7 +34,7 @@ namespace Sass {
};
struct
Dimension
{
double
numeric
_value
;
double
numeric
;
Token
unit
;
};
...
...
node_pimpl.cpp
View file @
6e2de911
...
...
@@ -6,6 +6,8 @@
namespace
Sass
{
using
namespace
std
;
inline
Node
::
Node
(
Node_Impl
*
ip
)
:
ip_
(
ip
)
{
}
inline
Node_Type
Node
::
type
()
{
return
ip_
->
type
;
}
...
...
node_pimpl.hpp
View file @
6e2de911
...
...
@@ -12,11 +12,11 @@ namespace Sass {
class
Node_Impl
;
// forward declaration
class
Node
{
private
:
Node_Impl
*
ip_
;
Node
(
Node_Impl
*
ip
);
friend
class
Node_Factory
;
public
:
public
:
Node_Type
type
();
bool
has_children
();
...
...
node_type.hpp
0 → 100644
View file @
6e2de911
#define SASS_NODE_TYPE_INCLUDED
namespace
Sass
{
enum
Node_Type
{
none
,
flags
,
comment
,
root
,
ruleset
,
propset
,
selector_group
,
selector
,
selector_combinator
,
simple_selector_sequence
,
backref
,
simple_selector
,
type_selector
,
class_selector
,
id_selector
,
pseudo
,
pseudo_negation
,
functional_pseudo
,
attribute_selector
,
block
,
rule
,
property
,
nil
,
comma_list
,
space_list
,
disjunction
,
conjunction
,
relation
,
eq
,
neq
,
gt
,
gte
,
lt
,
lte
,
expression
,
add
,
sub
,
term
,
mul
,
div
,
factor
,
unary_plus
,
unary_minus
,
values
,
value
,
identifier
,
uri
,
textual_percentage
,
textual_dimension
,
textual_number
,
textual_hex
,
color_name
,
string_constant
,
number
,
numeric_percentage
,
numeric_dimension
,
numeric_color
,
boolean
,
important
,
value_schema
,
string_schema
,
css_import
,
function_call
,
mixin
,
parameters
,
expansion
,
arguments
,
variable
,
assignment
};
}
\ 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