sassc 1.11.4 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +2 -2
- data/CODE_OF_CONDUCT.md +10 -0
- data/README.md +4 -1
- data/ext/libsass/.editorconfig +1 -1
- data/ext/libsass/.github/CONTRIBUTING.md +7 -7
- data/ext/libsass/.github/ISSUE_TEMPLATE.md +31 -6
- data/ext/libsass/.gitignore +3 -0
- data/ext/libsass/.travis.yml +37 -18
- data/ext/libsass/GNUmakefile.am +23 -37
- data/ext/libsass/Makefile +10 -6
- data/ext/libsass/Makefile.conf +3 -0
- data/ext/libsass/Readme.md +68 -63
- data/ext/libsass/appveyor.yml +7 -3
- data/ext/libsass/configure.ac +10 -14
- data/ext/libsass/docs/api-context-internal.md +29 -21
- data/ext/libsass/docs/api-context.md +26 -6
- data/ext/libsass/docs/api-doc.md +49 -16
- data/ext/libsass/docs/api-function-example.md +1 -1
- data/ext/libsass/docs/api-function.md +31 -7
- data/ext/libsass/docs/api-importer.md +19 -19
- data/ext/libsass/docs/api-value.md +4 -2
- data/ext/libsass/docs/build-on-windows.md +4 -4
- data/ext/libsass/docs/build-with-mingw.md +3 -3
- data/ext/libsass/docs/build.md +9 -9
- data/ext/libsass/docs/custom-functions-internal.md +10 -8
- data/ext/libsass/docs/implementations.md +20 -8
- data/ext/libsass/docs/unicode.md +16 -10
- data/ext/libsass/include/sass/base.h +0 -3
- data/ext/libsass/include/sass/context.h +20 -2
- data/ext/libsass/include/sass/functions.h +31 -0
- data/ext/libsass/include/sass/values.h +3 -1
- data/ext/libsass/include/sass/version.h +1 -1
- data/ext/libsass/include/sass/version.h.in +1 -1
- data/ext/libsass/include/sass2scss.h +1 -1
- data/ext/libsass/res/resource.rc +6 -6
- data/ext/libsass/script/ci-build-libsass +10 -5
- data/ext/libsass/script/ci-build-plugin +62 -0
- data/ext/libsass/script/ci-install-compiler +1 -1
- data/ext/libsass/script/ci-install-deps +4 -7
- data/ext/libsass/script/ci-report-coverage +13 -3
- data/ext/libsass/script/tap-driver +1 -1
- data/ext/libsass/script/tap-runner +1 -1
- data/ext/libsass/src/GNUmakefile.am +1 -1
- data/ext/libsass/src/ast.cpp +537 -762
- data/ext/libsass/src/ast.hpp +377 -419
- data/ext/libsass/src/ast_def_macros.hpp +26 -1
- data/ext/libsass/src/ast_fwd_decl.cpp +29 -0
- data/ext/libsass/src/ast_fwd_decl.hpp +94 -21
- data/ext/libsass/src/b64/encode.h +3 -1
- data/ext/libsass/src/backtrace.cpp +46 -0
- data/ext/libsass/src/backtrace.hpp +7 -54
- data/ext/libsass/src/bind.cpp +72 -50
- data/ext/libsass/src/bind.hpp +0 -1
- data/ext/libsass/src/cencode.c +6 -0
- data/ext/libsass/src/check_nesting.cpp +157 -135
- data/ext/libsass/src/check_nesting.hpp +11 -10
- data/ext/libsass/src/color_maps.cpp +10 -6
- data/ext/libsass/src/color_maps.hpp +6 -8
- data/ext/libsass/src/constants.cpp +4 -3
- data/ext/libsass/src/constants.hpp +4 -3
- data/ext/libsass/src/context.cpp +110 -47
- data/ext/libsass/src/context.hpp +11 -1
- data/ext/libsass/src/cssize.cpp +105 -94
- data/ext/libsass/src/cssize.hpp +4 -5
- data/ext/libsass/src/debugger.hpp +247 -244
- data/ext/libsass/src/emitter.cpp +30 -6
- data/ext/libsass/src/emitter.hpp +7 -0
- data/ext/libsass/src/environment.cpp +67 -16
- data/ext/libsass/src/environment.hpp +28 -7
- data/ext/libsass/src/error_handling.cpp +92 -64
- data/ext/libsass/src/error_handling.hpp +64 -43
- data/ext/libsass/src/eval.cpp +494 -544
- data/ext/libsass/src/eval.hpp +17 -23
- data/ext/libsass/src/expand.cpp +182 -154
- data/ext/libsass/src/expand.hpp +4 -5
- data/ext/libsass/src/extend.cpp +299 -291
- data/ext/libsass/src/extend.hpp +46 -11
- data/ext/libsass/src/file.cpp +103 -36
- data/ext/libsass/src/file.hpp +21 -4
- data/ext/libsass/src/functions.cpp +561 -312
- data/ext/libsass/src/functions.hpp +8 -5
- data/ext/libsass/src/inspect.cpp +108 -53
- data/ext/libsass/src/inspect.hpp +5 -2
- data/ext/libsass/src/lexer.cpp +15 -7
- data/ext/libsass/src/lexer.hpp +13 -4
- data/ext/libsass/src/listize.cpp +3 -2
- data/ext/libsass/src/listize.hpp +0 -1
- data/ext/libsass/src/memory/SharedPtr.cpp +16 -18
- data/ext/libsass/src/memory/SharedPtr.hpp +47 -43
- data/ext/libsass/src/node.cpp +34 -38
- data/ext/libsass/src/node.hpp +6 -8
- data/ext/libsass/src/operation.hpp +2 -2
- data/ext/libsass/src/operators.cpp +240 -0
- data/ext/libsass/src/operators.hpp +30 -0
- data/ext/libsass/src/output.cpp +22 -20
- data/ext/libsass/src/parser.cpp +719 -358
- data/ext/libsass/src/parser.hpp +57 -22
- data/ext/libsass/src/plugins.cpp +28 -10
- data/ext/libsass/src/position.cpp +21 -3
- data/ext/libsass/src/position.hpp +2 -1
- data/ext/libsass/src/prelexer.cpp +104 -19
- data/ext/libsass/src/prelexer.hpp +10 -3
- data/ext/libsass/src/remove_placeholders.cpp +9 -10
- data/ext/libsass/src/remove_placeholders.hpp +1 -5
- data/ext/libsass/src/sass.cpp +62 -4
- data/ext/libsass/src/sass.hpp +5 -2
- data/ext/libsass/src/sass_context.cpp +96 -58
- data/ext/libsass/src/sass_context.hpp +7 -5
- data/ext/libsass/src/sass_functions.cpp +63 -1
- data/ext/libsass/src/sass_functions.hpp +19 -1
- data/ext/libsass/src/sass_util.cpp +3 -3
- data/ext/libsass/src/sass_util.hpp +4 -4
- data/ext/libsass/src/sass_values.cpp +42 -39
- data/ext/libsass/src/sass_values.hpp +2 -1
- data/ext/libsass/src/source_map.cpp +16 -18
- data/ext/libsass/src/subset_map.cpp +6 -8
- data/ext/libsass/src/subset_map.hpp +6 -6
- data/ext/libsass/src/to_c.cpp +2 -2
- data/ext/libsass/src/to_value.cpp +8 -3
- data/ext/libsass/src/to_value.hpp +1 -0
- data/ext/libsass/src/units.cpp +349 -45
- data/ext/libsass/src/units.hpp +39 -22
- data/ext/libsass/src/utf8/checked.h +7 -0
- data/ext/libsass/src/utf8/unchecked.h +7 -0
- data/ext/libsass/src/utf8_string.cpp +1 -1
- data/ext/libsass/src/util.cpp +139 -45
- data/ext/libsass/src/util.hpp +4 -7
- data/ext/libsass/src/values.cpp +15 -23
- data/ext/libsass/win/libsass.sln +13 -2
- data/ext/libsass/win/libsass.sln.DotSettings +9 -0
- data/ext/libsass/win/libsass.targets +3 -0
- data/ext/libsass/win/libsass.vcxproj.filters +9 -0
- data/lib/sassc/version.rb +1 -1
- data/sassc.gemspec +1 -1
- data/test/native_test.rb +1 -1
- metadata +11 -4
data/ext/libsass/src/lexer.cpp
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#include "sass.hpp"
|
|
2
2
|
#include <cctype>
|
|
3
|
-
#include <cstddef>
|
|
4
3
|
#include <iostream>
|
|
5
4
|
#include <iomanip>
|
|
6
5
|
#include "lexer.hpp"
|
|
@@ -50,6 +49,12 @@ namespace Sass {
|
|
|
50
49
|
return unsigned(chr - '0') <= '9' - '0';
|
|
51
50
|
}
|
|
52
51
|
|
|
52
|
+
bool is_number(const char& chr)
|
|
53
|
+
{
|
|
54
|
+
// adapted the technique from is_alpha
|
|
55
|
+
return is_digit(chr) || chr == '-' || chr == '+';
|
|
56
|
+
}
|
|
57
|
+
|
|
53
58
|
bool is_xdigit(const char& chr)
|
|
54
59
|
{
|
|
55
60
|
// adapted the technique from is_alpha
|
|
@@ -80,10 +85,11 @@ namespace Sass {
|
|
|
80
85
|
// but with specific ranges (copied from Ruby Sass)
|
|
81
86
|
bool is_nonascii(const char& chr)
|
|
82
87
|
{
|
|
88
|
+
unsigned int cmp = unsigned(chr);
|
|
83
89
|
return (
|
|
84
|
-
(
|
|
85
|
-
(
|
|
86
|
-
(
|
|
90
|
+
(cmp >= 128 && cmp <= 15572911) ||
|
|
91
|
+
(cmp >= 15630464 && cmp <= 15712189) ||
|
|
92
|
+
(cmp >= 4036001920)
|
|
87
93
|
);
|
|
88
94
|
}
|
|
89
95
|
|
|
@@ -91,15 +97,17 @@ namespace Sass {
|
|
|
91
97
|
// valid in a uri (copied from Ruby Sass)
|
|
92
98
|
bool is_uri_character(const char& chr)
|
|
93
99
|
{
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
unsigned int cmp = unsigned(chr);
|
|
101
|
+
return (cmp > 41 && cmp < 127) ||
|
|
102
|
+
cmp == ':' || cmp == '/';
|
|
96
103
|
}
|
|
97
104
|
|
|
98
105
|
// check if char is within a reduced ascii range
|
|
99
106
|
// valid for escaping (copied from Ruby Sass)
|
|
100
107
|
bool is_escapable_character(const char& chr)
|
|
101
108
|
{
|
|
102
|
-
|
|
109
|
+
unsigned int cmp = unsigned(chr);
|
|
110
|
+
return cmp > 31 && cmp < 127;
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
// Match word character (look ahead)
|
data/ext/libsass/src/lexer.hpp
CHANGED
|
@@ -29,6 +29,7 @@ namespace Sass {
|
|
|
29
29
|
bool is_alpha(const char& src);
|
|
30
30
|
bool is_punct(const char& src);
|
|
31
31
|
bool is_digit(const char& src);
|
|
32
|
+
bool is_number(const char& src);
|
|
32
33
|
bool is_alnum(const char& src);
|
|
33
34
|
bool is_xdigit(const char& src);
|
|
34
35
|
bool is_unicode(const char& src);
|
|
@@ -96,9 +97,9 @@ namespace Sass {
|
|
|
96
97
|
// Regex equivalent: /(?:literal)/
|
|
97
98
|
template <const char* str>
|
|
98
99
|
const char* exactly(const char* src) {
|
|
99
|
-
if (str ==
|
|
100
|
+
if (str == NULL) return 0;
|
|
100
101
|
const char* pre = str;
|
|
101
|
-
if (src ==
|
|
102
|
+
if (src == NULL) return 0;
|
|
102
103
|
// there is a small chance that the search string
|
|
103
104
|
// is longer than the rest of the string to look at
|
|
104
105
|
while (*pre && *src == *pre) {
|
|
@@ -109,14 +110,22 @@ namespace Sass {
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
|
|
113
|
+
// Match a single character literal.
|
|
114
|
+
// Regex equivalent: /(?:x)/i
|
|
115
|
+
// only define lower case alpha chars
|
|
116
|
+
template <char chr>
|
|
117
|
+
const char* insensitive(const char* src) {
|
|
118
|
+
return *src == chr || *src+32 == chr ? src + 1 : 0;
|
|
119
|
+
}
|
|
120
|
+
|
|
112
121
|
// Match the full string literal.
|
|
113
122
|
// Regex equivalent: /(?:literal)/i
|
|
114
123
|
// only define lower case alpha chars
|
|
115
124
|
template <const char* str>
|
|
116
125
|
const char* insensitive(const char* src) {
|
|
117
|
-
if (str ==
|
|
126
|
+
if (str == NULL) return 0;
|
|
118
127
|
const char* pre = str;
|
|
119
|
-
if (src ==
|
|
128
|
+
if (src == NULL) return 0;
|
|
120
129
|
// there is a small chance that the search string
|
|
121
130
|
// is longer than the rest of the string to look at
|
|
122
131
|
while (*pre && (*src == *pre || *src+32 == *pre)) {
|
data/ext/libsass/src/listize.cpp
CHANGED
|
@@ -64,13 +64,14 @@ namespace Sass {
|
|
|
64
64
|
break;
|
|
65
65
|
case Complex_Selector::ANCESTOR_OF:
|
|
66
66
|
break;
|
|
67
|
+
default: break;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
Complex_Selector_Obj tail = sel->tail();
|
|
70
71
|
if (tail)
|
|
71
72
|
{
|
|
72
73
|
Expression_Obj tt = tail->perform(this);
|
|
73
|
-
if (List_Ptr ls =
|
|
74
|
+
if (List_Ptr ls = Cast<List>(tt))
|
|
74
75
|
{ l->concat(ls); }
|
|
75
76
|
}
|
|
76
77
|
if (l->length() == 0) return 0;
|
|
@@ -79,7 +80,7 @@ namespace Sass {
|
|
|
79
80
|
|
|
80
81
|
Expression_Ptr Listize::fallback_impl(AST_Node_Ptr n)
|
|
81
82
|
{
|
|
82
|
-
return
|
|
83
|
+
return Cast<Expression>(n);
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
}
|
data/ext/libsass/src/listize.hpp
CHANGED
|
@@ -17,8 +17,8 @@ namespace Sass {
|
|
|
17
17
|
std::cerr << "###################################\n";
|
|
18
18
|
std::cerr << "# REPORTING MISSING DEALLOCATIONS #\n";
|
|
19
19
|
std::cerr << "###################################\n";
|
|
20
|
-
for (
|
|
21
|
-
if (AST_Node_Ptr ast =
|
|
20
|
+
for (SharedObj* var : all) {
|
|
21
|
+
if (AST_Node_Ptr ast = dynamic_cast<AST_Node*>(var)) {
|
|
22
22
|
debug_ast(ast);
|
|
23
23
|
} else {
|
|
24
24
|
std::cerr << "LEAKED " << var << "\n";
|
|
@@ -37,22 +37,20 @@ namespace Sass {
|
|
|
37
37
|
, dbg(false)
|
|
38
38
|
#endif
|
|
39
39
|
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
SharedObj::~SharedObj() {
|
|
47
|
-
#ifdef DEBUG_SHARED_PTR
|
|
48
|
-
if (dbg) std::cerr << "Destruct " << this << "\n";
|
|
49
|
-
if(!all.empty()) { // check needed for MSVC (no clue why?)
|
|
50
|
-
all.erase(std::remove(all.begin(), all.end(), this), all.end());
|
|
51
|
-
}
|
|
52
|
-
#endif
|
|
53
|
-
};
|
|
54
|
-
|
|
40
|
+
refcounter = 0;
|
|
41
|
+
#ifdef DEBUG_SHARED_PTR
|
|
42
|
+
if (taint) all.push_back(this);
|
|
43
|
+
#endif
|
|
44
|
+
};
|
|
55
45
|
|
|
46
|
+
SharedObj::~SharedObj() {
|
|
47
|
+
#ifdef DEBUG_SHARED_PTR
|
|
48
|
+
if (dbg) std::cerr << "Destruct " << this << "\n";
|
|
49
|
+
if(!all.empty()) { // check needed for MSVC (no clue why?)
|
|
50
|
+
all.erase(std::remove(all.begin(), all.end(), this), all.end());
|
|
51
|
+
}
|
|
52
|
+
#endif
|
|
53
|
+
};
|
|
56
54
|
|
|
57
55
|
void SharedPtr::decRefCount() {
|
|
58
56
|
if (node) {
|
|
@@ -62,7 +60,7 @@ namespace Sass {
|
|
|
62
60
|
#endif
|
|
63
61
|
if (node->refcounter == 0) {
|
|
64
62
|
#ifdef DEBUG_SHARED_PTR
|
|
65
|
-
AST_Node_Ptr
|
|
63
|
+
// AST_Node_Ptr ast = dynamic_cast<AST_Node*>(node);
|
|
66
64
|
if (node->dbg) std::cerr << "DELETE NODE " << node << "\n";
|
|
67
65
|
#endif
|
|
68
66
|
if (!node->detached) {
|
|
@@ -17,7 +17,7 @@ namespace Sass {
|
|
|
17
17
|
#ifdef DEBUG_SHARED_PTR
|
|
18
18
|
|
|
19
19
|
#define SASS_MEMORY_NEW(Class, ...) \
|
|
20
|
-
|
|
20
|
+
((Class*)(new Class(__VA_ARGS__))->trace(__FILE__, __LINE__)) \
|
|
21
21
|
|
|
22
22
|
#define SASS_MEMORY_COPY(obj) \
|
|
23
23
|
((obj)->copy(__FILE__, __LINE__)) \
|
|
@@ -38,12 +38,6 @@ namespace Sass {
|
|
|
38
38
|
|
|
39
39
|
#endif
|
|
40
40
|
|
|
41
|
-
#define SASS_MEMORY_CAST(Class, obj) \
|
|
42
|
-
(dynamic_cast<Class##_Ptr>(&obj)) \
|
|
43
|
-
|
|
44
|
-
#define SASS_MEMORY_CAST_PTR(Class, ptr) \
|
|
45
|
-
(dynamic_cast<Class##_Ptr>(ptr)) \
|
|
46
|
-
|
|
47
41
|
class SharedObj {
|
|
48
42
|
protected:
|
|
49
43
|
friend class SharedPtr;
|
|
@@ -92,9 +86,9 @@ namespace Sass {
|
|
|
92
86
|
|
|
93
87
|
|
|
94
88
|
class SharedPtr {
|
|
95
|
-
|
|
89
|
+
protected:
|
|
96
90
|
SharedObj* node;
|
|
97
|
-
|
|
91
|
+
protected:
|
|
98
92
|
void decRefCount();
|
|
99
93
|
void incRefCount();
|
|
100
94
|
public:
|
|
@@ -103,24 +97,21 @@ namespace Sass {
|
|
|
103
97
|
: node(NULL) {};
|
|
104
98
|
// the create constructor
|
|
105
99
|
SharedPtr(SharedObj* ptr);
|
|
106
|
-
// copy assignment operator
|
|
107
|
-
SharedPtr& operator=(const SharedPtr& rhs);
|
|
108
|
-
// move assignment operator
|
|
109
|
-
/* SharedPtr& operator=(SharedPtr&& rhs); */
|
|
110
100
|
// the copy constructor
|
|
111
101
|
SharedPtr(const SharedPtr& obj);
|
|
112
102
|
// the move constructor
|
|
113
|
-
|
|
114
|
-
//
|
|
115
|
-
|
|
103
|
+
SharedPtr(SharedPtr&& obj);
|
|
104
|
+
// copy assignment operator
|
|
105
|
+
SharedPtr& operator=(const SharedPtr& obj);
|
|
106
|
+
// move assignment operator
|
|
107
|
+
SharedPtr& operator=(SharedPtr&& obj);
|
|
108
|
+
// pure virtual destructor
|
|
109
|
+
virtual ~SharedPtr() = 0;
|
|
116
110
|
public:
|
|
117
|
-
SharedObj* obj () {
|
|
118
|
-
return node;
|
|
119
|
-
};
|
|
120
111
|
SharedObj* obj () const {
|
|
121
112
|
return node;
|
|
122
113
|
};
|
|
123
|
-
SharedObj* operator-> () {
|
|
114
|
+
SharedObj* operator-> () const {
|
|
124
115
|
return node;
|
|
125
116
|
};
|
|
126
117
|
bool isNull () {
|
|
@@ -129,68 +120,81 @@ namespace Sass {
|
|
|
129
120
|
bool isNull () const {
|
|
130
121
|
return node == NULL;
|
|
131
122
|
};
|
|
132
|
-
SharedObj* detach() {
|
|
133
|
-
node->detached = true;
|
|
134
|
-
return node;
|
|
135
|
-
};
|
|
136
123
|
SharedObj* detach() const {
|
|
137
124
|
if (node) {
|
|
138
125
|
node->detached = true;
|
|
139
126
|
}
|
|
140
127
|
return node;
|
|
141
128
|
};
|
|
142
|
-
operator bool() {
|
|
143
|
-
return node != NULL;
|
|
144
|
-
};
|
|
145
129
|
operator bool() const {
|
|
146
130
|
return node != NULL;
|
|
147
131
|
};
|
|
148
132
|
|
|
149
133
|
};
|
|
150
134
|
|
|
151
|
-
template <
|
|
135
|
+
template < class T >
|
|
152
136
|
class SharedImpl : private SharedPtr {
|
|
153
137
|
public:
|
|
154
138
|
SharedImpl()
|
|
155
139
|
: SharedPtr(NULL) {};
|
|
156
140
|
SharedImpl(T* node)
|
|
157
141
|
: SharedPtr(node) {};
|
|
142
|
+
template < class U >
|
|
143
|
+
SharedImpl(SharedImpl<U> obj)
|
|
144
|
+
: SharedPtr(static_cast<T*>(obj.ptr())) {}
|
|
158
145
|
SharedImpl(T&& node)
|
|
159
146
|
: SharedPtr(node) {};
|
|
160
147
|
SharedImpl(const T& node)
|
|
161
148
|
: SharedPtr(node) {};
|
|
149
|
+
// the copy constructor
|
|
150
|
+
SharedImpl(const SharedImpl<T>& impl)
|
|
151
|
+
: SharedPtr(impl.node) {};
|
|
152
|
+
// the move constructor
|
|
153
|
+
SharedImpl(SharedImpl<T>&& impl)
|
|
154
|
+
: SharedPtr(impl.node) {};
|
|
155
|
+
// copy assignment operator
|
|
156
|
+
SharedImpl<T>& operator=(const SharedImpl<T>& rhs) {
|
|
157
|
+
if (node) decRefCount();
|
|
158
|
+
node = rhs.node;
|
|
159
|
+
incRefCount();
|
|
160
|
+
return *this;
|
|
161
|
+
}
|
|
162
|
+
// move assignment operator
|
|
163
|
+
SharedImpl<T>& operator=(SharedImpl<T>&& rhs) {
|
|
164
|
+
// don't move our self
|
|
165
|
+
if (this != &rhs) {
|
|
166
|
+
if (node) decRefCount();
|
|
167
|
+
node = std::move(rhs.node);
|
|
168
|
+
rhs.node = NULL;
|
|
169
|
+
}
|
|
170
|
+
return *this;
|
|
171
|
+
}
|
|
162
172
|
~SharedImpl() {};
|
|
163
173
|
public:
|
|
164
|
-
T*
|
|
165
|
-
return static_cast<T*>(this->obj());
|
|
166
|
-
};
|
|
167
|
-
T* operator& () const {
|
|
174
|
+
operator T*() const {
|
|
168
175
|
return static_cast<T*>(this->obj());
|
|
169
|
-
}
|
|
170
|
-
T&
|
|
176
|
+
}
|
|
177
|
+
operator T&() const {
|
|
171
178
|
return *static_cast<T*>(this->obj());
|
|
172
|
-
}
|
|
179
|
+
}
|
|
173
180
|
T& operator* () const {
|
|
174
181
|
return *static_cast<T*>(this->obj());
|
|
175
182
|
};
|
|
176
|
-
T* operator-> () {
|
|
177
|
-
return static_cast<T*>(this->obj());
|
|
178
|
-
};
|
|
179
183
|
T* operator-> () const {
|
|
180
184
|
return static_cast<T*>(this->obj());
|
|
181
185
|
};
|
|
182
|
-
T* ptr () {
|
|
186
|
+
T* ptr () const {
|
|
183
187
|
return static_cast<T*>(this->obj());
|
|
184
188
|
};
|
|
185
|
-
T* detach() {
|
|
189
|
+
T* detach() const {
|
|
186
190
|
if (this->obj() == NULL) return NULL;
|
|
187
191
|
return static_cast<T*>(SharedPtr::detach());
|
|
188
192
|
}
|
|
189
|
-
bool isNull() {
|
|
193
|
+
bool isNull() const {
|
|
190
194
|
return this->obj() == NULL;
|
|
191
195
|
}
|
|
192
|
-
operator
|
|
193
|
-
return this->
|
|
196
|
+
bool operator<(const T& rhs) const {
|
|
197
|
+
return *this->ptr() < rhs;
|
|
194
198
|
};
|
|
195
199
|
operator bool() const {
|
|
196
200
|
return this->obj() != NULL;
|
data/ext/libsass/src/node.cpp
CHANGED
|
@@ -14,15 +14,15 @@ namespace Sass {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
Node Node::createSelector(
|
|
17
|
+
Node Node::createSelector(const Complex_Selector& pSelector) {
|
|
18
18
|
NodeDequePtr null;
|
|
19
19
|
|
|
20
|
-
Complex_Selector_Ptr pStripped = SASS_MEMORY_COPY(pSelector);
|
|
20
|
+
Complex_Selector_Ptr pStripped = SASS_MEMORY_COPY(&pSelector);
|
|
21
21
|
pStripped->tail(NULL);
|
|
22
22
|
pStripped->combinator(Complex_Selector::ANCESTOR_OF);
|
|
23
23
|
|
|
24
24
|
Node n(SELECTOR, Complex_Selector::ANCESTOR_OF, pStripped, null /*pCollection*/);
|
|
25
|
-
|
|
25
|
+
n.got_line_feed = pSelector.has_line_feed();
|
|
26
26
|
return n;
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -50,12 +50,12 @@ namespace Sass {
|
|
|
50
50
|
{ if (pSelector) got_line_feed = pSelector->has_line_feed(); }
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
Node Node::klone(
|
|
53
|
+
Node Node::klone() const {
|
|
54
54
|
NodeDequePtr pNewCollection = std::make_shared<NodeDeque>();
|
|
55
55
|
if (mpCollection) {
|
|
56
56
|
for (NodeDeque::iterator iter = mpCollection->begin(), iterEnd = mpCollection->end(); iter != iterEnd; iter++) {
|
|
57
57
|
Node& toClone = *iter;
|
|
58
|
-
pNewCollection->push_back(toClone.klone(
|
|
58
|
+
pNewCollection->push_back(toClone.klone());
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -65,13 +65,13 @@ namespace Sass {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
bool Node::contains(const Node& potentialChild
|
|
69
|
-
|
|
68
|
+
bool Node::contains(const Node& potentialChild) const {
|
|
69
|
+
bool found = false;
|
|
70
70
|
|
|
71
71
|
for (NodeDeque::iterator iter = mpCollection->begin(), iterEnd = mpCollection->end(); iter != iterEnd; iter++) {
|
|
72
72
|
Node& toTest = *iter;
|
|
73
73
|
|
|
74
|
-
if (
|
|
74
|
+
if (toTest == potentialChild) {
|
|
75
75
|
found = true;
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
@@ -82,37 +82,32 @@ namespace Sass {
|
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
bool Node::operator==(const Node& rhs) const {
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
bool nodesEqual(const Node& lhs, const Node& rhs, bool simpleSelectorOrderDependent) {
|
|
90
|
-
if (lhs.type() != rhs.type()) {
|
|
85
|
+
if (this->type() != rhs.type()) {
|
|
91
86
|
return false;
|
|
92
87
|
}
|
|
93
88
|
|
|
94
|
-
if (
|
|
89
|
+
if (this->isCombinator()) {
|
|
95
90
|
|
|
96
|
-
|
|
91
|
+
return this->combinator() == rhs.combinator();
|
|
97
92
|
|
|
98
|
-
} else if (
|
|
93
|
+
} else if (this->isNil()) {
|
|
99
94
|
|
|
100
95
|
return true; // no state to check
|
|
101
96
|
|
|
102
|
-
} else if (
|
|
97
|
+
} else if (this->isSelector()){
|
|
103
98
|
|
|
104
|
-
return
|
|
99
|
+
return *this->selector() == *rhs.selector();
|
|
105
100
|
|
|
106
|
-
} else if (
|
|
101
|
+
} else if (this->isCollection()) {
|
|
107
102
|
|
|
108
|
-
if (
|
|
103
|
+
if (this->collection()->size() != rhs.collection()->size()) {
|
|
109
104
|
return false;
|
|
110
105
|
}
|
|
111
106
|
|
|
112
|
-
for (NodeDeque::iterator lhsIter =
|
|
107
|
+
for (NodeDeque::iterator lhsIter = this->collection()->begin(), lhsIterEnd = this->collection()->end(),
|
|
113
108
|
rhsIter = rhs.collection()->begin(); lhsIter != lhsIterEnd; lhsIter++, rhsIter++) {
|
|
114
109
|
|
|
115
|
-
if (
|
|
110
|
+
if (*lhsIter != *rhsIter) {
|
|
116
111
|
return false;
|
|
117
112
|
}
|
|
118
113
|
|
|
@@ -128,10 +123,10 @@ namespace Sass {
|
|
|
128
123
|
|
|
129
124
|
|
|
130
125
|
void Node::plus(Node& rhs) {
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
if (!this->isCollection() || !rhs.isCollection()) {
|
|
127
|
+
throw "Both the current node and rhs must be collections.";
|
|
133
128
|
}
|
|
134
|
-
|
|
129
|
+
this->collection()->insert(this->collection()->end(), rhs.collection()->begin(), rhs.collection()->end());
|
|
135
130
|
}
|
|
136
131
|
|
|
137
132
|
#ifdef DEBUG
|
|
@@ -177,7 +172,7 @@ namespace Sass {
|
|
|
177
172
|
#endif
|
|
178
173
|
|
|
179
174
|
|
|
180
|
-
Node complexSelectorToNode(Complex_Selector_Ptr pToConvert
|
|
175
|
+
Node complexSelectorToNode(Complex_Selector_Ptr pToConvert) {
|
|
181
176
|
if (pToConvert == NULL) {
|
|
182
177
|
return Node::createNil();
|
|
183
178
|
}
|
|
@@ -189,20 +184,22 @@ namespace Sass {
|
|
|
189
184
|
if (pToConvert->head() && pToConvert->head()->has_parent_ref()) {
|
|
190
185
|
Complex_Selector_Obj tail = pToConvert->tail();
|
|
191
186
|
if (tail) tail->has_line_feed(pToConvert->has_line_feed());
|
|
192
|
-
pToConvert =
|
|
187
|
+
pToConvert = tail;
|
|
193
188
|
}
|
|
194
189
|
|
|
195
190
|
while (pToConvert) {
|
|
196
191
|
|
|
197
192
|
bool empty_parent_ref = pToConvert->head() && pToConvert->head()->is_empty_reference();
|
|
198
193
|
|
|
199
|
-
if (pToConvert->head() || empty_parent_ref) {
|
|
200
|
-
}
|
|
201
|
-
|
|
202
194
|
// the first Complex_Selector may contain a dummy head pointer, skip it.
|
|
203
195
|
if (pToConvert->head() && !empty_parent_ref) {
|
|
204
|
-
node.collection()->push_back(Node::createSelector(pToConvert
|
|
196
|
+
node.collection()->push_back(Node::createSelector(*pToConvert));
|
|
205
197
|
if (has_lf) node.collection()->back().got_line_feed = has_lf;
|
|
198
|
+
if (pToConvert->head() || empty_parent_ref) {
|
|
199
|
+
if (pToConvert->tail()) {
|
|
200
|
+
pToConvert->tail()->has_line_feed(pToConvert->has_line_feed());
|
|
201
|
+
}
|
|
202
|
+
}
|
|
206
203
|
has_lf = false;
|
|
207
204
|
}
|
|
208
205
|
|
|
@@ -216,14 +213,14 @@ namespace Sass {
|
|
|
216
213
|
// pToConvert->tail()->has_line_feed(pToConvert->has_line_feed());
|
|
217
214
|
}
|
|
218
215
|
|
|
219
|
-
pToConvert =
|
|
216
|
+
pToConvert = pToConvert->tail();
|
|
220
217
|
}
|
|
221
218
|
|
|
222
219
|
return node;
|
|
223
220
|
}
|
|
224
221
|
|
|
225
222
|
|
|
226
|
-
Complex_Selector_Ptr nodeToComplexSelector(const Node& toConvert
|
|
223
|
+
Complex_Selector_Ptr nodeToComplexSelector(const Node& toConvert) {
|
|
227
224
|
if (toConvert.isNil()) {
|
|
228
225
|
return NULL;
|
|
229
226
|
}
|
|
@@ -237,7 +234,6 @@ namespace Sass {
|
|
|
237
234
|
NodeDeque& childNodes = *toConvert.collection();
|
|
238
235
|
|
|
239
236
|
std::string noPath("");
|
|
240
|
-
Position noPosition(-1, -1, -1);
|
|
241
237
|
Complex_Selector_Obj pFirst = SASS_MEMORY_NEW(Complex_Selector, ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, NULL, NULL);
|
|
242
238
|
|
|
243
239
|
Complex_Selector_Obj pCurrent = pFirst;
|
|
@@ -254,7 +250,7 @@ namespace Sass {
|
|
|
254
250
|
// collections, and can result in an infinite loop during the call to parentSuperselector()
|
|
255
251
|
pCurrent->tail(SASS_MEMORY_COPY(child.selector()));
|
|
256
252
|
// if (child.got_line_feed) pCurrent->has_line_feed(child.got_line_feed);
|
|
257
|
-
pCurrent =
|
|
253
|
+
pCurrent = pCurrent->tail();
|
|
258
254
|
} else if (child.isCombinator()) {
|
|
259
255
|
pCurrent->combinator(child.combinator());
|
|
260
256
|
if (child.got_line_feed) pCurrent->has_line_feed(child.got_line_feed);
|
|
@@ -265,7 +261,7 @@ namespace Sass {
|
|
|
265
261
|
if (nextNode.isCombinator()) {
|
|
266
262
|
pCurrent->tail(SASS_MEMORY_NEW(Complex_Selector, ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, NULL, NULL));
|
|
267
263
|
if (nextNode.got_line_feed) pCurrent->tail()->has_line_feed(nextNode.got_line_feed);
|
|
268
|
-
pCurrent =
|
|
264
|
+
pCurrent = pCurrent->tail();
|
|
269
265
|
}
|
|
270
266
|
}
|
|
271
267
|
} else {
|
|
@@ -285,7 +281,7 @@ namespace Sass {
|
|
|
285
281
|
|
|
286
282
|
// A very naive trim function, which removes duplicates in a node
|
|
287
283
|
// This is only used in Complex_Selector::unify_with for now, may need modifications to fit other needs
|
|
288
|
-
Node Node::naiveTrim(Node& seqses
|
|
284
|
+
Node Node::naiveTrim(Node& seqses) {
|
|
289
285
|
|
|
290
286
|
std::vector<Node*> res;
|
|
291
287
|
std::vector<Complex_Selector_Obj> known;
|