sassc 2.2.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/CHANGELOG.md +13 -0
  4. data/Rakefile +1 -3
  5. data/ext/extconf.rb +13 -5
  6. data/ext/libsass/VERSION +1 -1
  7. data/ext/libsass/include/sass/base.h +2 -1
  8. data/ext/libsass/include/sass/context.h +1 -0
  9. data/ext/libsass/src/ast.cpp +49 -59
  10. data/ext/libsass/src/ast.hpp +263 -102
  11. data/ext/libsass/src/ast_def_macros.hpp +8 -0
  12. data/ext/libsass/src/ast_fwd_decl.cpp +2 -1
  13. data/ext/libsass/src/ast_fwd_decl.hpp +40 -116
  14. data/ext/libsass/src/ast_helpers.hpp +292 -0
  15. data/ext/libsass/src/ast_sel_cmp.cpp +209 -722
  16. data/ext/libsass/src/ast_sel_super.cpp +539 -0
  17. data/ext/libsass/src/ast_sel_unify.cpp +207 -212
  18. data/ext/libsass/src/ast_sel_weave.cpp +616 -0
  19. data/ext/libsass/src/ast_selectors.cpp +559 -1001
  20. data/ext/libsass/src/ast_selectors.hpp +311 -367
  21. data/ext/libsass/src/ast_supports.cpp +1 -17
  22. data/ext/libsass/src/ast_values.cpp +216 -29
  23. data/ext/libsass/src/ast_values.hpp +42 -33
  24. data/ext/libsass/src/bind.cpp +1 -1
  25. data/ext/libsass/src/cencode.c +4 -6
  26. data/ext/libsass/src/check_nesting.cpp +5 -6
  27. data/ext/libsass/src/check_nesting.hpp +4 -0
  28. data/ext/libsass/src/color_maps.cpp +11 -10
  29. data/ext/libsass/src/color_maps.hpp +0 -8
  30. data/ext/libsass/src/constants.cpp +5 -0
  31. data/ext/libsass/src/constants.hpp +6 -0
  32. data/ext/libsass/src/context.cpp +30 -60
  33. data/ext/libsass/src/context.hpp +8 -20
  34. data/ext/libsass/src/cssize.cpp +36 -120
  35. data/ext/libsass/src/cssize.hpp +4 -10
  36. data/ext/libsass/src/dart_helpers.hpp +199 -0
  37. data/ext/libsass/src/debugger.hpp +364 -207
  38. data/ext/libsass/src/emitter.cpp +3 -4
  39. data/ext/libsass/src/emitter.hpp +0 -2
  40. data/ext/libsass/src/environment.hpp +5 -0
  41. data/ext/libsass/src/error_handling.cpp +21 -0
  42. data/ext/libsass/src/error_handling.hpp +25 -3
  43. data/ext/libsass/src/eval.cpp +33 -153
  44. data/ext/libsass/src/eval.hpp +11 -13
  45. data/ext/libsass/src/eval_selectors.cpp +75 -0
  46. data/ext/libsass/src/expand.cpp +214 -167
  47. data/ext/libsass/src/expand.hpp +26 -6
  48. data/ext/libsass/src/extender.cpp +1186 -0
  49. data/ext/libsass/src/extender.hpp +399 -0
  50. data/ext/libsass/src/extension.cpp +43 -0
  51. data/ext/libsass/src/extension.hpp +89 -0
  52. data/ext/libsass/src/file.cpp +15 -14
  53. data/ext/libsass/src/file.hpp +5 -12
  54. data/ext/libsass/src/fn_colors.cpp +12 -10
  55. data/ext/libsass/src/fn_lists.cpp +12 -11
  56. data/ext/libsass/src/fn_miscs.cpp +22 -34
  57. data/ext/libsass/src/fn_numbers.cpp +13 -6
  58. data/ext/libsass/src/fn_selectors.cpp +94 -124
  59. data/ext/libsass/src/fn_strings.cpp +16 -14
  60. data/ext/libsass/src/fn_utils.cpp +5 -6
  61. data/ext/libsass/src/fn_utils.hpp +9 -3
  62. data/ext/libsass/src/inspect.cpp +154 -117
  63. data/ext/libsass/src/inspect.hpp +10 -8
  64. data/ext/libsass/src/lexer.cpp +17 -81
  65. data/ext/libsass/src/lexer.hpp +5 -16
  66. data/ext/libsass/src/listize.cpp +22 -36
  67. data/ext/libsass/src/listize.hpp +8 -9
  68. data/ext/libsass/src/memory/SharedPtr.hpp +39 -5
  69. data/ext/libsass/src/operation.hpp +27 -17
  70. data/ext/libsass/src/operators.cpp +1 -0
  71. data/ext/libsass/src/ordered_map.hpp +112 -0
  72. data/ext/libsass/src/output.cpp +30 -49
  73. data/ext/libsass/src/output.hpp +1 -1
  74. data/ext/libsass/src/parser.cpp +211 -381
  75. data/ext/libsass/src/parser.hpp +17 -15
  76. data/ext/libsass/src/parser_selectors.cpp +189 -0
  77. data/ext/libsass/src/permutate.hpp +140 -0
  78. data/ext/libsass/src/position.hpp +1 -1
  79. data/ext/libsass/src/prelexer.cpp +6 -6
  80. data/ext/libsass/src/remove_placeholders.cpp +55 -56
  81. data/ext/libsass/src/remove_placeholders.hpp +21 -18
  82. data/ext/libsass/src/sass.hpp +1 -0
  83. data/ext/libsass/src/sass2scss.cpp +4 -4
  84. data/ext/libsass/src/sass_context.cpp +42 -91
  85. data/ext/libsass/src/sass_context.hpp +2 -2
  86. data/ext/libsass/src/sass_functions.cpp +1 -1
  87. data/ext/libsass/src/sass_values.cpp +0 -1
  88. data/ext/libsass/src/stylesheet.cpp +22 -0
  89. data/ext/libsass/src/stylesheet.hpp +57 -0
  90. data/ext/libsass/src/to_value.cpp +2 -2
  91. data/ext/libsass/src/to_value.hpp +1 -1
  92. data/ext/libsass/src/units.cpp +5 -3
  93. data/ext/libsass/src/util.cpp +10 -12
  94. data/ext/libsass/src/util.hpp +2 -3
  95. data/ext/libsass/src/util_string.cpp +111 -61
  96. data/ext/libsass/src/util_string.hpp +61 -8
  97. data/lib/sassc/engine.rb +5 -3
  98. data/lib/sassc/functions_handler.rb +8 -8
  99. data/lib/sassc/native.rb +1 -1
  100. data/lib/sassc/script.rb +4 -4
  101. data/lib/sassc/version.rb +1 -1
  102. data/test/functions_test.rb +18 -1
  103. data/test/native_test.rb +1 -1
  104. metadata +17 -12
  105. data/ext/libsass/src/extend.cpp +0 -2132
  106. data/ext/libsass/src/extend.hpp +0 -86
  107. data/ext/libsass/src/node.cpp +0 -322
  108. data/ext/libsass/src/node.hpp +0 -118
  109. data/ext/libsass/src/paths.hpp +0 -71
  110. data/ext/libsass/src/sass_util.cpp +0 -152
  111. data/ext/libsass/src/sass_util.hpp +0 -256
  112. data/ext/libsass/src/subset_map.cpp +0 -58
  113. data/ext/libsass/src/subset_map.hpp +0 -76
@@ -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
@@ -1,152 +0,0 @@
1
- // sass.hpp must go before all system headers to get the
2
- // __EXTENSIONS__ fix on Solaris.
3
- #include "sass.hpp"
4
-
5
- #include "node.hpp"
6
-
7
- namespace Sass {
8
-
9
-
10
- /*
11
- # This is the equivalent of ruby's Sass::Util.paths.
12
- #
13
- # Return an array of all possible paths through the given arrays.
14
- #
15
- # @param arrs [NodeCollection<NodeCollection<Node>>]
16
- # @return [NodeCollection<NodeCollection<Node>>]
17
- #
18
- # @example
19
- # paths([[1, 2], [3, 4], [5]]) #=>
20
- # # [[1, 3, 5],
21
- # # [2, 3, 5],
22
- # # [1, 4, 5],
23
- # # [2, 4, 5]]
24
-
25
- The following is the modified version of the ruby code that was more portable to C++. You
26
- should be able to drop it into ruby 3.2.19 and get the same results from ruby sass.
27
-
28
- def paths(arrs)
29
- // I changed the inject and maps to an iterative approach to make it easier to implement in C++
30
- loopStart = [[]]
31
-
32
- for arr in arrs do
33
- permutations = []
34
- for e in arr do
35
- for path in loopStart do
36
- permutations.push(path + [e])
37
- end
38
- end
39
- loopStart = permutations
40
- end
41
- end
42
- */
43
- Node paths(const Node& arrs) {
44
-
45
- Node loopStart = Node::createCollection();
46
- loopStart.collection()->push_back(Node::createCollection());
47
-
48
- for (NodeDeque::iterator arrsIter = arrs.collection()->begin(), arrsEndIter = arrs.collection()->end();
49
- arrsIter != arrsEndIter; ++arrsIter) {
50
-
51
- Node& arr = *arrsIter;
52
-
53
- Node permutations = Node::createCollection();
54
-
55
- for (NodeDeque::iterator arrIter = arr.collection()->begin(), arrIterEnd = arr.collection()->end();
56
- arrIter != arrIterEnd; ++arrIter) {
57
-
58
- Node& e = *arrIter;
59
-
60
- for (NodeDeque::iterator loopStartIter = loopStart.collection()->begin(), loopStartIterEnd = loopStart.collection()->end();
61
- loopStartIter != loopStartIterEnd; ++loopStartIter) {
62
-
63
- Node& path = *loopStartIter;
64
-
65
- Node newPermutation = Node::createCollection();
66
- newPermutation.got_line_feed = arr.got_line_feed;
67
- newPermutation.plus(path);
68
- newPermutation.collection()->push_back(e);
69
-
70
- permutations.collection()->push_back(newPermutation);
71
- }
72
- }
73
-
74
- loopStart = permutations;
75
- }
76
-
77
- return loopStart;
78
- }
79
-
80
-
81
- /*
82
- This is the equivalent of ruby sass' Sass::Util.flatten and [].flatten.
83
- Sass::Util.flatten requires the number of levels to flatten, while
84
- [].flatten doesn't and will flatten the entire array. This function
85
- supports both.
86
-
87
- # Flattens the first `n` nested arrays. If n == -1, all arrays will be flattened
88
- #
89
- # @param arr [NodeCollection] The array to flatten
90
- # @param n [int] The number of levels to flatten
91
- # @return [NodeCollection] The flattened array
92
-
93
- The following is the modified version of the ruby code that was more portable to C++. You
94
- should be able to drop it into ruby 3.2.19 and get the same results from ruby sass.
95
-
96
- def flatten(arr, n = -1)
97
- if n != -1 and n == 0 then
98
- return arr
99
- end
100
-
101
- flattened = []
102
-
103
- for e in arr do
104
- if e.is_a?(Array) then
105
- flattened.concat(flatten(e, n - 1))
106
- else
107
- flattened << e
108
- end
109
- end
110
-
111
- return flattened
112
- end
113
- */
114
- Node flatten(Node& arr, int n) {
115
- if (n != -1 && n == 0) {
116
- return arr;
117
- }
118
-
119
- Node flattened = Node::createCollection();
120
- if (arr.got_line_feed) flattened.got_line_feed = true;
121
-
122
- for (NodeDeque::iterator iter = arr.collection()->begin(), iterEnd = arr.collection()->end();
123
- iter != iterEnd; iter++) {
124
- Node& e = *iter;
125
-
126
- // e has the lf set
127
- if (e.isCollection()) {
128
-
129
- // e.collection().got_line_feed = e.got_line_feed;
130
- Node recurseFlattened = flatten(e, n - 1);
131
-
132
- if(e.got_line_feed) {
133
- flattened.got_line_feed = e.got_line_feed;
134
- recurseFlattened.got_line_feed = e.got_line_feed;
135
- }
136
-
137
- for(auto i : (*recurseFlattened.collection())) {
138
- if (recurseFlattened.got_line_feed) {
139
-
140
- i.got_line_feed = true;
141
- }
142
- flattened.collection()->push_back(i);
143
- }
144
-
145
- } else {
146
- flattened.collection()->push_back(e);
147
- }
148
- }
149
-
150
- return flattened;
151
- }
152
- }
@@ -1,256 +0,0 @@
1
- #ifndef SASS_SASS_UTIL_H
2
- #define SASS_SASS_UTIL_H
3
-
4
- #include "ast.hpp"
5
- #include "node.hpp"
6
- #include "debug.hpp"
7
-
8
- namespace Sass {
9
-
10
-
11
-
12
-
13
- /*
14
- This is for ports of functions in the Sass:Util module.
15
- */
16
-
17
-
18
- /*
19
- # Return a Node collection of all possible paths through the given Node collection of Node collections.
20
- #
21
- # @param arrs [NodeCollection<NodeCollection<Node>>]
22
- # @return [NodeCollection<NodeCollection<Node>>]
23
- #
24
- # @example
25
- # paths([[1, 2], [3, 4], [5]]) #=>
26
- # # [[1, 3, 5],
27
- # # [2, 3, 5],
28
- # # [1, 4, 5],
29
- # # [2, 4, 5]]
30
- */
31
- Node paths(const Node& arrs);
32
-
33
-
34
- /*
35
- This class is a default implementation of a Node comparator that can be passed to the lcs function below.
36
- It uses operator== for equality comparision. It then returns one if the Nodes are equal.
37
- */
38
- class DefaultLcsComparator {
39
- public:
40
- bool operator()(const Node& one, const Node& two, Node& out) const {
41
- // TODO: Is this the correct C++ interpretation?
42
- // block ||= proc {|a, b| a == b && a}
43
- if (one == two) {
44
- out = one;
45
- return true;
46
- }
47
-
48
- return false;
49
- }
50
- };
51
-
52
-
53
- typedef std::vector<std::vector<int> > LCSTable;
54
-
55
-
56
- /*
57
- This is the equivalent of ruby's Sass::Util.lcs_backtrace.
58
-
59
- # Computes a single longest common subsequence for arrays x and y.
60
- # Algorithm from http://en.wikipedia.org/wiki/Longest_common_subsequence_problem#Reading_out_an_LCS
61
- */
62
- template<typename ComparatorType>
63
- Node lcs_backtrace(const LCSTable& c, const Node& x, const Node& y, int i, int j, const ComparatorType& comparator) {
64
- DEBUG_PRINTLN(LCS, "LCSBACK: X=" << x << " Y=" << y << " I=" << i << " J=" << j)
65
-
66
- if (i == 0 || j == 0) {
67
- DEBUG_PRINTLN(LCS, "RETURNING EMPTY")
68
- return Node::createCollection();
69
- }
70
-
71
- NodeDeque& xChildren = *(x.collection());
72
- NodeDeque& yChildren = *(y.collection());
73
-
74
- Node compareOut = Node::createNil();
75
- if (comparator(xChildren[i], yChildren[j], compareOut)) {
76
- DEBUG_PRINTLN(LCS, "RETURNING AFTER ELEM COMPARE")
77
- Node result = lcs_backtrace(c, x, y, i - 1, j - 1, comparator);
78
- result.collection()->push_back(compareOut);
79
- return result;
80
- }
81
-
82
- if (c[i][j - 1] > c[i - 1][j]) {
83
- DEBUG_PRINTLN(LCS, "RETURNING AFTER TABLE COMPARE")
84
- return lcs_backtrace(c, x, y, i, j - 1, comparator);
85
- }
86
-
87
- DEBUG_PRINTLN(LCS, "FINAL RETURN")
88
- return lcs_backtrace(c, x, y, i - 1, j, comparator);
89
- }
90
-
91
-
92
- /*
93
- This is the equivalent of ruby's Sass::Util.lcs_table.
94
-
95
- # Calculates the memoization table for the Least Common Subsequence algorithm.
96
- # Algorithm from http://en.wikipedia.org/wiki/Longest_common_subsequence_problem#Computing_the_length_of_the_LCS
97
- */
98
- template<typename ComparatorType>
99
- void lcs_table(const Node& x, const Node& y, const ComparatorType& comparator, LCSTable& out) {
100
- DEBUG_PRINTLN(LCS, "LCSTABLE: X=" << x << " Y=" << y)
101
-
102
- NodeDeque& xChildren = *(x.collection());
103
- NodeDeque& yChildren = *(y.collection());
104
-
105
- LCSTable c(xChildren.size(), std::vector<int>(yChildren.size()));
106
-
107
- // These shouldn't be necessary since the vector will be initialized to 0 already.
108
- // x.size.times {|i| c[i][0] = 0}
109
- // y.size.times {|j| c[0][j] = 0}
110
-
111
- for (size_t i = 1; i < xChildren.size(); i++) {
112
- for (size_t j = 1; j < yChildren.size(); j++) {
113
- Node compareOut = Node::createNil();
114
-
115
- if (comparator(xChildren[i], yChildren[j], compareOut)) {
116
- c[i][j] = c[i - 1][j - 1] + 1;
117
- } else {
118
- c[i][j] = std::max(c[i][j - 1], c[i - 1][j]);
119
- }
120
- }
121
- }
122
-
123
- out = c;
124
- }
125
-
126
-
127
- /*
128
- This is the equivalent of ruby's Sass::Util.lcs.
129
-
130
- # Computes a single longest common subsequence for `x` and `y`.
131
- # If there are more than one longest common subsequences,
132
- # the one returned is that which starts first in `x`.
133
-
134
- # @param x [NodeCollection]
135
- # @param y [NodeCollection]
136
- # @comparator An equality check between elements of `x` and `y`.
137
- # @return [NodeCollection] The LCS
138
-
139
- http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
140
- */
141
- template<typename ComparatorType>
142
- Node lcs(Node& x, Node& y, const ComparatorType& comparator) {
143
- DEBUG_PRINTLN(LCS, "LCS: X=" << x << " Y=" << y)
144
-
145
- Node newX = Node::createCollection();
146
- newX.collection()->push_back(Node::createNil());
147
- newX.plus(x);
148
-
149
- Node newY = Node::createCollection();
150
- newY.collection()->push_back(Node::createNil());
151
- newY.plus(y);
152
-
153
- LCSTable table;
154
- lcs_table(newX, newY, comparator, table);
155
-
156
- return lcs_backtrace(table, newX, newY, static_cast<int>(newX.collection()->size()) - 1, static_cast<int>(newY.collection()->size()) - 1, comparator);
157
- }
158
-
159
-
160
- /*
161
- This is the equivalent of ruby sass' Sass::Util.flatten and [].flatten.
162
- Sass::Util.flatten requires the number of levels to flatten, while
163
- [].flatten doesn't and will flatten the entire array. This function
164
- supports both.
165
-
166
- # Flattens the first `n` nested arrays. If n == -1, all arrays will be flattened
167
- #
168
- # @param arr [NodeCollection] The array to flatten
169
- # @param n [int] The number of levels to flatten
170
- # @return [NodeCollection] The flattened array
171
- */
172
- Node flatten(Node& arr, int n = -1);
173
-
174
-
175
- /*
176
- This is the equivalent of ruby's Sass::Util.group_by_to_a.
177
-
178
- # Performs the equivalent of `enum.group_by.to_a`, but with a guaranteed
179
- # order. Unlike [#hash_to_a], the resulting order isn't sorted key order;
180
- # instead, it's the same order as `#group_by` has under Ruby 1.9 (key
181
- # appearance order).
182
- #
183
- # @param enum [Enumerable]
184
- # @return [Array<[Object, Array]>] An array of pairs.
185
-
186
- TODO: update @param and @return once I know what those are.
187
-
188
- The following is the modified version of the ruby code that was more portable to C++. You
189
- should be able to drop it into ruby 3.2.19 and get the same results from ruby sass.
190
-
191
- def group_by_to_a(enum, &block)
192
- order = {}
193
-
194
- arr = []
195
-
196
- grouped = {}
197
-
198
- for e in enum do
199
- key = block[e]
200
- unless order.include?(key)
201
- order[key] = order.size
202
- end
203
-
204
- if not grouped.has_key?(key) then
205
- grouped[key] = [e]
206
- else
207
- grouped[key].push(e)
208
- end
209
- end
210
-
211
- grouped.each do |key, vals|
212
- arr[order[key]] = [key, vals]
213
- end
214
-
215
- arr
216
- end
217
-
218
- */
219
- template<typename EnumType, typename KeyType, typename KeyFunctorType>
220
- void group_by_to_a(std::vector<EnumType>& enumeration, KeyFunctorType& keyFunc, std::vector<std::pair<KeyType, std::vector<EnumType> > >& arr /*out*/) {
221
-
222
- std::map<unsigned int, KeyType> order;
223
-
224
- std::map<size_t, std::vector<EnumType> > grouped;
225
-
226
- for (typename std::vector<EnumType>::iterator enumIter = enumeration.begin(), enumIterEnd = enumeration.end(); enumIter != enumIterEnd; enumIter++) {
227
- EnumType& e = *enumIter;
228
-
229
- KeyType key = keyFunc(e);
230
-
231
- if (grouped.find(key->hash()) == grouped.end()) {
232
- order.insert(std::make_pair((unsigned int)order.size(), key));
233
-
234
- std::vector<EnumType> newCollection;
235
- newCollection.push_back(e);
236
- grouped.insert(std::make_pair(key->hash(), newCollection));
237
- } else {
238
- std::vector<EnumType>& collection = grouped.at(key->hash());
239
- collection.push_back(e);
240
- }
241
- }
242
-
243
- for (unsigned int index = 0; index < order.size(); index++) {
244
- KeyType& key = order.at(index);
245
- std::vector<EnumType>& values = grouped.at(key->hash());
246
-
247
- std::pair<KeyType, std::vector<EnumType> > grouping = std::make_pair(key, values);
248
-
249
- arr.push_back(grouping);
250
- }
251
- }
252
-
253
-
254
- }
255
-
256
- #endif