sassc 2.3.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/.travis.yml +1 -0
- data/CHANGELOG.md +5 -0
- data/ext/libsass/VERSION +1 -1
- data/ext/libsass/include/sass/context.h +3 -0
- data/ext/libsass/src/MurmurHash2.hpp +91 -0
- data/ext/libsass/src/ast.cpp +117 -117
- data/ext/libsass/src/ast.hpp +160 -162
- data/ext/libsass/src/ast_def_macros.hpp +10 -10
- data/ext/libsass/src/ast_fwd_decl.cpp +2 -2
- data/ext/libsass/src/ast_fwd_decl.hpp +61 -52
- data/ext/libsass/src/ast_helpers.hpp +5 -5
- data/ext/libsass/src/ast_sel_cmp.cpp +18 -18
- data/ext/libsass/src/ast_sel_super.cpp +52 -52
- data/ext/libsass/src/ast_sel_unify.cpp +16 -16
- data/ext/libsass/src/ast_sel_weave.cpp +62 -62
- data/ext/libsass/src/ast_selectors.cpp +87 -77
- data/ext/libsass/src/ast_selectors.hpp +72 -62
- data/ext/libsass/src/ast_supports.cpp +35 -35
- data/ext/libsass/src/ast_supports.hpp +29 -29
- data/ext/libsass/src/ast_values.cpp +58 -58
- data/ext/libsass/src/ast_values.hpp +75 -75
- 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 +17 -17
- 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/check_nesting.cpp +36 -36
- data/ext/libsass/src/check_nesting.hpp +2 -2
- data/ext/libsass/src/color_maps.cpp +5 -5
- data/ext/libsass/src/color_maps.hpp +1 -1
- data/ext/libsass/src/context.cpp +63 -60
- data/ext/libsass/src/context.hpp +33 -33
- data/ext/libsass/src/cssize.cpp +30 -29
- data/ext/libsass/src/cssize.hpp +13 -13
- data/ext/libsass/src/dart_helpers.hpp +5 -5
- data/ext/libsass/src/debugger.hpp +127 -128
- data/ext/libsass/src/emitter.cpp +12 -12
- data/ext/libsass/src/emitter.hpp +10 -10
- data/ext/libsass/src/environment.cpp +27 -27
- data/ext/libsass/src/environment.hpp +24 -24
- data/ext/libsass/src/error_handling.cpp +42 -42
- data/ext/libsass/src/error_handling.hpp +38 -50
- data/ext/libsass/src/eval.cpp +138 -132
- data/ext/libsass/src/eval.hpp +17 -17
- data/ext/libsass/src/eval_selectors.cpp +3 -3
- data/ext/libsass/src/expand.cpp +70 -64
- data/ext/libsass/src/expand.hpp +12 -12
- data/ext/libsass/src/extender.cpp +55 -53
- data/ext/libsass/src/extender.hpp +14 -14
- data/ext/libsass/src/file.cpp +66 -58
- data/ext/libsass/src/file.hpp +23 -25
- data/ext/libsass/src/fn_colors.cpp +9 -9
- data/ext/libsass/src/fn_lists.cpp +18 -18
- data/ext/libsass/src/fn_maps.cpp +3 -3
- data/ext/libsass/src/fn_miscs.cpp +15 -15
- data/ext/libsass/src/fn_numbers.cpp +7 -7
- data/ext/libsass/src/fn_selectors.cpp +8 -8
- data/ext/libsass/src/fn_strings.cpp +34 -22
- data/ext/libsass/src/fn_utils.cpp +29 -26
- data/ext/libsass/src/fn_utils.hpp +10 -10
- data/ext/libsass/src/inspect.cpp +35 -34
- data/ext/libsass/src/inspect.hpp +21 -21
- data/ext/libsass/src/lexer.cpp +3 -1
- data/ext/libsass/src/listize.cpp +2 -2
- 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} +18 -6
- data/ext/libsass/src/operation.hpp +44 -44
- data/ext/libsass/src/operators.cpp +18 -18
- data/ext/libsass/src/operators.hpp +11 -11
- data/ext/libsass/src/ordered_map.hpp +18 -18
- data/ext/libsass/src/output.cpp +16 -16
- data/ext/libsass/src/output.hpp +5 -5
- data/ext/libsass/src/parser.cpp +327 -345
- data/ext/libsass/src/parser.hpp +77 -87
- data/ext/libsass/src/parser_selectors.cpp +6 -6
- data/ext/libsass/src/permutate.hpp +39 -15
- 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/remove_placeholders.cpp +4 -4
- data/ext/libsass/src/remove_placeholders.hpp +3 -3
- data/ext/libsass/src/sass.cpp +16 -15
- data/ext/libsass/src/sass.hpp +9 -5
- data/ext/libsass/src/sass_context.cpp +52 -34
- data/ext/libsass/src/sass_values.cpp +8 -10
- 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/units.cpp +19 -19
- 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 +38 -38
- data/ext/libsass/src/util.hpp +18 -18
- data/ext/libsass/src/util_string.cpp +13 -13
- data/ext/libsass/src/util_string.hpp +9 -8
- data/ext/libsass/src/values.cpp +12 -12
- data/lib/sassc/native.rb +3 -5
- data/lib/sassc/version.rb +1 -1
- data/test/native_test.rb +4 -4
- metadata +14 -5
- data/lib/sassc/native/lib_c.rb +0 -21
data/ext/libsass/src/plugins.hpp
CHANGED
@@ -36,19 +36,19 @@ namespace Sass {
|
|
36
36
|
|
37
37
|
public: // methods
|
38
38
|
// load one specific plugin
|
39
|
-
bool load_plugin(const
|
39
|
+
bool load_plugin(const sass::string& path);
|
40
40
|
// load all plugins from a directory
|
41
|
-
size_t load_plugins(const
|
41
|
+
size_t load_plugins(const sass::string& path);
|
42
42
|
|
43
43
|
public: // public accessors
|
44
|
-
const
|
45
|
-
const
|
46
|
-
const
|
44
|
+
const sass::vector<Sass_Importer_Entry> get_headers(void) { return headers; }
|
45
|
+
const sass::vector<Sass_Importer_Entry> get_importers(void) { return importers; }
|
46
|
+
const sass::vector<Sass_Function_Entry> get_functions(void) { return functions; }
|
47
47
|
|
48
48
|
private: // private vars
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
sass::vector<Sass_Importer_Entry> headers;
|
50
|
+
sass::vector<Sass_Importer_Entry> importers;
|
51
|
+
sass::vector<Sass_Function_Entry> functions;
|
52
52
|
|
53
53
|
};
|
54
54
|
|
@@ -3,6 +3,7 @@
|
|
3
3
|
#include "sass.hpp"
|
4
4
|
|
5
5
|
#include "position.hpp"
|
6
|
+
#include "source.hpp"
|
6
7
|
|
7
8
|
namespace Sass {
|
8
9
|
|
@@ -18,7 +19,7 @@ namespace Sass {
|
|
18
19
|
*this = inc(string, string + strlen(string));
|
19
20
|
}
|
20
21
|
|
21
|
-
Offset::Offset(const
|
22
|
+
Offset::Offset(const sass::string& text)
|
22
23
|
: line(0), column(0)
|
23
24
|
{
|
24
25
|
*this = inc(text.c_str(), text.c_str() + text.size());
|
@@ -56,7 +57,7 @@ namespace Sass {
|
|
56
57
|
// skip over 10xxxxxx
|
57
58
|
// is 1st bit not set
|
58
59
|
if ((chr & 128) == 0) {
|
59
|
-
// regular
|
60
|
+
// regular ASCII char
|
60
61
|
column += 1;
|
61
62
|
}
|
62
63
|
// is 2nd bit not set
|
@@ -117,14 +118,11 @@ namespace Sass {
|
|
117
118
|
: Offset(line, column), file(file) { }
|
118
119
|
|
119
120
|
|
120
|
-
|
121
|
-
:
|
121
|
+
SourceSpan::SourceSpan(const char* path)
|
122
|
+
: source(SASS_MEMORY_NEW(SynthFile, path)), position(0, 0), offset(0, 0) { }
|
122
123
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
ParserState::ParserState(const char* path, const char* src, const Token& token, const Position& position, Offset offset)
|
127
|
-
: Position(position), path(path), src(src), offset(offset), token(token) { }
|
124
|
+
SourceSpan::SourceSpan(SourceDataObj source, const Offset& position, const Offset& offset)
|
125
|
+
: source(source), position(position), offset(offset) { }
|
128
126
|
|
129
127
|
Position Position::add(const char* begin, const char* end)
|
130
128
|
{
|
@@ -164,21 +162,4 @@ namespace Sass {
|
|
164
162
|
return Offset(line - off.line, off.line == line ? column - off.column : column);
|
165
163
|
}
|
166
164
|
|
167
|
-
/* not used anymore - remove?
|
168
|
-
std::ostream& operator<<(std::ostream& strm, const Offset& off)
|
169
|
-
{
|
170
|
-
if (off.line == string::npos) strm << "-1:"; else strm << off.line << ":";
|
171
|
-
if (off.column == string::npos) strm << "-1"; else strm << off.column;
|
172
|
-
return strm;
|
173
|
-
} */
|
174
|
-
|
175
|
-
/* not used anymore - remove?
|
176
|
-
std::ostream& operator<<(std::ostream& strm, const Position& pos)
|
177
|
-
{
|
178
|
-
if (pos.file != string::npos) strm << pos.file << ":";
|
179
|
-
if (pos.line == string::npos) strm << "-1:"; else strm << pos.line << ":";
|
180
|
-
if (pos.column == string::npos) strm << "-1"; else strm << pos.column;
|
181
|
-
return strm;
|
182
|
-
} */
|
183
|
-
|
184
165
|
}
|
@@ -3,7 +3,8 @@
|
|
3
3
|
|
4
4
|
#include <string>
|
5
5
|
#include <cstring>
|
6
|
-
|
6
|
+
#include "source_data.hpp"
|
7
|
+
#include "ast_fwd_decl.hpp"
|
7
8
|
|
8
9
|
namespace Sass {
|
9
10
|
|
@@ -13,7 +14,7 @@ namespace Sass {
|
|
13
14
|
public: // c-tor
|
14
15
|
Offset(const char chr);
|
15
16
|
Offset(const char* string);
|
16
|
-
Offset(const
|
17
|
+
Offset(const sass::string& text);
|
17
18
|
Offset(const size_t line, const size_t column);
|
18
19
|
|
19
20
|
// return new position, incremented by the given string
|
@@ -85,37 +86,59 @@ namespace Sass {
|
|
85
86
|
: prefix(p), begin(b), end(e) { }
|
86
87
|
|
87
88
|
size_t length() const { return end - begin; }
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
sass::string ws_before() const { return sass::string(prefix, begin); }
|
90
|
+
sass::string to_string() const { return sass::string(begin, end); }
|
91
|
+
sass::string time_wspace() const {
|
92
|
+
sass::string str(to_string());
|
93
|
+
sass::string whitespaces(" \t\f\v\n\r");
|
93
94
|
return str.erase(str.find_last_not_of(whitespaces)+1);
|
94
95
|
}
|
95
96
|
|
96
97
|
operator bool() { return begin && end && begin >= end; }
|
97
|
-
operator
|
98
|
+
operator sass::string() { return to_string(); }
|
98
99
|
|
99
100
|
bool operator==(Token t) { return to_string() == t.to_string(); }
|
100
101
|
};
|
101
102
|
|
102
|
-
class
|
103
|
+
class SourceSpan {
|
103
104
|
|
104
|
-
public:
|
105
|
-
ParserState(const char* path, const char* src = 0, const size_t file = std::string::npos);
|
106
|
-
ParserState(const char* path, const char* src, const Position& position, Offset offset = Offset(0, 0));
|
107
|
-
ParserState(const char* path, const char* src, const Token& token, const Position& position, Offset offset = Offset(0, 0));
|
105
|
+
public:
|
108
106
|
|
109
|
-
|
110
|
-
Offset off() { return *this; }
|
111
|
-
Position pos() { return *this; }
|
112
|
-
ParserState pstate() { return *this; }
|
107
|
+
SourceSpan(const char* path);
|
113
108
|
|
114
|
-
|
115
|
-
|
116
|
-
|
109
|
+
SourceSpan(SourceDataObj source,
|
110
|
+
const Offset& position = Offset(0, 0),
|
111
|
+
const Offset& offset = Offset(0, 0));
|
112
|
+
|
113
|
+
const char* getPath() const {
|
114
|
+
return source->getPath();
|
115
|
+
}
|
116
|
+
|
117
|
+
const char* getRawData() const {
|
118
|
+
return source->getRawData();
|
119
|
+
}
|
120
|
+
|
121
|
+
Offset getPosition() const {
|
122
|
+
return position;
|
123
|
+
}
|
124
|
+
|
125
|
+
size_t getLine() const {
|
126
|
+
return position.line + 1;
|
127
|
+
}
|
128
|
+
|
129
|
+
size_t getColumn() const {
|
130
|
+
return position.column + 1;
|
131
|
+
}
|
132
|
+
|
133
|
+
size_t getSrcId() const {
|
134
|
+
return source == nullptr
|
135
|
+
? std::string::npos
|
136
|
+
: source->getSrcId();
|
137
|
+
}
|
138
|
+
|
139
|
+
SourceDataObj source;
|
140
|
+
Offset position;
|
117
141
|
Offset offset;
|
118
|
-
Token token;
|
119
142
|
|
120
143
|
};
|
121
144
|
|
@@ -18,7 +18,7 @@ namespace Sass {
|
|
18
18
|
|
19
19
|
void Remove_Placeholders::remove_placeholders(SimpleSelector* simple)
|
20
20
|
{
|
21
|
-
if (
|
21
|
+
if (PseudoSelector * pseudo = simple->getPseudoSelector()) {
|
22
22
|
if (pseudo->selector()) remove_placeholders(pseudo->selector());
|
23
23
|
}
|
24
24
|
}
|
@@ -60,7 +60,7 @@ namespace Sass {
|
|
60
60
|
if (rule->block()) operator()(rule->block());
|
61
61
|
}
|
62
62
|
|
63
|
-
void Remove_Placeholders::operator()(
|
63
|
+
void Remove_Placeholders::operator()(StyleRule* r)
|
64
64
|
{
|
65
65
|
if (SelectorListObj sl = r->selector()) {
|
66
66
|
// Set the new placeholder selector list
|
@@ -73,12 +73,12 @@ namespace Sass {
|
|
73
73
|
}
|
74
74
|
}
|
75
75
|
|
76
|
-
void Remove_Placeholders::operator()(
|
76
|
+
void Remove_Placeholders::operator()(SupportsRule* m)
|
77
77
|
{
|
78
78
|
if (m->block()) operator()(m->block());
|
79
79
|
}
|
80
80
|
|
81
|
-
void Remove_Placeholders::operator()(
|
81
|
+
void Remove_Placeholders::operator()(AtRule* a)
|
82
82
|
{
|
83
83
|
if (a->block()) a->block()->perform(this);
|
84
84
|
}
|
@@ -21,10 +21,10 @@ namespace Sass {
|
|
21
21
|
~Remove_Placeholders() { }
|
22
22
|
|
23
23
|
void operator()(Block*);
|
24
|
-
void operator()(
|
24
|
+
void operator()(StyleRule*);
|
25
25
|
void operator()(CssMediaRule*);
|
26
|
-
void operator()(
|
27
|
-
void operator()(
|
26
|
+
void operator()(SupportsRule*);
|
27
|
+
void operator()(AtRule*);
|
28
28
|
|
29
29
|
// ignore missed types
|
30
30
|
template <typename U>
|
data/ext/libsass/src/sass.cpp
CHANGED
@@ -17,9 +17,9 @@
|
|
17
17
|
namespace Sass {
|
18
18
|
|
19
19
|
// helper to convert string list to vector
|
20
|
-
|
20
|
+
sass::vector<sass::string> list2vec(struct string_list* cur)
|
21
21
|
{
|
22
|
-
|
22
|
+
sass::vector<sass::string> list;
|
23
23
|
while (cur) {
|
24
24
|
list.push_back(cur->string);
|
25
25
|
cur = cur->next;
|
@@ -46,6 +46,7 @@ extern "C" {
|
|
46
46
|
|
47
47
|
char* ADDCALL sass_copy_c_string(const char* str)
|
48
48
|
{
|
49
|
+
if (str == nullptr) return nullptr;
|
49
50
|
size_t len = strlen(str) + 1;
|
50
51
|
char* cpy = (char*) sass_alloc_memory(len);
|
51
52
|
std::memcpy(cpy, str, len);
|
@@ -61,14 +62,14 @@ extern "C" {
|
|
61
62
|
// caller must free the returned memory
|
62
63
|
char* ADDCALL sass_string_quote (const char *str, const char quote_mark)
|
63
64
|
{
|
64
|
-
|
65
|
+
sass::string quoted = quote(str, quote_mark);
|
65
66
|
return sass_copy_c_string(quoted.c_str());
|
66
67
|
}
|
67
68
|
|
68
69
|
// caller must free the returned memory
|
69
70
|
char* ADDCALL sass_string_unquote (const char *str)
|
70
71
|
{
|
71
|
-
|
72
|
+
sass::string unquoted = unquote(str);
|
72
73
|
return sass_copy_c_string(unquoted.c_str());
|
73
74
|
}
|
74
75
|
|
@@ -76,13 +77,13 @@ extern "C" {
|
|
76
77
|
{
|
77
78
|
// get the last import entry to get current base directory
|
78
79
|
Sass_Import_Entry import = sass_compiler_get_last_import(compiler);
|
79
|
-
const
|
80
|
+
const sass::vector<sass::string>& incs = compiler->cpp_ctx->include_paths;
|
80
81
|
// create the vector with paths to lookup
|
81
|
-
|
82
|
+
sass::vector<sass::string> paths(1 + incs.size());
|
82
83
|
paths.push_back(File::dir_name(import->abs_path));
|
83
84
|
paths.insert( paths.end(), incs.begin(), incs.end() );
|
84
85
|
// now resolve the file path relative to lookup paths
|
85
|
-
|
86
|
+
sass::string resolved(File::find_include(file, paths));
|
86
87
|
return sass_copy_c_string(resolved.c_str());
|
87
88
|
}
|
88
89
|
|
@@ -90,13 +91,13 @@ extern "C" {
|
|
90
91
|
{
|
91
92
|
// get the last import entry to get current base directory
|
92
93
|
Sass_Import_Entry import = sass_compiler_get_last_import(compiler);
|
93
|
-
const
|
94
|
+
const sass::vector<sass::string>& incs = compiler->cpp_ctx->include_paths;
|
94
95
|
// create the vector with paths to lookup
|
95
|
-
|
96
|
+
sass::vector<sass::string> paths(1 + incs.size());
|
96
97
|
paths.push_back(File::dir_name(import->abs_path));
|
97
98
|
paths.insert( paths.end(), incs.begin(), incs.end() );
|
98
99
|
// now resolve the file path relative to lookup paths
|
99
|
-
|
100
|
+
sass::string resolved(File::find_file(file, paths));
|
100
101
|
return sass_copy_c_string(resolved.c_str());
|
101
102
|
}
|
102
103
|
|
@@ -105,8 +106,8 @@ extern "C" {
|
|
105
106
|
// this has the original resolve logic for sass include
|
106
107
|
char* ADDCALL sass_find_include (const char* file, struct Sass_Options* opt)
|
107
108
|
{
|
108
|
-
|
109
|
-
|
109
|
+
sass::vector<sass::string> vec(list2vec(opt->include_paths));
|
110
|
+
sass::string resolved(File::find_include(file, vec));
|
110
111
|
return sass_copy_c_string(resolved.c_str());
|
111
112
|
}
|
112
113
|
|
@@ -114,8 +115,8 @@ extern "C" {
|
|
114
115
|
// Incs array has to be null terminated!
|
115
116
|
char* ADDCALL sass_find_file (const char* file, struct Sass_Options* opt)
|
116
117
|
{
|
117
|
-
|
118
|
-
|
118
|
+
sass::vector<sass::string> vec(list2vec(opt->include_paths));
|
119
|
+
sass::string resolved(File::find_file(file, vec));
|
119
120
|
return sass_copy_c_string(resolved.c_str());
|
120
121
|
}
|
121
122
|
|
@@ -136,7 +137,7 @@ extern "C" {
|
|
136
137
|
namespace Sass {
|
137
138
|
|
138
139
|
// helper to aid dreaded MSVC debug mode
|
139
|
-
char* sass_copy_string(
|
140
|
+
char* sass_copy_string(sass::string str)
|
140
141
|
{
|
141
142
|
// In MSVC the following can lead to segfault:
|
142
143
|
// sass_copy_c_string(stream.str().c_str());
|
data/ext/libsass/src/sass.hpp
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#pragma warning(disable : 4005)
|
12
12
|
#endif
|
13
13
|
|
14
|
-
//
|
14
|
+
// applies to MSVC and MinGW
|
15
15
|
#ifdef _WIN32
|
16
16
|
// we do not want the ERROR macro
|
17
17
|
# ifndef NOGDI
|
@@ -48,13 +48,17 @@
|
|
48
48
|
#endif
|
49
49
|
|
50
50
|
|
51
|
-
//
|
51
|
+
// Include C-API header
|
52
52
|
#include "sass/base.h"
|
53
53
|
|
54
|
+
// Include allocator
|
55
|
+
#include "memory.hpp"
|
56
|
+
|
54
57
|
// For C++ helper
|
55
58
|
#include <string>
|
59
|
+
#include <vector>
|
56
60
|
|
57
|
-
// output
|
61
|
+
// output behavior
|
58
62
|
namespace Sass {
|
59
63
|
|
60
64
|
// create some C++ aliases for the most used options
|
@@ -69,11 +73,11 @@ namespace Sass {
|
|
69
73
|
|
70
74
|
// helper to aid dreaded MSVC debug mode
|
71
75
|
// see implementation for more details
|
72
|
-
char* sass_copy_string(
|
76
|
+
char* sass_copy_string(sass::string str);
|
73
77
|
|
74
78
|
}
|
75
79
|
|
76
|
-
// input
|
80
|
+
// input behaviors
|
77
81
|
enum Sass_Input_Style {
|
78
82
|
SASS_CONTEXT_NULL,
|
79
83
|
SASS_CONTEXT_FILE,
|
@@ -10,17 +10,17 @@
|
|
10
10
|
|
11
11
|
// C++ helper
|
12
12
|
namespace Sass {
|
13
|
-
// see sass_copy_c_string(
|
14
|
-
static inline JsonNode* json_mkstream(const
|
13
|
+
// see sass_copy_c_string(sass::string str)
|
14
|
+
static inline JsonNode* json_mkstream(const sass::ostream& stream)
|
15
15
|
{
|
16
16
|
// hold on to string on stack!
|
17
|
-
|
17
|
+
sass::string str(stream.str());
|
18
18
|
return json_mkstring(str.c_str());
|
19
19
|
}
|
20
20
|
|
21
|
-
static void handle_string_error(Sass_Context* c_ctx, const
|
21
|
+
static void handle_string_error(Sass_Context* c_ctx, const sass::string& msg, int severety)
|
22
22
|
{
|
23
|
-
|
23
|
+
sass::ostream msg_stream;
|
24
24
|
JsonNode* json_err = json_mkobject();
|
25
25
|
msg_stream << "Internal Error: " << msg << std::endl;
|
26
26
|
json_append_member(json_err, "status", json_mknumber(severety));
|
@@ -41,9 +41,9 @@ namespace Sass {
|
|
41
41
|
throw;
|
42
42
|
}
|
43
43
|
catch (Exception::Base& e) {
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
sass::ostream msg_stream;
|
45
|
+
sass::string cwd(Sass::File::get_cwd());
|
46
|
+
sass::string msg_prefix(e.errtype());
|
47
47
|
bool got_newline = false;
|
48
48
|
msg_stream << msg_prefix << ": ";
|
49
49
|
const char* msg = e.what();
|
@@ -55,7 +55,7 @@ namespace Sass {
|
|
55
55
|
got_newline = true;
|
56
56
|
}
|
57
57
|
else if (got_newline) {
|
58
|
-
msg_stream <<
|
58
|
+
msg_stream << sass::string(msg_prefix.size() + 2, ' ');
|
59
59
|
got_newline = false;
|
60
60
|
}
|
61
61
|
msg_stream << *msg;
|
@@ -65,24 +65,25 @@ namespace Sass {
|
|
65
65
|
|
66
66
|
if (e.traces.empty()) {
|
67
67
|
// we normally should have some traces, still here as a fallback
|
68
|
-
|
69
|
-
msg_stream <<
|
70
|
-
msg_stream << " on line " << e.pstate.
|
68
|
+
sass::string rel_path(Sass::File::abs2rel(e.pstate.getPath(), cwd, cwd));
|
69
|
+
msg_stream << sass::string(msg_prefix.size() + 2, ' ');
|
70
|
+
msg_stream << " on line " << e.pstate.getLine() << " of " << rel_path << "\n";
|
71
71
|
}
|
72
72
|
else {
|
73
|
-
|
73
|
+
sass::string rel_path(Sass::File::abs2rel(e.pstate.getPath(), cwd, cwd));
|
74
74
|
msg_stream << traces_to_string(e.traces, " ");
|
75
75
|
}
|
76
76
|
|
77
77
|
// now create the code trace (ToDo: maybe have util functions?)
|
78
|
-
if (e.pstate.line !=
|
79
|
-
e.pstate.column !=
|
80
|
-
e.pstate.
|
81
|
-
|
78
|
+
if (e.pstate.position.line != sass::string::npos &&
|
79
|
+
e.pstate.position.column != sass::string::npos &&
|
80
|
+
e.pstate.source != nullptr) {
|
81
|
+
Offset offset(e.pstate.position);
|
82
|
+
size_t lines = offset.line;
|
82
83
|
// scan through src until target line
|
83
84
|
// move line_beg pointer to line start
|
84
85
|
const char* line_beg;
|
85
|
-
for (line_beg = e.pstate.
|
86
|
+
for (line_beg = e.pstate.getRawData(); *line_beg != '\0'; ++line_beg) {
|
86
87
|
if (lines == 0) break;
|
87
88
|
if (*line_beg == '\n') --lines;
|
88
89
|
}
|
@@ -96,12 +97,12 @@ namespace Sass {
|
|
96
97
|
size_t move_in = 0; size_t shorten = 0;
|
97
98
|
size_t left_chars = 42; size_t max_chars = 76;
|
98
99
|
// reported excerpt should not exceed `max_chars` chars
|
99
|
-
if (
|
100
|
-
if (
|
100
|
+
if (offset.column > line_len) left_chars = offset.column;
|
101
|
+
if (offset.column > left_chars) move_in = offset.column - left_chars;
|
101
102
|
if (line_len > max_chars + move_in) shorten = line_len - move_in - max_chars;
|
102
103
|
utf8::advance(line_beg, move_in, line_end);
|
103
104
|
utf8::retreat(line_end, shorten, line_beg);
|
104
|
-
|
105
|
+
sass::string sanitized; sass::string marker(offset.column - move_in, '-');
|
105
106
|
utf8::replace_invalid(line_beg, line_end, std::back_inserter(sanitized));
|
106
107
|
msg_stream << ">> " << sanitized << "\n";
|
107
108
|
msg_stream << " " << marker << "^\n";
|
@@ -109,9 +110,9 @@ namespace Sass {
|
|
109
110
|
|
110
111
|
JsonNode* json_err = json_mkobject();
|
111
112
|
json_append_member(json_err, "status", json_mknumber(1));
|
112
|
-
json_append_member(json_err, "file", json_mkstring(e.pstate.
|
113
|
-
json_append_member(json_err, "line", json_mknumber((double)(e.pstate.
|
114
|
-
json_append_member(json_err, "column", json_mknumber((double)(e.pstate.
|
113
|
+
json_append_member(json_err, "file", json_mkstring(e.pstate.getPath()));
|
114
|
+
json_append_member(json_err, "line", json_mknumber((double)(e.pstate.getLine())));
|
115
|
+
json_append_member(json_err, "column", json_mknumber((double)(e.pstate.getColumn())));
|
115
116
|
json_append_member(json_err, "message", json_mkstring(e.what()));
|
116
117
|
json_append_member(json_err, "formatted", json_mkstream(msg_stream));
|
117
118
|
try { c_ctx->error_json = json_stringify(json_err, " "); }
|
@@ -119,23 +120,23 @@ namespace Sass {
|
|
119
120
|
c_ctx->error_message = sass_copy_string(msg_stream.str());
|
120
121
|
c_ctx->error_text = sass_copy_c_string(e.what());
|
121
122
|
c_ctx->error_status = 1;
|
122
|
-
c_ctx->error_file = sass_copy_c_string(e.pstate.
|
123
|
-
c_ctx->error_line = e.pstate.
|
124
|
-
c_ctx->error_column = e.pstate.
|
125
|
-
c_ctx->error_src = sass_copy_c_string(e.pstate.
|
123
|
+
c_ctx->error_file = sass_copy_c_string(e.pstate.getPath());
|
124
|
+
c_ctx->error_line = e.pstate.getLine();
|
125
|
+
c_ctx->error_column = e.pstate.getColumn();
|
126
|
+
c_ctx->error_src = sass_copy_c_string(e.pstate.getRawData());
|
126
127
|
c_ctx->output_string = 0;
|
127
128
|
c_ctx->source_map_string = 0;
|
128
129
|
json_delete(json_err);
|
129
130
|
}
|
130
131
|
catch (std::bad_alloc& ba) {
|
131
|
-
|
132
|
+
sass::ostream msg_stream;
|
132
133
|
msg_stream << "Unable to allocate memory: " << ba.what();
|
133
134
|
handle_string_error(c_ctx, msg_stream.str(), 2);
|
134
135
|
}
|
135
136
|
catch (std::exception& e) {
|
136
137
|
handle_string_error(c_ctx, e.what(), 3);
|
137
138
|
}
|
138
|
-
catch (
|
139
|
+
catch (sass::string& e) {
|
139
140
|
handle_string_error(c_ctx, e, 4);
|
140
141
|
}
|
141
142
|
catch (const char* e) {
|
@@ -169,8 +170,8 @@ namespace Sass {
|
|
169
170
|
try {
|
170
171
|
|
171
172
|
// get input/output path from options
|
172
|
-
|
173
|
-
|
173
|
+
sass::string input_path = safe_str(c_ctx->input_path);
|
174
|
+
sass::string output_path = safe_str(c_ctx->output_path);
|
174
175
|
|
175
176
|
// maybe skip some entries of included files
|
176
177
|
// we do not include stdin for data contexts
|
@@ -279,8 +280,8 @@ extern "C" {
|
|
279
280
|
// reset error position
|
280
281
|
c_ctx->error_file = 0;
|
281
282
|
c_ctx->error_src = 0;
|
282
|
-
c_ctx->error_line =
|
283
|
-
c_ctx->error_column =
|
283
|
+
c_ctx->error_line = sass::string::npos;
|
284
|
+
c_ctx->error_column = sass::string::npos;
|
284
285
|
|
285
286
|
// allocate a new compiler instance
|
286
287
|
void* ctxmem = calloc(1, sizeof(struct Sass_Compiler));
|
@@ -702,6 +703,23 @@ extern "C" {
|
|
702
703
|
return cur->string;
|
703
704
|
}
|
704
705
|
|
706
|
+
// Push function for plugin paths (no manipulation support for now)
|
707
|
+
size_t ADDCALL sass_option_get_plugin_path_size(struct Sass_Options* options)
|
708
|
+
{
|
709
|
+
size_t len = 0;
|
710
|
+
struct string_list* cur = options->plugin_paths;
|
711
|
+
while (cur) { len++; cur = cur->next; }
|
712
|
+
return len;
|
713
|
+
}
|
714
|
+
|
715
|
+
// Push function for plugin paths (no manipulation support for now)
|
716
|
+
const char* ADDCALL sass_option_get_plugin_path(struct Sass_Options* options, size_t i)
|
717
|
+
{
|
718
|
+
struct string_list* cur = options->plugin_paths;
|
719
|
+
while (i) { i--; cur = cur->next; }
|
720
|
+
return cur->string;
|
721
|
+
}
|
722
|
+
|
705
723
|
// Push function for plugin paths (no manipulation support for now)
|
706
724
|
void ADDCALL sass_option_push_plugin_path(struct Sass_Options* options, const char* path)
|
707
725
|
{
|