sassc 2.2.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +18 -0
- data/Rakefile +1 -3
- data/ext/extconf.rb +13 -5
- data/ext/libsass/VERSION +1 -1
- data/ext/libsass/include/sass/base.h +2 -1
- data/ext/libsass/include/sass/context.h +4 -0
- data/ext/libsass/src/MurmurHash2.hpp +91 -0
- data/ext/libsass/src/ast.cpp +158 -168
- data/ext/libsass/src/ast.hpp +389 -230
- data/ext/libsass/src/ast_def_macros.hpp +18 -10
- data/ext/libsass/src/ast_fwd_decl.cpp +4 -3
- data/ext/libsass/src/ast_fwd_decl.hpp +98 -165
- data/ext/libsass/src/ast_helpers.hpp +292 -0
- data/ext/libsass/src/ast_sel_cmp.cpp +219 -732
- data/ext/libsass/src/ast_sel_super.cpp +539 -0
- data/ext/libsass/src/ast_sel_unify.cpp +207 -212
- data/ext/libsass/src/ast_sel_weave.cpp +616 -0
- data/ext/libsass/src/ast_selectors.cpp +594 -1026
- data/ext/libsass/src/ast_selectors.hpp +339 -385
- data/ext/libsass/src/ast_supports.cpp +36 -52
- data/ext/libsass/src/ast_supports.hpp +29 -29
- data/ext/libsass/src/ast_values.cpp +271 -84
- data/ext/libsass/src/ast_values.hpp +116 -107
- data/ext/libsass/src/backtrace.cpp +9 -9
- data/ext/libsass/src/backtrace.hpp +5 -5
- data/ext/libsass/src/base64vlq.cpp +2 -2
- data/ext/libsass/src/base64vlq.hpp +1 -1
- data/ext/libsass/src/bind.cpp +18 -18
- data/ext/libsass/src/bind.hpp +1 -1
- data/ext/libsass/src/c2ast.cpp +3 -3
- data/ext/libsass/src/c2ast.hpp +1 -1
- data/ext/libsass/src/cencode.c +4 -6
- data/ext/libsass/src/check_nesting.cpp +40 -41
- data/ext/libsass/src/check_nesting.hpp +6 -2
- data/ext/libsass/src/color_maps.cpp +14 -13
- data/ext/libsass/src/color_maps.hpp +1 -9
- data/ext/libsass/src/constants.cpp +5 -0
- data/ext/libsass/src/constants.hpp +6 -0
- data/ext/libsass/src/context.cpp +92 -119
- data/ext/libsass/src/context.hpp +41 -53
- data/ext/libsass/src/cssize.cpp +66 -149
- data/ext/libsass/src/cssize.hpp +17 -23
- data/ext/libsass/src/dart_helpers.hpp +199 -0
- data/ext/libsass/src/debugger.hpp +451 -295
- data/ext/libsass/src/emitter.cpp +15 -16
- data/ext/libsass/src/emitter.hpp +10 -12
- data/ext/libsass/src/environment.cpp +27 -27
- data/ext/libsass/src/environment.hpp +29 -24
- data/ext/libsass/src/error_handling.cpp +62 -41
- data/ext/libsass/src/error_handling.hpp +61 -51
- data/ext/libsass/src/eval.cpp +167 -281
- data/ext/libsass/src/eval.hpp +27 -29
- data/ext/libsass/src/eval_selectors.cpp +75 -0
- data/ext/libsass/src/expand.cpp +275 -222
- data/ext/libsass/src/expand.hpp +36 -16
- 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 +81 -72
- data/ext/libsass/src/file.hpp +28 -37
- data/ext/libsass/src/fn_colors.cpp +20 -18
- data/ext/libsass/src/fn_lists.cpp +30 -29
- data/ext/libsass/src/fn_maps.cpp +3 -3
- data/ext/libsass/src/fn_miscs.cpp +34 -46
- data/ext/libsass/src/fn_numbers.cpp +20 -13
- data/ext/libsass/src/fn_selectors.cpp +98 -128
- data/ext/libsass/src/fn_strings.cpp +47 -33
- data/ext/libsass/src/fn_utils.cpp +31 -29
- data/ext/libsass/src/fn_utils.hpp +17 -11
- data/ext/libsass/src/inspect.cpp +186 -148
- data/ext/libsass/src/inspect.hpp +31 -29
- data/ext/libsass/src/lexer.cpp +20 -82
- data/ext/libsass/src/lexer.hpp +5 -16
- data/ext/libsass/src/listize.cpp +23 -37
- data/ext/libsass/src/listize.hpp +8 -9
- data/ext/libsass/src/mapping.hpp +1 -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/{SharedPtr.cpp → shared_ptr.cpp} +2 -2
- data/ext/libsass/src/memory/{SharedPtr.hpp → shared_ptr.hpp} +55 -9
- data/ext/libsass/src/memory.hpp +12 -0
- data/ext/libsass/src/operation.hpp +71 -61
- data/ext/libsass/src/operators.cpp +19 -18
- data/ext/libsass/src/operators.hpp +11 -11
- data/ext/libsass/src/ordered_map.hpp +112 -0
- data/ext/libsass/src/output.cpp +45 -64
- data/ext/libsass/src/output.hpp +6 -6
- data/ext/libsass/src/parser.cpp +512 -700
- data/ext/libsass/src/parser.hpp +89 -97
- data/ext/libsass/src/parser_selectors.cpp +189 -0
- data/ext/libsass/src/permutate.hpp +164 -0
- data/ext/libsass/src/plugins.cpp +7 -7
- data/ext/libsass/src/plugins.hpp +8 -8
- data/ext/libsass/src/position.cpp +7 -26
- data/ext/libsass/src/position.hpp +44 -21
- data/ext/libsass/src/prelexer.cpp +6 -6
- data/ext/libsass/src/remove_placeholders.cpp +55 -56
- data/ext/libsass/src/remove_placeholders.hpp +21 -18
- data/ext/libsass/src/sass.cpp +16 -15
- data/ext/libsass/src/sass.hpp +10 -5
- data/ext/libsass/src/sass2scss.cpp +4 -4
- data/ext/libsass/src/sass_context.cpp +91 -122
- data/ext/libsass/src/sass_context.hpp +2 -2
- data/ext/libsass/src/sass_functions.cpp +1 -1
- data/ext/libsass/src/sass_values.cpp +8 -11
- 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 +22 -18
- data/ext/libsass/src/source_map.hpp +12 -9
- data/ext/libsass/src/stylesheet.cpp +22 -0
- data/ext/libsass/src/stylesheet.hpp +57 -0
- data/ext/libsass/src/to_value.cpp +2 -2
- data/ext/libsass/src/to_value.hpp +1 -1
- data/ext/libsass/src/units.cpp +24 -22
- data/ext/libsass/src/units.hpp +8 -8
- data/ext/libsass/src/utf8_string.cpp +9 -10
- data/ext/libsass/src/utf8_string.hpp +7 -6
- data/ext/libsass/src/util.cpp +48 -50
- data/ext/libsass/src/util.hpp +20 -21
- data/ext/libsass/src/util_string.cpp +111 -61
- data/ext/libsass/src/util_string.hpp +62 -8
- data/ext/libsass/src/values.cpp +12 -12
- data/lib/sassc/engine.rb +5 -3
- data/lib/sassc/functions_handler.rb +8 -8
- data/lib/sassc/native.rb +4 -6
- data/lib/sassc/script.rb +4 -4
- data/lib/sassc/version.rb +1 -1
- data/test/functions_test.rb +18 -1
- data/test/native_test.rb +4 -4
- metadata +29 -15
- data/ext/libsass/src/extend.cpp +0 -2132
- data/ext/libsass/src/extend.hpp +0 -86
- data/ext/libsass/src/node.cpp +0 -322
- data/ext/libsass/src/node.hpp +0 -118
- data/ext/libsass/src/paths.hpp +0 -71
- data/ext/libsass/src/sass_util.cpp +0 -152
- data/ext/libsass/src/sass_util.hpp +0 -256
- data/ext/libsass/src/subset_map.cpp +0 -58
- data/ext/libsass/src/subset_map.hpp +0 -76
- data/lib/sassc/native/lib_c.rb +0 -21
@@ -2,12 +2,12 @@
|
|
2
2
|
// __EXTENSIONS__ fix on Solaris.
|
3
3
|
#include "sass.hpp"
|
4
4
|
|
5
|
-
#include <cctype>
|
6
5
|
#include <iomanip>
|
7
6
|
#include "ast.hpp"
|
8
7
|
#include "fn_utils.hpp"
|
9
8
|
#include "fn_colors.hpp"
|
10
9
|
#include "util.hpp"
|
10
|
+
#include "util_string.hpp"
|
11
11
|
|
12
12
|
namespace Sass {
|
13
13
|
|
@@ -16,16 +16,16 @@ namespace Sass {
|
|
16
16
|
bool string_argument(AST_Node_Obj obj) {
|
17
17
|
String_Constant* s = Cast<String_Constant>(obj);
|
18
18
|
if (s == nullptr) return false;
|
19
|
-
const
|
19
|
+
const sass::string& str = s->value();
|
20
20
|
return starts_with(str, "calc(") ||
|
21
21
|
starts_with(str, "var(");
|
22
22
|
}
|
23
23
|
|
24
|
-
void hsla_alpha_percent_deprecation(const
|
24
|
+
void hsla_alpha_percent_deprecation(const SourceSpan& pstate, const sass::string val)
|
25
25
|
{
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
sass::string msg("Passing a percentage as the alpha value to hsla() will be interpreted");
|
28
|
+
sass::string tail("differently in future versions of Sass. For now, use " + val + " instead.");
|
29
29
|
|
30
30
|
deprecated(msg, tail, false, pstate);
|
31
31
|
|
@@ -104,7 +104,7 @@ namespace Sass {
|
|
104
104
|
if (
|
105
105
|
string_argument(env["$alpha"])
|
106
106
|
) {
|
107
|
-
|
107
|
+
sass::ostream strm;
|
108
108
|
strm << "rgba("
|
109
109
|
<< (int)c_arg->r() << ", "
|
110
110
|
<< (int)c_arg->g() << ", "
|
@@ -145,7 +145,7 @@ namespace Sass {
|
|
145
145
|
return SASS_MEMORY_NEW(Number, pstate, color->b());
|
146
146
|
}
|
147
147
|
|
148
|
-
Color_RGBA* colormix(Context& ctx,
|
148
|
+
Color_RGBA* colormix(Context& ctx, SourceSpan& pstate, Color* color1, Color* color2, double weight) {
|
149
149
|
Color_RGBA_Obj c1 = color1->toRGBA();
|
150
150
|
Color_RGBA_Obj c2 = color2->toRGBA();
|
151
151
|
double p = weight/100;
|
@@ -163,11 +163,11 @@ namespace Sass {
|
|
163
163
|
c1->a()*p + c2->a()*(1-p));
|
164
164
|
}
|
165
165
|
|
166
|
-
Signature mix_sig = "mix($
|
166
|
+
Signature mix_sig = "mix($color1, $color2, $weight: 50%)";
|
167
167
|
BUILT_IN(mix)
|
168
168
|
{
|
169
|
-
Color_Obj color1 = ARG("$
|
170
|
-
Color_Obj color2 = ARG("$
|
169
|
+
Color_Obj color1 = ARG("$color1", Color);
|
170
|
+
Color_Obj color2 = ARG("$color2", Color);
|
171
171
|
double weight = DARG_U_PRCT("$weight");
|
172
172
|
return colormix(ctx, pstate, color1, color2, weight);
|
173
173
|
|
@@ -230,7 +230,7 @@ namespace Sass {
|
|
230
230
|
Number_Obj val = SASS_MEMORY_COPY(alpha);
|
231
231
|
val->numerators.clear(); // convert
|
232
232
|
val->value(val->value() / 100.0);
|
233
|
-
|
233
|
+
sass::string nr(val->to_string(ctx.c_options));
|
234
234
|
hsla_alpha_percent_deprecation(pstate, nr);
|
235
235
|
}
|
236
236
|
|
@@ -361,12 +361,16 @@ namespace Sass {
|
|
361
361
|
{
|
362
362
|
// CSS3 filter function overload: pass literal through directly
|
363
363
|
Number* amount = Cast<Number>(env["$color"]);
|
364
|
+
double weight = DARG_U_PRCT("$weight");
|
364
365
|
if (amount) {
|
366
|
+
// TODO: does not throw on 100% manually passed as value
|
367
|
+
if (weight < 100.0) {
|
368
|
+
error("Only one argument may be passed to the plain-CSS invert() function.", pstate, traces);
|
369
|
+
}
|
365
370
|
return SASS_MEMORY_NEW(String_Quoted, pstate, "invert(" + amount->to_string(ctx.c_options) + ")");
|
366
371
|
}
|
367
372
|
|
368
373
|
Color* col = ARG("$color", Color);
|
369
|
-
double weight = DARG_U_PRCT("$weight");
|
370
374
|
Color_RGBA_Obj inv = col->copyAsRGBA();
|
371
375
|
inv->r(clip(255.0 - inv->r(), 0.0, 255.0));
|
372
376
|
inv->g(clip(255.0 - inv->g(), 0.0, 255.0));
|
@@ -504,7 +508,7 @@ namespace Sass {
|
|
504
508
|
double lscale = (l ? DARG_R_PRCT("$lightness") : 0.0) / 100.0;
|
505
509
|
double ascale = (a ? DARG_R_PRCT("$alpha") : 0.0) / 100.0;
|
506
510
|
if (hscale) c->h(c->h() + hscale * (hscale > 0.0 ? 360.0 - c->h() : c->h()));
|
507
|
-
if (sscale) c->s(c->s() + sscale * (sscale > 0.0 ? 100.0 - c->
|
511
|
+
if (sscale) c->s(c->s() + sscale * (sscale > 0.0 ? 100.0 - c->s() : c->s()));
|
508
512
|
if (lscale) c->l(c->l() + lscale * (lscale > 0.0 ? 100.0 - c->l() : c->l()));
|
509
513
|
if (ascale) c->a(c->a() + ascale * (ascale > 0.0 ? 1.0 - c->a() : c->a()));
|
510
514
|
return c.detach();
|
@@ -575,17 +579,15 @@ namespace Sass {
|
|
575
579
|
double b = clip(c->b(), 0.0, 255.0);
|
576
580
|
double a = clip(c->a(), 0.0, 1.0) * 255.0;
|
577
581
|
|
578
|
-
|
582
|
+
sass::ostream ss;
|
579
583
|
ss << '#' << std::setw(2) << std::setfill('0');
|
580
584
|
ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(a, ctx.c_options.precision));
|
581
585
|
ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(r, ctx.c_options.precision));
|
582
586
|
ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(g, ctx.c_options.precision));
|
583
587
|
ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(b, ctx.c_options.precision));
|
584
588
|
|
585
|
-
|
586
|
-
|
587
|
-
result[i] = std::toupper(result[i]);
|
588
|
-
}
|
589
|
+
sass::string result = ss.str();
|
590
|
+
Util::ascii_str_toupper(&result);
|
589
591
|
return SASS_MEMORY_NEW(String_Quoted, pstate, result);
|
590
592
|
}
|
591
593
|
|
@@ -1,3 +1,7 @@
|
|
1
|
+
// sass.hpp must go before all system headers to get the
|
2
|
+
// __EXTENSIONS__ fix on Solaris.
|
3
|
+
#include "sass.hpp"
|
4
|
+
|
1
5
|
#include "listize.hpp"
|
2
6
|
#include "operators.hpp"
|
3
7
|
#include "fn_utils.hpp"
|
@@ -17,9 +21,9 @@ namespace Sass {
|
|
17
21
|
List_Obj arglist = SASS_MEMORY_COPY(ARG("$args", List)); // copy
|
18
22
|
Map_Obj result = SASS_MEMORY_NEW(Map, pstate, 1);
|
19
23
|
for (size_t i = arglist->size(), L = arglist->length(); i < L; ++i) {
|
20
|
-
|
24
|
+
ExpressionObj obj = arglist->at(i);
|
21
25
|
Argument_Obj arg = (Argument*) obj.ptr(); // XXX
|
22
|
-
|
26
|
+
sass::string name = sass::string(arg->name());
|
23
27
|
name = name.erase(0, 1); // sanitize name (remove dollar sign)
|
24
28
|
*result << std::make_pair(SASS_MEMORY_NEW(String_Quoted,
|
25
29
|
pstate, name),
|
@@ -31,8 +35,8 @@ namespace Sass {
|
|
31
35
|
Signature length_sig = "length($list)";
|
32
36
|
BUILT_IN(length)
|
33
37
|
{
|
34
|
-
if (
|
35
|
-
return SASS_MEMORY_NEW(Number, pstate, (double)sl->length());
|
38
|
+
if (SelectorList * sl = Cast<SelectorList>(env["$list"])) {
|
39
|
+
return SASS_MEMORY_NEW(Number, pstate, (double) sl->length());
|
36
40
|
}
|
37
41
|
Expression* v = ARG("$list", Expression);
|
38
42
|
if (v->concrete_type() == Expression::MAP) {
|
@@ -40,9 +44,9 @@ namespace Sass {
|
|
40
44
|
return SASS_MEMORY_NEW(Number, pstate, (double)(map ? map->length() : 1));
|
41
45
|
}
|
42
46
|
if (v->concrete_type() == Expression::SELECTOR) {
|
43
|
-
if (
|
47
|
+
if (CompoundSelector * h = Cast<CompoundSelector>(v)) {
|
44
48
|
return SASS_MEMORY_NEW(Number, pstate, (double)h->length());
|
45
|
-
} else if (
|
49
|
+
} else if (SelectorList * ls = Cast<SelectorList>(v)) {
|
46
50
|
return SASS_MEMORY_NEW(Number, pstate, (double)ls->length());
|
47
51
|
} else {
|
48
52
|
return SASS_MEMORY_NEW(Number, pstate, 1);
|
@@ -60,18 +64,16 @@ namespace Sass {
|
|
60
64
|
{
|
61
65
|
double nr = ARGVAL("$n");
|
62
66
|
Map* m = Cast<Map>(env["$list"]);
|
63
|
-
if (
|
67
|
+
if (SelectorList * sl = Cast<SelectorList>(env["$list"])) {
|
64
68
|
size_t len = m ? m->length() : sl->length();
|
65
69
|
bool empty = m ? m->empty() : sl->empty();
|
66
|
-
if (empty) error("argument `$list` of `" +
|
70
|
+
if (empty) error("argument `$list` of `" + sass::string(sig) + "` must not be empty", pstate, traces);
|
67
71
|
double index = std::floor(nr < 0 ? len + nr : nr - 1);
|
68
|
-
if (index < 0 || index > len - 1) error("index out of bounds for `" +
|
69
|
-
|
70
|
-
Listize listize;
|
71
|
-
return Cast<Value>((*sl)[static_cast<int>(index)]->perform(&listize));
|
72
|
+
if (index < 0 || index > len - 1) error("index out of bounds for `" + sass::string(sig) + "`", pstate, traces);
|
73
|
+
return Cast<Value>(Listize::perform(sl->get(static_cast<int>(index))));
|
72
74
|
}
|
73
75
|
List_Obj l = Cast<List>(env["$list"]);
|
74
|
-
if (nr == 0) error("argument `$n` of `" +
|
76
|
+
if (nr == 0) error("argument `$n` of `" + sass::string(sig) + "` must be non-zero", pstate, traces);
|
75
77
|
// if the argument isn't a list, then wrap it in a singleton list
|
76
78
|
if (!m && !l) {
|
77
79
|
l = SASS_MEMORY_NEW(List, pstate, 1);
|
@@ -79,9 +81,9 @@ namespace Sass {
|
|
79
81
|
}
|
80
82
|
size_t len = m ? m->length() : l->length();
|
81
83
|
bool empty = m ? m->empty() : l->empty();
|
82
|
-
if (empty) error("argument `$list` of `" +
|
84
|
+
if (empty) error("argument `$list` of `" + sass::string(sig) + "` must not be empty", pstate, traces);
|
83
85
|
double index = std::floor(nr < 0 ? len + nr : nr - 1);
|
84
|
-
if (index < 0 || index > len - 1) error("index out of bounds for `" +
|
86
|
+
if (index < 0 || index > len - 1) error("index out of bounds for `" + sass::string(sig) + "`", pstate, traces);
|
85
87
|
|
86
88
|
if (m) {
|
87
89
|
l = SASS_MEMORY_NEW(List, pstate, 2);
|
@@ -90,7 +92,7 @@ namespace Sass {
|
|
90
92
|
return l.detach();
|
91
93
|
}
|
92
94
|
else {
|
93
|
-
|
95
|
+
ValueObj rv = l->value_at_index(static_cast<int>(index));
|
94
96
|
rv->set_delayed(false);
|
95
97
|
return rv.detach();
|
96
98
|
}
|
@@ -102,7 +104,7 @@ namespace Sass {
|
|
102
104
|
Map_Obj m = Cast<Map>(env["$list"]);
|
103
105
|
List_Obj l = Cast<List>(env["$list"]);
|
104
106
|
Number_Obj n = ARG("$n", Number);
|
105
|
-
|
107
|
+
ExpressionObj v = ARG("$value", Expression);
|
106
108
|
if (!l) {
|
107
109
|
l = SASS_MEMORY_NEW(List, pstate, 1);
|
108
110
|
l->append(ARG("$list", Expression));
|
@@ -110,9 +112,9 @@ namespace Sass {
|
|
110
112
|
if (m) {
|
111
113
|
l = m->to_list(pstate);
|
112
114
|
}
|
113
|
-
if (l->empty()) error("argument `$list` of `" +
|
115
|
+
if (l->empty()) error("argument `$list` of `" + sass::string(sig) + "` must not be empty", pstate, traces);
|
114
116
|
double index = std::floor(n->value() < 0 ? l->length() + n->value() : n->value() - 1);
|
115
|
-
if (index < 0 || index > l->length() - 1) error("index out of bounds for `" +
|
117
|
+
if (index < 0 || index > l->length() - 1) error("index out of bounds for `" + sass::string(sig) + "`", pstate, traces);
|
116
118
|
List* result = SASS_MEMORY_NEW(List, pstate, l->length(), l->separator(), false, l->is_bracketed());
|
117
119
|
for (size_t i = 0, L = l->length(); i < L; ++i) {
|
118
120
|
result->append(((i == index) ? v : (*l)[i]));
|
@@ -125,7 +127,7 @@ namespace Sass {
|
|
125
127
|
{
|
126
128
|
Map_Obj m = Cast<Map>(env["$list"]);
|
127
129
|
List_Obj l = Cast<List>(env["$list"]);
|
128
|
-
|
130
|
+
ExpressionObj v = ARG("$value", Expression);
|
129
131
|
if (!l) {
|
130
132
|
l = SASS_MEMORY_NEW(List, pstate, 1);
|
131
133
|
l->append(ARG("$list", Expression));
|
@@ -168,10 +170,10 @@ namespace Sass {
|
|
168
170
|
l2 = m2->to_list(pstate);
|
169
171
|
}
|
170
172
|
size_t len = l1->length() + l2->length();
|
171
|
-
|
173
|
+
sass::string sep_str = unquote(sep->value());
|
172
174
|
if (sep_str == "space") sep_val = SASS_SPACE;
|
173
175
|
else if (sep_str == "comma") sep_val = SASS_COMMA;
|
174
|
-
else if (sep_str != "auto") error("argument `$separator` of `" +
|
176
|
+
else if (sep_str != "auto") error("argument `$separator` of `" + sass::string(sig) + "` must be `space`, `comma`, or `auto`", pstate, traces);
|
175
177
|
String_Constant_Obj bracketed_as_str = Cast<String_Constant>(bracketed);
|
176
178
|
bool bracketed_is_auto = bracketed_as_str && unquote(bracketed_as_str->value()) == "auto";
|
177
179
|
if (!bracketed_is_auto) {
|
@@ -188,10 +190,9 @@ namespace Sass {
|
|
188
190
|
{
|
189
191
|
Map_Obj m = Cast<Map>(env["$list"]);
|
190
192
|
List_Obj l = Cast<List>(env["$list"]);
|
191
|
-
|
192
|
-
if (
|
193
|
-
Listize
|
194
|
-
l = Cast<List>(sl->perform(&listize));
|
193
|
+
ExpressionObj v = ARG("$val", Expression);
|
194
|
+
if (SelectorList * sl = Cast<SelectorList>(env["$list"])) {
|
195
|
+
l = Cast<List>(Listize::perform(sl));
|
195
196
|
}
|
196
197
|
String_Constant_Obj sep = ARG("$separator", String_Constant);
|
197
198
|
if (!l) {
|
@@ -202,11 +203,11 @@ namespace Sass {
|
|
202
203
|
l = m->to_list(pstate);
|
203
204
|
}
|
204
205
|
List* result = SASS_MEMORY_COPY(l);
|
205
|
-
|
206
|
+
sass::string sep_str(unquote(sep->value()));
|
206
207
|
if (sep_str != "auto") { // check default first
|
207
208
|
if (sep_str == "space") result->separator(SASS_SPACE);
|
208
209
|
else if (sep_str == "comma") result->separator(SASS_COMMA);
|
209
|
-
else error("argument `$separator` of `" +
|
210
|
+
else error("argument `$separator` of `" + sass::string(sig) + "` must be `space`, `comma`, or `auto`", pstate, traces);
|
210
211
|
}
|
211
212
|
if (l->is_arglist()) {
|
212
213
|
result->append(SASS_MEMORY_NEW(Argument,
|
@@ -274,7 +275,7 @@ namespace Sass {
|
|
274
275
|
Signature is_bracketed_sig = "is-bracketed($list)";
|
275
276
|
BUILT_IN(is_bracketed)
|
276
277
|
{
|
277
|
-
|
278
|
+
ValueObj value = ARG("$list", Value);
|
278
279
|
List_Obj list = Cast<List>(value);
|
279
280
|
return SASS_MEMORY_NEW(Boolean, pstate, list && list->is_bracketed());
|
280
281
|
}
|
data/ext/libsass/src/fn_maps.cpp
CHANGED
@@ -16,9 +16,9 @@ namespace Sass {
|
|
16
16
|
// leaks for "map-get((), foo)" if not Obj
|
17
17
|
// investigate why this is (unexpected)
|
18
18
|
Map_Obj m = ARGM("$map", Map);
|
19
|
-
|
19
|
+
ExpressionObj v = ARG("$key", Expression);
|
20
20
|
try {
|
21
|
-
|
21
|
+
ValueObj val = m->at(v);
|
22
22
|
if (!val) return SASS_MEMORY_NEW(Null, pstate);
|
23
23
|
val->set_delayed(false);
|
24
24
|
return val.detach();
|
@@ -32,7 +32,7 @@ namespace Sass {
|
|
32
32
|
BUILT_IN(map_has_key)
|
33
33
|
{
|
34
34
|
Map_Obj m = ARGM("$map", Map);
|
35
|
-
|
35
|
+
ExpressionObj v = ARG("$key", Expression);
|
36
36
|
return SASS_MEMORY_NEW(Boolean, pstate, m->has(v));
|
37
37
|
}
|
38
38
|
|
@@ -8,15 +8,6 @@ namespace Sass {
|
|
8
8
|
|
9
9
|
namespace Functions {
|
10
10
|
|
11
|
-
// features
|
12
|
-
static std::set<std::string> features {
|
13
|
-
"global-variable-shadowing",
|
14
|
-
"extend-selector-pseudoclass",
|
15
|
-
"at-error",
|
16
|
-
"units-level-3",
|
17
|
-
"custom-property"
|
18
|
-
};
|
19
|
-
|
20
11
|
//////////////////////////
|
21
12
|
// INTROSPECTION FUNCTIONS
|
22
13
|
//////////////////////////
|
@@ -31,7 +22,7 @@ namespace Sass {
|
|
31
22
|
Signature variable_exists_sig = "variable-exists($name)";
|
32
23
|
BUILT_IN(variable_exists)
|
33
24
|
{
|
34
|
-
|
25
|
+
sass::string s = Util::normalize_underscores(unquote(ARG("$name", String_Constant)->value()));
|
35
26
|
|
36
27
|
if(d_env.has("$"+s)) {
|
37
28
|
return SASS_MEMORY_NEW(Boolean, pstate, true);
|
@@ -44,7 +35,7 @@ namespace Sass {
|
|
44
35
|
Signature global_variable_exists_sig = "global-variable-exists($name)";
|
45
36
|
BUILT_IN(global_variable_exists)
|
46
37
|
{
|
47
|
-
|
38
|
+
sass::string s = Util::normalize_underscores(unquote(ARG("$name", String_Constant)->value()));
|
48
39
|
|
49
40
|
if(d_env.has_global("$"+s)) {
|
50
41
|
return SASS_MEMORY_NEW(Boolean, pstate, true);
|
@@ -62,7 +53,7 @@ namespace Sass {
|
|
62
53
|
error("$name: " + (env["$name"]->to_string()) + " is not a string for `function-exists'", pstate, traces);
|
63
54
|
}
|
64
55
|
|
65
|
-
|
56
|
+
sass::string name = Util::normalize_underscores(unquote(ss->value()));
|
66
57
|
|
67
58
|
if(d_env.has(name+"[f]")) {
|
68
59
|
return SASS_MEMORY_NEW(Boolean, pstate, true);
|
@@ -75,7 +66,7 @@ namespace Sass {
|
|
75
66
|
Signature mixin_exists_sig = "mixin-exists($name)";
|
76
67
|
BUILT_IN(mixin_exists)
|
77
68
|
{
|
78
|
-
|
69
|
+
sass::string s = Util::normalize_underscores(unquote(ARG("$name", String_Constant)->value()));
|
79
70
|
|
80
71
|
if(d_env.has(s+"[m]")) {
|
81
72
|
return SASS_MEMORY_NEW(Boolean, pstate, true);
|
@@ -85,52 +76,54 @@ namespace Sass {
|
|
85
76
|
}
|
86
77
|
}
|
87
78
|
|
88
|
-
Signature feature_exists_sig = "feature-exists($
|
79
|
+
Signature feature_exists_sig = "feature-exists($feature)";
|
89
80
|
BUILT_IN(feature_exists)
|
90
81
|
{
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
82
|
+
sass::string s = unquote(ARG("$feature", String_Constant)->value());
|
83
|
+
|
84
|
+
static const auto *const features = new std::unordered_set<sass::string> {
|
85
|
+
"global-variable-shadowing",
|
86
|
+
"extend-selector-pseudoclass",
|
87
|
+
"at-error",
|
88
|
+
"units-level-3",
|
89
|
+
"custom-property"
|
90
|
+
};
|
91
|
+
return SASS_MEMORY_NEW(Boolean, pstate, features->find(s) != features->end());
|
99
92
|
}
|
100
93
|
|
101
|
-
Signature call_sig = "call($
|
94
|
+
Signature call_sig = "call($function, $args...)";
|
102
95
|
BUILT_IN(call)
|
103
96
|
{
|
104
|
-
|
105
|
-
Function* ff = Cast<Function>(env["$
|
106
|
-
String_Constant* ss = Cast<String_Constant>(env["$
|
97
|
+
sass::string function;
|
98
|
+
Function* ff = Cast<Function>(env["$function"]);
|
99
|
+
String_Constant* ss = Cast<String_Constant>(env["$function"]);
|
107
100
|
|
108
101
|
if (ss) {
|
109
|
-
|
102
|
+
function = Util::normalize_underscores(unquote(ss->value()));
|
110
103
|
std::cerr << "DEPRECATION WARNING: ";
|
111
104
|
std::cerr << "Passing a string to call() is deprecated and will be illegal" << std::endl;
|
112
|
-
std::cerr << "in Sass 4.0. Use call(get-function(" + quote(
|
105
|
+
std::cerr << "in Sass 4.0. Use call(get-function(" + quote(function) + ")) instead." << std::endl;
|
113
106
|
std::cerr << std::endl;
|
114
107
|
} else if (ff) {
|
115
|
-
|
108
|
+
function = ff->name();
|
116
109
|
}
|
117
110
|
|
118
111
|
List_Obj arglist = SASS_MEMORY_COPY(ARG("$args", List));
|
119
112
|
|
120
113
|
Arguments_Obj args = SASS_MEMORY_NEW(Arguments, pstate);
|
121
|
-
//
|
114
|
+
// sass::string full_name(name + "[f]");
|
122
115
|
// Definition* def = d_env.has(full_name) ? Cast<Definition>((d_env)[full_name]) : 0;
|
123
116
|
// Parameters* params = def ? def->parameters() : 0;
|
124
117
|
// size_t param_size = params ? params->length() : 0;
|
125
118
|
for (size_t i = 0, L = arglist->length(); i < L; ++i) {
|
126
|
-
|
119
|
+
ExpressionObj expr = arglist->value_at_index(i);
|
127
120
|
// if (params && params->has_rest_parameter()) {
|
128
121
|
// Parameter_Obj p = param_size > i ? (*params)[i] : 0;
|
129
122
|
// List* list = Cast<List>(expr);
|
130
123
|
// if (list && p && !p->is_rest_parameter()) expr = (*list)[0];
|
131
124
|
// }
|
132
125
|
if (arglist->is_arglist()) {
|
133
|
-
|
126
|
+
ExpressionObj obj = arglist->at(i);
|
134
127
|
Argument_Obj arg = (Argument*) obj.ptr(); // XXX
|
135
128
|
args->append(SASS_MEMORY_NEW(Argument,
|
136
129
|
pstate,
|
@@ -142,8 +135,9 @@ namespace Sass {
|
|
142
135
|
args->append(SASS_MEMORY_NEW(Argument, pstate, expr));
|
143
136
|
}
|
144
137
|
}
|
145
|
-
Function_Call_Obj func = SASS_MEMORY_NEW(Function_Call, pstate,
|
146
|
-
|
138
|
+
Function_Call_Obj func = SASS_MEMORY_NEW(Function_Call, pstate, function, args);
|
139
|
+
|
140
|
+
Expand expand(ctx, &d_env, &selector_stack, &original_stack);
|
147
141
|
func->via_call(true); // calc invoke is allowed
|
148
142
|
if (ff) func->func(ff);
|
149
143
|
return Cast<PreValue>(func->perform(&expand.eval));
|
@@ -160,15 +154,13 @@ namespace Sass {
|
|
160
154
|
}
|
161
155
|
|
162
156
|
Signature if_sig = "if($condition, $if-true, $if-false)";
|
163
|
-
// BUILT_IN(sass_if)
|
164
|
-
// { return ARG("$condition", Expression)->is_false() ? ARG("$if-false", Expression) : ARG("$if-true", Expression); }
|
165
157
|
BUILT_IN(sass_if)
|
166
158
|
{
|
167
|
-
Expand expand(ctx, &d_env, &selector_stack);
|
168
|
-
|
159
|
+
Expand expand(ctx, &d_env, &selector_stack, &original_stack);
|
160
|
+
ExpressionObj cond = ARG("$condition", Expression)->perform(&expand.eval);
|
169
161
|
bool is_true = !cond->is_false();
|
170
|
-
|
171
|
-
|
162
|
+
ExpressionObj res = ARG(is_true ? "$if-true" : "$if-false", Expression);
|
163
|
+
ValueObj qwe = Cast<Value>(res->perform(&expand.eval));
|
172
164
|
// res = res->perform(&expand.eval.val_eval);
|
173
165
|
qwe->set_delayed(false); // clone?
|
174
166
|
return qwe.detach();
|
@@ -178,9 +170,6 @@ namespace Sass {
|
|
178
170
|
// MISCELLANEOUS FUNCTIONS
|
179
171
|
//////////////////////////
|
180
172
|
|
181
|
-
// value.check_deprecated_interp if value.is_a?(Sass::Script::Value::String)
|
182
|
-
// unquoted_string(value.to_sass)
|
183
|
-
|
184
173
|
Signature inspect_sig = "inspect($value)";
|
185
174
|
BUILT_IN(inspect)
|
186
175
|
{
|
@@ -208,7 +197,6 @@ namespace Sass {
|
|
208
197
|
ctx.c_options.output_style = old_style;
|
209
198
|
return SASS_MEMORY_NEW(String_Quoted, pstate, i.get_buffer());
|
210
199
|
}
|
211
|
-
// return v;
|
212
200
|
}
|
213
201
|
|
214
202
|
Signature content_exists_sig = "content-exists()";
|
@@ -228,8 +216,8 @@ namespace Sass {
|
|
228
216
|
error("$name: " + (env["$name"]->to_string()) + " is not a string for `get-function'", pstate, traces);
|
229
217
|
}
|
230
218
|
|
231
|
-
|
232
|
-
|
219
|
+
sass::string name = Util::normalize_underscores(unquote(ss->value()));
|
220
|
+
sass::string full_name = name + "[f]";
|
233
221
|
|
234
222
|
Boolean_Obj css = ARG("$css", Boolean);
|
235
223
|
if (!css->is_false()) {
|
@@ -5,7 +5,6 @@
|
|
5
5
|
#include <cstdint>
|
6
6
|
#include <cstdlib>
|
7
7
|
#include <cmath>
|
8
|
-
#include <cctype>
|
9
8
|
#include <random>
|
10
9
|
#include <sstream>
|
11
10
|
#include <iomanip>
|
@@ -61,7 +60,7 @@ namespace Sass {
|
|
61
60
|
BUILT_IN(percentage)
|
62
61
|
{
|
63
62
|
Number_Obj n = ARGN("$number");
|
64
|
-
if (!n->is_unitless()) error("argument $number of `" +
|
63
|
+
if (!n->is_unitless()) error("argument $number of `" + sass::string(sig) + "` must be unitless", pstate, traces);
|
65
64
|
return SASS_MEMORY_NEW(Number, pstate, n->value() * 100, "%");
|
66
65
|
}
|
67
66
|
|
@@ -106,8 +105,12 @@ namespace Sass {
|
|
106
105
|
{
|
107
106
|
List* arglist = ARG("$numbers", List);
|
108
107
|
Number_Obj least;
|
109
|
-
|
110
|
-
|
108
|
+
size_t L = arglist->length();
|
109
|
+
if (L == 0) {
|
110
|
+
error("At least one argument must be passed.", pstate, traces);
|
111
|
+
}
|
112
|
+
for (size_t i = 0; i < L; ++i) {
|
113
|
+
ExpressionObj val = arglist->value_at_index(i);
|
111
114
|
Number_Obj xi = Cast<Number>(val);
|
112
115
|
if (!xi) {
|
113
116
|
error("\"" + val->to_string(ctx.c_options) + "\" is not a number for `min'", pstate, traces);
|
@@ -124,8 +127,12 @@ namespace Sass {
|
|
124
127
|
{
|
125
128
|
List* arglist = ARG("$numbers", List);
|
126
129
|
Number_Obj greatest;
|
127
|
-
|
128
|
-
|
130
|
+
size_t L = arglist->length();
|
131
|
+
if (L == 0) {
|
132
|
+
error("At least one argument must be passed.", pstate, traces);
|
133
|
+
}
|
134
|
+
for (size_t i = 0; i < L; ++i) {
|
135
|
+
ExpressionObj val = arglist->value_at_index(i);
|
129
136
|
Number_Obj xi = Cast<Number>(val);
|
130
137
|
if (!xi) {
|
131
138
|
error("\"" + val->to_string(ctx.c_options) + "\" is not a number for `max'", pstate, traces);
|
@@ -147,13 +154,13 @@ namespace Sass {
|
|
147
154
|
if (l) {
|
148
155
|
double lv = l->value();
|
149
156
|
if (lv < 1) {
|
150
|
-
|
157
|
+
sass::ostream err;
|
151
158
|
err << "$limit " << lv << " must be greater than or equal to 1 for `random'";
|
152
159
|
error(err.str(), pstate, traces);
|
153
160
|
}
|
154
161
|
bool eq_int = std::fabs(trunc(lv) - lv) < NUMBER_EPSILON;
|
155
162
|
if (!eq_int) {
|
156
|
-
|
163
|
+
sass::ostream err;
|
157
164
|
err << "Expected $limit to be an integer but got " << lv << " for `random'";
|
158
165
|
error(err.str(), pstate, traces);
|
159
166
|
}
|
@@ -177,7 +184,7 @@ namespace Sass {
|
|
177
184
|
Signature unique_id_sig = "unique-id()";
|
178
185
|
BUILT_IN(unique_id)
|
179
186
|
{
|
180
|
-
|
187
|
+
sass::ostream ss;
|
181
188
|
std::uniform_real_distribution<> distributor(0, 4294967296); // 16^8
|
182
189
|
uint_fast32_t distributed = static_cast<uint_fast32_t>(distributor(rand));
|
183
190
|
ss << "u" << std::setfill('0') << std::setw(8) << std::hex << distributed;
|
@@ -188,7 +195,7 @@ namespace Sass {
|
|
188
195
|
BUILT_IN(unit)
|
189
196
|
{
|
190
197
|
Number_Obj arg = ARGN("$number");
|
191
|
-
|
198
|
+
sass::string str(quote(arg->unit(), '"'));
|
192
199
|
return SASS_MEMORY_NEW(String_Quoted, pstate, str);
|
193
200
|
}
|
194
201
|
|
@@ -200,11 +207,11 @@ namespace Sass {
|
|
200
207
|
return SASS_MEMORY_NEW(Boolean, pstate, unitless);
|
201
208
|
}
|
202
209
|
|
203
|
-
Signature comparable_sig = "comparable($
|
210
|
+
Signature comparable_sig = "comparable($number1, $number2)";
|
204
211
|
BUILT_IN(comparable)
|
205
212
|
{
|
206
|
-
Number_Obj n1 = ARGN("$
|
207
|
-
Number_Obj n2 = ARGN("$
|
213
|
+
Number_Obj n1 = ARGN("$number1");
|
214
|
+
Number_Obj n2 = ARGN("$number2");
|
208
215
|
if (n1->is_unitless() || n2->is_unitless()) {
|
209
216
|
return SASS_MEMORY_NEW(Boolean, pstate, true);
|
210
217
|
}
|