sassc 0.0.9 → 0.0.10
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 +4 -4
- data/Rakefile +1 -1
- data/ext/libsass/.gitignore +13 -6
- data/ext/libsass/Makefile +42 -26
- data/ext/libsass/Makefile.am +43 -30
- data/ext/libsass/Readme.md +4 -2
- data/ext/libsass/appveyor.yml +10 -14
- data/ext/libsass/ast.cpp +54 -44
- data/ext/libsass/ast.hpp +404 -236
- data/ext/libsass/ast_def_macros.hpp +5 -0
- data/ext/libsass/ast_factory.hpp +6 -3
- data/ext/libsass/ast_fwd_decl.hpp +12 -0
- data/ext/libsass/b64/encode.h +2 -2
- data/ext/libsass/backtrace.hpp +13 -17
- data/ext/libsass/base64vlq.hpp +4 -1
- data/ext/libsass/bind.cpp +12 -15
- data/ext/libsass/bind.hpp +6 -6
- data/ext/libsass/color_names.hpp +4 -1
- data/ext/libsass/configure.ac +7 -21
- data/ext/libsass/constants.cpp +6 -4
- data/ext/libsass/constants.hpp +10 -4
- data/ext/libsass/context.cpp +89 -58
- data/ext/libsass/context.hpp +28 -35
- data/ext/libsass/contextualize.cpp +20 -10
- data/ext/libsass/contextualize.hpp +8 -23
- data/ext/libsass/contrib/libsass.spec +66 -0
- data/ext/libsass/cssize.cpp +547 -0
- data/ext/libsass/cssize.hpp +82 -0
- data/ext/libsass/debug.hpp +3 -3
- data/ext/libsass/debugger.hpp +358 -0
- data/ext/libsass/emitter.cpp +255 -0
- data/ext/libsass/emitter.hpp +83 -0
- data/ext/libsass/environment.hpp +7 -3
- data/ext/libsass/error_handling.cpp +11 -14
- data/ext/libsass/error_handling.hpp +9 -7
- data/ext/libsass/eval.cpp +253 -161
- data/ext/libsass/eval.hpp +13 -13
- data/ext/libsass/expand.cpp +135 -64
- data/ext/libsass/expand.hpp +11 -13
- data/ext/libsass/extend.cpp +66 -20
- data/ext/libsass/extend.hpp +6 -11
- data/ext/libsass/file.cpp +31 -26
- data/ext/libsass/file.hpp +6 -1
- data/ext/libsass/functions.cpp +270 -287
- data/ext/libsass/functions.hpp +8 -11
- data/ext/libsass/inspect.cpp +385 -255
- data/ext/libsass/inspect.hpp +15 -26
- data/ext/libsass/kwd_arg_macros.hpp +5 -0
- data/ext/libsass/mapping.hpp +4 -3
- data/ext/libsass/memory_manager.hpp +5 -2
- data/ext/libsass/node.cpp +50 -50
- data/ext/libsass/node.hpp +26 -27
- data/ext/libsass/operation.hpp +15 -4
- data/ext/libsass/output.cpp +401 -0
- data/ext/libsass/output.hpp +56 -0
- data/ext/libsass/parser.cpp +573 -399
- data/ext/libsass/parser.hpp +122 -88
- data/ext/libsass/paths.hpp +7 -2
- data/ext/libsass/plugins.cpp +155 -0
- data/ext/libsass/plugins.hpp +56 -0
- data/ext/libsass/position.cpp +128 -0
- data/ext/libsass/position.hpp +108 -11
- data/ext/libsass/prelexer.cpp +184 -110
- data/ext/libsass/prelexer.hpp +131 -24
- data/ext/libsass/remove_placeholders.cpp +1 -1
- data/ext/libsass/remove_placeholders.hpp +6 -6
- data/ext/libsass/sass.cpp +3 -3
- data/ext/libsass/sass.h +12 -4
- data/ext/libsass/sass2scss.cpp +3 -2
- data/ext/libsass/sass2scss.h +5 -0
- data/ext/libsass/sass_context.cpp +136 -37
- data/ext/libsass/sass_context.h +19 -10
- data/ext/libsass/sass_functions.cpp +29 -2
- data/ext/libsass/sass_functions.h +8 -2
- data/ext/libsass/sass_interface.cpp +32 -23
- data/ext/libsass/sass_interface.h +9 -4
- data/ext/libsass/sass_util.cpp +19 -23
- data/ext/libsass/sass_util.hpp +28 -27
- data/ext/libsass/sass_values.cpp +6 -4
- data/ext/libsass/sass_values.h +3 -3
- data/ext/libsass/script/ci-build-libsass +13 -1
- data/ext/libsass/script/ci-report-coverage +2 -1
- data/ext/libsass/source_map.cpp +79 -28
- data/ext/libsass/source_map.hpp +35 -16
- data/ext/libsass/subset_map.hpp +6 -4
- data/ext/libsass/to_c.hpp +4 -4
- data/ext/libsass/to_string.cpp +13 -8
- data/ext/libsass/to_string.hpp +6 -4
- data/ext/libsass/units.cpp +2 -1
- data/ext/libsass/units.hpp +6 -1
- data/ext/libsass/utf8_string.cpp +0 -5
- data/ext/libsass/utf8_string.hpp +3 -2
- data/ext/libsass/util.cpp +461 -49
- data/ext/libsass/util.hpp +34 -13
- data/ext/libsass/version.sh +10 -0
- data/ext/libsass/win/libsass.filters +20 -11
- data/ext/libsass/win/libsass.vcxproj +11 -8
- data/lib/sassc/importer.rb +1 -8
- data/lib/sassc/native.rb +7 -0
- data/lib/sassc/native/native_context_api.rb +5 -5
- data/lib/sassc/version.rb +1 -1
- data/test/native_test.rb +1 -1
- metadata +14 -10
- data/ext/libsass/copy_c_str.cpp +0 -13
- data/ext/libsass/copy_c_str.hpp +0 -5
- data/ext/libsass/output_compressed.cpp +0 -401
- data/ext/libsass/output_compressed.hpp +0 -95
- data/ext/libsass/output_nested.cpp +0 -364
- data/ext/libsass/output_nested.hpp +0 -108
- data/ext/libsass/test-driver +0 -127
- data/ext/libsass/token.hpp +0 -32
data/ext/libsass/inspect.hpp
CHANGED
|
@@ -1,48 +1,38 @@
|
|
|
1
|
-
#ifndef
|
|
2
|
-
#define
|
|
1
|
+
#ifndef SASS_INSPECT_H
|
|
2
|
+
#define SASS_INSPECT_H
|
|
3
3
|
|
|
4
4
|
#include <string>
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
#include "position.hpp"
|
|
7
7
|
#include "operation.hpp"
|
|
8
|
-
#
|
|
9
|
-
|
|
10
|
-
// #ifndef SASS_TO_STRING
|
|
11
|
-
// #include "to_string.hpp"
|
|
12
|
-
// #endif
|
|
8
|
+
#include "emitter.hpp"
|
|
13
9
|
|
|
14
10
|
namespace Sass {
|
|
11
|
+
class Context;
|
|
15
12
|
using namespace std;
|
|
16
|
-
struct Context;
|
|
17
13
|
|
|
18
|
-
class Inspect : public Operation_CRTP<void, Inspect
|
|
14
|
+
class Inspect : public Operation_CRTP<void, Inspect>, public Emitter {
|
|
15
|
+
protected:
|
|
19
16
|
// import all the class-specific methods and override as desired
|
|
20
17
|
using Operation_CRTP<void, Inspect>::operator();
|
|
21
18
|
|
|
22
|
-
// To_String* to_string;
|
|
23
|
-
string buffer;
|
|
24
|
-
size_t indentation;
|
|
25
|
-
Context* ctx;
|
|
26
|
-
void indent();
|
|
27
|
-
|
|
28
19
|
void fallback_impl(AST_Node* n);
|
|
29
20
|
|
|
30
|
-
void append_to_buffer(const string& text);
|
|
31
|
-
|
|
32
21
|
public:
|
|
33
22
|
|
|
34
|
-
Inspect(
|
|
23
|
+
Inspect(Emitter emi);
|
|
35
24
|
virtual ~Inspect();
|
|
36
25
|
|
|
37
|
-
string get_buffer() { return buffer; }
|
|
38
|
-
|
|
39
26
|
// statements
|
|
40
27
|
virtual void operator()(Block*);
|
|
41
28
|
virtual void operator()(Ruleset*);
|
|
42
29
|
virtual void operator()(Propset*);
|
|
30
|
+
virtual void operator()(Bubble*);
|
|
43
31
|
virtual void operator()(Feature_Block*);
|
|
44
32
|
virtual void operator()(Media_Block*);
|
|
33
|
+
virtual void operator()(At_Root_Block*);
|
|
45
34
|
virtual void operator()(At_Rule*);
|
|
35
|
+
virtual void operator()(Keyframe_Rule*);
|
|
46
36
|
virtual void operator()(Declaration*);
|
|
47
37
|
virtual void operator()(Assignment*);
|
|
48
38
|
virtual void operator()(Import*);
|
|
@@ -74,10 +64,12 @@ namespace Sass {
|
|
|
74
64
|
virtual void operator()(Boolean*);
|
|
75
65
|
virtual void operator()(String_Schema*);
|
|
76
66
|
virtual void operator()(String_Constant*);
|
|
67
|
+
virtual void operator()(String_Quoted*);
|
|
77
68
|
virtual void operator()(Feature_Query*);
|
|
78
69
|
virtual void operator()(Feature_Query_Condition*);
|
|
79
70
|
virtual void operator()(Media_Query*);
|
|
80
71
|
virtual void operator()(Media_Query_Expression*);
|
|
72
|
+
virtual void operator()(At_Root_Expression*);
|
|
81
73
|
virtual void operator()(Null*);
|
|
82
74
|
// parameters and arguments
|
|
83
75
|
virtual void operator()(Parameter*);
|
|
@@ -97,12 +89,9 @@ namespace Sass {
|
|
|
97
89
|
virtual void operator()(Complex_Selector*);
|
|
98
90
|
virtual void operator()(Selector_List*);
|
|
99
91
|
|
|
100
|
-
template <typename U>
|
|
101
|
-
void fallback(U x) { fallback_impl(reinterpret_cast<AST_Node*>(x)); }
|
|
92
|
+
// template <typename U>
|
|
93
|
+
// void fallback(U x) { fallback_impl(reinterpret_cast<AST_Node*>(x)); }
|
|
102
94
|
};
|
|
103
95
|
|
|
104
|
-
string unquote(const string&);
|
|
105
|
-
string quote(const string&, char);
|
|
106
|
-
|
|
107
96
|
}
|
|
108
97
|
#endif
|
data/ext/libsass/mapping.hpp
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
#ifndef SASS_MEMORY_MANAGER_H
|
|
2
|
+
#define SASS_MEMORY_MANAGER_H
|
|
2
3
|
|
|
3
4
|
#include <vector>
|
|
4
5
|
#include <iostream>
|
|
5
|
-
using namespace std;
|
|
6
6
|
|
|
7
7
|
namespace Sass {
|
|
8
|
+
using namespace std;
|
|
8
9
|
/////////////////////////////////////////////////////////////////////////////
|
|
9
10
|
// A class for tracking allocations of AST_Node objects. The intended usage
|
|
10
11
|
// is something like: Some_Node* n = new (mem_mgr) Some_Node(...);
|
|
@@ -52,3 +53,5 @@ inline void operator delete(void *np, Sass::Memory_Manager<T>& mem_mgr)
|
|
|
52
53
|
mem_mgr.remove(reinterpret_cast<T*>(np));
|
|
53
54
|
operator delete(np);
|
|
54
55
|
}
|
|
56
|
+
|
|
57
|
+
#endif
|
data/ext/libsass/node.cpp
CHANGED
|
@@ -11,43 +11,41 @@ namespace Sass {
|
|
|
11
11
|
return Node(COMBINATOR, combinator, NULL /*pSelector*/, null /*pCollection*/);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
Node Node::createSelector(Complex_Selector* pSelector, Context& ctx) {
|
|
16
16
|
NodeDequePtr null;
|
|
17
17
|
|
|
18
18
|
Complex_Selector* pStripped = pSelector->clone(ctx);
|
|
19
19
|
pStripped->tail(NULL);
|
|
20
20
|
pStripped->combinator(Complex_Selector::ANCESTOR_OF);
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
return Node(SELECTOR, Complex_Selector::ANCESTOR_OF, pStripped, null /*pCollection*/);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
Node Node::createCollection() {
|
|
27
27
|
NodeDequePtr pEmptyCollection = make_shared<NodeDeque>();
|
|
28
28
|
return Node(COLLECTION, Complex_Selector::ANCESTOR_OF, NULL /*pSelector*/, pEmptyCollection);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
Node Node::createCollection(const NodeDeque& values) {
|
|
33
33
|
NodeDequePtr pShallowCopiedCollection = make_shared<NodeDeque>(values);
|
|
34
34
|
return Node(COLLECTION, Complex_Selector::ANCESTOR_OF, NULL /*pSelector*/, pShallowCopiedCollection);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
Node Node::createNil() {
|
|
39
39
|
NodeDequePtr null;
|
|
40
40
|
return Node(NIL, Complex_Selector::ANCESTOR_OF, NULL /*pSelector*/, null /*pCollection*/);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
Node::Node(const TYPE& type, Complex_Selector::Combinator combinator, Complex_Selector* pSelector, NodeDequePtr& pCollection) :
|
|
45
|
-
mType(type),
|
|
46
|
-
mCombinator(combinator),
|
|
47
|
-
mpSelector(pSelector),
|
|
48
|
-
mpCollection(pCollection) {}
|
|
49
43
|
|
|
50
|
-
|
|
44
|
+
Node::Node(const TYPE& type, Complex_Selector::Combinator combinator, Complex_Selector* pSelector, NodeDequePtr& pCollection)
|
|
45
|
+
: got_line_feed(false), mType(type), mCombinator(combinator), mpSelector(pSelector), mpCollection(pCollection)
|
|
46
|
+
{ /* if (pSelector) got_line_feed = pSelector->has_line_feed(); */ }
|
|
47
|
+
|
|
48
|
+
|
|
51
49
|
Node Node::clone(Context& ctx) const {
|
|
52
50
|
NodeDequePtr pNewCollection = make_shared<NodeDeque>();
|
|
53
51
|
if (mpCollection) {
|
|
@@ -56,14 +54,14 @@ namespace Sass {
|
|
|
56
54
|
pNewCollection->push_back(toClone.clone(ctx));
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
|
-
|
|
57
|
+
|
|
60
58
|
return Node(mType, mCombinator, mpSelector ? mpSelector->clone(ctx) : NULL, pNewCollection);
|
|
61
59
|
}
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
|
|
61
|
+
|
|
64
62
|
bool Node::contains(const Node& potentialChild, bool simpleSelectorOrderDependent) const {
|
|
65
63
|
bool found = false;
|
|
66
|
-
|
|
64
|
+
|
|
67
65
|
for (NodeDeque::iterator iter = mpCollection->begin(), iterEnd = mpCollection->end(); iter != iterEnd; iter++) {
|
|
68
66
|
Node& toTest = *iter;
|
|
69
67
|
|
|
@@ -75,18 +73,18 @@ namespace Sass {
|
|
|
75
73
|
|
|
76
74
|
return found;
|
|
77
75
|
}
|
|
78
|
-
|
|
76
|
+
|
|
79
77
|
|
|
80
78
|
bool Node::operator==(const Node& rhs) const {
|
|
81
79
|
return nodesEqual(*this, rhs, true /*simpleSelectorOrderDependent*/);
|
|
82
80
|
}
|
|
83
|
-
|
|
81
|
+
|
|
84
82
|
|
|
85
83
|
bool nodesEqual(const Node& lhs, const Node& rhs, bool simpleSelectorOrderDependent) {
|
|
86
84
|
if (lhs.type() != rhs.type()) {
|
|
87
85
|
return false;
|
|
88
86
|
}
|
|
89
|
-
|
|
87
|
+
|
|
90
88
|
if (lhs.isCombinator()) {
|
|
91
89
|
|
|
92
90
|
return lhs.combinator() == rhs.combinator();
|
|
@@ -117,20 +115,20 @@ namespace Sass {
|
|
|
117
115
|
return true;
|
|
118
116
|
|
|
119
117
|
}
|
|
120
|
-
|
|
118
|
+
|
|
121
119
|
// We shouldn't get here.
|
|
122
120
|
throw "Comparing unknown node types. A new type was probably added and this method wasn't implemented for it.";
|
|
123
121
|
}
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
|
|
123
|
+
|
|
126
124
|
void Node::plus(Node& rhs) {
|
|
127
125
|
if (!this->isCollection() || !rhs.isCollection()) {
|
|
128
126
|
throw "Both the current node and rhs must be collections.";
|
|
129
127
|
}
|
|
130
128
|
this->collection()->insert(this->collection()->end(), rhs.collection()->begin(), rhs.collection()->end());
|
|
131
129
|
}
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
|
|
131
|
+
#ifdef DEBUG
|
|
134
132
|
ostream& operator<<(ostream& os, const Node& node) {
|
|
135
133
|
|
|
136
134
|
if (node.isCombinator()) {
|
|
@@ -141,20 +139,20 @@ namespace Sass {
|
|
|
141
139
|
case Complex_Selector::PRECEDES: os << "\"~\""; break;
|
|
142
140
|
case Complex_Selector::ADJACENT_TO: os << "\"+\""; break;
|
|
143
141
|
}
|
|
144
|
-
|
|
142
|
+
|
|
145
143
|
} else if (node.isNil()) {
|
|
146
|
-
|
|
144
|
+
|
|
147
145
|
os << "nil";
|
|
148
|
-
|
|
146
|
+
|
|
149
147
|
} else if (node.isSelector()){
|
|
150
|
-
|
|
148
|
+
|
|
151
149
|
To_String to_string;
|
|
152
150
|
os << node.selector()->head()->perform(&to_string);
|
|
153
|
-
|
|
151
|
+
|
|
154
152
|
} else if (node.isCollection()) {
|
|
155
|
-
|
|
153
|
+
|
|
156
154
|
os << "[";
|
|
157
|
-
|
|
155
|
+
|
|
158
156
|
for (NodeDeque::iterator iter = node.collection()->begin(), iterBegin = node.collection()->begin(), iterEnd = node.collection()->end(); iter != iterEnd; iter++) {
|
|
159
157
|
if (iter != iterBegin) {
|
|
160
158
|
os << ", ";
|
|
@@ -162,23 +160,24 @@ namespace Sass {
|
|
|
162
160
|
|
|
163
161
|
os << (*iter);
|
|
164
162
|
}
|
|
165
|
-
|
|
163
|
+
|
|
166
164
|
os << "]";
|
|
167
|
-
|
|
165
|
+
|
|
168
166
|
}
|
|
169
|
-
|
|
167
|
+
|
|
170
168
|
return os;
|
|
171
169
|
|
|
172
170
|
}
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
#endif
|
|
172
|
+
|
|
173
|
+
|
|
175
174
|
Node complexSelectorToNode(Complex_Selector* pToConvert, Context& ctx) {
|
|
176
175
|
if (pToConvert == NULL) {
|
|
177
176
|
return Node::createNil();
|
|
178
177
|
}
|
|
179
178
|
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
Node node = Node::createCollection();
|
|
180
|
+
|
|
182
181
|
while (pToConvert) {
|
|
183
182
|
|
|
184
183
|
// the first Complex_Selector may contain a dummy head pointer, skip it.
|
|
@@ -192,7 +191,7 @@ namespace Sass {
|
|
|
192
191
|
|
|
193
192
|
pToConvert = pToConvert->tail();
|
|
194
193
|
}
|
|
195
|
-
|
|
194
|
+
|
|
196
195
|
return node;
|
|
197
196
|
}
|
|
198
197
|
|
|
@@ -206,30 +205,30 @@ namespace Sass {
|
|
|
206
205
|
if (!toConvert.isCollection()) {
|
|
207
206
|
throw "The node to convert to a Complex_Selector* must be a collection type or nil.";
|
|
208
207
|
}
|
|
209
|
-
|
|
208
|
+
|
|
210
209
|
|
|
211
210
|
NodeDeque& childNodes = *toConvert.collection();
|
|
212
|
-
|
|
211
|
+
|
|
213
212
|
string noPath("");
|
|
214
|
-
Position noPosition;
|
|
215
|
-
Complex_Selector* pFirst = new (ctx.mem) Complex_Selector(
|
|
213
|
+
Position noPosition(-1, -1, -1);
|
|
214
|
+
Complex_Selector* pFirst = new (ctx.mem) Complex_Selector(ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, NULL, NULL);
|
|
216
215
|
Complex_Selector* pCurrent = pFirst;
|
|
217
|
-
|
|
216
|
+
|
|
218
217
|
for (NodeDeque::iterator childIter = childNodes.begin(), childIterEnd = childNodes.end(); childIter != childIterEnd; childIter++) {
|
|
219
218
|
|
|
220
219
|
Node& child = *childIter;
|
|
221
|
-
|
|
220
|
+
|
|
222
221
|
if (child.isSelector()) {
|
|
223
222
|
pCurrent->tail(child.selector()->clone(ctx)); // JMA - need to clone the selector, because they can end up getting shared across Node collections, and can result in an infinite loop during the call to parentSuperselector()
|
|
224
223
|
pCurrent = pCurrent->tail();
|
|
225
224
|
} else if (child.isCombinator()) {
|
|
226
225
|
pCurrent->combinator(child.combinator());
|
|
227
|
-
|
|
226
|
+
|
|
228
227
|
// if the next node is also a combinator, create another Complex_Selector to hold it so it doesn't replace the current combinator
|
|
229
228
|
if (childIter+1 != childIterEnd) {
|
|
230
229
|
Node& nextNode = *(childIter+1);
|
|
231
230
|
if (nextNode.isCombinator()) {
|
|
232
|
-
pCurrent->tail(new (ctx.mem) Complex_Selector(
|
|
231
|
+
pCurrent->tail(new (ctx.mem) Complex_Selector(ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, NULL, NULL));
|
|
233
232
|
pCurrent = pCurrent->tail();
|
|
234
233
|
}
|
|
235
234
|
}
|
|
@@ -239,11 +238,12 @@ namespace Sass {
|
|
|
239
238
|
}
|
|
240
239
|
|
|
241
240
|
// Put the dummy Compound_Selector in the first position, for consistency with the rest of libsass
|
|
242
|
-
Compound_Selector* fakeHead = new (ctx.mem) Compound_Selector(
|
|
243
|
-
Selector_Reference* selectorRef = new (ctx.mem) Selector_Reference(
|
|
241
|
+
Compound_Selector* fakeHead = new (ctx.mem) Compound_Selector(ParserState("[NODE]"), 1);
|
|
242
|
+
Selector_Reference* selectorRef = new (ctx.mem) Selector_Reference(ParserState("[NODE]"), NULL);
|
|
244
243
|
fakeHead->elements().push_back(selectorRef);
|
|
245
244
|
pFirst->head(fakeHead);
|
|
246
|
-
|
|
245
|
+
pFirst->has_line_feed(pFirst->has_line_feed() || pFirst->tail()->has_line_feed() || toConvert.got_line_feed);
|
|
246
|
+
|
|
247
247
|
return pFirst;
|
|
248
248
|
}
|
|
249
249
|
|
data/ext/libsass/node.hpp
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
#ifndef SASS_NODE_H
|
|
2
|
+
#define SASS_NODE_H
|
|
3
3
|
|
|
4
4
|
#include <deque>
|
|
5
5
|
#include <iostream>
|
|
6
6
|
#include <memory>
|
|
7
7
|
|
|
8
|
-
#ifndef SASS_AST
|
|
9
8
|
#include "ast.hpp"
|
|
10
|
-
#endif
|
|
11
9
|
|
|
12
10
|
|
|
13
11
|
namespace Sass {
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
|
|
16
14
|
using namespace std;
|
|
17
15
|
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
class Context;
|
|
20
18
|
|
|
21
19
|
/*
|
|
22
20
|
There are a lot of stumbling blocks when trying to port the ruby extend code to C++. The biggest is the choice of
|
|
@@ -29,11 +27,11 @@ namespace Sass {
|
|
|
29
27
|
the inconsistent nesting levels. The variant nature (while making some of the C++ code uglier) allows the code to
|
|
30
28
|
more closely match the ruby code, which is a huge benefit when attempting to implement an complex algorithm like
|
|
31
29
|
the Extend operator.
|
|
32
|
-
|
|
30
|
+
|
|
33
31
|
Note that the current libsass data model also pairs the combinator with the Complex_Selector that follows it, but
|
|
34
32
|
ruby sass has no such restriction, so we attempt to create a data structure that can handle them split apart.
|
|
35
33
|
*/
|
|
36
|
-
|
|
34
|
+
|
|
37
35
|
class Node;
|
|
38
36
|
typedef deque<Node> NodeDeque;
|
|
39
37
|
typedef shared_ptr<NodeDeque> NodeDequePtr;
|
|
@@ -52,49 +50,50 @@ namespace Sass {
|
|
|
52
50
|
bool isSelector() const { return mType == SELECTOR; }
|
|
53
51
|
bool isCollection() const { return mType == COLLECTION; }
|
|
54
52
|
bool isNil() const { return mType == NIL; }
|
|
55
|
-
|
|
53
|
+
bool got_line_feed;
|
|
54
|
+
|
|
56
55
|
Complex_Selector::Combinator combinator() const { return mCombinator; }
|
|
57
|
-
|
|
56
|
+
|
|
58
57
|
Complex_Selector* selector() { return mpSelector; }
|
|
59
58
|
const Complex_Selector* selector() const { return mpSelector; }
|
|
60
|
-
|
|
59
|
+
|
|
61
60
|
NodeDequePtr collection() { return mpCollection; }
|
|
62
61
|
const NodeDequePtr collection() const { return mpCollection; }
|
|
63
|
-
|
|
62
|
+
|
|
64
63
|
static Node createCombinator(const Complex_Selector::Combinator& combinator);
|
|
65
64
|
|
|
66
65
|
// This method will clone the selector, stripping off the tail and combinator
|
|
67
66
|
static Node createSelector(Complex_Selector* pSelector, Context& ctx);
|
|
68
|
-
|
|
67
|
+
|
|
69
68
|
static Node createCollection();
|
|
70
69
|
static Node createCollection(const NodeDeque& values);
|
|
71
70
|
|
|
72
71
|
static Node createNil();
|
|
73
|
-
|
|
72
|
+
|
|
74
73
|
Node clone(Context& ctx) const;
|
|
75
|
-
|
|
74
|
+
|
|
76
75
|
bool operator==(const Node& rhs) const;
|
|
77
76
|
inline bool operator!=(const Node& rhs) const { return !(*this == rhs); }
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
|
|
78
|
+
|
|
80
79
|
/*
|
|
81
80
|
COLLECTION FUNCTIONS
|
|
82
|
-
|
|
81
|
+
|
|
83
82
|
Most types don't need any helper methods (nil and combinator due to their simplicity and
|
|
84
83
|
selector due to the fact that we leverage the non-node selector code on the Complex_Selector
|
|
85
84
|
whereever possible). The following methods are intended to be called on Node objects whose
|
|
86
85
|
type is COLLECTION only.
|
|
87
86
|
*/
|
|
88
|
-
|
|
87
|
+
|
|
89
88
|
// rhs and this must be node collections. Shallow copy the nodes from rhs to the end of this.
|
|
90
89
|
// This function DOES NOT remove the nodes from rhs.
|
|
91
90
|
void plus(Node& rhs);
|
|
92
|
-
|
|
91
|
+
|
|
93
92
|
// potentialChild must be a node collection of selectors/combinators. this must be a collection
|
|
94
93
|
// of collections of nodes/combinators. This method checks if potentialChild is a child of this
|
|
95
94
|
// Node.
|
|
96
95
|
bool contains(const Node& potentialChild, bool simpleSelectorOrderDependent) const;
|
|
97
|
-
|
|
96
|
+
|
|
98
97
|
private:
|
|
99
98
|
// Private constructor; Use the static methods (like createCombinator and createSelector)
|
|
100
99
|
// to instantiate this object. This is more expressive, and it allows us to break apart each
|
|
@@ -102,21 +101,21 @@ namespace Sass {
|
|
|
102
101
|
Node(const TYPE& type, Complex_Selector::Combinator combinator, Complex_Selector* pSelector, NodeDequePtr& pCollection);
|
|
103
102
|
|
|
104
103
|
TYPE mType;
|
|
105
|
-
|
|
104
|
+
|
|
106
105
|
// TODO: can we union these to save on memory?
|
|
107
106
|
Complex_Selector::Combinator mCombinator;
|
|
108
107
|
Complex_Selector* mpSelector; // this is an AST_Node, so it will be handled by the Memory_Manager
|
|
109
108
|
NodeDequePtr mpCollection;
|
|
110
109
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
ostream& operator<<(ostream& os, const Node& node);
|
|
114
|
-
|
|
115
110
|
|
|
111
|
+
#ifdef DEBUG
|
|
112
|
+
ostream& operator<<(ostream& os, const Node& node);
|
|
113
|
+
#endif
|
|
116
114
|
Node complexSelectorToNode(Complex_Selector* pToConvert, Context& ctx);
|
|
117
115
|
Complex_Selector* nodeToComplexSelector(const Node& toConvert, Context& ctx);
|
|
118
116
|
|
|
119
|
-
|
|
120
117
|
bool nodesEqual(const Node& one, const Node& two, bool simpleSelectorOrderDependent);
|
|
121
118
|
|
|
122
119
|
}
|
|
120
|
+
|
|
121
|
+
#endif
|