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
11a8906f
Commit
11a8906f
authored
May 02, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved the less-than node comparison over to the refactored version.
parent
c73a1b9d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
4 deletions
+34
-4
node.cpp
node.cpp
+29
-4
node.hpp
node.hpp
+1
-0
test_node_factory.cpp
test_node_factory.cpp
+4
-0
No files found.
node.cpp
View file @
11a8906f
#include <sstream>
#include "node.hpp"
#include "error.hpp"
namespace
Sass
{
using
namespace
std
;
...
...
@@ -61,8 +62,32 @@ namespace Sass {
return
true
;
}
break
;
}
return
false
;
}
bool
Node
::
operator
<
(
Node
rhs
)
const
{
Type
lhs_type
=
type
();
Type
rhs_type
=
rhs
.
type
();
if
(
lhs_type
==
number
&&
rhs_type
==
number
||
lhs_type
==
numeric_percentage
&&
rhs_type
==
numeric_percentage
)
{
return
numeric_value
()
<
rhs
.
numeric_value
();
}
else
if
(
lhs_type
==
numeric_dimension
&&
rhs_type
==
numeric_dimension
)
{
if
(
unit
()
==
rhs
.
unit
())
{
return
numeric_value
()
<
rhs
.
numeric_value
();
}
else
{
throw
Error
(
Error
::
evaluation
,
line_number
(),
file_name
(),
"incompatible units"
);
}
}
else
{
throw
Error
(
Error
::
evaluation
,
line_number
(),
file_name
(),
"incomparable types"
);
}
}
// ------------------------------------------------------------------------
// Token method implementations
// ------------------------------------------------------------------------
...
...
@@ -150,11 +175,11 @@ namespace Sass {
const
char
*
last2
=
rhs
.
end
;
while
(
first1
!=
last1
)
{
if
(
first2
==
last2
||
*
first2
<
*
first1
)
return
false
;
else
if
(
*
first1
<
*
first2
)
return
true
;
first1
++
;
first2
++
;
if
(
first2
==
last2
||
*
first2
<
*
first1
)
return
false
;
else
if
(
*
first1
<
*
first2
)
return
true
;
++
first1
;
++
first2
;
}
return
(
first2
!=
last2
);
return
(
first2
!=
last2
);
}
bool
Token
::
operator
==
(
const
Token
&
rhs
)
const
...
...
node.hpp
View file @
11a8906f
...
...
@@ -180,6 +180,7 @@ namespace Sass {
Token
unit
()
const
;
bool
operator
==
(
Node
rhs
)
const
;
bool
operator
<
(
Node
rhs
)
const
;
};
struct
Node_Impl
{
...
...
test_node_factory.cpp
View file @
11a8906f
...
...
@@ -36,5 +36,8 @@ int main()
cout
<<
(
num
==
num2
)
<<
endl
;
cout
<<
(
num
==
num3
)
<<
endl
<<
endl
;
cout
<<
(
num3
[
2
]
<
num2
[
2
])
<<
endl
;
cout
<<
(
num2
[
3
]
<
num3
[
3
])
<<
endl
<<
endl
;
return
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