sassc 2.0.0 → 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/.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/emitter.cpp
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
// sass.hpp must go before all system headers to get the
|
|
2
|
+
// __EXTENSIONS__ fix on Solaris.
|
|
1
3
|
#include "sass.hpp"
|
|
2
|
-
#include "util.hpp"
|
|
3
|
-
#include "context.hpp"
|
|
4
|
-
#include "output.hpp"
|
|
5
4
|
#include "emitter.hpp"
|
|
6
|
-
#include "
|
|
5
|
+
#include "util_string.hpp"
|
|
6
|
+
#include "util.hpp"
|
|
7
7
|
|
|
8
8
|
namespace Sass {
|
|
9
9
|
|
|
@@ -26,7 +26,7 @@ namespace Sass {
|
|
|
26
26
|
{ }
|
|
27
27
|
|
|
28
28
|
// return buffer as string
|
|
29
|
-
|
|
29
|
+
sass::string Emitter::get_buffer(void)
|
|
30
30
|
{
|
|
31
31
|
return wbuf.buffer;
|
|
32
32
|
}
|
|
@@ -41,19 +41,19 @@ namespace Sass {
|
|
|
41
41
|
void Emitter::add_source_index(size_t idx)
|
|
42
42
|
{ wbuf.smap.source_index.push_back(idx); }
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
sass::string Emitter::render_srcmap(Context &ctx)
|
|
45
45
|
{ return wbuf.smap.render_srcmap(ctx); }
|
|
46
46
|
|
|
47
|
-
void Emitter::set_filename(const
|
|
47
|
+
void Emitter::set_filename(const sass::string& str)
|
|
48
48
|
{ wbuf.smap.file = str; }
|
|
49
49
|
|
|
50
|
-
void Emitter::schedule_mapping(const
|
|
50
|
+
void Emitter::schedule_mapping(const AST_Node* node)
|
|
51
51
|
{ scheduled_mapping = node; }
|
|
52
|
-
void Emitter::add_open_mapping(const
|
|
52
|
+
void Emitter::add_open_mapping(const AST_Node* node)
|
|
53
53
|
{ wbuf.smap.add_open_mapping(node); }
|
|
54
|
-
void Emitter::add_close_mapping(const
|
|
54
|
+
void Emitter::add_close_mapping(const AST_Node* node)
|
|
55
55
|
{ wbuf.smap.add_close_mapping(node); }
|
|
56
|
-
|
|
56
|
+
SourceSpan Emitter::remap(const SourceSpan& pstate)
|
|
57
57
|
{ return wbuf.smap.remap(pstate); }
|
|
58
58
|
|
|
59
59
|
// MAIN BUFFER MANIPULATION
|
|
@@ -74,7 +74,7 @@ namespace Sass {
|
|
|
74
74
|
{
|
|
75
75
|
// check the schedule
|
|
76
76
|
if (scheduled_linefeed) {
|
|
77
|
-
|
|
77
|
+
sass::string linefeeds = "";
|
|
78
78
|
|
|
79
79
|
for (size_t i = 0; i < scheduled_linefeed; i++)
|
|
80
80
|
linefeeds += opt.linefeed;
|
|
@@ -83,7 +83,7 @@ namespace Sass {
|
|
|
83
83
|
append_string(linefeeds);
|
|
84
84
|
|
|
85
85
|
} else if (scheduled_space) {
|
|
86
|
-
|
|
86
|
+
sass::string spaces(scheduled_space, ' ');
|
|
87
87
|
scheduled_space = 0;
|
|
88
88
|
append_string(spaces);
|
|
89
89
|
}
|
|
@@ -101,7 +101,7 @@ namespace Sass {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
// prepend some text or token to the buffer
|
|
104
|
-
void Emitter::prepend_string(const
|
|
104
|
+
void Emitter::prepend_string(const sass::string& text)
|
|
105
105
|
{
|
|
106
106
|
// do not adjust mappings for utf8 bom
|
|
107
107
|
// seems they are not counted in any UA
|
|
@@ -128,19 +128,19 @@ namespace Sass {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
// append some text or token to the buffer
|
|
131
|
-
void Emitter::append_string(const
|
|
131
|
+
void Emitter::append_string(const sass::string& text)
|
|
132
132
|
{
|
|
133
133
|
|
|
134
134
|
// write space/lf
|
|
135
135
|
flush_schedules();
|
|
136
136
|
|
|
137
|
-
if (in_comment
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
// account for data in source-maps
|
|
137
|
+
if (in_comment) {
|
|
138
|
+
sass::string out = Util::normalize_newlines(text);
|
|
139
|
+
if (output_style() == COMPACT) {
|
|
140
|
+
out = comment_to_compact_string(out);
|
|
141
|
+
}
|
|
143
142
|
wbuf.smap.append(Offset(out));
|
|
143
|
+
wbuf.buffer += std::move(out);
|
|
144
144
|
} else {
|
|
145
145
|
// add to buffer
|
|
146
146
|
wbuf.buffer += text;
|
|
@@ -150,7 +150,7 @@ namespace Sass {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
// append some white-space only text
|
|
153
|
-
void Emitter::append_wspace(const
|
|
153
|
+
void Emitter::append_wspace(const sass::string& text)
|
|
154
154
|
{
|
|
155
155
|
if (text.empty()) return;
|
|
156
156
|
if (peek_linefeed(text.c_str())) {
|
|
@@ -161,7 +161,7 @@ namespace Sass {
|
|
|
161
161
|
|
|
162
162
|
// append some text or token to the buffer
|
|
163
163
|
// this adds source-mappings for node start and end
|
|
164
|
-
void Emitter::append_token(const
|
|
164
|
+
void Emitter::append_token(const sass::string& text, const AST_Node* node)
|
|
165
165
|
{
|
|
166
166
|
flush_schedules();
|
|
167
167
|
add_open_mapping(node);
|
|
@@ -184,7 +184,7 @@ namespace Sass {
|
|
|
184
184
|
if (in_declaration && in_comma_array) return;
|
|
185
185
|
if (scheduled_linefeed && indentation)
|
|
186
186
|
scheduled_linefeed = 1;
|
|
187
|
-
|
|
187
|
+
sass::string indent = "";
|
|
188
188
|
for (size_t i = 0; i < indentation; i++)
|
|
189
189
|
indent += opt.indent;
|
|
190
190
|
append_string(indent);
|
|
@@ -263,7 +263,7 @@ namespace Sass {
|
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
void Emitter::append_scope_opener(
|
|
266
|
+
void Emitter::append_scope_opener(AST_Node* node)
|
|
267
267
|
{
|
|
268
268
|
scheduled_linefeed = 0;
|
|
269
269
|
append_optional_space();
|
|
@@ -274,7 +274,7 @@ namespace Sass {
|
|
|
274
274
|
// append_optional_space();
|
|
275
275
|
++ indentation;
|
|
276
276
|
}
|
|
277
|
-
void Emitter::append_scope_closer(
|
|
277
|
+
void Emitter::append_scope_closer(AST_Node* node)
|
|
278
278
|
{
|
|
279
279
|
-- indentation;
|
|
280
280
|
scheduled_linefeed = 0;
|
data/ext/libsass/src/emitter.hpp
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
#ifndef SASS_EMITTER_H
|
|
2
2
|
#define SASS_EMITTER_H
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// sass.hpp must go before all system headers to get the
|
|
5
|
+
// __EXTENSIONS__ fix on Solaris.
|
|
5
6
|
#include "sass.hpp"
|
|
7
|
+
|
|
6
8
|
#include "sass/base.h"
|
|
7
9
|
#include "source_map.hpp"
|
|
8
10
|
#include "ast_fwd_decl.hpp"
|
|
@@ -19,17 +21,17 @@ namespace Sass {
|
|
|
19
21
|
protected:
|
|
20
22
|
OutputBuffer wbuf;
|
|
21
23
|
public:
|
|
22
|
-
const
|
|
24
|
+
const sass::string& buffer(void) { return wbuf.buffer; }
|
|
23
25
|
const SourceMap smap(void) { return wbuf.smap; }
|
|
24
26
|
const OutputBuffer output(void) { return wbuf; }
|
|
25
27
|
// proxy methods for source maps
|
|
26
28
|
void add_source_index(size_t idx);
|
|
27
|
-
void set_filename(const
|
|
28
|
-
void add_open_mapping(const
|
|
29
|
-
void add_close_mapping(const
|
|
30
|
-
void schedule_mapping(const
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
void set_filename(const sass::string& str);
|
|
30
|
+
void add_open_mapping(const AST_Node* node);
|
|
31
|
+
void add_close_mapping(const AST_Node* node);
|
|
32
|
+
void schedule_mapping(const AST_Node* node);
|
|
33
|
+
sass::string render_srcmap(Context &ctx);
|
|
34
|
+
SourceSpan remap(const SourceSpan& pstate);
|
|
33
35
|
|
|
34
36
|
public:
|
|
35
37
|
struct Sass_Output_Options& opt;
|
|
@@ -37,8 +39,8 @@ namespace Sass {
|
|
|
37
39
|
size_t scheduled_space;
|
|
38
40
|
size_t scheduled_linefeed;
|
|
39
41
|
bool scheduled_delimiter;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
const AST_Node* scheduled_crutch;
|
|
43
|
+
const AST_Node* scheduled_mapping;
|
|
42
44
|
|
|
43
45
|
public:
|
|
44
46
|
// output strings different in custom css properties
|
|
@@ -56,8 +58,8 @@ namespace Sass {
|
|
|
56
58
|
bool in_comma_array;
|
|
57
59
|
|
|
58
60
|
public:
|
|
59
|
-
// return buffer as
|
|
60
|
-
|
|
61
|
+
// return buffer as sass::string
|
|
62
|
+
sass::string get_buffer(void);
|
|
61
63
|
// flush scheduled space/linefeed
|
|
62
64
|
Sass_Output_Style output_style(void) const;
|
|
63
65
|
// add outstanding linefeed
|
|
@@ -65,17 +67,17 @@ namespace Sass {
|
|
|
65
67
|
// flush scheduled space/linefeed
|
|
66
68
|
void flush_schedules(void);
|
|
67
69
|
// prepend some text or token to the buffer
|
|
68
|
-
void prepend_string(const
|
|
70
|
+
void prepend_string(const sass::string& text);
|
|
69
71
|
void prepend_output(const OutputBuffer& out);
|
|
70
72
|
// append some text or token to the buffer
|
|
71
|
-
void append_string(const
|
|
73
|
+
void append_string(const sass::string& text);
|
|
72
74
|
// append a single character to buffer
|
|
73
75
|
void append_char(const char chr);
|
|
74
76
|
// append some white-space only text
|
|
75
|
-
void append_wspace(const
|
|
77
|
+
void append_wspace(const sass::string& text);
|
|
76
78
|
// append some text or token to the buffer
|
|
77
79
|
// this adds source-mappings for node start and end
|
|
78
|
-
void append_token(const
|
|
80
|
+
void append_token(const sass::string& text, const AST_Node* node);
|
|
79
81
|
// query last appended character
|
|
80
82
|
char last_char();
|
|
81
83
|
|
|
@@ -86,8 +88,8 @@ namespace Sass {
|
|
|
86
88
|
void append_special_linefeed(void);
|
|
87
89
|
void append_optional_linefeed(void);
|
|
88
90
|
void append_mandatory_linefeed(void);
|
|
89
|
-
void append_scope_opener(
|
|
90
|
-
void append_scope_closer(
|
|
91
|
+
void append_scope_opener(AST_Node* node = 0);
|
|
92
|
+
void append_scope_closer(AST_Node* node = 0);
|
|
91
93
|
void append_comma_separator(void);
|
|
92
94
|
void append_colon_separator(void);
|
|
93
95
|
void append_delimiter(void);
|
|
@@ -6,17 +6,17 @@ namespace Sass {
|
|
|
6
6
|
|
|
7
7
|
template <typename T>
|
|
8
8
|
Environment<T>::Environment(bool is_shadow)
|
|
9
|
-
: local_frame_(environment_map<
|
|
9
|
+
: local_frame_(environment_map<sass::string, T>()),
|
|
10
10
|
parent_(0), is_shadow_(false)
|
|
11
11
|
{ }
|
|
12
12
|
template <typename T>
|
|
13
13
|
Environment<T>::Environment(Environment<T>* env, bool is_shadow)
|
|
14
|
-
: local_frame_(environment_map<
|
|
14
|
+
: local_frame_(environment_map<sass::string, T>()),
|
|
15
15
|
parent_(env), is_shadow_(is_shadow)
|
|
16
16
|
{ }
|
|
17
17
|
template <typename T>
|
|
18
18
|
Environment<T>::Environment(Environment<T>& env, bool is_shadow)
|
|
19
|
-
: local_frame_(environment_map<
|
|
19
|
+
: local_frame_(environment_map<sass::string, T>()),
|
|
20
20
|
parent_(&env), is_shadow_(is_shadow)
|
|
21
21
|
{ }
|
|
22
22
|
|
|
@@ -45,16 +45,16 @@ namespace Sass {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
template <typename T>
|
|
48
|
-
environment_map<
|
|
48
|
+
environment_map<sass::string, T>& Environment<T>::local_frame() {
|
|
49
49
|
return local_frame_;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
template <typename T>
|
|
53
|
-
bool Environment<T>::has_local(const
|
|
53
|
+
bool Environment<T>::has_local(const sass::string& key) const
|
|
54
54
|
{ return local_frame_.find(key) != local_frame_.end(); }
|
|
55
55
|
|
|
56
56
|
template <typename T> EnvResult
|
|
57
|
-
Environment<T>::find_local(const
|
|
57
|
+
Environment<T>::find_local(const sass::string& key)
|
|
58
58
|
{
|
|
59
59
|
auto end = local_frame_.end();
|
|
60
60
|
auto it = local_frame_.find(key);
|
|
@@ -62,22 +62,22 @@ namespace Sass {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
template <typename T>
|
|
65
|
-
T& Environment<T>::get_local(const
|
|
65
|
+
T& Environment<T>::get_local(const sass::string& key)
|
|
66
66
|
{ return local_frame_[key]; }
|
|
67
67
|
|
|
68
68
|
template <typename T>
|
|
69
|
-
void Environment<T>::set_local(const
|
|
69
|
+
void Environment<T>::set_local(const sass::string& key, const T& val)
|
|
70
70
|
{
|
|
71
71
|
local_frame_[key] = val;
|
|
72
72
|
}
|
|
73
73
|
template <typename T>
|
|
74
|
-
void Environment<T>::set_local(const
|
|
74
|
+
void Environment<T>::set_local(const sass::string& key, T&& val)
|
|
75
75
|
{
|
|
76
76
|
local_frame_[key] = val;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
template <typename T>
|
|
80
|
-
void Environment<T>::del_local(const
|
|
80
|
+
void Environment<T>::del_local(const sass::string& key)
|
|
81
81
|
{ local_frame_.erase(key); }
|
|
82
82
|
|
|
83
83
|
template <typename T>
|
|
@@ -91,30 +91,30 @@ namespace Sass {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
template <typename T>
|
|
94
|
-
bool Environment<T>::has_global(const
|
|
94
|
+
bool Environment<T>::has_global(const sass::string& key)
|
|
95
95
|
{ return global_env()->has(key); }
|
|
96
96
|
|
|
97
97
|
template <typename T>
|
|
98
|
-
T& Environment<T>::get_global(const
|
|
98
|
+
T& Environment<T>::get_global(const sass::string& key)
|
|
99
99
|
{ return (*global_env())[key]; }
|
|
100
100
|
|
|
101
101
|
template <typename T>
|
|
102
|
-
void Environment<T>::set_global(const
|
|
102
|
+
void Environment<T>::set_global(const sass::string& key, const T& val)
|
|
103
103
|
{
|
|
104
104
|
global_env()->local_frame_[key] = val;
|
|
105
105
|
}
|
|
106
106
|
template <typename T>
|
|
107
|
-
void Environment<T>::set_global(const
|
|
107
|
+
void Environment<T>::set_global(const sass::string& key, T&& val)
|
|
108
108
|
{
|
|
109
109
|
global_env()->local_frame_[key] = val;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
template <typename T>
|
|
113
|
-
void Environment<T>::del_global(const
|
|
113
|
+
void Environment<T>::del_global(const sass::string& key)
|
|
114
114
|
{ global_env()->local_frame_.erase(key); }
|
|
115
115
|
|
|
116
116
|
template <typename T>
|
|
117
|
-
Environment<T>* Environment<T>::lexical_env(const
|
|
117
|
+
Environment<T>* Environment<T>::lexical_env(const sass::string& key)
|
|
118
118
|
{
|
|
119
119
|
Environment* cur = this;
|
|
120
120
|
while (cur) {
|
|
@@ -130,7 +130,7 @@ namespace Sass {
|
|
|
130
130
|
// move down the stack but stop before we
|
|
131
131
|
// reach the global frame (is not included)
|
|
132
132
|
template <typename T>
|
|
133
|
-
bool Environment<T>::has_lexical(const
|
|
133
|
+
bool Environment<T>::has_lexical(const sass::string& key) const
|
|
134
134
|
{
|
|
135
135
|
auto cur = this;
|
|
136
136
|
while (cur->is_lexical()) {
|
|
@@ -144,7 +144,7 @@ namespace Sass {
|
|
|
144
144
|
// either update already existing lexical value
|
|
145
145
|
// or if flag is set, we create one if no lexical found
|
|
146
146
|
template <typename T>
|
|
147
|
-
void Environment<T>::set_lexical(const
|
|
147
|
+
void Environment<T>::set_lexical(const sass::string& key, const T& val)
|
|
148
148
|
{
|
|
149
149
|
Environment<T>* cur = this;
|
|
150
150
|
bool shadow = false;
|
|
@@ -161,7 +161,7 @@ namespace Sass {
|
|
|
161
161
|
}
|
|
162
162
|
// this one moves the value
|
|
163
163
|
template <typename T>
|
|
164
|
-
void Environment<T>::set_lexical(const
|
|
164
|
+
void Environment<T>::set_lexical(const sass::string& key, T&& val)
|
|
165
165
|
{
|
|
166
166
|
Environment<T>* cur = this;
|
|
167
167
|
bool shadow = false;
|
|
@@ -180,7 +180,7 @@ namespace Sass {
|
|
|
180
180
|
// look on the full stack for key
|
|
181
181
|
// include all scopes available
|
|
182
182
|
template <typename T>
|
|
183
|
-
bool Environment<T>::has(const
|
|
183
|
+
bool Environment<T>::has(const sass::string& key) const
|
|
184
184
|
{
|
|
185
185
|
auto cur = this;
|
|
186
186
|
while (cur) {
|
|
@@ -195,7 +195,7 @@ namespace Sass {
|
|
|
195
195
|
// look on the full stack for key
|
|
196
196
|
// include all scopes available
|
|
197
197
|
template <typename T> EnvResult
|
|
198
|
-
Environment<T>::find(const
|
|
198
|
+
Environment<T>::find(const sass::string& key)
|
|
199
199
|
{
|
|
200
200
|
auto cur = this;
|
|
201
201
|
while (true) {
|
|
@@ -208,7 +208,21 @@ namespace Sass {
|
|
|
208
208
|
|
|
209
209
|
// use array access for getter and setter functions
|
|
210
210
|
template <typename T>
|
|
211
|
-
T& Environment<T>::
|
|
211
|
+
T& Environment<T>::get(const sass::string& key)
|
|
212
|
+
{
|
|
213
|
+
auto cur = this;
|
|
214
|
+
while (cur) {
|
|
215
|
+
if (cur->has_local(key)) {
|
|
216
|
+
return cur->get_local(key);
|
|
217
|
+
}
|
|
218
|
+
cur = cur->parent_;
|
|
219
|
+
}
|
|
220
|
+
return get_local(key);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// use array access for getter and setter functions
|
|
224
|
+
template <typename T>
|
|
225
|
+
T& Environment<T>::operator[](const sass::string& key)
|
|
212
226
|
{
|
|
213
227
|
auto cur = this;
|
|
214
228
|
while (cur) {
|
|
@@ -222,15 +236,15 @@ namespace Sass {
|
|
|
222
236
|
/*
|
|
223
237
|
#ifdef DEBUG
|
|
224
238
|
template <typename T>
|
|
225
|
-
size_t Environment<T>::print(
|
|
239
|
+
size_t Environment<T>::print(sass::string prefix)
|
|
226
240
|
{
|
|
227
241
|
size_t indent = 0;
|
|
228
242
|
if (parent_) indent = parent_->print(prefix) + 1;
|
|
229
|
-
std::cerr << prefix <<
|
|
230
|
-
for (typename environment_map<
|
|
243
|
+
std::cerr << prefix << sass::string(indent, ' ') << "== " << this << std::endl;
|
|
244
|
+
for (typename environment_map<sass::string, T>::iterator i = local_frame_.begin(); i != local_frame_.end(); ++i) {
|
|
231
245
|
if (!ends_with(i->first, "[f]") && !ends_with(i->first, "[f]4") && !ends_with(i->first, "[f]2")) {
|
|
232
|
-
std::cerr << prefix <<
|
|
233
|
-
if (
|
|
246
|
+
std::cerr << prefix << sass::string(indent, ' ') << i->first << " " << i->second;
|
|
247
|
+
if (Value* val = Cast<Value>(i->second))
|
|
234
248
|
{ std::cerr << " : " << val->to_string(); }
|
|
235
249
|
std::cerr << std::endl;
|
|
236
250
|
}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
#ifndef SASS_ENVIRONMENT_H
|
|
2
2
|
#define SASS_ENVIRONMENT_H
|
|
3
3
|
|
|
4
|
+
// sass.hpp must go before all system headers to get the
|
|
5
|
+
// __EXTENSIONS__ fix on Solaris.
|
|
6
|
+
#include "sass.hpp"
|
|
7
|
+
|
|
8
|
+
#include <map>
|
|
4
9
|
#include <string>
|
|
5
10
|
#include "ast_fwd_decl.hpp"
|
|
6
11
|
#include "ast_def_macros.hpp"
|
|
7
12
|
|
|
8
13
|
namespace Sass {
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
// this defeats the whole purpose of environment being templatable!!
|
|
16
|
+
typedef environment_map<sass::string, AST_Node_Obj>::iterator EnvIter;
|
|
11
17
|
|
|
12
18
|
class EnvResult {
|
|
13
19
|
public:
|
|
@@ -21,7 +27,7 @@ namespace Sass {
|
|
|
21
27
|
template <typename T>
|
|
22
28
|
class Environment {
|
|
23
29
|
// TODO: test with map
|
|
24
|
-
environment_map<
|
|
30
|
+
environment_map<sass::string, T> local_frame_;
|
|
25
31
|
ADD_PROPERTY(Environment*, parent)
|
|
26
32
|
ADD_PROPERTY(bool, is_shadow)
|
|
27
33
|
|
|
@@ -46,67 +52,72 @@ namespace Sass {
|
|
|
46
52
|
|
|
47
53
|
// scope operates on the current frame
|
|
48
54
|
|
|
49
|
-
environment_map<
|
|
55
|
+
environment_map<sass::string, T>& local_frame();
|
|
50
56
|
|
|
51
|
-
bool has_local(const
|
|
57
|
+
bool has_local(const sass::string& key) const;
|
|
52
58
|
|
|
53
|
-
EnvResult find_local(const
|
|
59
|
+
EnvResult find_local(const sass::string& key);
|
|
54
60
|
|
|
55
|
-
T& get_local(const
|
|
61
|
+
T& get_local(const sass::string& key);
|
|
56
62
|
|
|
57
63
|
// set variable on the current frame
|
|
58
|
-
void set_local(const
|
|
59
|
-
void set_local(const
|
|
64
|
+
void set_local(const sass::string& key, const T& val);
|
|
65
|
+
void set_local(const sass::string& key, T&& val);
|
|
60
66
|
|
|
61
|
-
void del_local(const
|
|
67
|
+
void del_local(const sass::string& key);
|
|
62
68
|
|
|
63
69
|
// global operates on the global frame
|
|
64
70
|
// which is the second last on the stack
|
|
65
71
|
Environment* global_env();
|
|
66
72
|
// get the env where the variable already exists
|
|
67
73
|
// if it does not yet exist, we return current env
|
|
68
|
-
Environment* lexical_env(const
|
|
74
|
+
Environment* lexical_env(const sass::string& key);
|
|
69
75
|
|
|
70
|
-
bool has_global(const
|
|
76
|
+
bool has_global(const sass::string& key);
|
|
71
77
|
|
|
72
|
-
T& get_global(const
|
|
78
|
+
T& get_global(const sass::string& key);
|
|
73
79
|
|
|
74
80
|
// set a variable on the global frame
|
|
75
|
-
void set_global(const
|
|
76
|
-
void set_global(const
|
|
81
|
+
void set_global(const sass::string& key, const T& val);
|
|
82
|
+
void set_global(const sass::string& key, T&& val);
|
|
77
83
|
|
|
78
|
-
void del_global(const
|
|
84
|
+
void del_global(const sass::string& key);
|
|
79
85
|
|
|
80
86
|
// see if we have a lexical variable
|
|
81
87
|
// move down the stack but stop before we
|
|
82
88
|
// reach the global frame (is not included)
|
|
83
|
-
bool has_lexical(const
|
|
89
|
+
bool has_lexical(const sass::string& key) const;
|
|
84
90
|
|
|
85
91
|
// see if we have a lexical we could update
|
|
86
92
|
// either update already existing lexical value
|
|
87
93
|
// or we create a new one on the current frame
|
|
88
|
-
void set_lexical(const
|
|
89
|
-
void set_lexical(const
|
|
94
|
+
void set_lexical(const sass::string& key, T&& val);
|
|
95
|
+
void set_lexical(const sass::string& key, const T& val);
|
|
96
|
+
|
|
97
|
+
// look on the full stack for key
|
|
98
|
+
// include all scopes available
|
|
99
|
+
bool has(const sass::string& key) const;
|
|
90
100
|
|
|
91
101
|
// look on the full stack for key
|
|
92
102
|
// include all scopes available
|
|
93
|
-
|
|
103
|
+
T& get(const sass::string& key);
|
|
94
104
|
|
|
95
105
|
// look on the full stack for key
|
|
96
106
|
// include all scopes available
|
|
97
|
-
EnvResult find(const
|
|
107
|
+
EnvResult find(const sass::string& key);
|
|
98
108
|
|
|
99
109
|
// use array access for getter and setter functions
|
|
100
|
-
T& operator[](const
|
|
110
|
+
T& operator[](const sass::string& key);
|
|
101
111
|
|
|
102
112
|
#ifdef DEBUG
|
|
103
|
-
size_t print(
|
|
113
|
+
size_t print(sass::string prefix = "");
|
|
104
114
|
#endif
|
|
105
115
|
|
|
106
116
|
};
|
|
107
117
|
|
|
108
118
|
// define typedef for our use case
|
|
109
119
|
typedef Environment<AST_Node_Obj> Env;
|
|
120
|
+
typedef sass::vector<Env*> EnvStack;
|
|
110
121
|
|
|
111
122
|
}
|
|
112
123
|
|