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
a82ee26f
Commit
a82ee26f
authored
May 02, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't need these files anymore.
parent
6c3ca1bc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
418 deletions
+0
-418
node_impl.cpp
node_impl.cpp
+0
-211
node_impl.hpp
node_impl.hpp
+0
-117
node_type.hpp
node_type.hpp
+0
-90
No files found.
node_impl.cpp
deleted
100644 → 0
View file @
6c3ca1bc
#include <cstring>
#include "node_impl.hpp"
namespace
Sass
{
// ------------------------------------------------------------------------
// Token method implementations
// ------------------------------------------------------------------------
inline
size_t
Token
::
length
()
const
{
return
end
-
begin
;
}
inline
string
Token
::
to_string
()
const
{
return
string
(
begin
,
end
-
begin
);
}
inline
Token
::
operator
bool
()
{
return
begin
&&
end
&&
begin
>=
end
;
}
// Need Token::make(...) because tokens are union members, and hence they
// can't have user-implemented default and copy constructors.
inline
Token
Token
::
make
()
{
Token
t
;
t
.
begin
=
0
;
t
.
end
=
0
;
return
t
;
}
inline
Token
Token
::
make
(
const
char
*
s
)
{
Token
t
;
t
.
begin
=
s
;
t
.
end
=
s
+
std
::
strlen
(
s
);
return
t
;
}
inline
Token
Token
::
make
(
const
char
*
b
,
const
char
*
e
)
{
Token
t
;
t
.
begin
=
b
;
t
.
end
=
e
;
return
t
;
}
string
Token
::
unquote
()
const
{
string
result
;
const
char
*
p
=
begin
;
if
(
*
begin
==
'\''
||
*
begin
==
'"'
)
{
++
p
;
while
(
p
<
end
)
{
if
(
*
p
==
'\\'
)
{
switch
(
*
(
++
p
))
{
case
'n'
:
result
+=
'\n'
;
break
;
case
't'
:
result
+=
'\t'
;
break
;
case
'b'
:
result
+=
'\b'
;
break
;
case
'r'
:
result
+=
'\r'
;
break
;
case
'f'
:
result
+=
'\f'
;
break
;
case
'v'
:
result
+=
'\v'
;
break
;
case
'a'
:
result
+=
'\a'
;
break
;
case
'\\'
:
result
+=
'\\'
;
break
;
default
:
result
+=
*
p
;
break
;
}
}
else
if
(
p
==
end
-
1
)
{
return
result
;
}
else
{
result
+=
*
p
;
}
++
p
;
}
return
result
;
}
else
{
while
(
p
<
end
)
{
result
+=
*
(
p
++
);
}
return
result
;
}
}
void
Token
::
unquote_to_stream
(
std
::
stringstream
&
buf
)
const
{
const
char
*
p
=
begin
;
if
(
*
begin
==
'\''
||
*
begin
==
'"'
)
{
++
p
;
while
(
p
<
end
)
{
if
(
*
p
==
'\\'
)
{
switch
(
*
(
++
p
))
{
case
'n'
:
buf
<<
'\n'
;
break
;
case
't'
:
buf
<<
'\t'
;
break
;
case
'b'
:
buf
<<
'\b'
;
break
;
case
'r'
:
buf
<<
'\r'
;
break
;
case
'f'
:
buf
<<
'\f'
;
break
;
case
'v'
:
buf
<<
'\v'
;
break
;
case
'a'
:
buf
<<
'\a'
;
break
;
case
'\\'
:
buf
<<
'\\'
;
break
;
default
:
buf
<<
*
p
;
break
;
}
}
else
if
(
p
==
end
-
1
)
{
return
;
}
else
{
buf
<<
*
p
;
}
++
p
;
}
return
;
}
else
{
while
(
p
<
end
)
{
buf
<<
*
(
p
++
);
}
return
;
}
}
bool
Token
::
operator
<
(
const
Token
&
rhs
)
const
{
const
char
*
first1
=
begin
;
const
char
*
last1
=
end
;
const
char
*
first2
=
rhs
.
begin
;
const
char
*
last2
=
rhs
.
end
;
while
(
first1
!=
last1
)
{
if
(
first2
==
last2
||
*
first2
<*
first1
)
return
false
;
else
if
(
*
first1
<*
first2
)
return
true
;
first1
++
;
first2
++
;
}
return
(
first2
!=
last2
);
}
bool
Token
::
operator
==
(
const
Token
&
rhs
)
const
{
if
(
length
()
!=
rhs
.
length
())
return
false
;
if
((
begin
[
0
]
==
'"'
||
begin
[
0
]
==
'\''
)
&&
(
rhs
.
begin
[
0
]
==
'"'
||
rhs
.
begin
[
0
]
==
'\''
))
{
return
unquote
()
==
rhs
.
unquote
();
}
const
char
*
p
=
begin
;
const
char
*
q
=
rhs
.
begin
;
for
(;
p
<
end
;
++
p
,
++
q
)
if
(
*
p
!=
*
q
)
return
false
;
return
true
;
}
// ------------------------------------------------------------------------
// Node_Impl method implementations
// ------------------------------------------------------------------------
inline
bool
Node_Impl
::
is_numeric
()
{
return
type
>=
number
&&
type
<=
numeric_dimension
;
}
inline
size_t
Node_Impl
::
size
()
{
return
children
.
size
();
}
inline
Node
&
Node_Impl
::
at
(
size_t
i
)
{
return
children
.
at
(
i
);
}
inline
Node
&
Node_Impl
::
back
()
{
return
children
.
back
();
}
inline
void
Node_Impl
::
push_back
(
const
Node
&
n
)
{
children
.
push_back
(
n
);
}
inline
Node
&
Node_Impl
::
pop_back
()
{
children
.
pop_back
();
}
inline
bool
Node_Impl
::
boolean_value
()
{
return
value
.
boolean
;
}
inline
double
Node_Impl
::
numeric_value
()
{
switch
(
type
)
{
case
number
:
case
numeric_percentage
:
return
value
.
numeric
;
case
numeric_dimension
:
return
value
.
dimension
.
numeric
;
default
:
break
;
// throw an exception?
}
return
0
;
}
inline
string
Node_Impl
::
unit
()
{
switch
(
type
)
{
case
numeric_percentage
:
{
return
"
\"
%
\"
"
;
}
break
;
case
numeric_dimension
:
{
string
result
(
"
\"
"
);
result
+=
value
.
dimension
.
unit
.
to_string
();
result
+=
"
\"
"
;
return
result
;
}
break
;
default
:
break
;
}
return
"
\"\"
"
;
}
}
\ No newline at end of file
node_impl.hpp
deleted
100644 → 0
View file @
6c3ca1bc
#include <vector>
#include <sstream>
#ifndef SASS_NODE_TYPE_INCLUDED
#include "node_type.hpp"
#endif
#include "node.hpp"
namespace
Sass
{
using
namespace
std
;
struct
Token
{
const
char
*
begin
;
const
char
*
end
;
// Need Token::make(...) because tokens are union members, and hence they
// can't have user-implemented default and copy constructors.
static
Token
make
();
static
Token
make
(
const
char
*
s
);
static
Token
make
(
const
char
*
b
,
const
char
*
e
);
size_t
length
()
const
;
string
to_string
()
const
;
string
unquote
()
const
;
void
unquote_to_stream
(
std
::
stringstream
&
buf
)
const
;
bool
operator
<
(
const
Token
&
rhs
)
const
;
bool
operator
==
(
const
Token
&
rhs
)
const
;
operator
bool
();
};
struct
Dimension
{
double
numeric
;
Token
unit
;
};
struct
Node_Impl
{
union
{
bool
boolean
;
double
numeric
;
Token
token
;
Dimension
dimension
;
}
value
;
vector
<
Node
>
children
;
string
*
file_name
;
size_t
line_number
;
Node_Type
type
;
bool
has_children
;
bool
has_statements
;
bool
has_blocks
;
bool
has_expansions
;
bool
has_backref
;
bool
from_variable
;
bool
eval_me
;
bool
is_unquoted
;
bool
is_numeric
();
size_t
size
();
Node
&
at
(
size_t
i
);
Node
&
back
();
Node
&
pop_back
();
void
push_back
(
const
Node
&
n
);
bool
boolean_value
();
double
numeric_value
();
string
unit
();
};
}
\ No newline at end of file
node_type.hpp
deleted
100644 → 0
View file @
6c3ca1bc
#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