sassc 1.8.3 → 1.8.4
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/README.md +3 -1
- data/ext/libsass/.editorconfig +1 -1
- data/ext/libsass/.gitignore +1 -0
- data/ext/libsass/LICENSE +1 -1
- data/ext/libsass/Makefile +20 -14
- data/ext/libsass/Makefile.conf +0 -1
- data/ext/libsass/Readme.md +3 -1
- data/ext/libsass/appveyor.yml +19 -11
- data/ext/libsass/docs/api-importer-example.md +2 -1235
- data/ext/libsass/docs/build-with-autotools.md +10 -0
- data/ext/libsass/docs/build-with-makefiles.md +18 -0
- data/ext/libsass/include/sass/base.h +4 -1
- data/ext/libsass/include/sass/values.h +2 -1
- data/ext/libsass/src/ast.cpp +279 -346
- data/ext/libsass/src/ast.hpp +234 -60
- data/ext/libsass/src/base64vlq.cpp +1 -0
- data/ext/libsass/src/bind.cpp +35 -45
- data/ext/libsass/src/bind.hpp +1 -0
- data/ext/libsass/src/color_maps.cpp +1 -0
- data/ext/libsass/src/constants.cpp +4 -1
- data/ext/libsass/src/constants.hpp +2 -1
- data/ext/libsass/src/context.cpp +41 -31
- data/ext/libsass/src/context.hpp +10 -10
- data/ext/libsass/src/cssize.cpp +7 -4
- data/ext/libsass/src/cssize.hpp +1 -3
- data/ext/libsass/src/debugger.hpp +73 -14
- data/ext/libsass/src/emitter.cpp +37 -25
- data/ext/libsass/src/emitter.hpp +10 -9
- data/ext/libsass/src/environment.cpp +16 -5
- data/ext/libsass/src/environment.hpp +5 -3
- data/ext/libsass/src/error_handling.cpp +91 -14
- data/ext/libsass/src/error_handling.hpp +105 -4
- data/ext/libsass/src/eval.cpp +519 -330
- data/ext/libsass/src/eval.hpp +12 -13
- data/ext/libsass/src/expand.cpp +92 -56
- data/ext/libsass/src/expand.hpp +5 -3
- data/ext/libsass/src/extend.cpp +60 -51
- data/ext/libsass/src/extend.hpp +1 -3
- data/ext/libsass/src/file.cpp +37 -27
- data/ext/libsass/src/functions.cpp +78 -62
- data/ext/libsass/src/functions.hpp +1 -0
- data/ext/libsass/src/inspect.cpp +293 -64
- data/ext/libsass/src/inspect.hpp +2 -0
- data/ext/libsass/src/lexer.cpp +1 -0
- data/ext/libsass/src/listize.cpp +14 -15
- data/ext/libsass/src/listize.hpp +3 -5
- data/ext/libsass/src/memory_manager.cpp +1 -0
- data/ext/libsass/src/node.cpp +2 -3
- data/ext/libsass/src/operation.hpp +70 -71
- data/ext/libsass/src/output.cpp +28 -32
- data/ext/libsass/src/output.hpp +1 -2
- data/ext/libsass/src/parser.cpp +402 -183
- data/ext/libsass/src/parser.hpp +19 -9
- data/ext/libsass/src/plugins.cpp +1 -0
- data/ext/libsass/src/position.cpp +1 -0
- data/ext/libsass/src/prelexer.cpp +134 -56
- data/ext/libsass/src/prelexer.hpp +51 -3
- data/ext/libsass/src/remove_placeholders.cpp +35 -9
- data/ext/libsass/src/remove_placeholders.hpp +4 -3
- data/ext/libsass/src/sass.cpp +1 -0
- data/ext/libsass/src/sass.hpp +129 -0
- data/ext/libsass/src/sass_context.cpp +31 -14
- data/ext/libsass/src/sass_context.hpp +2 -31
- data/ext/libsass/src/sass_functions.cpp +1 -0
- data/ext/libsass/src/sass_interface.cpp +5 -6
- data/ext/libsass/src/sass_util.cpp +1 -2
- data/ext/libsass/src/sass_util.hpp +5 -5
- data/ext/libsass/src/sass_values.cpp +13 -10
- data/ext/libsass/src/source_map.cpp +4 -3
- data/ext/libsass/src/source_map.hpp +2 -2
- data/ext/libsass/src/subset_map.hpp +0 -1
- data/ext/libsass/src/to_c.cpp +1 -0
- data/ext/libsass/src/to_c.hpp +1 -3
- data/ext/libsass/src/to_value.cpp +3 -5
- data/ext/libsass/src/to_value.hpp +1 -1
- data/ext/libsass/src/units.cpp +96 -59
- data/ext/libsass/src/units.hpp +10 -8
- data/ext/libsass/src/utf8_string.cpp +5 -0
- data/ext/libsass/src/util.cpp +23 -156
- data/ext/libsass/src/util.hpp +10 -14
- data/ext/libsass/src/values.cpp +1 -0
- data/ext/libsass/test/test_node.cpp +2 -6
- data/ext/libsass/test/test_selector_difference.cpp +1 -3
- data/ext/libsass/test/test_specificity.cpp +0 -2
- data/ext/libsass/test/test_superselector.cpp +0 -2
- data/ext/libsass/test/test_unification.cpp +1 -3
- data/ext/libsass/win/libsass.targets +18 -5
- data/ext/libsass/win/libsass.vcxproj +9 -7
- data/ext/libsass/win/libsass.vcxproj.filters +148 -106
- data/lib/sassc/version.rb +1 -1
- data/test/engine_test.rb +12 -0
- data/test/native_test.rb +1 -1
- metadata +3 -4
- data/ext/libsass/src/to_string.cpp +0 -48
- data/ext/libsass/src/to_string.hpp +0 -38
data/ext/libsass/src/bind.cpp
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#include "sass.hpp"
|
|
1
2
|
#include "bind.hpp"
|
|
2
3
|
#include "ast.hpp"
|
|
3
4
|
#include "context.hpp"
|
|
@@ -5,14 +6,14 @@
|
|
|
5
6
|
#include <map>
|
|
6
7
|
#include <iostream>
|
|
7
8
|
#include <sstream>
|
|
8
|
-
#include "to_string.hpp"
|
|
9
9
|
|
|
10
10
|
namespace Sass {
|
|
11
11
|
|
|
12
12
|
void bind(std::string type, std::string name, Parameters* ps, Arguments* as, Context* ctx, Env* env, Eval* eval)
|
|
13
13
|
{
|
|
14
14
|
std::string callee(type + " " + name);
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
Listize listize(ctx->mem);
|
|
16
17
|
std::map<std::string, Parameter*> param_map;
|
|
17
18
|
|
|
18
19
|
for (size_t i = 0, L = as->length(); i < L; ++i) {
|
|
@@ -60,18 +61,9 @@ namespace Sass {
|
|
|
60
61
|
if (p->is_rest_parameter()) {
|
|
61
62
|
// The next argument by coincidence provides a rest argument
|
|
62
63
|
if (a->is_rest_argument()) {
|
|
64
|
+
|
|
63
65
|
// We should always get a list for rest arguments
|
|
64
66
|
if (List* rest = dynamic_cast<List*>(a->value())) {
|
|
65
|
-
// arg contains a list
|
|
66
|
-
List* args = rest;
|
|
67
|
-
// make sure it's an arglist
|
|
68
|
-
if (rest->is_arglist()) {
|
|
69
|
-
// can pass it through as it was
|
|
70
|
-
env->local_frame()[p->name()] = args;
|
|
71
|
-
}
|
|
72
|
-
// create a new list and wrap each item as an argument
|
|
73
|
-
// otherwise we will not be able to fetch it again
|
|
74
|
-
else {
|
|
75
67
|
// create a new list object for wrapped items
|
|
76
68
|
List* arglist = SASS_MEMORY_NEW(ctx->mem, List,
|
|
77
69
|
p->pstate(),
|
|
@@ -80,17 +72,20 @@ namespace Sass {
|
|
|
80
72
|
true);
|
|
81
73
|
// wrap each item from list as an argument
|
|
82
74
|
for (Expression* item : rest->elements()) {
|
|
83
|
-
(*
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
75
|
+
if (Argument* arg = dynamic_cast<Argument*>(item)) {
|
|
76
|
+
(*arglist) << SASS_MEMORY_NEW(ctx->mem, Argument, *arg);
|
|
77
|
+
} else {
|
|
78
|
+
(*arglist) << SASS_MEMORY_NEW(ctx->mem, Argument,
|
|
79
|
+
item->pstate(),
|
|
80
|
+
item,
|
|
81
|
+
"",
|
|
82
|
+
false,
|
|
83
|
+
false);
|
|
84
|
+
}
|
|
89
85
|
}
|
|
90
86
|
// assign new arglist to environment
|
|
91
87
|
env->local_frame()[p->name()] = arglist;
|
|
92
88
|
}
|
|
93
|
-
}
|
|
94
89
|
// invalid state
|
|
95
90
|
else {
|
|
96
91
|
throw std::runtime_error("invalid state");
|
|
@@ -127,27 +122,27 @@ namespace Sass {
|
|
|
127
122
|
List* ls = dynamic_cast<List*>(a->value());
|
|
128
123
|
// skip any list completely if empty
|
|
129
124
|
if (ls && ls->empty() && a->is_rest_argument()) continue;
|
|
130
|
-
|
|
131
|
-
if (
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
125
|
+
|
|
126
|
+
if (Argument* arg = dynamic_cast<Argument*>(a->value())) {
|
|
127
|
+
(*arglist) << SASS_MEMORY_NEW(ctx->mem, Argument, *arg);
|
|
128
|
+
}
|
|
129
|
+
// check if we have rest argument
|
|
130
|
+
else if (a->is_rest_argument()) {
|
|
131
|
+
// preserve the list separator from rest args
|
|
132
|
+
if (List* rest = dynamic_cast<List*>(a->value())) {
|
|
133
|
+
arglist->separator(rest->separator());
|
|
134
|
+
|
|
135
|
+
for (size_t i = 0, L = rest->size(); i < L; ++i) {
|
|
139
136
|
(*arglist) << SASS_MEMORY_NEW(ctx->mem, Argument,
|
|
140
|
-
(*
|
|
141
|
-
(*
|
|
137
|
+
(*rest)[i]->pstate(),
|
|
138
|
+
(*rest)[i],
|
|
142
139
|
"",
|
|
143
140
|
false,
|
|
144
141
|
false);
|
|
145
142
|
}
|
|
146
143
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
else if (Argument* arg = dynamic_cast<Argument*>(a->value())) {
|
|
150
|
-
(*arglist) << SASS_MEMORY_NEW(ctx->mem, Argument, *arg);
|
|
144
|
+
// no more arguments
|
|
145
|
+
break;
|
|
151
146
|
}
|
|
152
147
|
// wrap all other value types into Argument
|
|
153
148
|
else {
|
|
@@ -158,15 +153,6 @@ namespace Sass {
|
|
|
158
153
|
false,
|
|
159
154
|
false);
|
|
160
155
|
}
|
|
161
|
-
// check if we have rest argument
|
|
162
|
-
if (a->is_rest_argument()) {
|
|
163
|
-
// preserve the list separator from rest args
|
|
164
|
-
if (List* rest = dynamic_cast<List*>(a->value())) {
|
|
165
|
-
arglist->separator(rest->separator());
|
|
166
|
-
}
|
|
167
|
-
// no more arguments
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
156
|
}
|
|
171
157
|
// assign new arglist to environment
|
|
172
158
|
env->local_frame()[p->name()] = arglist;
|
|
@@ -185,7 +171,7 @@ namespace Sass {
|
|
|
185
171
|
if (!arglist->length()) {
|
|
186
172
|
break;
|
|
187
173
|
} else {
|
|
188
|
-
if (arglist->length()
|
|
174
|
+
if (arglist->length() > LP - ip && !ps->has_rest_parameter()) {
|
|
189
175
|
int arg_count = (arglist->length() + LA - 1);
|
|
190
176
|
std::stringstream msg;
|
|
191
177
|
msg << callee << " takes " << LP;
|
|
@@ -193,6 +179,10 @@ namespace Sass {
|
|
|
193
179
|
msg << " but " << arg_count;
|
|
194
180
|
msg << (arg_count == 1 ? " was passed" : " were passed.");
|
|
195
181
|
deprecated_bind(msg.str(), as->pstate());
|
|
182
|
+
|
|
183
|
+
while (arglist->length() > LP - ip) {
|
|
184
|
+
arglist->elements().erase(arglist->elements().end() - 1);
|
|
185
|
+
}
|
|
196
186
|
}
|
|
197
187
|
}
|
|
198
188
|
// otherwise move one of the rest args into the param, converting to argument if necessary
|
|
@@ -209,6 +199,7 @@ namespace Sass {
|
|
|
209
199
|
if (!arglist->length() || (!arglist->is_arglist() && ip + 1 == LP)) {
|
|
210
200
|
++ia;
|
|
211
201
|
}
|
|
202
|
+
|
|
212
203
|
} else if (a->is_keyword_argument()) {
|
|
213
204
|
Map* argmap = static_cast<Map*>(a->value());
|
|
214
205
|
|
|
@@ -267,7 +258,6 @@ namespace Sass {
|
|
|
267
258
|
// That's only okay if they have default values, or were already bound by
|
|
268
259
|
// named arguments, or if it's a single rest-param.
|
|
269
260
|
for (size_t i = ip; i < LP; ++i) {
|
|
270
|
-
To_String to_string(ctx);
|
|
271
261
|
Parameter* leftover = (*ps)[i];
|
|
272
262
|
// cerr << "env for default params:" << endl;
|
|
273
263
|
// env->print();
|
data/ext/libsass/src/bind.hpp
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#include "sass.hpp"
|
|
1
2
|
#include "constants.hpp"
|
|
2
3
|
|
|
3
4
|
namespace Sass {
|
|
@@ -78,7 +79,7 @@ namespace Sass {
|
|
|
78
79
|
extern const char keyframes_kwd[] = "keyframes";
|
|
79
80
|
extern const char only_kwd[] = "only";
|
|
80
81
|
extern const char rgb_kwd[] = "rgb(";
|
|
81
|
-
extern const char url_kwd[] = "url
|
|
82
|
+
extern const char url_kwd[] = "url";
|
|
82
83
|
// extern const char url_prefix_kwd[] = "url-prefix(";
|
|
83
84
|
extern const char important_kwd[] = "important";
|
|
84
85
|
extern const char pseudo_not_kwd[] = ":not(";
|
|
@@ -86,6 +87,7 @@ namespace Sass {
|
|
|
86
87
|
extern const char odd_kwd[] = "odd";
|
|
87
88
|
extern const char progid_kwd[] = "progid";
|
|
88
89
|
extern const char expression_kwd[] = "expression";
|
|
90
|
+
extern const char calc_fn_kwd[] = "calc";
|
|
89
91
|
extern const char calc_kwd[] = "calc(";
|
|
90
92
|
extern const char moz_calc_kwd[] = "-moz-calc(";
|
|
91
93
|
extern const char webkit_calc_kwd[] = "-webkit-calc(";
|
|
@@ -124,6 +126,7 @@ namespace Sass {
|
|
|
124
126
|
extern const char rbrace[] = "}";
|
|
125
127
|
extern const char rparen[] = ")";
|
|
126
128
|
extern const char sign_chars[] = "-+";
|
|
129
|
+
extern const char op_chars[] = "-+";
|
|
127
130
|
extern const char hyphen[] = "-";
|
|
128
131
|
extern const char ellipsis[] = "...";
|
|
129
132
|
// extern const char url_space_chars[] = " \t\r\n\f";
|
|
@@ -81,7 +81,6 @@ namespace Sass {
|
|
|
81
81
|
extern const char rgb_kwd[];
|
|
82
82
|
extern const char url_kwd[];
|
|
83
83
|
// extern const char url_prefix_kwd[];
|
|
84
|
-
extern const char image_url_kwd[];
|
|
85
84
|
extern const char important_kwd[];
|
|
86
85
|
extern const char pseudo_not_kwd[];
|
|
87
86
|
extern const char even_kwd[];
|
|
@@ -89,6 +88,7 @@ namespace Sass {
|
|
|
89
88
|
extern const char progid_kwd[];
|
|
90
89
|
extern const char expression_kwd[];
|
|
91
90
|
extern const char calc_kwd[];
|
|
91
|
+
extern const char calc_fn_kwd[];
|
|
92
92
|
extern const char moz_calc_kwd[];
|
|
93
93
|
extern const char webkit_calc_kwd[];
|
|
94
94
|
extern const char ms_calc_kwd[];
|
|
@@ -126,6 +126,7 @@ namespace Sass {
|
|
|
126
126
|
extern const char rbrace[];
|
|
127
127
|
extern const char rparen[];
|
|
128
128
|
extern const char sign_chars[];
|
|
129
|
+
extern const char op_chars[];
|
|
129
130
|
extern const char hyphen[];
|
|
130
131
|
extern const char ellipsis[];
|
|
131
132
|
// extern const char url_space_chars[];
|
data/ext/libsass/src/context.cpp
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
#
|
|
2
|
-
#define PATH_SEP ';'
|
|
3
|
-
#else
|
|
4
|
-
#define PATH_SEP ':'
|
|
5
|
-
#endif
|
|
6
|
-
|
|
1
|
+
#include "sass.hpp"
|
|
7
2
|
#include <string>
|
|
8
3
|
#include <cstdlib>
|
|
9
4
|
#include <cstring>
|
|
@@ -28,6 +23,7 @@
|
|
|
28
23
|
#include "extend.hpp"
|
|
29
24
|
#include "remove_placeholders.hpp"
|
|
30
25
|
#include "functions.hpp"
|
|
26
|
+
#include "sass_functions.hpp"
|
|
31
27
|
#include "backtrace.hpp"
|
|
32
28
|
#include "sass2scss.h"
|
|
33
29
|
#include "prelexer.hpp"
|
|
@@ -62,13 +58,14 @@ namespace Sass {
|
|
|
62
58
|
return safe_path == "" ? "stdout" : safe_path;
|
|
63
59
|
}
|
|
64
60
|
|
|
65
|
-
Context::Context(struct Sass_Context
|
|
61
|
+
Context::Context(struct Sass_Context& c_ctx)
|
|
66
62
|
: CWD(File::get_cwd()),
|
|
63
|
+
c_options(c_ctx),
|
|
67
64
|
entry_path(""),
|
|
68
65
|
head_imports(0),
|
|
69
66
|
mem(Memory_Manager()),
|
|
70
67
|
plugins(),
|
|
71
|
-
emitter(
|
|
68
|
+
emitter(c_options),
|
|
72
69
|
|
|
73
70
|
strings(),
|
|
74
71
|
resources(),
|
|
@@ -76,19 +73,17 @@ namespace Sass {
|
|
|
76
73
|
subset_map(),
|
|
77
74
|
import_stack(),
|
|
78
75
|
|
|
79
|
-
c_options (c_ctx),
|
|
80
|
-
|
|
81
76
|
c_headers (std::vector<Sass_Importer_Entry>()),
|
|
82
77
|
c_importers (std::vector<Sass_Importer_Entry>()),
|
|
83
78
|
c_functions (std::vector<Sass_Function_Entry>()),
|
|
84
79
|
|
|
85
|
-
indent (safe_str(c_options
|
|
86
|
-
linefeed (safe_str(c_options
|
|
80
|
+
indent (safe_str(c_options.indent, " ")),
|
|
81
|
+
linefeed (safe_str(c_options.linefeed, "\n")),
|
|
87
82
|
|
|
88
|
-
input_path (make_canonical_path(safe_input(c_options
|
|
89
|
-
output_path (make_canonical_path(safe_output(c_options
|
|
90
|
-
source_map_file (make_canonical_path(safe_str(c_options
|
|
91
|
-
source_map_root (make_canonical_path(safe_str(c_options
|
|
83
|
+
input_path (make_canonical_path(safe_input(c_options.input_path))),
|
|
84
|
+
output_path (make_canonical_path(safe_output(c_options.output_path, input_path))),
|
|
85
|
+
source_map_file (make_canonical_path(safe_str(c_options.source_map_file, ""))),
|
|
86
|
+
source_map_root (make_canonical_path(safe_str(c_options.source_map_root, "")))
|
|
92
87
|
|
|
93
88
|
{
|
|
94
89
|
|
|
@@ -96,10 +91,10 @@ namespace Sass {
|
|
|
96
91
|
include_paths.push_back(CWD);
|
|
97
92
|
|
|
98
93
|
// collect more paths from different options
|
|
99
|
-
collect_include_paths(
|
|
100
|
-
// collect_include_paths(
|
|
101
|
-
collect_plugin_paths(
|
|
102
|
-
// collect_plugin_paths(
|
|
94
|
+
collect_include_paths(c_options.include_path);
|
|
95
|
+
// collect_include_paths(c_options.include_paths);
|
|
96
|
+
collect_plugin_paths(c_options.plugin_path);
|
|
97
|
+
// collect_plugin_paths(c_options.plugin_paths);
|
|
103
98
|
|
|
104
99
|
// load plugins and register custom behaviors
|
|
105
100
|
for(auto plug : plugin_paths) plugins.load_plugins(plug);
|
|
@@ -254,7 +249,7 @@ namespace Sass {
|
|
|
254
249
|
|
|
255
250
|
// register include with resolved path and its content
|
|
256
251
|
// memory of the resources will be freed by us on exit
|
|
257
|
-
void Context::register_resource(const Include& inc, const Resource& res)
|
|
252
|
+
void Context::register_resource(const Include& inc, const Resource& res, ParserState* prstate)
|
|
258
253
|
{
|
|
259
254
|
|
|
260
255
|
// do not parse same resource twice
|
|
@@ -297,6 +292,24 @@ namespace Sass {
|
|
|
297
292
|
strings.push_back(sass_strdup(inc.abs_path.c_str()));
|
|
298
293
|
// create the initial parser state from resource
|
|
299
294
|
ParserState pstate(strings.back(), contents, idx);
|
|
295
|
+
|
|
296
|
+
// check existing import stack for possible recursion
|
|
297
|
+
for (size_t i = 0; i < import_stack.size() - 2; ++i) {
|
|
298
|
+
auto parent = import_stack[i];
|
|
299
|
+
if (std::strcmp(parent->abs_path, import->abs_path) == 0) {
|
|
300
|
+
std::string stack("An @import loop has been found:");
|
|
301
|
+
for (size_t n = 1; n < i + 2; ++n) {
|
|
302
|
+
stack += "\n " + std::string(import_stack[n]->imp_path) +
|
|
303
|
+
" imports " + std::string(import_stack[n+1]->imp_path);
|
|
304
|
+
}
|
|
305
|
+
// implement error throw directly until we
|
|
306
|
+
// decided how to handle full stack traces
|
|
307
|
+
ParserState state = prstate ? *prstate : pstate;
|
|
308
|
+
throw Exception::InvalidSyntax(state, stack, &import_stack);
|
|
309
|
+
// error(stack, prstate ? *prstate : pstate, import_stack);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
300
313
|
// create a parser instance from the given c_str buffer
|
|
301
314
|
Parser p(Parser::from_c_str(contents, *this, pstate));
|
|
302
315
|
// do not yet dispose these buffers
|
|
@@ -344,7 +357,7 @@ namespace Sass {
|
|
|
344
357
|
// the memory buffer returned must be freed by us!
|
|
345
358
|
if (char* contents = read_file(resolved[0].abs_path)) {
|
|
346
359
|
// register the newly resolved file resource
|
|
347
|
-
register_resource(resolved[0], { contents, 0 });
|
|
360
|
+
register_resource(resolved[0], { contents, 0 }, &pstate);
|
|
348
361
|
// return resolved entry
|
|
349
362
|
return resolved[0];
|
|
350
363
|
}
|
|
@@ -365,10 +378,7 @@ namespace Sass {
|
|
|
365
378
|
if (const char* proto = sequence< identifier, exactly<':'>, exactly<'/'>, exactly<'/'> >(imp_path.c_str())) {
|
|
366
379
|
|
|
367
380
|
protocol = std::string(imp_path.c_str(), proto - 3);
|
|
368
|
-
//
|
|
369
|
-
if (protocol.compare("file") && true) {
|
|
370
|
-
|
|
371
|
-
}
|
|
381
|
+
// if (protocol.compare("file") && true) { }
|
|
372
382
|
}
|
|
373
383
|
|
|
374
384
|
// add urls (protocol other than file) and urls without procotol to `urls` member
|
|
@@ -433,7 +443,7 @@ namespace Sass {
|
|
|
433
443
|
// handle error message passed back from custom importer
|
|
434
444
|
// it may (or may not) override the line and column info
|
|
435
445
|
if (const char* err_message = sass_import_get_error_message(include)) {
|
|
436
|
-
if (source || srcmap) register_resource({ importer, uniq_path }, { source, srcmap });
|
|
446
|
+
if (source || srcmap) register_resource({ importer, uniq_path }, { source, srcmap }, &pstate);
|
|
437
447
|
if (line == std::string::npos && column == std::string::npos) error(err_message, pstate);
|
|
438
448
|
else error(err_message, ParserState(ctx_path, source, Position(line, column)));
|
|
439
449
|
}
|
|
@@ -447,7 +457,7 @@ namespace Sass {
|
|
|
447
457
|
// attach information to AST node
|
|
448
458
|
imp->incs().push_back(include);
|
|
449
459
|
// register the resource buffers
|
|
450
|
-
register_resource(include, { source, srcmap });
|
|
460
|
+
register_resource(include, { source, srcmap }, &pstate);
|
|
451
461
|
}
|
|
452
462
|
// only a path was retuned
|
|
453
463
|
// try to load it like normal
|
|
@@ -494,9 +504,9 @@ namespace Sass {
|
|
|
494
504
|
// get the resulting buffer from stream
|
|
495
505
|
OutputBuffer emitted = emitter.get_buffer();
|
|
496
506
|
// should we append a source map url?
|
|
497
|
-
if (!c_options
|
|
507
|
+
if (!c_options.omit_source_map_url) {
|
|
498
508
|
// generate an embeded source map
|
|
499
|
-
if (c_options
|
|
509
|
+
if (c_options.source_map_embed) {
|
|
500
510
|
emitted.buffer += linefeed;
|
|
501
511
|
emitted.buffer += format_embedded_source_map();
|
|
502
512
|
}
|
|
@@ -581,7 +591,7 @@ namespace Sass {
|
|
|
581
591
|
if (!source_c_str) return 0;
|
|
582
592
|
|
|
583
593
|
// convert indented sass syntax
|
|
584
|
-
if(c_options
|
|
594
|
+
if(c_options.is_indented_syntax_src) {
|
|
585
595
|
// call sass2scss to convert the string
|
|
586
596
|
char * converted = sass2scss(source_c_str,
|
|
587
597
|
// preserve the structure as much as possible
|
data/ext/libsass/src/context.hpp
CHANGED
|
@@ -38,6 +38,7 @@ namespace Sass {
|
|
|
38
38
|
|
|
39
39
|
public:
|
|
40
40
|
const std::string CWD;
|
|
41
|
+
struct Sass_Options& c_options;
|
|
41
42
|
std::string entry_path;
|
|
42
43
|
size_t head_imports;
|
|
43
44
|
Memory_Manager mem;
|
|
@@ -53,7 +54,6 @@ namespace Sass {
|
|
|
53
54
|
std::vector<Sass_Import_Entry> import_stack;
|
|
54
55
|
|
|
55
56
|
struct Sass_Compiler* c_compiler;
|
|
56
|
-
struct Sass_Options* c_options;
|
|
57
57
|
|
|
58
58
|
// absolute paths to includes
|
|
59
59
|
std::vector<std::string> included_files;
|
|
@@ -86,17 +86,17 @@ namespace Sass {
|
|
|
86
86
|
const std::string source_map_root; // path for sourceRoot property (pass-through)
|
|
87
87
|
|
|
88
88
|
virtual ~Context();
|
|
89
|
-
Context(struct Sass_Context
|
|
89
|
+
Context(struct Sass_Context&);
|
|
90
90
|
virtual Block* parse() = 0;
|
|
91
91
|
virtual Block* compile();
|
|
92
92
|
virtual char* render(Block* root);
|
|
93
93
|
virtual char* render_srcmap();
|
|
94
94
|
|
|
95
|
-
void register_resource(const Include&, const Resource
|
|
95
|
+
void register_resource(const Include&, const Resource&, ParserState* = 0);
|
|
96
96
|
std::vector<Include> find_includes(const Importer& import);
|
|
97
97
|
Include load_import(const Importer&, ParserState pstate);
|
|
98
98
|
|
|
99
|
-
Sass_Output_Style output_style() { return c_options
|
|
99
|
+
Sass_Output_Style output_style() { return c_options.output_style; };
|
|
100
100
|
std::vector<std::string> get_included_files(bool skip = false, size_t headers = 0);
|
|
101
101
|
|
|
102
102
|
private:
|
|
@@ -119,7 +119,7 @@ namespace Sass {
|
|
|
119
119
|
|
|
120
120
|
class File_Context : public Context {
|
|
121
121
|
public:
|
|
122
|
-
File_Context(struct Sass_File_Context
|
|
122
|
+
File_Context(struct Sass_File_Context& ctx)
|
|
123
123
|
: Context(ctx)
|
|
124
124
|
{ }
|
|
125
125
|
virtual ~File_Context();
|
|
@@ -130,13 +130,13 @@ namespace Sass {
|
|
|
130
130
|
public:
|
|
131
131
|
char* source_c_str;
|
|
132
132
|
char* srcmap_c_str;
|
|
133
|
-
Data_Context(struct Sass_Data_Context
|
|
133
|
+
Data_Context(struct Sass_Data_Context& ctx)
|
|
134
134
|
: Context(ctx)
|
|
135
135
|
{
|
|
136
|
-
source_c_str = ctx
|
|
137
|
-
srcmap_c_str = ctx
|
|
138
|
-
ctx
|
|
139
|
-
ctx
|
|
136
|
+
source_c_str = ctx.source_string;
|
|
137
|
+
srcmap_c_str = ctx.srcmap_string;
|
|
138
|
+
ctx.source_string = 0; // passed away
|
|
139
|
+
ctx.srcmap_string = 0; // passed away
|
|
140
140
|
}
|
|
141
141
|
virtual ~Data_Context();
|
|
142
142
|
virtual Block* parse();
|