sassc 1.11.4 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +2 -2
- data/CODE_OF_CONDUCT.md +10 -0
- data/README.md +4 -1
- data/ext/libsass/.editorconfig +1 -1
- data/ext/libsass/.github/CONTRIBUTING.md +7 -7
- data/ext/libsass/.github/ISSUE_TEMPLATE.md +31 -6
- data/ext/libsass/.gitignore +3 -0
- data/ext/libsass/.travis.yml +37 -18
- data/ext/libsass/GNUmakefile.am +23 -37
- data/ext/libsass/Makefile +10 -6
- data/ext/libsass/Makefile.conf +3 -0
- data/ext/libsass/Readme.md +68 -63
- data/ext/libsass/appveyor.yml +7 -3
- data/ext/libsass/configure.ac +10 -14
- data/ext/libsass/docs/api-context-internal.md +29 -21
- data/ext/libsass/docs/api-context.md +26 -6
- data/ext/libsass/docs/api-doc.md +49 -16
- data/ext/libsass/docs/api-function-example.md +1 -1
- data/ext/libsass/docs/api-function.md +31 -7
- data/ext/libsass/docs/api-importer.md +19 -19
- data/ext/libsass/docs/api-value.md +4 -2
- data/ext/libsass/docs/build-on-windows.md +4 -4
- data/ext/libsass/docs/build-with-mingw.md +3 -3
- data/ext/libsass/docs/build.md +9 -9
- data/ext/libsass/docs/custom-functions-internal.md +10 -8
- data/ext/libsass/docs/implementations.md +20 -8
- data/ext/libsass/docs/unicode.md +16 -10
- data/ext/libsass/include/sass/base.h +0 -3
- data/ext/libsass/include/sass/context.h +20 -2
- data/ext/libsass/include/sass/functions.h +31 -0
- data/ext/libsass/include/sass/values.h +3 -1
- data/ext/libsass/include/sass/version.h +1 -1
- data/ext/libsass/include/sass/version.h.in +1 -1
- data/ext/libsass/include/sass2scss.h +1 -1
- data/ext/libsass/res/resource.rc +6 -6
- data/ext/libsass/script/ci-build-libsass +10 -5
- data/ext/libsass/script/ci-build-plugin +62 -0
- data/ext/libsass/script/ci-install-compiler +1 -1
- data/ext/libsass/script/ci-install-deps +4 -7
- data/ext/libsass/script/ci-report-coverage +13 -3
- data/ext/libsass/script/tap-driver +1 -1
- data/ext/libsass/script/tap-runner +1 -1
- data/ext/libsass/src/GNUmakefile.am +1 -1
- data/ext/libsass/src/ast.cpp +537 -762
- data/ext/libsass/src/ast.hpp +377 -419
- data/ext/libsass/src/ast_def_macros.hpp +26 -1
- data/ext/libsass/src/ast_fwd_decl.cpp +29 -0
- data/ext/libsass/src/ast_fwd_decl.hpp +94 -21
- data/ext/libsass/src/b64/encode.h +3 -1
- data/ext/libsass/src/backtrace.cpp +46 -0
- data/ext/libsass/src/backtrace.hpp +7 -54
- data/ext/libsass/src/bind.cpp +72 -50
- data/ext/libsass/src/bind.hpp +0 -1
- data/ext/libsass/src/cencode.c +6 -0
- data/ext/libsass/src/check_nesting.cpp +157 -135
- data/ext/libsass/src/check_nesting.hpp +11 -10
- data/ext/libsass/src/color_maps.cpp +10 -6
- data/ext/libsass/src/color_maps.hpp +6 -8
- data/ext/libsass/src/constants.cpp +4 -3
- data/ext/libsass/src/constants.hpp +4 -3
- data/ext/libsass/src/context.cpp +110 -47
- data/ext/libsass/src/context.hpp +11 -1
- data/ext/libsass/src/cssize.cpp +105 -94
- data/ext/libsass/src/cssize.hpp +4 -5
- data/ext/libsass/src/debugger.hpp +247 -244
- data/ext/libsass/src/emitter.cpp +30 -6
- data/ext/libsass/src/emitter.hpp +7 -0
- data/ext/libsass/src/environment.cpp +67 -16
- data/ext/libsass/src/environment.hpp +28 -7
- data/ext/libsass/src/error_handling.cpp +92 -64
- data/ext/libsass/src/error_handling.hpp +64 -43
- data/ext/libsass/src/eval.cpp +494 -544
- data/ext/libsass/src/eval.hpp +17 -23
- data/ext/libsass/src/expand.cpp +182 -154
- data/ext/libsass/src/expand.hpp +4 -5
- data/ext/libsass/src/extend.cpp +299 -291
- data/ext/libsass/src/extend.hpp +46 -11
- data/ext/libsass/src/file.cpp +103 -36
- data/ext/libsass/src/file.hpp +21 -4
- data/ext/libsass/src/functions.cpp +561 -312
- data/ext/libsass/src/functions.hpp +8 -5
- data/ext/libsass/src/inspect.cpp +108 -53
- data/ext/libsass/src/inspect.hpp +5 -2
- data/ext/libsass/src/lexer.cpp +15 -7
- data/ext/libsass/src/lexer.hpp +13 -4
- data/ext/libsass/src/listize.cpp +3 -2
- data/ext/libsass/src/listize.hpp +0 -1
- data/ext/libsass/src/memory/SharedPtr.cpp +16 -18
- data/ext/libsass/src/memory/SharedPtr.hpp +47 -43
- data/ext/libsass/src/node.cpp +34 -38
- data/ext/libsass/src/node.hpp +6 -8
- data/ext/libsass/src/operation.hpp +2 -2
- data/ext/libsass/src/operators.cpp +240 -0
- data/ext/libsass/src/operators.hpp +30 -0
- data/ext/libsass/src/output.cpp +22 -20
- data/ext/libsass/src/parser.cpp +719 -358
- data/ext/libsass/src/parser.hpp +57 -22
- data/ext/libsass/src/plugins.cpp +28 -10
- data/ext/libsass/src/position.cpp +21 -3
- data/ext/libsass/src/position.hpp +2 -1
- data/ext/libsass/src/prelexer.cpp +104 -19
- data/ext/libsass/src/prelexer.hpp +10 -3
- data/ext/libsass/src/remove_placeholders.cpp +9 -10
- data/ext/libsass/src/remove_placeholders.hpp +1 -5
- data/ext/libsass/src/sass.cpp +62 -4
- data/ext/libsass/src/sass.hpp +5 -2
- data/ext/libsass/src/sass_context.cpp +96 -58
- data/ext/libsass/src/sass_context.hpp +7 -5
- data/ext/libsass/src/sass_functions.cpp +63 -1
- data/ext/libsass/src/sass_functions.hpp +19 -1
- data/ext/libsass/src/sass_util.cpp +3 -3
- data/ext/libsass/src/sass_util.hpp +4 -4
- data/ext/libsass/src/sass_values.cpp +42 -39
- data/ext/libsass/src/sass_values.hpp +2 -1
- data/ext/libsass/src/source_map.cpp +16 -18
- data/ext/libsass/src/subset_map.cpp +6 -8
- data/ext/libsass/src/subset_map.hpp +6 -6
- data/ext/libsass/src/to_c.cpp +2 -2
- data/ext/libsass/src/to_value.cpp +8 -3
- data/ext/libsass/src/to_value.hpp +1 -0
- data/ext/libsass/src/units.cpp +349 -45
- data/ext/libsass/src/units.hpp +39 -22
- data/ext/libsass/src/utf8/checked.h +7 -0
- data/ext/libsass/src/utf8/unchecked.h +7 -0
- data/ext/libsass/src/utf8_string.cpp +1 -1
- data/ext/libsass/src/util.cpp +139 -45
- data/ext/libsass/src/util.hpp +4 -7
- data/ext/libsass/src/values.cpp +15 -23
- data/ext/libsass/win/libsass.sln +13 -2
- data/ext/libsass/win/libsass.sln.DotSettings +9 -0
- data/ext/libsass/win/libsass.targets +3 -0
- data/ext/libsass/win/libsass.vcxproj.filters +9 -0
- data/lib/sassc/version.rb +1 -1
- data/sassc.gemspec +1 -1
- data/test/native_test.rb +1 -1
- metadata +11 -4
@@ -1,9 +1,8 @@
|
|
1
1
|
#ifndef SASS_SASS_CONTEXT_H
|
2
2
|
#define SASS_SASS_CONTEXT_H
|
3
3
|
|
4
|
-
#include "sass.h"
|
5
|
-
#include "sass.
|
6
|
-
#include "context.hpp"
|
4
|
+
#include "sass/base.h"
|
5
|
+
#include "sass/context.h"
|
7
6
|
#include "ast_fwd_decl.hpp"
|
8
7
|
|
9
8
|
// sass config options structure
|
@@ -33,7 +32,7 @@ struct Sass_Options : Sass_Output_Options {
|
|
33
32
|
char* input_path;
|
34
33
|
|
35
34
|
// The output path is used for source map
|
36
|
-
// generation.
|
35
|
+
// generation. LibSass will not write to
|
37
36
|
// this file, it is just used to create
|
38
37
|
// information in source-maps etc.
|
39
38
|
char* output_path;
|
@@ -41,9 +40,12 @@ struct Sass_Options : Sass_Output_Options {
|
|
41
40
|
// Colon-separated list of paths
|
42
41
|
// Semicolon-separated on Windows
|
43
42
|
// Maybe use array interface instead?
|
43
|
+
char* extension;
|
44
44
|
char* include_path;
|
45
45
|
char* plugin_path;
|
46
46
|
|
47
|
+
// Extensions (linked string list)
|
48
|
+
struct string_list* extensions;
|
47
49
|
// Include paths (linked string list)
|
48
50
|
struct string_list* include_paths;
|
49
51
|
// Plugin paths (linked string list)
|
@@ -127,4 +129,4 @@ struct Sass_Compiler {
|
|
127
129
|
Sass::Block_Obj root;
|
128
130
|
};
|
129
131
|
|
130
|
-
#endif
|
132
|
+
#endif
|
@@ -2,6 +2,7 @@
|
|
2
2
|
#include <cstring>
|
3
3
|
#include "util.hpp"
|
4
4
|
#include "context.hpp"
|
5
|
+
#include "values.hpp"
|
5
6
|
#include "sass/functions.h"
|
6
7
|
#include "sass_functions.hpp"
|
7
8
|
|
@@ -17,12 +18,30 @@ extern "C" {
|
|
17
18
|
{
|
18
19
|
Sass_Function_Entry cb = (Sass_Function_Entry) calloc(1, sizeof(Sass_Function));
|
19
20
|
if (cb == 0) return 0;
|
20
|
-
cb->signature = signature;
|
21
|
+
cb->signature = sass_copy_c_string(signature);
|
21
22
|
cb->function = function;
|
22
23
|
cb->cookie = cookie;
|
23
24
|
return cb;
|
24
25
|
}
|
25
26
|
|
27
|
+
void ADDCALL sass_delete_function(Sass_Function_Entry entry)
|
28
|
+
{
|
29
|
+
free(entry->signature);
|
30
|
+
free(entry);
|
31
|
+
}
|
32
|
+
|
33
|
+
// Deallocator for the allocated memory
|
34
|
+
void ADDCALL sass_delete_function_list(Sass_Function_List list)
|
35
|
+
{
|
36
|
+
Sass_Function_List it = list;
|
37
|
+
if (list == 0) return;
|
38
|
+
while(*list) {
|
39
|
+
sass_delete_function(*list);
|
40
|
+
++list;
|
41
|
+
}
|
42
|
+
free(it);
|
43
|
+
}
|
44
|
+
|
26
45
|
// Setters and getters for callbacks on function lists
|
27
46
|
Sass_Function_Entry ADDCALL sass_function_get_list_entry(Sass_Function_List list, size_t pos) { return list[pos]; }
|
28
47
|
void sass_function_set_list_entry(Sass_Function_List list, size_t pos, Sass_Function_Entry cb) { list[pos] = cb; }
|
@@ -57,6 +76,18 @@ extern "C" {
|
|
57
76
|
return (Sass_Importer_List) calloc(length + 1, sizeof(Sass_Importer_Entry));
|
58
77
|
}
|
59
78
|
|
79
|
+
// Deallocator for the allocated memory
|
80
|
+
void ADDCALL sass_delete_importer_list(Sass_Importer_List list)
|
81
|
+
{
|
82
|
+
Sass_Importer_List it = list;
|
83
|
+
if (list == 0) return;
|
84
|
+
while(*list) {
|
85
|
+
sass_delete_importer(*list);
|
86
|
+
++list;
|
87
|
+
}
|
88
|
+
free(it);
|
89
|
+
}
|
90
|
+
|
60
91
|
Sass_Importer_Entry ADDCALL sass_importer_get_list_entry(Sass_Importer_List list, size_t idx) { return list[idx]; }
|
61
92
|
void ADDCALL sass_importer_set_list_entry(Sass_Importer_List list, size_t idx, Sass_Importer_Entry cb) { list[idx] = cb; }
|
62
93
|
|
@@ -126,6 +157,37 @@ extern "C" {
|
|
126
157
|
free(import);
|
127
158
|
}
|
128
159
|
|
160
|
+
// Getter for callee entry
|
161
|
+
const char* ADDCALL sass_callee_get_name(Sass_Callee_Entry entry) { return entry->name; }
|
162
|
+
const char* ADDCALL sass_callee_get_path(Sass_Callee_Entry entry) { return entry->path; }
|
163
|
+
size_t ADDCALL sass_callee_get_line(Sass_Callee_Entry entry) { return entry->line; }
|
164
|
+
size_t ADDCALL sass_callee_get_column(Sass_Callee_Entry entry) { return entry->column; }
|
165
|
+
enum Sass_Callee_Type ADDCALL sass_callee_get_type(Sass_Callee_Entry entry) { return entry->type; }
|
166
|
+
Sass_Env_Frame ADDCALL sass_callee_get_env (Sass_Callee_Entry entry) { return &entry->env; }
|
167
|
+
|
168
|
+
// Getters and Setters for environments (lexical, local and global)
|
169
|
+
union Sass_Value* ADDCALL sass_env_get_lexical (Sass_Env_Frame env, const char* name) {
|
170
|
+
Expression_Ptr ex = Cast<Expression>((*env->frame)[name]);
|
171
|
+
return ex != NULL ? ast_node_to_sass_value(ex) : NULL;
|
172
|
+
}
|
173
|
+
void ADDCALL sass_env_set_lexical (Sass_Env_Frame env, const char* name, union Sass_Value* val) {
|
174
|
+
(*env->frame)[name] = sass_value_to_ast_node(val);
|
175
|
+
}
|
176
|
+
union Sass_Value* ADDCALL sass_env_get_local (Sass_Env_Frame env, const char* name) {
|
177
|
+
Expression_Ptr ex = Cast<Expression>(env->frame->get_local(name));
|
178
|
+
return ex != NULL ? ast_node_to_sass_value(ex) : NULL;
|
179
|
+
}
|
180
|
+
void ADDCALL sass_env_set_local (Sass_Env_Frame env, const char* name, union Sass_Value* val) {
|
181
|
+
env->frame->set_local(name, sass_value_to_ast_node(val));
|
182
|
+
}
|
183
|
+
union Sass_Value* ADDCALL sass_env_get_global (Sass_Env_Frame env, const char* name) {
|
184
|
+
Expression_Ptr ex = Cast<Expression>(env->frame->get_global(name));
|
185
|
+
return ex != NULL ? ast_node_to_sass_value(ex) : NULL;
|
186
|
+
}
|
187
|
+
void ADDCALL sass_env_set_global (Sass_Env_Frame env, const char* name, union Sass_Value* val) {
|
188
|
+
env->frame->set_global(name, sass_value_to_ast_node(val));
|
189
|
+
}
|
190
|
+
|
129
191
|
// Getter for import entry
|
130
192
|
const char* ADDCALL sass_import_get_imp_path(Sass_Import_Entry entry) { return entry->imp_path; }
|
131
193
|
const char* ADDCALL sass_import_get_abs_path(Sass_Import_Entry entry) { return entry->abs_path; }
|
@@ -2,10 +2,12 @@
|
|
2
2
|
#define SASS_SASS_FUNCTIONS_H
|
3
3
|
|
4
4
|
#include "sass.h"
|
5
|
+
#include "environment.hpp"
|
6
|
+
#include "functions.hpp"
|
5
7
|
|
6
8
|
// Struct to hold custom function callback
|
7
9
|
struct Sass_Function {
|
8
|
-
|
10
|
+
char* signature;
|
9
11
|
Sass_Function_Fn function;
|
10
12
|
void* cookie;
|
11
13
|
};
|
@@ -22,6 +24,22 @@ struct Sass_Import {
|
|
22
24
|
size_t column;
|
23
25
|
};
|
24
26
|
|
27
|
+
// External environments
|
28
|
+
struct Sass_Env {
|
29
|
+
// links to parent frames
|
30
|
+
Sass::Env* frame;
|
31
|
+
};
|
32
|
+
|
33
|
+
// External call entry
|
34
|
+
struct Sass_Callee {
|
35
|
+
const char* name;
|
36
|
+
const char* path;
|
37
|
+
size_t line;
|
38
|
+
size_t column;
|
39
|
+
enum Sass_Callee_Type type;
|
40
|
+
struct Sass_Env env;
|
41
|
+
};
|
42
|
+
|
25
43
|
// Struct to hold importer callback
|
26
44
|
struct Sass_Importer {
|
27
45
|
Sass_Importer_Fn importer;
|
@@ -37,7 +37,7 @@ namespace Sass {
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
*/
|
40
|
-
Node paths(const Node& arrs
|
40
|
+
Node paths(const Node& arrs) {
|
41
41
|
|
42
42
|
Node loopStart = Node::createCollection();
|
43
43
|
loopStart.collection()->push_back(Node::createCollection());
|
@@ -108,7 +108,7 @@ namespace Sass {
|
|
108
108
|
return flattened
|
109
109
|
end
|
110
110
|
*/
|
111
|
-
Node flatten(Node& arr,
|
111
|
+
Node flatten(Node& arr, int n) {
|
112
112
|
if (n != -1 && n == 0) {
|
113
113
|
return arr;
|
114
114
|
}
|
@@ -124,7 +124,7 @@ namespace Sass {
|
|
124
124
|
if (e.isCollection()) {
|
125
125
|
|
126
126
|
// e.collection().got_line_feed = e.got_line_feed;
|
127
|
-
Node recurseFlattened = flatten(e,
|
127
|
+
Node recurseFlattened = flatten(e, n - 1);
|
128
128
|
|
129
129
|
if(e.got_line_feed) {
|
130
130
|
flattened.got_line_feed = e.got_line_feed;
|
@@ -28,7 +28,7 @@ namespace Sass {
|
|
28
28
|
# # [1, 4, 5],
|
29
29
|
# # [2, 4, 5]]
|
30
30
|
*/
|
31
|
-
Node paths(const Node& arrs
|
31
|
+
Node paths(const Node& arrs);
|
32
32
|
|
33
33
|
|
34
34
|
/*
|
@@ -40,7 +40,7 @@ namespace Sass {
|
|
40
40
|
bool operator()(const Node& one, const Node& two, Node& out) const {
|
41
41
|
// TODO: Is this the correct C++ interpretation?
|
42
42
|
// block ||= proc {|a, b| a == b && a}
|
43
|
-
if (
|
43
|
+
if (one == two) {
|
44
44
|
out = one;
|
45
45
|
return true;
|
46
46
|
}
|
@@ -139,7 +139,7 @@ namespace Sass {
|
|
139
139
|
http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
|
140
140
|
*/
|
141
141
|
template<typename ComparatorType>
|
142
|
-
Node lcs(Node& x, Node& y, const ComparatorType& comparator
|
142
|
+
Node lcs(Node& x, Node& y, const ComparatorType& comparator) {
|
143
143
|
DEBUG_PRINTLN(LCS, "LCS: X=" << x << " Y=" << y)
|
144
144
|
|
145
145
|
Node newX = Node::createCollection();
|
@@ -169,7 +169,7 @@ namespace Sass {
|
|
169
169
|
# @param n [int] The number of levels to flatten
|
170
170
|
# @return [NodeCollection] The flattened array
|
171
171
|
*/
|
172
|
-
Node flatten(Node& arr,
|
172
|
+
Node flatten(Node& arr, int n = -1);
|
173
173
|
|
174
174
|
|
175
175
|
/*
|
@@ -4,6 +4,7 @@
|
|
4
4
|
#include "util.hpp"
|
5
5
|
#include "eval.hpp"
|
6
6
|
#include "values.hpp"
|
7
|
+
#include "operators.hpp"
|
7
8
|
#include "sass/values.h"
|
8
9
|
#include "sass_values.hpp"
|
9
10
|
|
@@ -54,6 +55,8 @@ extern "C" {
|
|
54
55
|
size_t ADDCALL sass_list_get_length(const union Sass_Value* v) { return v->list.length; }
|
55
56
|
enum Sass_Separator ADDCALL sass_list_get_separator(const union Sass_Value* v) { return v->list.separator; }
|
56
57
|
void ADDCALL sass_list_set_separator(union Sass_Value* v, enum Sass_Separator separator) { v->list.separator = separator; }
|
58
|
+
bool ADDCALL sass_list_get_is_bracketed(const union Sass_Value* v) { return v->list.is_bracketed; }
|
59
|
+
void ADDCALL sass_list_set_is_bracketed(union Sass_Value* v, bool is_bracketed) { v->list.is_bracketed = is_bracketed; }
|
57
60
|
// Getters and setters for Sass_List values
|
58
61
|
union Sass_Value* ADDCALL sass_list_get_value(const union Sass_Value* v, size_t i) { return v->list.values[i]; }
|
59
62
|
void ADDCALL sass_list_set_value(union Sass_Value* v, size_t i, union Sass_Value* value) { v->list.values[i] = value; }
|
@@ -130,13 +133,14 @@ extern "C" {
|
|
130
133
|
return v;
|
131
134
|
}
|
132
135
|
|
133
|
-
union Sass_Value* ADDCALL sass_make_list(size_t len, enum Sass_Separator sep)
|
136
|
+
union Sass_Value* ADDCALL sass_make_list(size_t len, enum Sass_Separator sep, bool is_bracketed)
|
134
137
|
{
|
135
138
|
union Sass_Value* v = (Sass_Value*) calloc(1, sizeof(Sass_Value));
|
136
139
|
if (v == 0) return 0;
|
137
140
|
v->list.tag = SASS_LIST;
|
138
141
|
v->list.length = len;
|
139
142
|
v->list.separator = sep;
|
143
|
+
v->list.is_bracketed = is_bracketed;
|
140
144
|
v->list.values = (union Sass_Value**) calloc(len, sizeof(union Sass_Value*));
|
141
145
|
if (v->list.values == 0) { free(v); return 0; }
|
142
146
|
return v;
|
@@ -218,6 +222,7 @@ extern "C" {
|
|
218
222
|
case SASS_WARNING: {
|
219
223
|
free(val->error.message);
|
220
224
|
} break;
|
225
|
+
default: break;
|
221
226
|
}
|
222
227
|
|
223
228
|
free(val);
|
@@ -233,26 +238,26 @@ extern "C" {
|
|
233
238
|
switch(val->unknown.tag) {
|
234
239
|
case SASS_NULL: {
|
235
240
|
return sass_make_null();
|
236
|
-
}
|
241
|
+
}
|
237
242
|
case SASS_BOOLEAN: {
|
238
243
|
return sass_make_boolean(val->boolean.value);
|
239
|
-
}
|
244
|
+
}
|
240
245
|
case SASS_NUMBER: {
|
241
246
|
return sass_make_number(val->number.value, val->number.unit);
|
242
|
-
}
|
247
|
+
}
|
243
248
|
case SASS_COLOR: {
|
244
249
|
return sass_make_color(val->color.r, val->color.g, val->color.b, val->color.a);
|
245
|
-
}
|
250
|
+
}
|
246
251
|
case SASS_STRING: {
|
247
252
|
return sass_string_is_quoted(val) ? sass_make_qstring(val->string.value) : sass_make_string(val->string.value);
|
248
|
-
}
|
253
|
+
}
|
249
254
|
case SASS_LIST: {
|
250
|
-
union Sass_Value* list = sass_make_list(val->list.length, val->list.separator);
|
255
|
+
union Sass_Value* list = sass_make_list(val->list.length, val->list.separator, val->list.is_bracketed);
|
251
256
|
for (i = 0; i < list->list.length; i++) {
|
252
257
|
list->list.values[i] = sass_clone_value(val->list.values[i]);
|
253
258
|
}
|
254
259
|
return list;
|
255
|
-
}
|
260
|
+
}
|
256
261
|
case SASS_MAP: {
|
257
262
|
union Sass_Value* map = sass_make_map(val->map.length);
|
258
263
|
for (i = 0; i < val->map.length; i++) {
|
@@ -260,13 +265,14 @@ extern "C" {
|
|
260
265
|
map->map.pairs[i].value = sass_clone_value(val->map.pairs[i].value);
|
261
266
|
}
|
262
267
|
return map;
|
263
|
-
}
|
268
|
+
}
|
264
269
|
case SASS_ERROR: {
|
265
270
|
return sass_make_error(val->error.message);
|
266
|
-
}
|
271
|
+
}
|
267
272
|
case SASS_WARNING: {
|
268
273
|
return sass_make_warning(val->warning.message);
|
269
|
-
}
|
274
|
+
}
|
275
|
+
default: break;
|
270
276
|
}
|
271
277
|
|
272
278
|
return 0;
|
@@ -284,7 +290,7 @@ extern "C" {
|
|
284
290
|
union Sass_Value* ADDCALL sass_value_op (enum Sass_OP op, const union Sass_Value* a, const union Sass_Value* b)
|
285
291
|
{
|
286
292
|
|
287
|
-
Sass::Value_Ptr rv
|
293
|
+
Sass::Value_Ptr rv;
|
288
294
|
|
289
295
|
try {
|
290
296
|
|
@@ -294,41 +300,41 @@ extern "C" {
|
|
294
300
|
|
295
301
|
// see if it's a relational expression
|
296
302
|
switch(op) {
|
297
|
-
case Sass_OP::EQ: return sass_make_boolean(
|
298
|
-
case Sass_OP::NEQ: return sass_make_boolean(
|
299
|
-
case Sass_OP::GT: return sass_make_boolean(
|
300
|
-
case Sass_OP::GTE: return sass_make_boolean(
|
301
|
-
case Sass_OP::LT: return sass_make_boolean(
|
302
|
-
case Sass_OP::LTE: return sass_make_boolean(
|
303
|
-
case Sass_OP::AND: return ast_node_to_sass_value(lhs->is_false() ?
|
304
|
-
case Sass_OP::OR: return ast_node_to_sass_value(lhs->is_false() ?
|
305
|
-
default:
|
303
|
+
case Sass_OP::EQ: return sass_make_boolean(Operators::eq(lhs, rhs));
|
304
|
+
case Sass_OP::NEQ: return sass_make_boolean(Operators::neq(lhs, rhs));
|
305
|
+
case Sass_OP::GT: return sass_make_boolean(Operators::gt(lhs, rhs));
|
306
|
+
case Sass_OP::GTE: return sass_make_boolean(Operators::gte(lhs, rhs));
|
307
|
+
case Sass_OP::LT: return sass_make_boolean(Operators::lt(lhs, rhs));
|
308
|
+
case Sass_OP::LTE: return sass_make_boolean(Operators::lte(lhs, rhs));
|
309
|
+
case Sass_OP::AND: return ast_node_to_sass_value(lhs->is_false() ? lhs : rhs);
|
310
|
+
case Sass_OP::OR: return ast_node_to_sass_value(lhs->is_false() ? rhs : lhs);
|
311
|
+
default: break;
|
306
312
|
}
|
307
313
|
|
308
314
|
if (sass_value_is_number(a) && sass_value_is_number(b)) {
|
309
|
-
Number_Ptr_Const l_n =
|
310
|
-
Number_Ptr_Const r_n =
|
311
|
-
rv =
|
315
|
+
Number_Ptr_Const l_n = Cast<Number>(lhs);
|
316
|
+
Number_Ptr_Const r_n = Cast<Number>(rhs);
|
317
|
+
rv = Operators::op_numbers(op, *l_n, *r_n, options, l_n->pstate());
|
312
318
|
}
|
313
319
|
else if (sass_value_is_number(a) && sass_value_is_color(a)) {
|
314
|
-
Number_Ptr_Const l_n =
|
315
|
-
Color_Ptr_Const r_c =
|
316
|
-
rv =
|
320
|
+
Number_Ptr_Const l_n = Cast<Number>(lhs);
|
321
|
+
Color_Ptr_Const r_c = Cast<Color>(rhs);
|
322
|
+
rv = Operators::op_number_color(op, *l_n, *r_c, options, l_n->pstate());
|
317
323
|
}
|
318
324
|
else if (sass_value_is_color(a) && sass_value_is_number(b)) {
|
319
|
-
Color_Ptr_Const l_c =
|
320
|
-
Number_Ptr_Const r_n =
|
321
|
-
rv =
|
325
|
+
Color_Ptr_Const l_c = Cast<Color>(lhs);
|
326
|
+
Number_Ptr_Const r_n = Cast<Number>(rhs);
|
327
|
+
rv = Operators::op_color_number(op, *l_c, *r_n, options, l_c->pstate());
|
322
328
|
}
|
323
329
|
else if (sass_value_is_color(a) && sass_value_is_color(b)) {
|
324
|
-
Color_Ptr_Const l_c =
|
325
|
-
Color_Ptr_Const r_c =
|
326
|
-
rv =
|
330
|
+
Color_Ptr_Const l_c = Cast<Color>(lhs);
|
331
|
+
Color_Ptr_Const r_c = Cast<Color>(rhs);
|
332
|
+
rv = Operators::op_colors(op, *l_c, *r_c, options, l_c->pstate());
|
327
333
|
}
|
328
334
|
else /* convert other stuff to string and apply operation */ {
|
329
|
-
Value_Ptr l_v =
|
330
|
-
Value_Ptr r_v =
|
331
|
-
rv =
|
335
|
+
Value_Ptr l_v = Cast<Value>(lhs);
|
336
|
+
Value_Ptr r_v = Cast<Value>(rhs);
|
337
|
+
rv = Operators::op_strings(op, *l_v, *r_v, options, l_v->pstate());
|
332
338
|
}
|
333
339
|
|
334
340
|
// ToDo: maybe we should should return null value?
|
@@ -346,9 +352,6 @@ extern "C" {
|
|
346
352
|
catch (std::string& e) { return sass_make_error(e.c_str()); }
|
347
353
|
catch (const char* e) { return sass_make_error(e); }
|
348
354
|
catch (...) { return sass_make_error("unknown"); }
|
349
|
-
|
350
|
-
return 0;
|
351
|
-
|
352
355
|
}
|
353
356
|
|
354
357
|
}
|
@@ -35,6 +35,7 @@ struct Sass_String {
|
|
35
35
|
struct Sass_List {
|
36
36
|
enum Sass_Tag tag;
|
37
37
|
enum Sass_Separator separator;
|
38
|
+
bool is_bracketed;
|
38
39
|
size_t length;
|
39
40
|
// null terminated "array"
|
40
41
|
union Sass_Value** values;
|
@@ -78,4 +79,4 @@ struct Sass_MapPair {
|
|
78
79
|
union Sass_Value* value;
|
79
80
|
};
|
80
81
|
|
81
|
-
#endif
|
82
|
+
#endif
|
@@ -2,7 +2,6 @@
|
|
2
2
|
#include <string>
|
3
3
|
#include <sstream>
|
4
4
|
#include <iostream>
|
5
|
-
#include <cstddef>
|
6
5
|
#include <iomanip>
|
7
6
|
|
8
7
|
#include "ast.hpp"
|
@@ -25,9 +24,9 @@ namespace Sass {
|
|
25
24
|
|
26
25
|
json_append_member(json_srcmap, "version", json_mknumber(3));
|
27
26
|
|
28
|
-
const char *
|
29
|
-
JsonNode *
|
30
|
-
json_append_member(json_srcmap, "file",
|
27
|
+
const char *file_name = file.c_str();
|
28
|
+
JsonNode *json_file_name = json_mkstring(file_name);
|
29
|
+
json_append_member(json_srcmap, "file", json_file_name);
|
31
30
|
|
32
31
|
// pass-through sourceRoot option
|
33
32
|
if (!ctx.source_map_root.empty()) {
|
@@ -35,35 +34,34 @@ namespace Sass {
|
|
35
34
|
json_append_member(json_srcmap, "sourceRoot", root);
|
36
35
|
}
|
37
36
|
|
38
|
-
JsonNode *
|
37
|
+
JsonNode *json_sources = json_mkarray();
|
39
38
|
for (size_t i = 0; i < source_index.size(); ++i) {
|
40
|
-
std::string
|
39
|
+
std::string source(links[source_index[i]]);
|
41
40
|
if (ctx.c_options.source_map_file_urls) {
|
42
|
-
|
41
|
+
source = File::rel2abs(source);
|
43
42
|
// check for windows abs path
|
44
|
-
if (
|
43
|
+
if (source[0] == '/') {
|
45
44
|
// ends up with three slashes
|
46
|
-
|
45
|
+
source = "file://" + source;
|
47
46
|
} else {
|
48
47
|
// needs an additional slash
|
49
|
-
|
48
|
+
source = "file:///" + source;
|
50
49
|
}
|
51
50
|
}
|
52
|
-
const char*
|
53
|
-
JsonNode *
|
54
|
-
json_append_element(
|
51
|
+
const char* source_name = source.c_str();
|
52
|
+
JsonNode *json_source_name = json_mkstring(source_name);
|
53
|
+
json_append_element(json_sources, json_source_name);
|
55
54
|
}
|
56
|
-
json_append_member(json_srcmap, "sources",
|
55
|
+
json_append_member(json_srcmap, "sources", json_sources);
|
57
56
|
|
58
|
-
if (include_sources) {
|
57
|
+
if (include_sources && source_index.size()) {
|
59
58
|
JsonNode *json_contents = json_mkarray();
|
60
59
|
for (size_t i = 0; i < source_index.size(); ++i) {
|
61
60
|
const Resource& resource(sources[source_index[i]]);
|
62
61
|
JsonNode *json_content = json_mkstring(resource.contents);
|
63
62
|
json_append_element(json_contents, json_content);
|
64
63
|
}
|
65
|
-
|
66
|
-
json_append_member(json_srcmap, "sourcesContent", json_contents);
|
64
|
+
json_append_member(json_srcmap, "sourcesContent", json_contents);
|
67
65
|
}
|
68
66
|
|
69
67
|
JsonNode *json_names = json_mkarray();
|
@@ -138,7 +136,7 @@ namespace Sass {
|
|
138
136
|
}
|
139
137
|
}
|
140
138
|
}
|
141
|
-
//
|
139
|
+
// adjust the buffer offset
|
142
140
|
prepend(Offset(out.buffer));
|
143
141
|
// now add the new mappings
|
144
142
|
VECTOR_UNSHIFT(mappings, out.smap.mappings);
|