sassc 1.11.1 → 1.11.2
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/.travis.yml +2 -2
- data/README.md +3 -2
- data/ext/libsass/Makefile.conf +2 -1
- data/ext/libsass/appveyor.yml +10 -5
- data/ext/libsass/docs/dev-ast-memory.md +223 -0
- data/ext/libsass/include/sass/base.h +2 -0
- data/ext/libsass/script/bootstrap +7 -4
- data/ext/libsass/script/ci-build-libsass +3 -3
- data/ext/libsass/script/ci-install-compiler +2 -0
- data/ext/libsass/script/ci-report-coverage +2 -1
- data/ext/libsass/script/test-leaks.pl +103 -0
- data/ext/libsass/src/ast.cpp +621 -495
- data/ext/libsass/src/ast.hpp +801 -367
- data/ext/libsass/src/ast_def_macros.hpp +5 -5
- data/ext/libsass/src/ast_fwd_decl.hpp +312 -14
- data/ext/libsass/src/bind.cpp +54 -51
- data/ext/libsass/src/bind.hpp +3 -7
- data/ext/libsass/src/check_nesting.cpp +117 -120
- data/ext/libsass/src/check_nesting.hpp +38 -34
- data/ext/libsass/src/color_maps.cpp +3 -3
- data/ext/libsass/src/color_maps.hpp +3 -3
- data/ext/libsass/src/context.cpp +33 -34
- data/ext/libsass/src/context.hpp +12 -14
- data/ext/libsass/src/cssize.cpp +200 -228
- data/ext/libsass/src/cssize.hpp +49 -49
- data/ext/libsass/src/debugger.hpp +260 -241
- data/ext/libsass/src/emitter.cpp +6 -6
- data/ext/libsass/src/emitter.hpp +7 -7
- data/ext/libsass/src/environment.cpp +2 -2
- data/ext/libsass/src/environment.hpp +0 -2
- data/ext/libsass/src/error_handling.cpp +5 -5
- data/ext/libsass/src/error_handling.hpp +12 -12
- data/ext/libsass/src/eval.cpp +412 -401
- data/ext/libsass/src/eval.hpp +61 -62
- data/ext/libsass/src/expand.cpp +223 -204
- data/ext/libsass/src/expand.hpp +42 -42
- data/ext/libsass/src/extend.cpp +198 -201
- data/ext/libsass/src/extend.hpp +12 -14
- data/ext/libsass/src/file.hpp +4 -5
- data/ext/libsass/src/functions.cpp +413 -418
- data/ext/libsass/src/functions.hpp +7 -10
- data/ext/libsass/src/inspect.cpp +115 -109
- data/ext/libsass/src/inspect.hpp +69 -69
- data/ext/libsass/src/listize.cpp +31 -33
- data/ext/libsass/src/listize.hpp +8 -10
- data/ext/libsass/src/memory/SharedPtr.cpp +116 -0
- data/ext/libsass/src/memory/SharedPtr.hpp +202 -0
- data/ext/libsass/src/node.cpp +45 -43
- data/ext/libsass/src/node.hpp +15 -15
- data/ext/libsass/src/operation.hpp +136 -136
- data/ext/libsass/src/output.cpp +48 -49
- data/ext/libsass/src/output.hpp +14 -14
- data/ext/libsass/src/parser.cpp +530 -554
- data/ext/libsass/src/parser.hpp +91 -96
- data/ext/libsass/src/prelexer.cpp +13 -10
- data/ext/libsass/src/remove_placeholders.cpp +25 -21
- data/ext/libsass/src/remove_placeholders.hpp +7 -7
- data/ext/libsass/src/sass2scss.cpp +2 -1
- data/ext/libsass/src/sass_context.cpp +125 -107
- data/ext/libsass/src/sass_context.hpp +1 -1
- data/ext/libsass/src/sass_util.hpp +5 -5
- data/ext/libsass/src/sass_values.cpp +27 -27
- data/ext/libsass/src/source_map.cpp +2 -2
- data/ext/libsass/src/source_map.hpp +2 -2
- data/ext/libsass/src/subset_map.cpp +57 -0
- data/ext/libsass/src/subset_map.hpp +8 -76
- data/ext/libsass/src/to_c.cpp +13 -13
- data/ext/libsass/src/to_c.hpp +14 -14
- data/ext/libsass/src/to_value.cpp +20 -20
- data/ext/libsass/src/to_value.hpp +20 -21
- data/ext/libsass/src/util.cpp +55 -88
- data/ext/libsass/src/util.hpp +9 -13
- data/ext/libsass/src/values.cpp +27 -26
- data/ext/libsass/src/values.hpp +2 -2
- data/ext/libsass/test/test_subset_map.cpp +69 -69
- data/ext/libsass/win/libsass.targets +3 -2
- data/ext/libsass/win/libsass.vcxproj.filters +9 -6
- data/lib/sassc/version.rb +1 -1
- data/sassc.gemspec +0 -1
- data/test/native_test.rb +1 -1
- metadata +7 -5
- data/ext/libsass/src/ast_factory.hpp +0 -92
- data/ext/libsass/src/memory_manager.cpp +0 -77
- data/ext/libsass/src/memory_manager.hpp +0 -48
@@ -40,7 +40,7 @@ namespace Sass {
|
|
40
40
|
bool operator()(const Node& one, const Node& two, Node& out) const {
|
41
41
|
// TODO: Is this the correct C++ interpretation?
|
42
42
|
// block ||= proc {|a, b| a == b && a}
|
43
|
-
if (one
|
43
|
+
if (nodesEqual(one, two, true)) {
|
44
44
|
out = one;
|
45
45
|
return true;
|
46
46
|
}
|
@@ -228,21 +228,21 @@ namespace Sass {
|
|
228
228
|
|
229
229
|
KeyType key = keyFunc(e);
|
230
230
|
|
231
|
-
if (grouped.find(key
|
231
|
+
if (grouped.find(key->hash()) == grouped.end()) {
|
232
232
|
order.insert(std::make_pair((unsigned int)order.size(), key));
|
233
233
|
|
234
234
|
std::vector<EnumType> newCollection;
|
235
235
|
newCollection.push_back(e);
|
236
|
-
grouped.insert(std::make_pair(key
|
236
|
+
grouped.insert(std::make_pair(key->hash(), newCollection));
|
237
237
|
} else {
|
238
|
-
std::vector<EnumType>& collection = grouped.at(key
|
238
|
+
std::vector<EnumType>& collection = grouped.at(key->hash());
|
239
239
|
collection.push_back(e);
|
240
240
|
}
|
241
241
|
}
|
242
242
|
|
243
243
|
for (unsigned int index = 0; index < order.size(); index++) {
|
244
244
|
KeyType& key = order.at(index);
|
245
|
-
std::vector<EnumType>& values = grouped.at(key
|
245
|
+
std::vector<EnumType>& values = grouped.at(key->hash());
|
246
246
|
|
247
247
|
std::pair<KeyType, std::vector<EnumType> > grouping = std::make_pair(key, values);
|
248
248
|
|
@@ -275,8 +275,7 @@ extern "C" {
|
|
275
275
|
|
276
276
|
union Sass_Value* ADDCALL sass_value_stringify (const union Sass_Value* v, bool compressed, int precision)
|
277
277
|
{
|
278
|
-
|
279
|
-
Value* val = sass_value_to_ast_node(mem, v);
|
278
|
+
Value_Obj val = sass_value_to_ast_node(v);
|
280
279
|
Sass_Inspect_Options options(compressed ? COMPRESSED : NESTED, precision);
|
281
280
|
std::string str(val->to_string(options));
|
282
281
|
return sass_make_qstring(str.c_str());
|
@@ -285,50 +284,51 @@ extern "C" {
|
|
285
284
|
union Sass_Value* ADDCALL sass_value_op (enum Sass_OP op, const union Sass_Value* a, const union Sass_Value* b)
|
286
285
|
{
|
287
286
|
|
288
|
-
Sass::
|
289
|
-
Memory_Manager mem;
|
287
|
+
Sass::Value_Ptr rv = 0;
|
290
288
|
|
291
289
|
try {
|
292
290
|
|
293
|
-
|
294
|
-
|
291
|
+
Value_Obj lhs = sass_value_to_ast_node(a);
|
292
|
+
Value_Obj rhs = sass_value_to_ast_node(b);
|
295
293
|
struct Sass_Inspect_Options options(NESTED, 5);
|
296
294
|
|
297
295
|
// see if it's a relational expression
|
298
296
|
switch(op) {
|
299
|
-
case Sass_OP::EQ: return sass_make_boolean(Eval::eq(lhs, rhs));
|
300
|
-
case Sass_OP::NEQ: return sass_make_boolean(!Eval::eq(lhs, rhs));
|
301
|
-
case Sass_OP::GT: return sass_make_boolean(!Eval::lt(lhs, rhs, "gt") && !Eval::eq(lhs, rhs));
|
302
|
-
case Sass_OP::GTE: return sass_make_boolean(!Eval::lt(lhs, rhs, "gte"));
|
303
|
-
case Sass_OP::LT: return sass_make_boolean(Eval::lt(lhs, rhs, "lt"));
|
304
|
-
case Sass_OP::LTE: return sass_make_boolean(Eval::lt(lhs, rhs, "lte") || Eval::eq(lhs, rhs));
|
297
|
+
case Sass_OP::EQ: return sass_make_boolean(Eval::eq(&lhs, &rhs));
|
298
|
+
case Sass_OP::NEQ: return sass_make_boolean(!Eval::eq(&lhs, &rhs));
|
299
|
+
case Sass_OP::GT: return sass_make_boolean(!Eval::lt(&lhs, &rhs, "gt") && !Eval::eq(&lhs, &rhs));
|
300
|
+
case Sass_OP::GTE: return sass_make_boolean(!Eval::lt(&lhs, &rhs, "gte"));
|
301
|
+
case Sass_OP::LT: return sass_make_boolean(Eval::lt(&lhs, &rhs, "lt"));
|
302
|
+
case Sass_OP::LTE: return sass_make_boolean(Eval::lt(&lhs, &rhs, "lte") || Eval::eq(&lhs, &rhs));
|
303
|
+
case Sass_OP::AND: return ast_node_to_sass_value(lhs->is_false() ? &lhs : &rhs);
|
304
|
+
case Sass_OP::OR: return ast_node_to_sass_value(lhs->is_false() ? &rhs : &lhs);
|
305
305
|
default: break;
|
306
306
|
}
|
307
307
|
|
308
308
|
if (sass_value_is_number(a) && sass_value_is_number(b)) {
|
309
|
-
|
310
|
-
|
311
|
-
rv = Eval::op_numbers(
|
309
|
+
Number_Ptr_Const l_n = SASS_MEMORY_CAST(Number, lhs);
|
310
|
+
Number_Ptr_Const r_n = SASS_MEMORY_CAST(Number, rhs);
|
311
|
+
rv = Eval::op_numbers(op, *l_n, *r_n, options);
|
312
312
|
}
|
313
313
|
else if (sass_value_is_number(a) && sass_value_is_color(a)) {
|
314
|
-
|
315
|
-
|
316
|
-
rv = Eval::op_number_color(
|
314
|
+
Number_Ptr_Const l_n = SASS_MEMORY_CAST(Number, lhs);
|
315
|
+
Color_Ptr_Const r_c = SASS_MEMORY_CAST(Color, rhs);
|
316
|
+
rv = Eval::op_number_color(op, *l_n, *r_c, options);
|
317
317
|
}
|
318
318
|
else if (sass_value_is_color(a) && sass_value_is_number(b)) {
|
319
|
-
|
320
|
-
|
321
|
-
rv = Eval::op_color_number(
|
319
|
+
Color_Ptr_Const l_c = SASS_MEMORY_CAST(Color, lhs);
|
320
|
+
Number_Ptr_Const r_n = SASS_MEMORY_CAST(Number, rhs);
|
321
|
+
rv = Eval::op_color_number(op, *l_c, *r_n, options);
|
322
322
|
}
|
323
323
|
else if (sass_value_is_color(a) && sass_value_is_color(b)) {
|
324
|
-
|
325
|
-
|
326
|
-
rv = Eval::op_colors(
|
324
|
+
Color_Ptr_Const l_c = SASS_MEMORY_CAST(Color, lhs);
|
325
|
+
Color_Ptr_Const r_c = SASS_MEMORY_CAST(Color, rhs);
|
326
|
+
rv = Eval::op_colors(op, *l_c, *r_c, options);
|
327
327
|
}
|
328
328
|
else /* convert other stuff to string and apply operation */ {
|
329
|
-
|
330
|
-
|
331
|
-
rv = Eval::op_strings(
|
329
|
+
Value_Ptr l_v = SASS_MEMORY_CAST(Value, lhs);
|
330
|
+
Value_Ptr r_v = SASS_MEMORY_CAST(Value, rhs);
|
331
|
+
rv = Eval::op_strings(op, *l_v, *r_v, options);
|
332
332
|
}
|
333
333
|
|
334
334
|
// ToDo: maybe we should should return null value?
|
@@ -172,12 +172,12 @@ namespace Sass {
|
|
172
172
|
current_position += offset;
|
173
173
|
}
|
174
174
|
|
175
|
-
void SourceMap::add_open_mapping(const
|
175
|
+
void SourceMap::add_open_mapping(const AST_Node_Ptr node)
|
176
176
|
{
|
177
177
|
mappings.push_back(Mapping(node->pstate(), current_position));
|
178
178
|
}
|
179
179
|
|
180
|
-
void SourceMap::add_close_mapping(const
|
180
|
+
void SourceMap::add_close_mapping(const AST_Node_Ptr node)
|
181
181
|
{
|
182
182
|
mappings.push_back(Mapping(node->pstate() + node->pstate().offset, current_position));
|
183
183
|
}
|
@@ -28,8 +28,8 @@ namespace Sass {
|
|
28
28
|
void prepend(const Offset& offset);
|
29
29
|
void append(const OutputBuffer& out);
|
30
30
|
void prepend(const OutputBuffer& out);
|
31
|
-
void add_open_mapping(const
|
32
|
-
void add_close_mapping(const
|
31
|
+
void add_open_mapping(const AST_Node_Ptr node);
|
32
|
+
void add_close_mapping(const AST_Node_Ptr node);
|
33
33
|
|
34
34
|
std::string render_srcmap(Context &ctx);
|
35
35
|
ParserState remap(const ParserState& pstate);
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#include "sass.hpp"
|
2
|
+
#include "ast.hpp"
|
3
|
+
#include "subset_map.hpp"
|
4
|
+
|
5
|
+
namespace Sass {
|
6
|
+
|
7
|
+
void Subset_Map::put(const Compound_Selector_Obj& sel, const Subset_Map_Val& value)
|
8
|
+
{
|
9
|
+
if (sel->empty()) throw std::runtime_error("internal error: subset map keys may not be empty");
|
10
|
+
size_t index = values_.size();
|
11
|
+
values_.push_back(value);
|
12
|
+
for (size_t i = 0, S = sel->length(); i < S; ++i)
|
13
|
+
{
|
14
|
+
hash_[(*sel)[i]].push_back(std::make_pair(&sel, index));
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
std::vector<Subset_Map_Val> Subset_Map::get_kv(const Compound_Selector_Obj& sel)
|
19
|
+
{
|
20
|
+
// std::vector<Subset_Map_Key> s = sel->to_str_vec();
|
21
|
+
// std::set<std::string> dict(s.begin(), s.end());
|
22
|
+
std::unordered_set<Simple_Selector_Obj, HashSimpleSelector, CompareSimpleSelector> dict(sel->begin(), sel->end());
|
23
|
+
std::vector<size_t> indices;
|
24
|
+
for (size_t i = 0, S = sel->length(); i < S; ++i) {
|
25
|
+
if (!hash_.count((*sel)[i])) {
|
26
|
+
continue;
|
27
|
+
}
|
28
|
+
const std::vector<std::pair<Compound_Selector_Obj, size_t> >& subsets = hash_[(*sel)[i]];
|
29
|
+
for (const std::pair<Compound_Selector_Obj, size_t>& item : subsets) {
|
30
|
+
bool include = true;
|
31
|
+
for (const Simple_Selector_Obj& it : item.first->elements()) {
|
32
|
+
auto found = dict.find(it);
|
33
|
+
if (found == dict.end()) {
|
34
|
+
include = false;
|
35
|
+
break;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
if (include) indices.push_back(item.second);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
sort(indices.begin(), indices.end());
|
42
|
+
std::vector<size_t>::iterator indices_end = unique(indices.begin(), indices.end());
|
43
|
+
indices.resize(distance(indices.begin(), indices_end));
|
44
|
+
|
45
|
+
std::vector<Subset_Map_Val> results;
|
46
|
+
for (size_t i = 0, S = indices.size(); i < S; ++i) {
|
47
|
+
results.push_back(values_[indices[i]]);
|
48
|
+
}
|
49
|
+
return results;
|
50
|
+
}
|
51
|
+
|
52
|
+
std::vector<Subset_Map_Val> Subset_Map::get_v(const Compound_Selector_Obj& sel)
|
53
|
+
{
|
54
|
+
return get_kv(sel);
|
55
|
+
}
|
56
|
+
|
57
|
+
}
|
@@ -7,6 +7,8 @@
|
|
7
7
|
#include <algorithm>
|
8
8
|
#include <iterator>
|
9
9
|
|
10
|
+
#include "ast_fwd_decl.hpp"
|
11
|
+
|
10
12
|
|
11
13
|
// #include <iostream>
|
12
14
|
// #include <sstream>
|
@@ -56,89 +58,19 @@
|
|
56
58
|
|
57
59
|
namespace Sass {
|
58
60
|
|
59
|
-
template<typename F, typename S, typename T>
|
60
|
-
struct triple {
|
61
|
-
F first;
|
62
|
-
S second;
|
63
|
-
T third;
|
64
|
-
|
65
|
-
triple(const F& f, const S& s, const T& t) : first(f), second(s), third(t) { }
|
66
|
-
};
|
67
|
-
|
68
|
-
template<typename F, typename S, typename T>
|
69
|
-
triple<F, S, T> make_triple(const F& f, const S& s, const T& t)
|
70
|
-
{ return triple<F, S, T>(f, s, t); }
|
71
|
-
|
72
|
-
template<typename K, typename V>
|
73
61
|
class Subset_Map {
|
74
62
|
private:
|
75
|
-
std::vector<
|
76
|
-
std::map<
|
63
|
+
std::vector<Subset_Map_Val> values_;
|
64
|
+
std::map<Simple_Selector_Obj, std::vector<std::pair<Compound_Selector_Obj, size_t> > > hash_;
|
77
65
|
public:
|
78
|
-
void put(const
|
79
|
-
std::vector<
|
80
|
-
std::vector<
|
66
|
+
void put(const Compound_Selector_Obj& sel, const Subset_Map_Val& value);
|
67
|
+
std::vector<Subset_Map_Val> get_kv(const Compound_Selector_Obj& s);
|
68
|
+
std::vector<Subset_Map_Val> get_v(const Compound_Selector_Obj& s);
|
81
69
|
bool empty() { return values_.empty(); }
|
82
70
|
void clear() { values_.clear(); hash_.clear(); }
|
83
|
-
const std::vector<
|
71
|
+
const std::vector<Subset_Map_Val> values(void) { return values_; }
|
84
72
|
};
|
85
73
|
|
86
|
-
template<typename K, typename V>
|
87
|
-
void Subset_Map<K, V>::put(const std::vector<K>& s, const V& value)
|
88
|
-
{
|
89
|
-
if (s.empty()) throw "internal error: subset map keys may not be empty";
|
90
|
-
size_t index = values_.size();
|
91
|
-
values_.push_back(value);
|
92
|
-
std::set<K> ss;
|
93
|
-
for (size_t i = 0, S = s.size(); i < S; ++i)
|
94
|
-
{ ss.insert(s[i]); }
|
95
|
-
for (size_t i = 0, S = s.size(); i < S; ++i)
|
96
|
-
{
|
97
|
-
hash_[s[i]].push_back(make_triple(s, ss, index));
|
98
|
-
}
|
99
|
-
}
|
100
|
-
|
101
|
-
template<typename K, typename V>
|
102
|
-
std::vector<std::pair<V, std::vector<K> > > Subset_Map<K, V>::get_kv(const std::vector<K>& s)
|
103
|
-
{
|
104
|
-
std::vector<K> sorted = s;
|
105
|
-
sort(sorted.begin(), sorted.end());
|
106
|
-
std::vector<std::pair<size_t, std::vector<K> > > indices;
|
107
|
-
for (size_t i = 0, S = s.size(); i < S; ++i) {
|
108
|
-
if (!hash_.count(s[i])) {
|
109
|
-
continue;
|
110
|
-
}
|
111
|
-
std::vector<triple<std::vector<K>, std::set<K>, size_t> > subsets = hash_[s[i]];
|
112
|
-
// std::cerr << "length of subsets: " << subsets.size() << std::endl;
|
113
|
-
for (size_t j = 0, T = subsets.size(); j < T; ++j) {
|
114
|
-
if (!includes(sorted.begin(), sorted.end(), subsets[j].second.begin(), subsets[j].second.end())) {
|
115
|
-
// std::cout << vector_to_string(s) << " doesn't include " << set_to_string(subsets[j].second) << std::endl;
|
116
|
-
continue;
|
117
|
-
}
|
118
|
-
indices.push_back(std::make_pair(subsets[j].third, subsets[j].first));
|
119
|
-
// std::cerr << "pushed " << subsets[j].third << " and " << vector_to_string(subsets[j].first) << " onto indices" << std::endl;
|
120
|
-
}
|
121
|
-
}
|
122
|
-
sort(indices.begin(), indices.end());
|
123
|
-
typename std::vector<std::pair<size_t, std::vector<K> > >::iterator indices_end = unique(indices.begin(), indices.end());
|
124
|
-
indices.resize(distance(indices.begin(), indices_end));
|
125
|
-
|
126
|
-
std::vector<std::pair<V, std::vector<K> > > results;
|
127
|
-
for (size_t i = 0, S = indices.size(); i < S; ++i) {
|
128
|
-
results.push_back(std::make_pair(values_[indices[i].first], indices[i].second));
|
129
|
-
}
|
130
|
-
return results;
|
131
|
-
}
|
132
|
-
|
133
|
-
template<typename K, typename V>
|
134
|
-
std::vector<V> Subset_Map<K, V>::get_v(const std::vector<K>& s)
|
135
|
-
{
|
136
|
-
std::vector<std::pair<V, std::vector<K> > > kvs = get_kv(s);
|
137
|
-
std::vector<V> results;
|
138
|
-
for (size_t i = 0, S = kvs.size(); i < S; ++i) results.push_back(kvs[i].first);
|
139
|
-
return results;
|
140
|
-
}
|
141
|
-
|
142
74
|
}
|
143
75
|
|
144
76
|
#endif
|
data/ext/libsass/src/to_c.cpp
CHANGED
@@ -4,25 +4,25 @@
|
|
4
4
|
|
5
5
|
namespace Sass {
|
6
6
|
|
7
|
-
union Sass_Value* To_C::fallback_impl(
|
7
|
+
union Sass_Value* To_C::fallback_impl(AST_Node_Ptr n)
|
8
8
|
{ return sass_make_error("unknown type for C-API"); }
|
9
9
|
|
10
|
-
union Sass_Value* To_C::operator()(
|
10
|
+
union Sass_Value* To_C::operator()(Boolean_Ptr b)
|
11
11
|
{ return sass_make_boolean(b->value()); }
|
12
12
|
|
13
|
-
union Sass_Value* To_C::operator()(
|
13
|
+
union Sass_Value* To_C::operator()(Number_Ptr n)
|
14
14
|
{ return sass_make_number(n->value(), n->unit().c_str()); }
|
15
15
|
|
16
|
-
union Sass_Value* To_C::operator()(
|
16
|
+
union Sass_Value* To_C::operator()(Custom_Warning_Ptr w)
|
17
17
|
{ return sass_make_warning(w->message().c_str()); }
|
18
18
|
|
19
|
-
union Sass_Value* To_C::operator()(
|
19
|
+
union Sass_Value* To_C::operator()(Custom_Error_Ptr e)
|
20
20
|
{ return sass_make_error(e->message().c_str()); }
|
21
21
|
|
22
|
-
union Sass_Value* To_C::operator()(
|
22
|
+
union Sass_Value* To_C::operator()(Color_Ptr c)
|
23
23
|
{ return sass_make_color(c->r(), c->g(), c->b(), c->a()); }
|
24
24
|
|
25
|
-
union Sass_Value* To_C::operator()(
|
25
|
+
union Sass_Value* To_C::operator()(String_Constant_Ptr s)
|
26
26
|
{
|
27
27
|
if (s->quote_mark()) {
|
28
28
|
return sass_make_qstring(s->value().c_str());
|
@@ -31,10 +31,10 @@ namespace Sass {
|
|
31
31
|
}
|
32
32
|
}
|
33
33
|
|
34
|
-
union Sass_Value* To_C::operator()(
|
34
|
+
union Sass_Value* To_C::operator()(String_Quoted_Ptr s)
|
35
35
|
{ return sass_make_qstring(s->value().c_str()); }
|
36
36
|
|
37
|
-
union Sass_Value* To_C::operator()(
|
37
|
+
union Sass_Value* To_C::operator()(List_Ptr l)
|
38
38
|
{
|
39
39
|
union Sass_Value* v = sass_make_list(l->length(), l->separator());
|
40
40
|
for (size_t i = 0, L = l->length(); i < L; ++i) {
|
@@ -43,7 +43,7 @@ namespace Sass {
|
|
43
43
|
return v;
|
44
44
|
}
|
45
45
|
|
46
|
-
union Sass_Value* To_C::operator()(
|
46
|
+
union Sass_Value* To_C::operator()(Map_Ptr m)
|
47
47
|
{
|
48
48
|
union Sass_Value* v = sass_make_map(m->length());
|
49
49
|
int i = 0;
|
@@ -55,7 +55,7 @@ namespace Sass {
|
|
55
55
|
return v;
|
56
56
|
}
|
57
57
|
|
58
|
-
union Sass_Value* To_C::operator()(
|
58
|
+
union Sass_Value* To_C::operator()(Arguments_Ptr a)
|
59
59
|
{
|
60
60
|
union Sass_Value* v = sass_make_list(a->length(), SASS_COMMA);
|
61
61
|
for (size_t i = 0, L = a->length(); i < L; ++i) {
|
@@ -64,11 +64,11 @@ namespace Sass {
|
|
64
64
|
return v;
|
65
65
|
}
|
66
66
|
|
67
|
-
union Sass_Value* To_C::operator()(
|
67
|
+
union Sass_Value* To_C::operator()(Argument_Ptr a)
|
68
68
|
{ return a->value()->perform(this); }
|
69
69
|
|
70
70
|
// not strictly necessary because of the fallback
|
71
|
-
union Sass_Value* To_C::operator()(
|
71
|
+
union Sass_Value* To_C::operator()(Null_Ptr n)
|
72
72
|
{ return sass_make_null(); }
|
73
73
|
|
74
74
|
};
|
data/ext/libsass/src/to_c.hpp
CHANGED
@@ -9,28 +9,28 @@ namespace Sass {
|
|
9
9
|
|
10
10
|
class To_C : public Operation_CRTP<union Sass_Value*, To_C> {
|
11
11
|
// override this to define a catch-all
|
12
|
-
union Sass_Value* fallback_impl(
|
12
|
+
union Sass_Value* fallback_impl(AST_Node_Ptr n);
|
13
13
|
|
14
14
|
public:
|
15
15
|
|
16
16
|
To_C() { }
|
17
17
|
~To_C() { }
|
18
18
|
|
19
|
-
union Sass_Value* operator()(
|
20
|
-
union Sass_Value* operator()(
|
21
|
-
union Sass_Value* operator()(
|
22
|
-
union Sass_Value* operator()(
|
23
|
-
union Sass_Value* operator()(
|
24
|
-
union Sass_Value* operator()(
|
25
|
-
union Sass_Value* operator()(
|
26
|
-
union Sass_Value* operator()(
|
27
|
-
union Sass_Value* operator()(
|
28
|
-
union Sass_Value* operator()(
|
29
|
-
union Sass_Value* operator()(
|
30
|
-
union Sass_Value* operator()(
|
19
|
+
union Sass_Value* operator()(Boolean_Ptr);
|
20
|
+
union Sass_Value* operator()(Number_Ptr);
|
21
|
+
union Sass_Value* operator()(Color_Ptr);
|
22
|
+
union Sass_Value* operator()(String_Constant_Ptr);
|
23
|
+
union Sass_Value* operator()(String_Quoted_Ptr);
|
24
|
+
union Sass_Value* operator()(Custom_Warning_Ptr);
|
25
|
+
union Sass_Value* operator()(Custom_Error_Ptr);
|
26
|
+
union Sass_Value* operator()(List_Ptr);
|
27
|
+
union Sass_Value* operator()(Map_Ptr);
|
28
|
+
union Sass_Value* operator()(Null_Ptr);
|
29
|
+
union Sass_Value* operator()(Arguments_Ptr);
|
30
|
+
union Sass_Value* operator()(Argument_Ptr);
|
31
31
|
|
32
32
|
// dispatch to fallback implementation
|
33
|
-
union Sass_Value* fallback(
|
33
|
+
union Sass_Value* fallback(AST_Node_Ptr x)
|
34
34
|
{ return fallback_impl(x); }
|
35
35
|
};
|
36
36
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
namespace Sass {
|
6
6
|
|
7
|
-
|
7
|
+
Value_Ptr To_Value::fallback_impl(AST_Node_Ptr n)
|
8
8
|
{
|
9
9
|
// throw a runtime error if this happens
|
10
10
|
// we want a well defined set of possible nodes
|
@@ -14,92 +14,92 @@ namespace Sass {
|
|
14
14
|
}
|
15
15
|
|
16
16
|
// Custom_Error is a valid value
|
17
|
-
|
17
|
+
Value_Ptr To_Value::operator()(Custom_Error_Ptr e)
|
18
18
|
{
|
19
19
|
return e;
|
20
20
|
}
|
21
21
|
|
22
22
|
// Custom_Warning is a valid value
|
23
|
-
|
23
|
+
Value_Ptr To_Value::operator()(Custom_Warning_Ptr w)
|
24
24
|
{
|
25
25
|
return w;
|
26
26
|
}
|
27
27
|
|
28
28
|
// Boolean is a valid value
|
29
|
-
|
29
|
+
Value_Ptr To_Value::operator()(Boolean_Ptr b)
|
30
30
|
{
|
31
31
|
return b;
|
32
32
|
}
|
33
33
|
|
34
34
|
// Number is a valid value
|
35
|
-
|
35
|
+
Value_Ptr To_Value::operator()(Number_Ptr n)
|
36
36
|
{
|
37
37
|
return n;
|
38
38
|
}
|
39
39
|
|
40
40
|
// Color is a valid value
|
41
|
-
|
41
|
+
Value_Ptr To_Value::operator()(Color_Ptr c)
|
42
42
|
{
|
43
43
|
return c;
|
44
44
|
}
|
45
45
|
|
46
46
|
// String_Constant is a valid value
|
47
|
-
|
47
|
+
Value_Ptr To_Value::operator()(String_Constant_Ptr s)
|
48
48
|
{
|
49
49
|
return s;
|
50
50
|
}
|
51
51
|
|
52
52
|
// String_Quoted is a valid value
|
53
|
-
|
53
|
+
Value_Ptr To_Value::operator()(String_Quoted_Ptr s)
|
54
54
|
{
|
55
55
|
return s;
|
56
56
|
}
|
57
57
|
|
58
58
|
// List is a valid value
|
59
|
-
|
59
|
+
Value_Ptr To_Value::operator()(List_Ptr l)
|
60
60
|
{
|
61
|
-
|
61
|
+
List_Obj ll = SASS_MEMORY_NEW(List,
|
62
62
|
l->pstate(),
|
63
63
|
l->length(),
|
64
64
|
l->separator(),
|
65
65
|
l->is_arglist());
|
66
66
|
for (size_t i = 0, L = l->length(); i < L; ++i) {
|
67
|
-
|
67
|
+
ll->append((*l)[i]->perform(this));
|
68
68
|
}
|
69
|
-
return ll;
|
69
|
+
return ll.detach();
|
70
70
|
}
|
71
71
|
|
72
72
|
// Map is a valid value
|
73
|
-
|
73
|
+
Value_Ptr To_Value::operator()(Map_Ptr m)
|
74
74
|
{
|
75
75
|
return m;
|
76
76
|
}
|
77
77
|
|
78
78
|
// Null is a valid value
|
79
|
-
|
79
|
+
Value_Ptr To_Value::operator()(Null_Ptr n)
|
80
80
|
{
|
81
81
|
return n;
|
82
82
|
}
|
83
83
|
|
84
84
|
// Argument returns its value
|
85
|
-
|
85
|
+
Value_Ptr To_Value::operator()(Argument_Ptr arg)
|
86
86
|
{
|
87
87
|
if (!arg->name().empty()) return 0;
|
88
88
|
return arg->value()->perform(this);
|
89
89
|
}
|
90
90
|
|
91
|
-
//
|
92
|
-
|
91
|
+
// Selector_List is converted to a string
|
92
|
+
Value_Ptr To_Value::operator()(Selector_List_Ptr s)
|
93
93
|
{
|
94
|
-
return SASS_MEMORY_NEW(
|
94
|
+
return SASS_MEMORY_NEW(String_Quoted,
|
95
95
|
s->pstate(),
|
96
96
|
s->to_string(ctx.c_options));
|
97
97
|
}
|
98
98
|
|
99
99
|
// Binary_Expression is converted to a string
|
100
|
-
|
100
|
+
Value_Ptr To_Value::operator()(Binary_Expression_Ptr s)
|
101
101
|
{
|
102
|
-
return SASS_MEMORY_NEW(
|
102
|
+
return SASS_MEMORY_NEW(String_Quoted,
|
103
103
|
s->pstate(),
|
104
104
|
s->to_string(ctx.c_options));
|
105
105
|
}
|