sassc 2.2.1 → 2.3.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 +13 -0
- data/Rakefile +1 -3
- data/ext/extconf.rb +13 -5
- data/ext/libsass/VERSION +1 -1
- data/ext/libsass/include/sass/base.h +2 -1
- data/ext/libsass/include/sass/context.h +1 -0
- data/ext/libsass/src/ast.cpp +49 -59
- data/ext/libsass/src/ast.hpp +263 -102
- data/ext/libsass/src/ast_def_macros.hpp +8 -0
- data/ext/libsass/src/ast_fwd_decl.cpp +2 -1
- data/ext/libsass/src/ast_fwd_decl.hpp +40 -116
- data/ext/libsass/src/ast_helpers.hpp +292 -0
- data/ext/libsass/src/ast_sel_cmp.cpp +209 -722
- 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 +559 -1001
- data/ext/libsass/src/ast_selectors.hpp +311 -367
- data/ext/libsass/src/ast_supports.cpp +1 -17
- data/ext/libsass/src/ast_values.cpp +216 -29
- data/ext/libsass/src/ast_values.hpp +42 -33
- data/ext/libsass/src/bind.cpp +1 -1
- data/ext/libsass/src/cencode.c +4 -6
- data/ext/libsass/src/check_nesting.cpp +5 -6
- data/ext/libsass/src/check_nesting.hpp +4 -0
- data/ext/libsass/src/color_maps.cpp +11 -10
- data/ext/libsass/src/color_maps.hpp +0 -8
- data/ext/libsass/src/constants.cpp +5 -0
- data/ext/libsass/src/constants.hpp +6 -0
- data/ext/libsass/src/context.cpp +30 -60
- data/ext/libsass/src/context.hpp +8 -20
- data/ext/libsass/src/cssize.cpp +36 -120
- data/ext/libsass/src/cssize.hpp +4 -10
- data/ext/libsass/src/dart_helpers.hpp +199 -0
- data/ext/libsass/src/debugger.hpp +364 -207
- data/ext/libsass/src/emitter.cpp +3 -4
- data/ext/libsass/src/emitter.hpp +0 -2
- data/ext/libsass/src/environment.hpp +5 -0
- data/ext/libsass/src/error_handling.cpp +21 -0
- data/ext/libsass/src/error_handling.hpp +25 -3
- data/ext/libsass/src/eval.cpp +33 -153
- data/ext/libsass/src/eval.hpp +11 -13
- data/ext/libsass/src/eval_selectors.cpp +75 -0
- data/ext/libsass/src/expand.cpp +214 -167
- data/ext/libsass/src/expand.hpp +26 -6
- data/ext/libsass/src/extender.cpp +1186 -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 +15 -14
- data/ext/libsass/src/file.hpp +5 -12
- data/ext/libsass/src/fn_colors.cpp +12 -10
- data/ext/libsass/src/fn_lists.cpp +12 -11
- data/ext/libsass/src/fn_miscs.cpp +22 -34
- data/ext/libsass/src/fn_numbers.cpp +13 -6
- data/ext/libsass/src/fn_selectors.cpp +94 -124
- data/ext/libsass/src/fn_strings.cpp +16 -14
- data/ext/libsass/src/fn_utils.cpp +5 -6
- data/ext/libsass/src/fn_utils.hpp +9 -3
- data/ext/libsass/src/inspect.cpp +154 -117
- data/ext/libsass/src/inspect.hpp +10 -8
- data/ext/libsass/src/lexer.cpp +17 -81
- data/ext/libsass/src/lexer.hpp +5 -16
- data/ext/libsass/src/listize.cpp +22 -36
- data/ext/libsass/src/listize.hpp +8 -9
- data/ext/libsass/src/memory/SharedPtr.hpp +39 -5
- data/ext/libsass/src/operation.hpp +27 -17
- data/ext/libsass/src/operators.cpp +1 -0
- data/ext/libsass/src/ordered_map.hpp +112 -0
- data/ext/libsass/src/output.cpp +30 -49
- data/ext/libsass/src/output.hpp +1 -1
- data/ext/libsass/src/parser.cpp +211 -381
- data/ext/libsass/src/parser.hpp +17 -15
- data/ext/libsass/src/parser_selectors.cpp +189 -0
- data/ext/libsass/src/permutate.hpp +140 -0
- data/ext/libsass/src/position.hpp +1 -1
- 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.hpp +1 -0
- data/ext/libsass/src/sass2scss.cpp +4 -4
- data/ext/libsass/src/sass_context.cpp +42 -91
- 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 +0 -1
- 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 +5 -3
- data/ext/libsass/src/util.cpp +10 -12
- data/ext/libsass/src/util.hpp +2 -3
- data/ext/libsass/src/util_string.cpp +111 -61
- data/ext/libsass/src/util_string.hpp +61 -8
- data/lib/sassc/engine.rb +5 -3
- data/lib/sassc/functions_handler.rb +8 -8
- data/lib/sassc/native.rb +1 -1
- data/lib/sassc/script.rb +4 -4
- data/lib/sassc/version.rb +1 -1
- data/test/functions_test.rb +18 -1
- data/test/native_test.rb +1 -1
- metadata +17 -12
- 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
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
// sass.hpp must go before all system headers to get the
|
|
2
2
|
// __EXTENSIONS__ fix on Solaris.
|
|
3
3
|
#include "sass.hpp"
|
|
4
|
+
#include "ast.hpp"
|
|
4
5
|
|
|
5
6
|
#include "remove_placeholders.hpp"
|
|
6
|
-
#include "context.hpp"
|
|
7
|
-
#include "inspect.hpp"
|
|
8
|
-
#include <iostream>
|
|
9
7
|
|
|
10
8
|
namespace Sass {
|
|
11
9
|
|
|
@@ -13,75 +11,76 @@ namespace Sass {
|
|
|
13
11
|
{ }
|
|
14
12
|
|
|
15
13
|
void Remove_Placeholders::operator()(Block* b) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
14
|
+
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
|
15
|
+
if (b->get(i)) b->get(i)->perform(this);
|
|
16
|
+
}
|
|
20
17
|
}
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
void Remove_Placeholders::remove_placeholders(SimpleSelector* simple)
|
|
23
20
|
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
for (size_t i = 0, L = sl->length(); i < L; ++i) {
|
|
27
|
-
if (!sl->at(i)->contains_placeholder()) {
|
|
28
|
-
new_sl->append(sl->at(i));
|
|
29
|
-
}
|
|
21
|
+
if (Pseudo_Selector * pseudo = simple->getPseudoSelector()) {
|
|
22
|
+
if (pseudo->selector()) remove_placeholders(pseudo->selector());
|
|
30
23
|
}
|
|
31
|
-
|
|
32
|
-
return new_sl;
|
|
33
|
-
|
|
34
24
|
}
|
|
35
25
|
|
|
26
|
+
void Remove_Placeholders::remove_placeholders(CompoundSelector* compound)
|
|
27
|
+
{
|
|
28
|
+
for (size_t i = 0, L = compound->length(); i < L; ++i) {
|
|
29
|
+
if (compound->get(i)) remove_placeholders(compound->get(i));
|
|
30
|
+
}
|
|
31
|
+
listEraseItemIf(compound->elements(), listIsEmpty<SimpleSelector>);
|
|
32
|
+
}
|
|
36
33
|
|
|
37
|
-
void Remove_Placeholders::
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
while (cs) {
|
|
47
|
-
if (cs->head()) {
|
|
48
|
-
for (Simple_Selector_Obj& ss : cs->head()->elements()) {
|
|
49
|
-
if (Wrapped_Selector* ws = Cast<Wrapped_Selector>(ss)) {
|
|
50
|
-
if (Selector_List* wsl = Cast<Selector_List>(ws->selector())) {
|
|
51
|
-
Selector_List* clean = remove_placeholders(wsl);
|
|
52
|
-
// also clean superflous parent selectors
|
|
53
|
-
// probably not really the correct place
|
|
54
|
-
clean->remove_parent_selectors();
|
|
55
|
-
ws->selector(clean);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
cs = cs->tail();
|
|
61
|
-
}
|
|
34
|
+
void Remove_Placeholders::remove_placeholders(ComplexSelector* complex)
|
|
35
|
+
{
|
|
36
|
+
if (complex->has_placeholder()) {
|
|
37
|
+
complex->clear(); // remove all
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
for (size_t i = 0, L = complex->length(); i < L; ++i) {
|
|
41
|
+
if (CompoundSelector * compound = complex->get(i)->getCompound()) {
|
|
42
|
+
if (compound) remove_placeholders(compound);
|
|
62
43
|
}
|
|
63
44
|
}
|
|
45
|
+
listEraseItemIf(complex->elements(), listIsEmpty<SelectorComponent>);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
64
48
|
|
|
65
|
-
|
|
66
|
-
|
|
49
|
+
SelectorList* Remove_Placeholders::remove_placeholders(SelectorList* sl)
|
|
50
|
+
{
|
|
51
|
+
for (size_t i = 0, L = sl->length(); i < L; ++i) {
|
|
52
|
+
if (sl->get(i)) remove_placeholders(sl->get(i));
|
|
53
|
+
}
|
|
54
|
+
listEraseItemIf(sl->elements(), listIsEmpty<ComplexSelector>);
|
|
55
|
+
return sl;
|
|
56
|
+
}
|
|
67
57
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
st->perform(this);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
58
|
+
void Remove_Placeholders::operator()(CssMediaRule* rule)
|
|
59
|
+
{
|
|
60
|
+
if (rule->block()) operator()(rule->block());
|
|
74
61
|
}
|
|
75
62
|
|
|
76
|
-
void Remove_Placeholders::operator()(
|
|
77
|
-
|
|
63
|
+
void Remove_Placeholders::operator()(Ruleset* r)
|
|
64
|
+
{
|
|
65
|
+
if (SelectorListObj sl = r->selector()) {
|
|
66
|
+
// Set the new placeholder selector list
|
|
67
|
+
r->selector((remove_placeholders(sl)));
|
|
68
|
+
}
|
|
69
|
+
// Iterate into child blocks
|
|
70
|
+
Block_Obj b = r->block();
|
|
71
|
+
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
|
72
|
+
if (b->get(i)) { b->get(i)->perform(this); }
|
|
73
|
+
}
|
|
78
74
|
}
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
|
|
76
|
+
void Remove_Placeholders::operator()(Supports_Block* m)
|
|
77
|
+
{
|
|
78
|
+
if (m->block()) operator()(m->block());
|
|
81
79
|
}
|
|
82
80
|
|
|
83
|
-
void Remove_Placeholders::operator()(Directive* a)
|
|
84
|
-
|
|
81
|
+
void Remove_Placeholders::operator()(Directive* a)
|
|
82
|
+
{
|
|
83
|
+
if (a->block()) a->block()->perform(this);
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
}
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
#ifndef SASS_REMOVE_PLACEHOLDERS_H
|
|
2
2
|
#define SASS_REMOVE_PLACEHOLDERS_H
|
|
3
3
|
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
#include "ast.hpp"
|
|
4
|
+
#include "ast_fwd_decl.hpp"
|
|
7
5
|
#include "operation.hpp"
|
|
8
6
|
|
|
9
7
|
namespace Sass {
|
|
10
8
|
|
|
9
|
+
class Remove_Placeholders : public Operation_CRTP<void, Remove_Placeholders> {
|
|
10
|
+
|
|
11
|
+
public:
|
|
12
|
+
|
|
13
|
+
SelectorList* remove_placeholders(SelectorList*);
|
|
14
|
+
void remove_placeholders(SimpleSelector* simple);
|
|
15
|
+
void remove_placeholders(CompoundSelector* complex);
|
|
16
|
+
void remove_placeholders(ComplexSelector* complex);
|
|
11
17
|
|
|
12
|
-
class Remove_Placeholders : public Operation_CRTP<void, Remove_Placeholders> {
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
public:
|
|
20
|
+
Remove_Placeholders();
|
|
21
|
+
~Remove_Placeholders() { }
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
void operator()(Block*);
|
|
24
|
+
void operator()(Ruleset*);
|
|
25
|
+
void operator()(CssMediaRule*);
|
|
26
|
+
void operator()(Supports_Block*);
|
|
27
|
+
void operator()(Directive*);
|
|
20
28
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
void operator()(Supports_Block*);
|
|
25
|
-
void operator()(Directive*);
|
|
29
|
+
// ignore missed types
|
|
30
|
+
template <typename U>
|
|
31
|
+
void fallback(U x) {}
|
|
26
32
|
|
|
27
|
-
|
|
28
|
-
template <typename U>
|
|
29
|
-
void fallback(U x) {}
|
|
30
|
-
};
|
|
33
|
+
};
|
|
31
34
|
|
|
32
35
|
}
|
|
33
36
|
|
data/ext/libsass/src/sass.hpp
CHANGED
|
@@ -65,6 +65,7 @@ namespace Sass {
|
|
|
65
65
|
// only used internal to trigger ruby inspect behavior
|
|
66
66
|
const static Sass_Output_Style INSPECT = SASS_STYLE_INSPECT;
|
|
67
67
|
const static Sass_Output_Style TO_SASS = SASS_STYLE_TO_SASS;
|
|
68
|
+
const static Sass_Output_Style TO_CSS = SASS_STYLE_TO_CSS;
|
|
68
69
|
|
|
69
70
|
// helper to aid dreaded MSVC debug mode
|
|
70
71
|
// see implementation for more details
|
|
@@ -467,7 +467,7 @@ namespace Sass
|
|
|
467
467
|
// right trim input
|
|
468
468
|
sass = rtrim(sass);
|
|
469
469
|
|
|
470
|
-
// get
|
|
470
|
+
// get position of first meaningfull character in string
|
|
471
471
|
size_t pos_left = sass.find_first_not_of(SASS2SCSS_FIND_WHITESPACE);
|
|
472
472
|
|
|
473
473
|
// special case for final run
|
|
@@ -557,7 +557,7 @@ namespace Sass
|
|
|
557
557
|
// default to a selector
|
|
558
558
|
// change back if property found
|
|
559
559
|
converter.selector = true;
|
|
560
|
-
// get
|
|
560
|
+
// get position of first whitespace char
|
|
561
561
|
size_t pos_wspace = sass.find_first_of(SASS2SCSS_FIND_WHITESPACE, pos_left);
|
|
562
562
|
// assertion check for valid result
|
|
563
563
|
if (pos_wspace != std::string::npos)
|
|
@@ -580,7 +580,7 @@ namespace Sass
|
|
|
580
580
|
// assertion for valid result
|
|
581
581
|
if (pos_colon != std::string::npos)
|
|
582
582
|
{
|
|
583
|
-
// ... after the first word (skip
|
|
583
|
+
// ... after the first word (skip beginning colons)
|
|
584
584
|
pos_colon = sass.find_first_of(":", pos_colon);
|
|
585
585
|
// it is a selector if there was no colon found
|
|
586
586
|
converter.selector = pos_colon == std::string::npos;
|
|
@@ -758,7 +758,7 @@ namespace Sass
|
|
|
758
758
|
scss += flush(sass, converter);
|
|
759
759
|
}
|
|
760
760
|
|
|
761
|
-
// get
|
|
761
|
+
// get position of last meaningfull char
|
|
762
762
|
size_t pos_right = sass.find_last_not_of(SASS2SCSS_FIND_WHITESPACE);
|
|
763
763
|
|
|
764
764
|
// check for invalid result
|
|
@@ -1,23 +1,10 @@
|
|
|
1
1
|
// sass.hpp must go before all system headers to get the
|
|
2
2
|
// __EXTENSIONS__ fix on Solaris.
|
|
3
3
|
#include "sass.hpp"
|
|
4
|
-
|
|
5
|
-
#include <cstring>
|
|
6
|
-
#include <stdexcept>
|
|
7
|
-
#include <sstream>
|
|
8
|
-
#include <string>
|
|
9
|
-
#include <vector>
|
|
10
|
-
|
|
11
|
-
#include "sass.h"
|
|
12
4
|
#include "ast.hpp"
|
|
13
|
-
|
|
14
|
-
#include "json.hpp"
|
|
15
|
-
#include "util.hpp"
|
|
16
|
-
#include "context.hpp"
|
|
17
|
-
#include "sass_context.hpp"
|
|
5
|
+
|
|
18
6
|
#include "sass_functions.hpp"
|
|
19
|
-
#include "
|
|
20
|
-
#include "error_handling.hpp"
|
|
7
|
+
#include "json.hpp"
|
|
21
8
|
|
|
22
9
|
#define LFEED "\n"
|
|
23
10
|
|
|
@@ -31,6 +18,24 @@ namespace Sass {
|
|
|
31
18
|
return json_mkstring(str.c_str());
|
|
32
19
|
}
|
|
33
20
|
|
|
21
|
+
static void handle_string_error(Sass_Context* c_ctx, const std::string& msg, int severety)
|
|
22
|
+
{
|
|
23
|
+
std::stringstream msg_stream;
|
|
24
|
+
JsonNode* json_err = json_mkobject();
|
|
25
|
+
msg_stream << "Internal Error: " << msg << std::endl;
|
|
26
|
+
json_append_member(json_err, "status", json_mknumber(severety));
|
|
27
|
+
json_append_member(json_err, "message", json_mkstring(msg.c_str()));
|
|
28
|
+
json_append_member(json_err, "formatted", json_mkstream(msg_stream));
|
|
29
|
+
try { c_ctx->error_json = json_stringify(json_err, " "); }
|
|
30
|
+
catch (...) {}
|
|
31
|
+
c_ctx->error_message = sass_copy_string(msg_stream.str());
|
|
32
|
+
c_ctx->error_text = sass_copy_c_string(msg.c_str());
|
|
33
|
+
c_ctx->error_status = severety;
|
|
34
|
+
c_ctx->output_string = 0;
|
|
35
|
+
c_ctx->source_map_string = 0;
|
|
36
|
+
json_delete(json_err);
|
|
37
|
+
}
|
|
38
|
+
|
|
34
39
|
static int handle_error(Sass_Context* c_ctx) {
|
|
35
40
|
try {
|
|
36
41
|
throw;
|
|
@@ -110,96 +115,34 @@ namespace Sass {
|
|
|
110
115
|
json_append_member(json_err, "message", json_mkstring(e.what()));
|
|
111
116
|
json_append_member(json_err, "formatted", json_mkstream(msg_stream));
|
|
112
117
|
try { c_ctx->error_json = json_stringify(json_err, " "); }
|
|
113
|
-
catch (...) {}
|
|
118
|
+
catch (...) {} // silently ignore this error?
|
|
114
119
|
c_ctx->error_message = sass_copy_string(msg_stream.str());
|
|
115
120
|
c_ctx->error_text = sass_copy_c_string(e.what());
|
|
116
121
|
c_ctx->error_status = 1;
|
|
117
122
|
c_ctx->error_file = sass_copy_c_string(e.pstate.path);
|
|
118
123
|
c_ctx->error_line = e.pstate.line + 1;
|
|
119
124
|
c_ctx->error_column = e.pstate.column + 1;
|
|
120
|
-
c_ctx->error_src = e.pstate.src;
|
|
125
|
+
c_ctx->error_src = sass_copy_c_string(e.pstate.src);
|
|
121
126
|
c_ctx->output_string = 0;
|
|
122
127
|
c_ctx->source_map_string = 0;
|
|
123
128
|
json_delete(json_err);
|
|
124
129
|
}
|
|
125
130
|
catch (std::bad_alloc& ba) {
|
|
126
131
|
std::stringstream msg_stream;
|
|
127
|
-
|
|
128
|
-
msg_stream
|
|
129
|
-
json_append_member(json_err, "status", json_mknumber(2));
|
|
130
|
-
json_append_member(json_err, "message", json_mkstring(ba.what()));
|
|
131
|
-
json_append_member(json_err, "formatted", json_mkstream(msg_stream));
|
|
132
|
-
try { c_ctx->error_json = json_stringify(json_err, " "); }
|
|
133
|
-
catch (...) {}
|
|
134
|
-
c_ctx->error_message = sass_copy_string(msg_stream.str());
|
|
135
|
-
c_ctx->error_text = sass_copy_c_string(ba.what());
|
|
136
|
-
c_ctx->error_status = 2;
|
|
137
|
-
c_ctx->output_string = 0;
|
|
138
|
-
c_ctx->source_map_string = 0;
|
|
139
|
-
json_delete(json_err);
|
|
132
|
+
msg_stream << "Unable to allocate memory: " << ba.what();
|
|
133
|
+
handle_string_error(c_ctx, msg_stream.str(), 2);
|
|
140
134
|
}
|
|
141
135
|
catch (std::exception& e) {
|
|
142
|
-
|
|
143
|
-
JsonNode* json_err = json_mkobject();
|
|
144
|
-
msg_stream << "Internal Error: " << e.what() << std::endl;
|
|
145
|
-
json_append_member(json_err, "status", json_mknumber(3));
|
|
146
|
-
json_append_member(json_err, "message", json_mkstring(e.what()));
|
|
147
|
-
json_append_member(json_err, "formatted", json_mkstream(msg_stream));
|
|
148
|
-
try { c_ctx->error_json = json_stringify(json_err, " "); }
|
|
149
|
-
catch (...) {}
|
|
150
|
-
c_ctx->error_message = sass_copy_string(msg_stream.str());
|
|
151
|
-
c_ctx->error_text = sass_copy_c_string(e.what());
|
|
152
|
-
c_ctx->error_status = 3;
|
|
153
|
-
c_ctx->output_string = 0;
|
|
154
|
-
c_ctx->source_map_string = 0;
|
|
155
|
-
json_delete(json_err);
|
|
136
|
+
handle_string_error(c_ctx, e.what(), 3);
|
|
156
137
|
}
|
|
157
138
|
catch (std::string& e) {
|
|
158
|
-
|
|
159
|
-
JsonNode* json_err = json_mkobject();
|
|
160
|
-
msg_stream << "Internal Error: " << e << std::endl;
|
|
161
|
-
json_append_member(json_err, "status", json_mknumber(4));
|
|
162
|
-
json_append_member(json_err, "message", json_mkstring(e.c_str()));
|
|
163
|
-
json_append_member(json_err, "formatted", json_mkstream(msg_stream));
|
|
164
|
-
try { c_ctx->error_json = json_stringify(json_err, " "); }
|
|
165
|
-
catch (...) {}
|
|
166
|
-
c_ctx->error_message = sass_copy_string(msg_stream.str());
|
|
167
|
-
c_ctx->error_text = sass_copy_c_string(e.c_str());
|
|
168
|
-
c_ctx->error_status = 4;
|
|
169
|
-
c_ctx->output_string = 0;
|
|
170
|
-
c_ctx->source_map_string = 0;
|
|
171
|
-
json_delete(json_err);
|
|
139
|
+
handle_string_error(c_ctx, e, 4);
|
|
172
140
|
}
|
|
173
141
|
catch (const char* e) {
|
|
174
|
-
|
|
175
|
-
JsonNode* json_err = json_mkobject();
|
|
176
|
-
msg_stream << "Internal Error: " << e << std::endl;
|
|
177
|
-
json_append_member(json_err, "status", json_mknumber(4));
|
|
178
|
-
json_append_member(json_err, "message", json_mkstring(e));
|
|
179
|
-
json_append_member(json_err, "formatted", json_mkstream(msg_stream));
|
|
180
|
-
try { c_ctx->error_json = json_stringify(json_err, " "); }
|
|
181
|
-
catch (...) {}
|
|
182
|
-
c_ctx->error_message = sass_copy_string(msg_stream.str());
|
|
183
|
-
c_ctx->error_text = sass_copy_c_string(e);
|
|
184
|
-
c_ctx->error_status = 4;
|
|
185
|
-
c_ctx->output_string = 0;
|
|
186
|
-
c_ctx->source_map_string = 0;
|
|
187
|
-
json_delete(json_err);
|
|
142
|
+
handle_string_error(c_ctx, e, 4);
|
|
188
143
|
}
|
|
189
144
|
catch (...) {
|
|
190
|
-
|
|
191
|
-
JsonNode* json_err = json_mkobject();
|
|
192
|
-
msg_stream << "Unknown error occurred" << std::endl;
|
|
193
|
-
json_append_member(json_err, "status", json_mknumber(5));
|
|
194
|
-
json_append_member(json_err, "message", json_mkstring("unknown"));
|
|
195
|
-
try { c_ctx->error_json = json_stringify(json_err, " "); }
|
|
196
|
-
catch (...) {}
|
|
197
|
-
c_ctx->error_message = sass_copy_string(msg_stream.str());
|
|
198
|
-
c_ctx->error_text = sass_copy_c_string("unknown");
|
|
199
|
-
c_ctx->error_status = 5;
|
|
200
|
-
c_ctx->output_string = 0;
|
|
201
|
-
c_ctx->source_map_string = 0;
|
|
202
|
-
json_delete(json_err);
|
|
145
|
+
handle_string_error(c_ctx, "unknown", 5);
|
|
203
146
|
}
|
|
204
147
|
return c_ctx->error_status;
|
|
205
148
|
}
|
|
@@ -334,8 +277,8 @@ extern "C" {
|
|
|
334
277
|
c_ctx->error_message = 0;
|
|
335
278
|
c_ctx->error_status = 0;
|
|
336
279
|
// reset error position
|
|
337
|
-
c_ctx->error_src = 0;
|
|
338
280
|
c_ctx->error_file = 0;
|
|
281
|
+
c_ctx->error_src = 0;
|
|
339
282
|
c_ctx->error_line = std::string::npos;
|
|
340
283
|
c_ctx->error_column = std::string::npos;
|
|
341
284
|
|
|
@@ -399,7 +342,9 @@ extern "C" {
|
|
|
399
342
|
|
|
400
343
|
Sass_File_Context* ADDCALL sass_make_file_context(const char* input_path)
|
|
401
344
|
{
|
|
402
|
-
|
|
345
|
+
#ifdef DEBUG_SHARED_PTR
|
|
346
|
+
SharedObj::setTaint(true);
|
|
347
|
+
#endif
|
|
403
348
|
struct Sass_File_Context* ctx = (struct Sass_File_Context*) calloc(1, sizeof(struct Sass_File_Context));
|
|
404
349
|
if (ctx == 0) { std::cerr << "Error allocating memory for file context" << std::endl; return 0; }
|
|
405
350
|
ctx->type = SASS_CONTEXT_FILE;
|
|
@@ -416,6 +361,9 @@ extern "C" {
|
|
|
416
361
|
|
|
417
362
|
Sass_Data_Context* ADDCALL sass_make_data_context(char* source_string)
|
|
418
363
|
{
|
|
364
|
+
#ifdef DEBUG_SHARED_PTR
|
|
365
|
+
SharedObj::setTaint(true);
|
|
366
|
+
#endif
|
|
419
367
|
struct Sass_Data_Context* ctx = (struct Sass_Data_Context*) calloc(1, sizeof(struct Sass_Data_Context));
|
|
420
368
|
if (ctx == 0) { std::cerr << "Error allocating memory for data context" << std::endl; return 0; }
|
|
421
369
|
ctx->type = SASS_CONTEXT_DATA;
|
|
@@ -451,7 +399,7 @@ extern "C" {
|
|
|
451
399
|
return data_ctx->error_status;
|
|
452
400
|
try {
|
|
453
401
|
if (data_ctx->source_string == 0) { throw(std::runtime_error("Data context has no source string")); }
|
|
454
|
-
// empty source string is a valid case, even if not really
|
|
402
|
+
// empty source string is a valid case, even if not really useful (different than with file context)
|
|
455
403
|
// if (*data_ctx->source_string == 0) { throw(std::runtime_error("Data context has empty source string")); }
|
|
456
404
|
}
|
|
457
405
|
catch (...) { return handle_errors(data_ctx) | 1; }
|
|
@@ -533,7 +481,7 @@ extern "C" {
|
|
|
533
481
|
static void sass_clear_options (struct Sass_Options* options)
|
|
534
482
|
{
|
|
535
483
|
if (options == 0) return;
|
|
536
|
-
// Deallocate custom functions, headers and
|
|
484
|
+
// Deallocate custom functions, headers and imports
|
|
537
485
|
sass_delete_function_list(options->c_functions);
|
|
538
486
|
sass_delete_importer_list(options->c_importers);
|
|
539
487
|
sass_delete_importer_list(options->c_headers);
|
|
@@ -594,6 +542,7 @@ extern "C" {
|
|
|
594
542
|
if (ctx->error_text) free(ctx->error_text);
|
|
595
543
|
if (ctx->error_json) free(ctx->error_json);
|
|
596
544
|
if (ctx->error_file) free(ctx->error_file);
|
|
545
|
+
if (ctx->error_src) free(ctx->error_src);
|
|
597
546
|
free_string_array(ctx->included_files);
|
|
598
547
|
// play safe and reset properties
|
|
599
548
|
ctx->output_string = 0;
|
|
@@ -602,6 +551,7 @@ extern "C" {
|
|
|
602
551
|
ctx->error_text = 0;
|
|
603
552
|
ctx->error_json = 0;
|
|
604
553
|
ctx->error_file = 0;
|
|
554
|
+
ctx->error_src = 0;
|
|
605
555
|
ctx->included_files = 0;
|
|
606
556
|
// debug leaked memory
|
|
607
557
|
#ifdef DEBUG_SHARED_PTR
|
|
@@ -656,7 +606,7 @@ extern "C" {
|
|
|
656
606
|
void ADDCALL sass_file_context_set_options (struct Sass_File_Context* ctx, struct Sass_Options* opt) { copy_options(ctx, opt); }
|
|
657
607
|
void ADDCALL sass_data_context_set_options (struct Sass_Data_Context* ctx, struct Sass_Options* opt) { copy_options(ctx, opt); }
|
|
658
608
|
|
|
659
|
-
// Getters for Sass_Compiler options (get
|
|
609
|
+
// Getters for Sass_Compiler options (get connected sass context)
|
|
660
610
|
enum Sass_Compiler_State ADDCALL sass_compiler_get_state(struct Sass_Compiler* compiler) { return compiler->state; }
|
|
661
611
|
struct Sass_Context* ADDCALL sass_compiler_get_context(struct Sass_Compiler* compiler) { return compiler->c_ctx; }
|
|
662
612
|
struct Sass_Options* ADDCALL sass_compiler_get_options(struct Sass_Compiler* compiler) { return compiler->c_ctx; }
|
|
@@ -700,9 +650,9 @@ extern "C" {
|
|
|
700
650
|
IMPLEMENT_SASS_CONTEXT_GETTER(const char*, error_message);
|
|
701
651
|
IMPLEMENT_SASS_CONTEXT_GETTER(const char*, error_text);
|
|
702
652
|
IMPLEMENT_SASS_CONTEXT_GETTER(const char*, error_file);
|
|
653
|
+
IMPLEMENT_SASS_CONTEXT_GETTER(const char*, error_src);
|
|
703
654
|
IMPLEMENT_SASS_CONTEXT_GETTER(size_t, error_line);
|
|
704
655
|
IMPLEMENT_SASS_CONTEXT_GETTER(size_t, error_column);
|
|
705
|
-
IMPLEMENT_SASS_CONTEXT_GETTER(const char*, error_src);
|
|
706
656
|
IMPLEMENT_SASS_CONTEXT_GETTER(const char*, output_string);
|
|
707
657
|
IMPLEMENT_SASS_CONTEXT_GETTER(const char*, source_map_string);
|
|
708
658
|
IMPLEMENT_SASS_CONTEXT_GETTER(char**, included_files);
|
|
@@ -712,6 +662,7 @@ extern "C" {
|
|
|
712
662
|
IMPLEMENT_SASS_CONTEXT_TAKER(char*, error_message);
|
|
713
663
|
IMPLEMENT_SASS_CONTEXT_TAKER(char*, error_text);
|
|
714
664
|
IMPLEMENT_SASS_CONTEXT_TAKER(char*, error_file);
|
|
665
|
+
IMPLEMENT_SASS_CONTEXT_TAKER(char*, error_src);
|
|
715
666
|
IMPLEMENT_SASS_CONTEXT_TAKER(char*, output_string);
|
|
716
667
|
IMPLEMENT_SASS_CONTEXT_TAKER(char*, source_map_string);
|
|
717
668
|
IMPLEMENT_SASS_CONTEXT_TAKER(char**, included_files);
|