sassc 2.0.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.gitmodules +1 -1
- data/.travis.yml +9 -3
- data/CHANGELOG.md +36 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/README.md +1 -1
- data/Rakefile +43 -7
- data/ext/depend +4 -0
- data/ext/extconf.rb +92 -0
- data/ext/libsass/VERSION +1 -0
- data/ext/libsass/include/sass/base.h +9 -1
- data/ext/libsass/include/sass/context.h +5 -1
- data/ext/libsass/src/MurmurHash2.hpp +91 -0
- data/ext/libsass/src/ast.cpp +755 -2028
- data/ext/libsass/src/ast.hpp +492 -2477
- data/ext/libsass/src/{to_c.cpp → ast2c.cpp} +22 -16
- data/ext/libsass/src/ast2c.hpp +39 -0
- data/ext/libsass/src/ast_def_macros.hpp +70 -10
- data/ext/libsass/src/ast_fwd_decl.cpp +5 -3
- data/ext/libsass/src/ast_fwd_decl.hpp +107 -296
- data/ext/libsass/src/ast_helpers.hpp +292 -0
- data/ext/libsass/src/ast_sel_cmp.cpp +396 -0
- data/ext/libsass/src/ast_sel_super.cpp +539 -0
- data/ext/libsass/src/ast_sel_unify.cpp +275 -0
- data/ext/libsass/src/ast_sel_weave.cpp +616 -0
- data/ext/libsass/src/ast_selectors.cpp +1043 -0
- data/ext/libsass/src/ast_selectors.hpp +522 -0
- data/ext/libsass/src/ast_supports.cpp +114 -0
- data/ext/libsass/src/ast_supports.hpp +121 -0
- data/ext/libsass/src/ast_values.cpp +1154 -0
- data/ext/libsass/src/ast_values.hpp +498 -0
- data/ext/libsass/src/backtrace.cpp +11 -7
- data/ext/libsass/src/backtrace.hpp +5 -5
- data/ext/libsass/src/base64vlq.cpp +5 -2
- data/ext/libsass/src/base64vlq.hpp +1 -1
- data/ext/libsass/src/bind.cpp +35 -34
- data/ext/libsass/src/bind.hpp +3 -1
- data/ext/libsass/src/c2ast.cpp +64 -0
- data/ext/libsass/src/c2ast.hpp +14 -0
- data/ext/libsass/src/cencode.c +4 -6
- data/ext/libsass/src/check_nesting.cpp +83 -88
- data/ext/libsass/src/check_nesting.hpp +39 -34
- data/ext/libsass/src/color_maps.cpp +168 -164
- data/ext/libsass/src/color_maps.hpp +152 -160
- data/ext/libsass/src/constants.cpp +20 -0
- data/ext/libsass/src/constants.hpp +19 -0
- data/ext/libsass/src/context.cpp +104 -121
- data/ext/libsass/src/context.hpp +43 -55
- data/ext/libsass/src/cssize.cpp +103 -188
- data/ext/libsass/src/cssize.hpp +45 -51
- data/ext/libsass/src/dart_helpers.hpp +199 -0
- data/ext/libsass/src/debugger.hpp +524 -361
- data/ext/libsass/src/emitter.cpp +26 -26
- data/ext/libsass/src/emitter.hpp +20 -18
- data/ext/libsass/src/environment.cpp +41 -27
- data/ext/libsass/src/environment.hpp +33 -22
- data/ext/libsass/src/error_handling.cpp +92 -94
- data/ext/libsass/src/error_handling.hpp +73 -50
- data/ext/libsass/src/eval.cpp +380 -515
- data/ext/libsass/src/eval.hpp +64 -57
- data/ext/libsass/src/eval_selectors.cpp +75 -0
- data/ext/libsass/src/expand.cpp +322 -263
- data/ext/libsass/src/expand.hpp +55 -39
- data/ext/libsass/src/extender.cpp +1188 -0
- data/ext/libsass/src/extender.hpp +399 -0
- data/ext/libsass/src/extension.cpp +43 -0
- data/ext/libsass/src/extension.hpp +89 -0
- data/ext/libsass/src/file.cpp +134 -88
- data/ext/libsass/src/file.hpp +28 -37
- data/ext/libsass/src/fn_colors.cpp +596 -0
- data/ext/libsass/src/fn_colors.hpp +85 -0
- data/ext/libsass/src/fn_lists.cpp +285 -0
- data/ext/libsass/src/fn_lists.hpp +34 -0
- data/ext/libsass/src/fn_maps.cpp +94 -0
- data/ext/libsass/src/fn_maps.hpp +30 -0
- data/ext/libsass/src/fn_miscs.cpp +244 -0
- data/ext/libsass/src/fn_miscs.hpp +40 -0
- data/ext/libsass/src/fn_numbers.cpp +227 -0
- data/ext/libsass/src/fn_numbers.hpp +45 -0
- data/ext/libsass/src/fn_selectors.cpp +205 -0
- data/ext/libsass/src/fn_selectors.hpp +35 -0
- data/ext/libsass/src/fn_strings.cpp +268 -0
- data/ext/libsass/src/fn_strings.hpp +34 -0
- data/ext/libsass/src/fn_utils.cpp +158 -0
- data/ext/libsass/src/fn_utils.hpp +62 -0
- data/ext/libsass/src/inspect.cpp +253 -266
- data/ext/libsass/src/inspect.hpp +72 -74
- data/ext/libsass/src/json.cpp +2 -2
- data/ext/libsass/src/lexer.cpp +25 -84
- data/ext/libsass/src/lexer.hpp +5 -16
- data/ext/libsass/src/listize.cpp +27 -43
- data/ext/libsass/src/listize.hpp +14 -11
- data/ext/libsass/src/mapping.hpp +1 -0
- data/ext/libsass/src/memory.hpp +12 -0
- data/ext/libsass/src/memory/allocator.cpp +48 -0
- data/ext/libsass/src/memory/allocator.hpp +138 -0
- data/ext/libsass/src/memory/config.hpp +20 -0
- data/ext/libsass/src/memory/memory_pool.hpp +186 -0
- data/ext/libsass/src/memory/shared_ptr.cpp +33 -0
- data/ext/libsass/src/memory/shared_ptr.hpp +332 -0
- data/ext/libsass/src/operation.hpp +193 -143
- data/ext/libsass/src/operators.cpp +56 -29
- data/ext/libsass/src/operators.hpp +11 -11
- data/ext/libsass/src/ordered_map.hpp +112 -0
- data/ext/libsass/src/output.cpp +59 -75
- data/ext/libsass/src/output.hpp +15 -22
- data/ext/libsass/src/parser.cpp +662 -818
- data/ext/libsass/src/parser.hpp +96 -100
- data/ext/libsass/src/parser_selectors.cpp +189 -0
- data/ext/libsass/src/permutate.hpp +164 -0
- data/ext/libsass/src/plugins.cpp +12 -8
- data/ext/libsass/src/plugins.hpp +8 -8
- data/ext/libsass/src/position.cpp +10 -26
- data/ext/libsass/src/position.hpp +44 -21
- data/ext/libsass/src/prelexer.cpp +14 -8
- data/ext/libsass/src/prelexer.hpp +9 -9
- data/ext/libsass/src/remove_placeholders.cpp +59 -57
- data/ext/libsass/src/remove_placeholders.hpp +20 -18
- data/ext/libsass/src/sass.cpp +25 -18
- data/ext/libsass/src/sass.hpp +22 -14
- data/ext/libsass/src/sass2scss.cpp +49 -18
- data/ext/libsass/src/sass_context.cpp +104 -132
- data/ext/libsass/src/sass_context.hpp +2 -2
- data/ext/libsass/src/sass_functions.cpp +7 -4
- data/ext/libsass/src/sass_functions.hpp +1 -1
- data/ext/libsass/src/sass_values.cpp +26 -21
- data/ext/libsass/src/settings.hpp +19 -0
- data/ext/libsass/src/source.cpp +69 -0
- data/ext/libsass/src/source.hpp +95 -0
- data/ext/libsass/src/source_data.hpp +32 -0
- data/ext/libsass/src/source_map.cpp +27 -20
- data/ext/libsass/src/source_map.hpp +14 -11
- data/ext/libsass/src/stylesheet.cpp +22 -0
- data/ext/libsass/src/stylesheet.hpp +57 -0
- data/ext/libsass/src/to_value.cpp +24 -22
- data/ext/libsass/src/to_value.hpp +18 -22
- data/ext/libsass/src/units.cpp +28 -22
- data/ext/libsass/src/units.hpp +9 -8
- data/ext/libsass/src/utf8/checked.h +12 -10
- data/ext/libsass/src/utf8/core.h +3 -0
- data/ext/libsass/src/utf8_string.cpp +12 -10
- data/ext/libsass/src/utf8_string.hpp +7 -6
- data/ext/libsass/src/util.cpp +97 -107
- data/ext/libsass/src/util.hpp +74 -30
- data/ext/libsass/src/util_string.cpp +125 -0
- data/ext/libsass/src/util_string.hpp +73 -0
- data/ext/libsass/src/values.cpp +33 -24
- data/ext/libsass/src/values.hpp +2 -2
- data/lib/sassc.rb +24 -0
- data/lib/sassc/engine.rb +7 -5
- data/lib/sassc/functions_handler.rb +11 -13
- data/lib/sassc/native.rb +10 -9
- data/lib/sassc/native/native_functions_api.rb +0 -5
- data/lib/sassc/script.rb +4 -6
- data/lib/sassc/version.rb +1 -1
- data/sassc.gemspec +32 -12
- data/test/engine_test.rb +32 -2
- data/test/functions_test.rb +38 -1
- data/test/native_test.rb +4 -4
- metadata +95 -109
- data/ext/Rakefile +0 -3
- data/ext/libsass/.editorconfig +0 -15
- data/ext/libsass/.gitattributes +0 -2
- data/ext/libsass/.github/CONTRIBUTING.md +0 -65
- data/ext/libsass/.github/ISSUE_TEMPLATE.md +0 -54
- data/ext/libsass/.gitignore +0 -85
- data/ext/libsass/.travis.yml +0 -64
- data/ext/libsass/COPYING +0 -25
- data/ext/libsass/GNUmakefile.am +0 -88
- data/ext/libsass/INSTALL +0 -1
- data/ext/libsass/LICENSE +0 -25
- data/ext/libsass/Makefile +0 -351
- data/ext/libsass/Makefile.conf +0 -55
- data/ext/libsass/Readme.md +0 -104
- data/ext/libsass/SECURITY.md +0 -10
- data/ext/libsass/appveyor.yml +0 -91
- data/ext/libsass/configure.ac +0 -138
- data/ext/libsass/contrib/libsass.spec +0 -66
- data/ext/libsass/docs/README.md +0 -20
- data/ext/libsass/docs/api-context-example.md +0 -45
- data/ext/libsass/docs/api-context-internal.md +0 -163
- data/ext/libsass/docs/api-context.md +0 -295
- data/ext/libsass/docs/api-doc.md +0 -215
- data/ext/libsass/docs/api-function-example.md +0 -67
- data/ext/libsass/docs/api-function-internal.md +0 -8
- data/ext/libsass/docs/api-function.md +0 -74
- data/ext/libsass/docs/api-importer-example.md +0 -112
- data/ext/libsass/docs/api-importer-internal.md +0 -20
- data/ext/libsass/docs/api-importer.md +0 -86
- data/ext/libsass/docs/api-value-example.md +0 -55
- data/ext/libsass/docs/api-value-internal.md +0 -76
- data/ext/libsass/docs/api-value.md +0 -154
- data/ext/libsass/docs/build-on-darwin.md +0 -27
- data/ext/libsass/docs/build-on-gentoo.md +0 -55
- data/ext/libsass/docs/build-on-windows.md +0 -139
- data/ext/libsass/docs/build-shared-library.md +0 -35
- data/ext/libsass/docs/build-with-autotools.md +0 -78
- data/ext/libsass/docs/build-with-makefiles.md +0 -68
- data/ext/libsass/docs/build-with-mingw.md +0 -107
- data/ext/libsass/docs/build-with-visual-studio.md +0 -90
- data/ext/libsass/docs/build.md +0 -97
- data/ext/libsass/docs/compatibility-plan.md +0 -48
- data/ext/libsass/docs/contributing.md +0 -17
- data/ext/libsass/docs/custom-functions-internal.md +0 -122
- data/ext/libsass/docs/dev-ast-memory.md +0 -223
- data/ext/libsass/docs/implementations.md +0 -56
- data/ext/libsass/docs/plugins.md +0 -47
- data/ext/libsass/docs/setup-environment.md +0 -68
- data/ext/libsass/docs/source-map-internals.md +0 -51
- data/ext/libsass/docs/trace.md +0 -26
- data/ext/libsass/docs/triage.md +0 -17
- data/ext/libsass/docs/unicode.md +0 -39
- data/ext/libsass/extconf.rb +0 -6
- data/ext/libsass/include/sass/version.h.in +0 -12
- data/ext/libsass/m4/.gitkeep +0 -0
- data/ext/libsass/m4/m4-ax_cxx_compile_stdcxx_11.m4 +0 -167
- data/ext/libsass/res/resource.rc +0 -35
- data/ext/libsass/script/bootstrap +0 -13
- data/ext/libsass/script/branding +0 -10
- data/ext/libsass/script/ci-build-libsass +0 -134
- data/ext/libsass/script/ci-build-plugin +0 -62
- data/ext/libsass/script/ci-install-compiler +0 -6
- data/ext/libsass/script/ci-install-deps +0 -20
- data/ext/libsass/script/ci-report-coverage +0 -42
- data/ext/libsass/script/spec +0 -5
- data/ext/libsass/script/tap-driver +0 -652
- data/ext/libsass/script/tap-runner +0 -1
- data/ext/libsass/script/test-leaks.pl +0 -103
- data/ext/libsass/src/GNUmakefile.am +0 -54
- data/ext/libsass/src/extend.cpp +0 -2130
- data/ext/libsass/src/extend.hpp +0 -86
- data/ext/libsass/src/functions.cpp +0 -2234
- data/ext/libsass/src/functions.hpp +0 -198
- data/ext/libsass/src/memory/SharedPtr.cpp +0 -114
- data/ext/libsass/src/memory/SharedPtr.hpp +0 -206
- data/ext/libsass/src/node.cpp +0 -319
- data/ext/libsass/src/node.hpp +0 -118
- data/ext/libsass/src/paths.hpp +0 -71
- data/ext/libsass/src/sass_util.cpp +0 -149
- data/ext/libsass/src/sass_util.hpp +0 -256
- data/ext/libsass/src/subset_map.cpp +0 -55
- data/ext/libsass/src/subset_map.hpp +0 -76
- data/ext/libsass/src/support/libsass.pc.in +0 -11
- data/ext/libsass/src/to_c.hpp +0 -39
- data/ext/libsass/test/test_node.cpp +0 -94
- data/ext/libsass/test/test_paths.cpp +0 -28
- data/ext/libsass/test/test_selector_difference.cpp +0 -25
- data/ext/libsass/test/test_specificity.cpp +0 -25
- data/ext/libsass/test/test_subset_map.cpp +0 -472
- data/ext/libsass/test/test_superselector.cpp +0 -69
- data/ext/libsass/test/test_unification.cpp +0 -31
- data/ext/libsass/version.sh +0 -10
- data/ext/libsass/win/libsass.sln +0 -39
- data/ext/libsass/win/libsass.sln.DotSettings +0 -9
- data/ext/libsass/win/libsass.targets +0 -118
- data/ext/libsass/win/libsass.vcxproj +0 -188
- data/ext/libsass/win/libsass.vcxproj.filters +0 -357
- data/lib/sassc/native/lib_c.rb +0 -21
- data/lib/tasks/libsass.rb +0 -33
data/ext/libsass/src/node.cpp
DELETED
@@ -1,319 +0,0 @@
|
|
1
|
-
#include "sass.hpp"
|
2
|
-
#include <vector>
|
3
|
-
|
4
|
-
#include "node.hpp"
|
5
|
-
#include "context.hpp"
|
6
|
-
#include "parser.hpp"
|
7
|
-
|
8
|
-
namespace Sass {
|
9
|
-
|
10
|
-
|
11
|
-
Node Node::createCombinator(const Complex_Selector::Combinator& combinator) {
|
12
|
-
NodeDequePtr null;
|
13
|
-
return Node(COMBINATOR, combinator, NULL /*pSelector*/, null /*pCollection*/);
|
14
|
-
}
|
15
|
-
|
16
|
-
|
17
|
-
Node Node::createSelector(const Complex_Selector& pSelector) {
|
18
|
-
NodeDequePtr null;
|
19
|
-
|
20
|
-
Complex_Selector_Ptr pStripped = SASS_MEMORY_COPY(&pSelector);
|
21
|
-
pStripped->tail(NULL);
|
22
|
-
pStripped->combinator(Complex_Selector::ANCESTOR_OF);
|
23
|
-
|
24
|
-
Node n(SELECTOR, Complex_Selector::ANCESTOR_OF, pStripped, null /*pCollection*/);
|
25
|
-
n.got_line_feed = pSelector.has_line_feed();
|
26
|
-
return n;
|
27
|
-
}
|
28
|
-
|
29
|
-
|
30
|
-
Node Node::createCollection() {
|
31
|
-
NodeDequePtr pEmptyCollection = std::make_shared<NodeDeque>();
|
32
|
-
return Node(COLLECTION, Complex_Selector::ANCESTOR_OF, NULL /*pSelector*/, pEmptyCollection);
|
33
|
-
}
|
34
|
-
|
35
|
-
|
36
|
-
Node Node::createCollection(const NodeDeque& values) {
|
37
|
-
NodeDequePtr pShallowCopiedCollection = std::make_shared<NodeDeque>(values);
|
38
|
-
return Node(COLLECTION, Complex_Selector::ANCESTOR_OF, NULL /*pSelector*/, pShallowCopiedCollection);
|
39
|
-
}
|
40
|
-
|
41
|
-
|
42
|
-
Node Node::createNil() {
|
43
|
-
NodeDequePtr null;
|
44
|
-
return Node(NIL, Complex_Selector::ANCESTOR_OF, NULL /*pSelector*/, null /*pCollection*/);
|
45
|
-
}
|
46
|
-
|
47
|
-
|
48
|
-
Node::Node(const TYPE& type, Complex_Selector::Combinator combinator, Complex_Selector_Ptr pSelector, NodeDequePtr& pCollection)
|
49
|
-
: got_line_feed(false), mType(type), mCombinator(combinator), mpSelector(pSelector), mpCollection(pCollection)
|
50
|
-
{ if (pSelector) got_line_feed = pSelector->has_line_feed(); }
|
51
|
-
|
52
|
-
|
53
|
-
Node Node::klone() const {
|
54
|
-
NodeDequePtr pNewCollection = std::make_shared<NodeDeque>();
|
55
|
-
if (mpCollection) {
|
56
|
-
for (NodeDeque::iterator iter = mpCollection->begin(), iterEnd = mpCollection->end(); iter != iterEnd; iter++) {
|
57
|
-
Node& toClone = *iter;
|
58
|
-
pNewCollection->push_back(toClone.klone());
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
|
-
Node n(mType, mCombinator, mpSelector ? SASS_MEMORY_COPY(mpSelector) : NULL, pNewCollection);
|
63
|
-
n.got_line_feed = got_line_feed;
|
64
|
-
return n;
|
65
|
-
}
|
66
|
-
|
67
|
-
|
68
|
-
bool Node::contains(const Node& potentialChild) const {
|
69
|
-
bool found = false;
|
70
|
-
|
71
|
-
for (NodeDeque::iterator iter = mpCollection->begin(), iterEnd = mpCollection->end(); iter != iterEnd; iter++) {
|
72
|
-
Node& toTest = *iter;
|
73
|
-
|
74
|
-
if (toTest == potentialChild) {
|
75
|
-
found = true;
|
76
|
-
break;
|
77
|
-
}
|
78
|
-
}
|
79
|
-
|
80
|
-
return found;
|
81
|
-
}
|
82
|
-
|
83
|
-
|
84
|
-
bool Node::operator==(const Node& rhs) const {
|
85
|
-
if (this->type() != rhs.type()) {
|
86
|
-
return false;
|
87
|
-
}
|
88
|
-
|
89
|
-
if (this->isCombinator()) {
|
90
|
-
|
91
|
-
return this->combinator() == rhs.combinator();
|
92
|
-
|
93
|
-
} else if (this->isNil()) {
|
94
|
-
|
95
|
-
return true; // no state to check
|
96
|
-
|
97
|
-
} else if (this->isSelector()){
|
98
|
-
|
99
|
-
return *this->selector() == *rhs.selector();
|
100
|
-
|
101
|
-
} else if (this->isCollection()) {
|
102
|
-
|
103
|
-
if (this->collection()->size() != rhs.collection()->size()) {
|
104
|
-
return false;
|
105
|
-
}
|
106
|
-
|
107
|
-
for (NodeDeque::iterator lhsIter = this->collection()->begin(), lhsIterEnd = this->collection()->end(),
|
108
|
-
rhsIter = rhs.collection()->begin(); lhsIter != lhsIterEnd; lhsIter++, rhsIter++) {
|
109
|
-
|
110
|
-
if (*lhsIter != *rhsIter) {
|
111
|
-
return false;
|
112
|
-
}
|
113
|
-
|
114
|
-
}
|
115
|
-
|
116
|
-
return true;
|
117
|
-
|
118
|
-
}
|
119
|
-
|
120
|
-
// We shouldn't get here.
|
121
|
-
throw "Comparing unknown node types. A new type was probably added and this method wasn't implemented for it.";
|
122
|
-
}
|
123
|
-
|
124
|
-
|
125
|
-
void Node::plus(Node& rhs) {
|
126
|
-
if (!this->isCollection() || !rhs.isCollection()) {
|
127
|
-
throw "Both the current node and rhs must be collections.";
|
128
|
-
}
|
129
|
-
this->collection()->insert(this->collection()->end(), rhs.collection()->begin(), rhs.collection()->end());
|
130
|
-
}
|
131
|
-
|
132
|
-
#ifdef DEBUG
|
133
|
-
std::ostream& operator<<(std::ostream& os, const Node& node) {
|
134
|
-
|
135
|
-
if (node.isCombinator()) {
|
136
|
-
|
137
|
-
switch (node.combinator()) {
|
138
|
-
case Complex_Selector::ANCESTOR_OF: os << "\" \""; break;
|
139
|
-
case Complex_Selector::PARENT_OF: os << "\">\""; break;
|
140
|
-
case Complex_Selector::PRECEDES: os << "\"~\""; break;
|
141
|
-
case Complex_Selector::ADJACENT_TO: os << "\"+\""; break;
|
142
|
-
case Complex_Selector::REFERENCE: os << "\"/\""; break;
|
143
|
-
}
|
144
|
-
|
145
|
-
} else if (node.isNil()) {
|
146
|
-
|
147
|
-
os << "nil";
|
148
|
-
|
149
|
-
} else if (node.isSelector()){
|
150
|
-
|
151
|
-
os << node.selector()->head()->to_string();
|
152
|
-
|
153
|
-
} else if (node.isCollection()) {
|
154
|
-
|
155
|
-
os << "[";
|
156
|
-
|
157
|
-
for (NodeDeque::iterator iter = node.collection()->begin(), iterBegin = node.collection()->begin(), iterEnd = node.collection()->end(); iter != iterEnd; iter++) {
|
158
|
-
if (iter != iterBegin) {
|
159
|
-
os << ", ";
|
160
|
-
}
|
161
|
-
|
162
|
-
os << (*iter);
|
163
|
-
}
|
164
|
-
|
165
|
-
os << "]";
|
166
|
-
|
167
|
-
}
|
168
|
-
|
169
|
-
return os;
|
170
|
-
|
171
|
-
}
|
172
|
-
#endif
|
173
|
-
|
174
|
-
|
175
|
-
Node complexSelectorToNode(Complex_Selector_Ptr pToConvert) {
|
176
|
-
if (pToConvert == NULL) {
|
177
|
-
return Node::createNil();
|
178
|
-
}
|
179
|
-
Node node = Node::createCollection();
|
180
|
-
node.got_line_feed = pToConvert->has_line_feed();
|
181
|
-
bool has_lf = pToConvert->has_line_feed();
|
182
|
-
|
183
|
-
// unwrap the selector from parent ref
|
184
|
-
if (pToConvert->head() && pToConvert->head()->has_parent_ref()) {
|
185
|
-
Complex_Selector_Obj tail = pToConvert->tail();
|
186
|
-
if (tail) tail->has_line_feed(pToConvert->has_line_feed());
|
187
|
-
pToConvert = tail;
|
188
|
-
}
|
189
|
-
|
190
|
-
while (pToConvert) {
|
191
|
-
|
192
|
-
bool empty_parent_ref = pToConvert->head() && pToConvert->head()->is_empty_reference();
|
193
|
-
|
194
|
-
// the first Complex_Selector may contain a dummy head pointer, skip it.
|
195
|
-
if (pToConvert->head() && !empty_parent_ref) {
|
196
|
-
node.collection()->push_back(Node::createSelector(*pToConvert));
|
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
|
-
}
|
203
|
-
has_lf = false;
|
204
|
-
}
|
205
|
-
|
206
|
-
if (pToConvert->combinator() != Complex_Selector::ANCESTOR_OF) {
|
207
|
-
node.collection()->push_back(Node::createCombinator(pToConvert->combinator()));
|
208
|
-
if (has_lf) node.collection()->back().got_line_feed = has_lf;
|
209
|
-
has_lf = false;
|
210
|
-
}
|
211
|
-
|
212
|
-
if (pToConvert && empty_parent_ref && pToConvert->tail()) {
|
213
|
-
// pToConvert->tail()->has_line_feed(pToConvert->has_line_feed());
|
214
|
-
}
|
215
|
-
|
216
|
-
pToConvert = pToConvert->tail();
|
217
|
-
}
|
218
|
-
|
219
|
-
return node;
|
220
|
-
}
|
221
|
-
|
222
|
-
|
223
|
-
Complex_Selector_Ptr nodeToComplexSelector(const Node& toConvert) {
|
224
|
-
if (toConvert.isNil()) {
|
225
|
-
return NULL;
|
226
|
-
}
|
227
|
-
|
228
|
-
|
229
|
-
if (!toConvert.isCollection()) {
|
230
|
-
throw "The node to convert to a Complex_Selector_Ptr must be a collection type or nil.";
|
231
|
-
}
|
232
|
-
|
233
|
-
|
234
|
-
NodeDeque& childNodes = *toConvert.collection();
|
235
|
-
|
236
|
-
std::string noPath("");
|
237
|
-
Complex_Selector_Obj pFirst = SASS_MEMORY_NEW(Complex_Selector, ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, NULL, NULL);
|
238
|
-
|
239
|
-
Complex_Selector_Obj pCurrent = pFirst;
|
240
|
-
|
241
|
-
if (toConvert.isSelector()) pFirst->has_line_feed(toConvert.got_line_feed);
|
242
|
-
if (toConvert.isCombinator()) pFirst->has_line_feed(toConvert.got_line_feed);
|
243
|
-
|
244
|
-
for (NodeDeque::iterator childIter = childNodes.begin(), childIterEnd = childNodes.end(); childIter != childIterEnd; childIter++) {
|
245
|
-
|
246
|
-
Node& child = *childIter;
|
247
|
-
|
248
|
-
if (child.isSelector()) {
|
249
|
-
// JMA - need to clone the selector, because they can end up getting shared across Node
|
250
|
-
// collections, and can result in an infinite loop during the call to parentSuperselector()
|
251
|
-
pCurrent->tail(SASS_MEMORY_COPY(child.selector()));
|
252
|
-
// if (child.got_line_feed) pCurrent->has_line_feed(child.got_line_feed);
|
253
|
-
pCurrent = pCurrent->tail();
|
254
|
-
} else if (child.isCombinator()) {
|
255
|
-
pCurrent->combinator(child.combinator());
|
256
|
-
if (child.got_line_feed) pCurrent->has_line_feed(child.got_line_feed);
|
257
|
-
|
258
|
-
// if the next node is also a combinator, create another Complex_Selector to hold it so it doesn't replace the current combinator
|
259
|
-
if (childIter+1 != childIterEnd) {
|
260
|
-
Node& nextNode = *(childIter+1);
|
261
|
-
if (nextNode.isCombinator()) {
|
262
|
-
pCurrent->tail(SASS_MEMORY_NEW(Complex_Selector, ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, NULL, NULL));
|
263
|
-
if (nextNode.got_line_feed) pCurrent->tail()->has_line_feed(nextNode.got_line_feed);
|
264
|
-
pCurrent = pCurrent->tail();
|
265
|
-
}
|
266
|
-
}
|
267
|
-
} else {
|
268
|
-
throw "The node to convert's children must be only combinators or selectors.";
|
269
|
-
}
|
270
|
-
}
|
271
|
-
|
272
|
-
// Put the dummy Compound_Selector in the first position, for consistency with the rest of libsass
|
273
|
-
Compound_Selector_Ptr fakeHead = SASS_MEMORY_NEW(Compound_Selector, ParserState("[NODE]"), 1);
|
274
|
-
Parent_Selector_Ptr selectorRef = SASS_MEMORY_NEW(Parent_Selector, ParserState("[NODE]"));
|
275
|
-
fakeHead->elements().push_back(selectorRef);
|
276
|
-
if (toConvert.got_line_feed) pFirst->has_line_feed(toConvert.got_line_feed);
|
277
|
-
// pFirst->has_line_feed(pFirst->has_line_feed() || pFirst->tail()->has_line_feed() || toConvert.got_line_feed);
|
278
|
-
pFirst->head(fakeHead);
|
279
|
-
return SASS_MEMORY_COPY(pFirst);
|
280
|
-
}
|
281
|
-
|
282
|
-
// A very naive trim function, which removes duplicates in a node
|
283
|
-
// This is only used in Complex_Selector::unify_with for now, may need modifications to fit other needs
|
284
|
-
Node Node::naiveTrim(Node& seqses) {
|
285
|
-
|
286
|
-
std::vector<Node*> res;
|
287
|
-
std::vector<Complex_Selector_Obj> known;
|
288
|
-
|
289
|
-
NodeDeque::reverse_iterator seqsesIter = seqses.collection()->rbegin(),
|
290
|
-
seqsesIterEnd = seqses.collection()->rend();
|
291
|
-
|
292
|
-
for (; seqsesIter != seqsesIterEnd; ++seqsesIter)
|
293
|
-
{
|
294
|
-
Node& seqs1 = *seqsesIter;
|
295
|
-
if( seqs1.isSelector() ) {
|
296
|
-
Complex_Selector_Obj sel = seqs1.selector();
|
297
|
-
std::vector<Complex_Selector_Obj>::iterator it;
|
298
|
-
bool found = false;
|
299
|
-
for (it = known.begin(); it != known.end(); ++it) {
|
300
|
-
if (**it == *sel) { found = true; break; }
|
301
|
-
}
|
302
|
-
if( !found ) {
|
303
|
-
known.push_back(seqs1.selector());
|
304
|
-
res.push_back(&seqs1);
|
305
|
-
}
|
306
|
-
} else {
|
307
|
-
res.push_back(&seqs1);
|
308
|
-
}
|
309
|
-
}
|
310
|
-
|
311
|
-
Node result = Node::createCollection();
|
312
|
-
|
313
|
-
for (size_t i = res.size() - 1; i != std::string::npos; --i) {
|
314
|
-
result.collection()->push_back(*res[i]);
|
315
|
-
}
|
316
|
-
|
317
|
-
return result;
|
318
|
-
}
|
319
|
-
}
|
data/ext/libsass/src/node.hpp
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
#ifndef SASS_NODE_H
|
2
|
-
#define SASS_NODE_H
|
3
|
-
|
4
|
-
#include <deque>
|
5
|
-
#include <memory>
|
6
|
-
|
7
|
-
#include "ast.hpp"
|
8
|
-
|
9
|
-
|
10
|
-
namespace Sass {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
class Context;
|
16
|
-
|
17
|
-
/*
|
18
|
-
There are a lot of stumbling blocks when trying to port the ruby extend code to C++. The biggest is the choice of
|
19
|
-
data type. The ruby code will pretty seamlessly switch types between an Array<SimpleSequence or Op> (libsass'
|
20
|
-
equivalent is the Complex_Selector) to a Sequence, which contains more metadata about the sequence than just the
|
21
|
-
selector info. They also have the ability to have arbitrary nestings of arrays like [1, [2]], which is hard to
|
22
|
-
implement using Array equivalents in C++ (like the deque or vector). They also have the ability to include nil
|
23
|
-
in the arrays, like [1, nil, 3], which has potential semantic differences than an empty array [1, [], 3]. To be
|
24
|
-
able to represent all of these as unique cases, we need to create a tree of variant objects. The tree nature allows
|
25
|
-
the inconsistent nesting levels. The variant nature (while making some of the C++ code uglier) allows the code to
|
26
|
-
more closely match the ruby code, which is a huge benefit when attempting to implement an complex algorithm like
|
27
|
-
the Extend operator.
|
28
|
-
|
29
|
-
Note that the current libsass data model also pairs the combinator with the Complex_Selector that follows it, but
|
30
|
-
ruby sass has no such restriction, so we attempt to create a data structure that can handle them split apart.
|
31
|
-
*/
|
32
|
-
|
33
|
-
class Node;
|
34
|
-
typedef std::deque<Node> NodeDeque;
|
35
|
-
typedef std::shared_ptr<NodeDeque> NodeDequePtr;
|
36
|
-
|
37
|
-
class Node {
|
38
|
-
public:
|
39
|
-
enum TYPE {
|
40
|
-
SELECTOR,
|
41
|
-
COMBINATOR,
|
42
|
-
COLLECTION,
|
43
|
-
NIL
|
44
|
-
};
|
45
|
-
|
46
|
-
TYPE type() const { return mType; }
|
47
|
-
bool isCombinator() const { return mType == COMBINATOR; }
|
48
|
-
bool isSelector() const { return mType == SELECTOR; }
|
49
|
-
bool isCollection() const { return mType == COLLECTION; }
|
50
|
-
bool isNil() const { return mType == NIL; }
|
51
|
-
bool got_line_feed;
|
52
|
-
|
53
|
-
Complex_Selector::Combinator combinator() const { return mCombinator; }
|
54
|
-
|
55
|
-
Complex_Selector_Obj selector() { return mpSelector; }
|
56
|
-
Complex_Selector_Obj selector() const { return mpSelector; }
|
57
|
-
|
58
|
-
NodeDequePtr collection() { return mpCollection; }
|
59
|
-
const NodeDequePtr collection() const { return mpCollection; }
|
60
|
-
|
61
|
-
static Node createCombinator(const Complex_Selector::Combinator& combinator);
|
62
|
-
|
63
|
-
// This method will klone the selector, stripping off the tail and combinator
|
64
|
-
static Node createSelector(const Complex_Selector& pSelector);
|
65
|
-
|
66
|
-
static Node createCollection();
|
67
|
-
static Node createCollection(const NodeDeque& values);
|
68
|
-
|
69
|
-
static Node createNil();
|
70
|
-
static Node naiveTrim(Node& seqses);
|
71
|
-
|
72
|
-
Node klone() const;
|
73
|
-
|
74
|
-
bool operator==(const Node& rhs) const;
|
75
|
-
inline bool operator!=(const Node& rhs) const { return !(*this == rhs); }
|
76
|
-
|
77
|
-
|
78
|
-
/*
|
79
|
-
COLLECTION FUNCTIONS
|
80
|
-
|
81
|
-
Most types don't need any helper methods (nil and combinator due to their simplicity and
|
82
|
-
selector due to the fact that we leverage the non-node selector code on the Complex_Selector
|
83
|
-
whereever possible). The following methods are intended to be called on Node objects whose
|
84
|
-
type is COLLECTION only.
|
85
|
-
*/
|
86
|
-
|
87
|
-
// rhs and this must be node collections. Shallow copy the nodes from rhs to the end of this.
|
88
|
-
// This function DOES NOT remove the nodes from rhs.
|
89
|
-
void plus(Node& rhs);
|
90
|
-
|
91
|
-
// potentialChild must be a node collection of selectors/combinators. this must be a collection
|
92
|
-
// of collections of nodes/combinators. This method checks if potentialChild is a child of this
|
93
|
-
// Node.
|
94
|
-
bool contains(const Node& potentialChild) const;
|
95
|
-
|
96
|
-
private:
|
97
|
-
// Private constructor; Use the static methods (like createCombinator and createSelector)
|
98
|
-
// to instantiate this object. This is more expressive, and it allows us to break apart each
|
99
|
-
// case into separate functions.
|
100
|
-
Node(const TYPE& type, Complex_Selector::Combinator combinator, Complex_Selector_Ptr pSelector, NodeDequePtr& pCollection);
|
101
|
-
|
102
|
-
TYPE mType;
|
103
|
-
|
104
|
-
// TODO: can we union these to save on memory?
|
105
|
-
Complex_Selector::Combinator mCombinator;
|
106
|
-
Complex_Selector_Obj mpSelector;
|
107
|
-
NodeDequePtr mpCollection;
|
108
|
-
};
|
109
|
-
|
110
|
-
#ifdef DEBUG
|
111
|
-
std::ostream& operator<<(std::ostream& os, const Node& node);
|
112
|
-
#endif
|
113
|
-
Node complexSelectorToNode(Complex_Selector_Ptr pToConvert);
|
114
|
-
Complex_Selector_Ptr nodeToComplexSelector(const Node& toConvert);
|
115
|
-
|
116
|
-
}
|
117
|
-
|
118
|
-
#endif
|
data/ext/libsass/src/paths.hpp
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
#ifndef SASS_PATHS_H
|
2
|
-
#define SASS_PATHS_H
|
3
|
-
|
4
|
-
#include <string>
|
5
|
-
#include <vector>
|
6
|
-
#include <sstream>
|
7
|
-
|
8
|
-
|
9
|
-
template<typename T>
|
10
|
-
std::string vector_to_string(std::vector<T> v)
|
11
|
-
{
|
12
|
-
std::stringstream buffer;
|
13
|
-
buffer << "[";
|
14
|
-
|
15
|
-
if (!v.empty())
|
16
|
-
{ buffer << v[0]; }
|
17
|
-
else
|
18
|
-
{ buffer << "]"; }
|
19
|
-
|
20
|
-
if (v.size() == 1)
|
21
|
-
{ buffer << "]"; }
|
22
|
-
else
|
23
|
-
{
|
24
|
-
for (size_t i = 1, S = v.size(); i < S; ++i) buffer << ", " << v[i];
|
25
|
-
buffer << "]";
|
26
|
-
}
|
27
|
-
|
28
|
-
return buffer.str();
|
29
|
-
}
|
30
|
-
|
31
|
-
namespace Sass {
|
32
|
-
|
33
|
-
|
34
|
-
template<typename T>
|
35
|
-
std::vector<std::vector<T> > paths(std::vector<std::vector<T> > strata, size_t from_end = 0)
|
36
|
-
{
|
37
|
-
if (strata.empty()) {
|
38
|
-
return std::vector<std::vector<T> >();
|
39
|
-
}
|
40
|
-
|
41
|
-
size_t end = strata.size() - from_end;
|
42
|
-
if (end <= 1) {
|
43
|
-
std::vector<std::vector<T> > starting_points;
|
44
|
-
starting_points.reserve(strata[0].size());
|
45
|
-
for (size_t i = 0, S = strata[0].size(); i < S; ++i) {
|
46
|
-
std::vector<T> starting_point;
|
47
|
-
starting_point.push_back(strata[0][i]);
|
48
|
-
starting_points.push_back(starting_point);
|
49
|
-
}
|
50
|
-
return starting_points;
|
51
|
-
}
|
52
|
-
|
53
|
-
std::vector<std::vector<T> > up_to_here = paths(strata, from_end + 1);
|
54
|
-
std::vector<T> here = strata[end-1];
|
55
|
-
|
56
|
-
std::vector<std::vector<T> > branches;
|
57
|
-
branches.reserve(up_to_here.size() * here.size());
|
58
|
-
for (size_t i = 0, S1 = up_to_here.size(); i < S1; ++i) {
|
59
|
-
for (size_t j = 0, S2 = here.size(); j < S2; ++j) {
|
60
|
-
std::vector<T> branch = up_to_here[i];
|
61
|
-
branch.push_back(here[j]);
|
62
|
-
branches.push_back(branch);
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
return branches;
|
67
|
-
}
|
68
|
-
|
69
|
-
}
|
70
|
-
|
71
|
-
#endif
|