sassc 2.1.0.pre3 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +24 -0
- data/Rakefile +2 -4
- 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.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/{SharedPtr.cpp → shared_ptr.cpp} +2 -2
- data/ext/libsass/src/memory/{SharedPtr.hpp → shared_ptr.hpp} +55 -9
- 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 +11 -13
- data/lib/sassc/native.rb +9 -7
- data/lib/sassc/script.rb +4 -6
- data/lib/sassc/version.rb +1 -1
- data/test/functions_test.rb +38 -1
- data/test/native_test.rb +4 -4
- metadata +31 -18
- 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
data/ext/libsass/src/emitter.cpp
CHANGED
@@ -1,10 +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
5
|
#include "util_string.hpp"
|
7
|
-
#include "
|
6
|
+
#include "util.hpp"
|
8
7
|
|
9
8
|
namespace Sass {
|
10
9
|
|
@@ -27,7 +26,7 @@ namespace Sass {
|
|
27
26
|
{ }
|
28
27
|
|
29
28
|
// return buffer as string
|
30
|
-
|
29
|
+
sass::string Emitter::get_buffer(void)
|
31
30
|
{
|
32
31
|
return wbuf.buffer;
|
33
32
|
}
|
@@ -42,10 +41,10 @@ namespace Sass {
|
|
42
41
|
void Emitter::add_source_index(size_t idx)
|
43
42
|
{ wbuf.smap.source_index.push_back(idx); }
|
44
43
|
|
45
|
-
|
44
|
+
sass::string Emitter::render_srcmap(Context &ctx)
|
46
45
|
{ return wbuf.smap.render_srcmap(ctx); }
|
47
46
|
|
48
|
-
void Emitter::set_filename(const
|
47
|
+
void Emitter::set_filename(const sass::string& str)
|
49
48
|
{ wbuf.smap.file = str; }
|
50
49
|
|
51
50
|
void Emitter::schedule_mapping(const AST_Node* node)
|
@@ -54,7 +53,7 @@ namespace Sass {
|
|
54
53
|
{ wbuf.smap.add_open_mapping(node); }
|
55
54
|
void Emitter::add_close_mapping(const AST_Node* node)
|
56
55
|
{ wbuf.smap.add_close_mapping(node); }
|
57
|
-
|
56
|
+
SourceSpan Emitter::remap(const SourceSpan& pstate)
|
58
57
|
{ return wbuf.smap.remap(pstate); }
|
59
58
|
|
60
59
|
// MAIN BUFFER MANIPULATION
|
@@ -75,7 +74,7 @@ namespace Sass {
|
|
75
74
|
{
|
76
75
|
// check the schedule
|
77
76
|
if (scheduled_linefeed) {
|
78
|
-
|
77
|
+
sass::string linefeeds = "";
|
79
78
|
|
80
79
|
for (size_t i = 0; i < scheduled_linefeed; i++)
|
81
80
|
linefeeds += opt.linefeed;
|
@@ -84,7 +83,7 @@ namespace Sass {
|
|
84
83
|
append_string(linefeeds);
|
85
84
|
|
86
85
|
} else if (scheduled_space) {
|
87
|
-
|
86
|
+
sass::string spaces(scheduled_space, ' ');
|
88
87
|
scheduled_space = 0;
|
89
88
|
append_string(spaces);
|
90
89
|
}
|
@@ -102,7 +101,7 @@ namespace Sass {
|
|
102
101
|
}
|
103
102
|
|
104
103
|
// prepend some text or token to the buffer
|
105
|
-
void Emitter::prepend_string(const
|
104
|
+
void Emitter::prepend_string(const sass::string& text)
|
106
105
|
{
|
107
106
|
// do not adjust mappings for utf8 bom
|
108
107
|
// seems they are not counted in any UA
|
@@ -129,14 +128,14 @@ namespace Sass {
|
|
129
128
|
}
|
130
129
|
|
131
130
|
// append some text or token to the buffer
|
132
|
-
void Emitter::append_string(const
|
131
|
+
void Emitter::append_string(const sass::string& text)
|
133
132
|
{
|
134
133
|
|
135
134
|
// write space/lf
|
136
135
|
flush_schedules();
|
137
136
|
|
138
137
|
if (in_comment) {
|
139
|
-
|
138
|
+
sass::string out = Util::normalize_newlines(text);
|
140
139
|
if (output_style() == COMPACT) {
|
141
140
|
out = comment_to_compact_string(out);
|
142
141
|
}
|
@@ -151,7 +150,7 @@ namespace Sass {
|
|
151
150
|
}
|
152
151
|
|
153
152
|
// append some white-space only text
|
154
|
-
void Emitter::append_wspace(const
|
153
|
+
void Emitter::append_wspace(const sass::string& text)
|
155
154
|
{
|
156
155
|
if (text.empty()) return;
|
157
156
|
if (peek_linefeed(text.c_str())) {
|
@@ -162,7 +161,7 @@ namespace Sass {
|
|
162
161
|
|
163
162
|
// append some text or token to the buffer
|
164
163
|
// this adds source-mappings for node start and end
|
165
|
-
void Emitter::append_token(const
|
164
|
+
void Emitter::append_token(const sass::string& text, const AST_Node* node)
|
166
165
|
{
|
167
166
|
flush_schedules();
|
168
167
|
add_open_mapping(node);
|
@@ -185,7 +184,7 @@ namespace Sass {
|
|
185
184
|
if (in_declaration && in_comma_array) return;
|
186
185
|
if (scheduled_linefeed && indentation)
|
187
186
|
scheduled_linefeed = 1;
|
188
|
-
|
187
|
+
sass::string indent = "";
|
189
188
|
for (size_t i = 0; i < indentation; i++)
|
190
189
|
indent += opt.indent;
|
191
190
|
append_string(indent);
|
data/ext/libsass/src/emitter.hpp
CHANGED
@@ -5,8 +5,6 @@
|
|
5
5
|
// __EXTENSIONS__ fix on Solaris.
|
6
6
|
#include "sass.hpp"
|
7
7
|
|
8
|
-
#include <string>
|
9
|
-
|
10
8
|
#include "sass/base.h"
|
11
9
|
#include "source_map.hpp"
|
12
10
|
#include "ast_fwd_decl.hpp"
|
@@ -23,17 +21,17 @@ namespace Sass {
|
|
23
21
|
protected:
|
24
22
|
OutputBuffer wbuf;
|
25
23
|
public:
|
26
|
-
const
|
24
|
+
const sass::string& buffer(void) { return wbuf.buffer; }
|
27
25
|
const SourceMap smap(void) { return wbuf.smap; }
|
28
26
|
const OutputBuffer output(void) { return wbuf; }
|
29
27
|
// proxy methods for source maps
|
30
28
|
void add_source_index(size_t idx);
|
31
|
-
void set_filename(const
|
29
|
+
void set_filename(const sass::string& str);
|
32
30
|
void add_open_mapping(const AST_Node* node);
|
33
31
|
void add_close_mapping(const AST_Node* node);
|
34
32
|
void schedule_mapping(const AST_Node* node);
|
35
|
-
|
36
|
-
|
33
|
+
sass::string render_srcmap(Context &ctx);
|
34
|
+
SourceSpan remap(const SourceSpan& pstate);
|
37
35
|
|
38
36
|
public:
|
39
37
|
struct Sass_Output_Options& opt;
|
@@ -60,8 +58,8 @@ namespace Sass {
|
|
60
58
|
bool in_comma_array;
|
61
59
|
|
62
60
|
public:
|
63
|
-
// return buffer as
|
64
|
-
|
61
|
+
// return buffer as sass::string
|
62
|
+
sass::string get_buffer(void);
|
65
63
|
// flush scheduled space/linefeed
|
66
64
|
Sass_Output_Style output_style(void) const;
|
67
65
|
// add outstanding linefeed
|
@@ -69,17 +67,17 @@ namespace Sass {
|
|
69
67
|
// flush scheduled space/linefeed
|
70
68
|
void flush_schedules(void);
|
71
69
|
// prepend some text or token to the buffer
|
72
|
-
void prepend_string(const
|
70
|
+
void prepend_string(const sass::string& text);
|
73
71
|
void prepend_output(const OutputBuffer& out);
|
74
72
|
// append some text or token to the buffer
|
75
|
-
void append_string(const
|
73
|
+
void append_string(const sass::string& text);
|
76
74
|
// append a single character to buffer
|
77
75
|
void append_char(const char chr);
|
78
76
|
// append some white-space only text
|
79
|
-
void append_wspace(const
|
77
|
+
void append_wspace(const sass::string& text);
|
80
78
|
// append some text or token to the buffer
|
81
79
|
// this adds source-mappings for node start and end
|
82
|
-
void append_token(const
|
80
|
+
void append_token(const sass::string& text, const AST_Node* node);
|
83
81
|
// query last appended character
|
84
82
|
char last_char();
|
85
83
|
|
@@ -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,7 @@ namespace Sass {
|
|
208
208
|
|
209
209
|
// use array access for getter and setter functions
|
210
210
|
template <typename T>
|
211
|
-
T& Environment<T>::get(const
|
211
|
+
T& Environment<T>::get(const sass::string& key)
|
212
212
|
{
|
213
213
|
auto cur = this;
|
214
214
|
while (cur) {
|
@@ -222,7 +222,7 @@ namespace Sass {
|
|
222
222
|
|
223
223
|
// use array access for getter and setter functions
|
224
224
|
template <typename T>
|
225
|
-
T& Environment<T>::operator[](const
|
225
|
+
T& Environment<T>::operator[](const sass::string& key)
|
226
226
|
{
|
227
227
|
auto cur = this;
|
228
228
|
while (cur) {
|
@@ -236,14 +236,14 @@ namespace Sass {
|
|
236
236
|
/*
|
237
237
|
#ifdef DEBUG
|
238
238
|
template <typename T>
|
239
|
-
size_t Environment<T>::print(
|
239
|
+
size_t Environment<T>::print(sass::string prefix)
|
240
240
|
{
|
241
241
|
size_t indent = 0;
|
242
242
|
if (parent_) indent = parent_->print(prefix) + 1;
|
243
|
-
std::cerr << prefix <<
|
244
|
-
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) {
|
245
245
|
if (!ends_with(i->first, "[f]") && !ends_with(i->first, "[f]4") && !ends_with(i->first, "[f]2")) {
|
246
|
-
std::cerr << prefix <<
|
246
|
+
std::cerr << prefix << sass::string(indent, ' ') << i->first << " " << i->second;
|
247
247
|
if (Value* val = Cast<Value>(i->second))
|
248
248
|
{ std::cerr << " : " << val->to_string(); }
|
249
249
|
std::cerr << std::endl;
|
@@ -1,6 +1,11 @@
|
|
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"
|
@@ -8,7 +13,7 @@
|
|
8
13
|
namespace Sass {
|
9
14
|
|
10
15
|
// this defeats the whole purpose of environment being templatable!!
|
11
|
-
typedef environment_map<
|
16
|
+
typedef environment_map<sass::string, AST_Node_Obj>::iterator EnvIter;
|
12
17
|
|
13
18
|
class EnvResult {
|
14
19
|
public:
|
@@ -22,7 +27,7 @@ namespace Sass {
|
|
22
27
|
template <typename T>
|
23
28
|
class Environment {
|
24
29
|
// TODO: test with map
|
25
|
-
environment_map<
|
30
|
+
environment_map<sass::string, T> local_frame_;
|
26
31
|
ADD_PROPERTY(Environment*, parent)
|
27
32
|
ADD_PROPERTY(bool, is_shadow)
|
28
33
|
|
@@ -47,72 +52,72 @@ namespace Sass {
|
|
47
52
|
|
48
53
|
// scope operates on the current frame
|
49
54
|
|
50
|
-
environment_map<
|
55
|
+
environment_map<sass::string, T>& local_frame();
|
51
56
|
|
52
|
-
bool has_local(const
|
57
|
+
bool has_local(const sass::string& key) const;
|
53
58
|
|
54
|
-
EnvResult find_local(const
|
59
|
+
EnvResult find_local(const sass::string& key);
|
55
60
|
|
56
|
-
T& get_local(const
|
61
|
+
T& get_local(const sass::string& key);
|
57
62
|
|
58
63
|
// set variable on the current frame
|
59
|
-
void set_local(const
|
60
|
-
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);
|
61
66
|
|
62
|
-
void del_local(const
|
67
|
+
void del_local(const sass::string& key);
|
63
68
|
|
64
69
|
// global operates on the global frame
|
65
70
|
// which is the second last on the stack
|
66
71
|
Environment* global_env();
|
67
72
|
// get the env where the variable already exists
|
68
73
|
// if it does not yet exist, we return current env
|
69
|
-
Environment* lexical_env(const
|
74
|
+
Environment* lexical_env(const sass::string& key);
|
70
75
|
|
71
|
-
bool has_global(const
|
76
|
+
bool has_global(const sass::string& key);
|
72
77
|
|
73
|
-
T& get_global(const
|
78
|
+
T& get_global(const sass::string& key);
|
74
79
|
|
75
80
|
// set a variable on the global frame
|
76
|
-
void set_global(const
|
77
|
-
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);
|
78
83
|
|
79
|
-
void del_global(const
|
84
|
+
void del_global(const sass::string& key);
|
80
85
|
|
81
86
|
// see if we have a lexical variable
|
82
87
|
// move down the stack but stop before we
|
83
88
|
// reach the global frame (is not included)
|
84
|
-
bool has_lexical(const
|
89
|
+
bool has_lexical(const sass::string& key) const;
|
85
90
|
|
86
91
|
// see if we have a lexical we could update
|
87
92
|
// either update already existing lexical value
|
88
93
|
// or we create a new one on the current frame
|
89
|
-
void set_lexical(const
|
90
|
-
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);
|
91
96
|
|
92
97
|
// look on the full stack for key
|
93
98
|
// include all scopes available
|
94
|
-
bool has(const
|
99
|
+
bool has(const sass::string& key) const;
|
95
100
|
|
96
101
|
// look on the full stack for key
|
97
102
|
// include all scopes available
|
98
|
-
T& get(const
|
103
|
+
T& get(const sass::string& key);
|
99
104
|
|
100
105
|
// look on the full stack for key
|
101
106
|
// include all scopes available
|
102
|
-
EnvResult find(const
|
107
|
+
EnvResult find(const sass::string& key);
|
103
108
|
|
104
109
|
// use array access for getter and setter functions
|
105
|
-
T& operator[](const
|
110
|
+
T& operator[](const sass::string& key);
|
106
111
|
|
107
112
|
#ifdef DEBUG
|
108
|
-
size_t print(
|
113
|
+
size_t print(sass::string prefix = "");
|
109
114
|
#endif
|
110
115
|
|
111
116
|
};
|
112
117
|
|
113
118
|
// define typedef for our use case
|
114
119
|
typedef Environment<AST_Node_Obj> Env;
|
115
|
-
typedef
|
120
|
+
typedef sass::vector<Env*> EnvStack;
|
116
121
|
|
117
122
|
}
|
118
123
|
|