sassc 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/ext/libsass/.gitignore +13 -6
- data/ext/libsass/Makefile +42 -26
- data/ext/libsass/Makefile.am +43 -30
- data/ext/libsass/Readme.md +4 -2
- data/ext/libsass/appveyor.yml +10 -14
- data/ext/libsass/ast.cpp +54 -44
- data/ext/libsass/ast.hpp +404 -236
- data/ext/libsass/ast_def_macros.hpp +5 -0
- data/ext/libsass/ast_factory.hpp +6 -3
- data/ext/libsass/ast_fwd_decl.hpp +12 -0
- data/ext/libsass/b64/encode.h +2 -2
- data/ext/libsass/backtrace.hpp +13 -17
- data/ext/libsass/base64vlq.hpp +4 -1
- data/ext/libsass/bind.cpp +12 -15
- data/ext/libsass/bind.hpp +6 -6
- data/ext/libsass/color_names.hpp +4 -1
- data/ext/libsass/configure.ac +7 -21
- data/ext/libsass/constants.cpp +6 -4
- data/ext/libsass/constants.hpp +10 -4
- data/ext/libsass/context.cpp +89 -58
- data/ext/libsass/context.hpp +28 -35
- data/ext/libsass/contextualize.cpp +20 -10
- data/ext/libsass/contextualize.hpp +8 -23
- data/ext/libsass/contrib/libsass.spec +66 -0
- data/ext/libsass/cssize.cpp +547 -0
- data/ext/libsass/cssize.hpp +82 -0
- data/ext/libsass/debug.hpp +3 -3
- data/ext/libsass/debugger.hpp +358 -0
- data/ext/libsass/emitter.cpp +255 -0
- data/ext/libsass/emitter.hpp +83 -0
- data/ext/libsass/environment.hpp +7 -3
- data/ext/libsass/error_handling.cpp +11 -14
- data/ext/libsass/error_handling.hpp +9 -7
- data/ext/libsass/eval.cpp +253 -161
- data/ext/libsass/eval.hpp +13 -13
- data/ext/libsass/expand.cpp +135 -64
- data/ext/libsass/expand.hpp +11 -13
- data/ext/libsass/extend.cpp +66 -20
- data/ext/libsass/extend.hpp +6 -11
- data/ext/libsass/file.cpp +31 -26
- data/ext/libsass/file.hpp +6 -1
- data/ext/libsass/functions.cpp +270 -287
- data/ext/libsass/functions.hpp +8 -11
- data/ext/libsass/inspect.cpp +385 -255
- data/ext/libsass/inspect.hpp +15 -26
- data/ext/libsass/kwd_arg_macros.hpp +5 -0
- data/ext/libsass/mapping.hpp +4 -3
- data/ext/libsass/memory_manager.hpp +5 -2
- data/ext/libsass/node.cpp +50 -50
- data/ext/libsass/node.hpp +26 -27
- data/ext/libsass/operation.hpp +15 -4
- data/ext/libsass/output.cpp +401 -0
- data/ext/libsass/output.hpp +56 -0
- data/ext/libsass/parser.cpp +573 -399
- data/ext/libsass/parser.hpp +122 -88
- data/ext/libsass/paths.hpp +7 -2
- data/ext/libsass/plugins.cpp +155 -0
- data/ext/libsass/plugins.hpp +56 -0
- data/ext/libsass/position.cpp +128 -0
- data/ext/libsass/position.hpp +108 -11
- data/ext/libsass/prelexer.cpp +184 -110
- data/ext/libsass/prelexer.hpp +131 -24
- data/ext/libsass/remove_placeholders.cpp +1 -1
- data/ext/libsass/remove_placeholders.hpp +6 -6
- data/ext/libsass/sass.cpp +3 -3
- data/ext/libsass/sass.h +12 -4
- data/ext/libsass/sass2scss.cpp +3 -2
- data/ext/libsass/sass2scss.h +5 -0
- data/ext/libsass/sass_context.cpp +136 -37
- data/ext/libsass/sass_context.h +19 -10
- data/ext/libsass/sass_functions.cpp +29 -2
- data/ext/libsass/sass_functions.h +8 -2
- data/ext/libsass/sass_interface.cpp +32 -23
- data/ext/libsass/sass_interface.h +9 -4
- data/ext/libsass/sass_util.cpp +19 -23
- data/ext/libsass/sass_util.hpp +28 -27
- data/ext/libsass/sass_values.cpp +6 -4
- data/ext/libsass/sass_values.h +3 -3
- data/ext/libsass/script/ci-build-libsass +13 -1
- data/ext/libsass/script/ci-report-coverage +2 -1
- data/ext/libsass/source_map.cpp +79 -28
- data/ext/libsass/source_map.hpp +35 -16
- data/ext/libsass/subset_map.hpp +6 -4
- data/ext/libsass/to_c.hpp +4 -4
- data/ext/libsass/to_string.cpp +13 -8
- data/ext/libsass/to_string.hpp +6 -4
- data/ext/libsass/units.cpp +2 -1
- data/ext/libsass/units.hpp +6 -1
- data/ext/libsass/utf8_string.cpp +0 -5
- data/ext/libsass/utf8_string.hpp +3 -2
- data/ext/libsass/util.cpp +461 -49
- data/ext/libsass/util.hpp +34 -13
- data/ext/libsass/version.sh +10 -0
- data/ext/libsass/win/libsass.filters +20 -11
- data/ext/libsass/win/libsass.vcxproj +11 -8
- data/lib/sassc/importer.rb +1 -8
- data/lib/sassc/native.rb +7 -0
- data/lib/sassc/native/native_context_api.rb +5 -5
- data/lib/sassc/version.rb +1 -1
- data/test/native_test.rb +1 -1
- metadata +14 -10
- data/ext/libsass/copy_c_str.cpp +0 -13
- data/ext/libsass/copy_c_str.hpp +0 -5
- data/ext/libsass/output_compressed.cpp +0 -401
- data/ext/libsass/output_compressed.hpp +0 -95
- data/ext/libsass/output_nested.cpp +0 -364
- data/ext/libsass/output_nested.hpp +0 -108
- data/ext/libsass/test-driver +0 -127
- data/ext/libsass/token.hpp +0 -32
data/ext/libsass/sass_context.h
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#ifndef
|
2
|
-
#define
|
1
|
+
#ifndef SASS_C_CONTEXT_H
|
2
|
+
#define SASS_C_CONTEXT_H
|
3
3
|
|
4
4
|
#include <stddef.h>
|
5
5
|
#include <stdbool.h>
|
@@ -50,7 +50,7 @@ ADDAPI void ADDCALL sass_delete_data_context (struct Sass_Data_Context* ctx);
|
|
50
50
|
ADDAPI struct Sass_Context* ADDCALL sass_file_context_get_context (struct Sass_File_Context* file_ctx);
|
51
51
|
ADDAPI struct Sass_Context* ADDCALL sass_data_context_get_context (struct Sass_Data_Context* data_ctx);
|
52
52
|
|
53
|
-
// Getters for
|
53
|
+
// Getters for Context_Options from Sass_Context
|
54
54
|
ADDAPI struct Sass_Options* ADDCALL sass_context_get_options (struct Sass_Context* ctx);
|
55
55
|
ADDAPI struct Sass_Options* ADDCALL sass_file_context_get_options (struct Sass_File_Context* file_ctx);
|
56
56
|
ADDAPI struct Sass_Options* ADDCALL sass_data_context_get_options (struct Sass_Data_Context* data_ctx);
|
@@ -58,7 +58,7 @@ ADDAPI void ADDCALL sass_file_context_set_options (struct Sass_File_Context* fil
|
|
58
58
|
ADDAPI void ADDCALL sass_data_context_set_options (struct Sass_Data_Context* data_ctx, struct Sass_Options* opt);
|
59
59
|
|
60
60
|
|
61
|
-
// Getters for
|
61
|
+
// Getters for Context_Option values
|
62
62
|
ADDAPI int ADDCALL sass_option_get_precision (struct Sass_Options* options);
|
63
63
|
ADDAPI enum Sass_Output_Style ADDCALL sass_option_get_output_style (struct Sass_Options* options);
|
64
64
|
ADDAPI bool ADDCALL sass_option_get_source_comments (struct Sass_Options* options);
|
@@ -66,15 +66,18 @@ ADDAPI bool ADDCALL sass_option_get_source_map_embed (struct Sass_Options* optio
|
|
66
66
|
ADDAPI bool ADDCALL sass_option_get_source_map_contents (struct Sass_Options* options);
|
67
67
|
ADDAPI bool ADDCALL sass_option_get_omit_source_map_url (struct Sass_Options* options);
|
68
68
|
ADDAPI bool ADDCALL sass_option_get_is_indented_syntax_src (struct Sass_Options* options);
|
69
|
+
ADDAPI const char* ADDCALL sass_option_get_indent (struct Sass_Options* options);
|
70
|
+
ADDAPI const char* ADDCALL sass_option_get_linefeed (struct Sass_Options* options);
|
69
71
|
ADDAPI const char* ADDCALL sass_option_get_input_path (struct Sass_Options* options);
|
70
72
|
ADDAPI const char* ADDCALL sass_option_get_output_path (struct Sass_Options* options);
|
71
|
-
ADDAPI const char* ADDCALL
|
73
|
+
ADDAPI const char* ADDCALL sass_option_get_plugin_path (struct Sass_Options* options);
|
72
74
|
ADDAPI const char* ADDCALL sass_option_get_include_path (struct Sass_Options* options);
|
73
75
|
ADDAPI const char* ADDCALL sass_option_get_source_map_file (struct Sass_Options* options);
|
76
|
+
ADDAPI const char* ADDCALL sass_option_get_source_map_root (struct Sass_Options* options);
|
74
77
|
ADDAPI Sass_C_Function_List ADDCALL sass_option_get_c_functions (struct Sass_Options* options);
|
75
78
|
ADDAPI Sass_C_Import_Callback ADDCALL sass_option_get_importer (struct Sass_Options* options);
|
76
79
|
|
77
|
-
// Setters for
|
80
|
+
// Setters for Context_Option values
|
78
81
|
ADDAPI void ADDCALL sass_option_set_precision (struct Sass_Options* options, int precision);
|
79
82
|
ADDAPI void ADDCALL sass_option_set_output_style (struct Sass_Options* options, enum Sass_Output_Style output_style);
|
80
83
|
ADDAPI void ADDCALL sass_option_set_source_comments (struct Sass_Options* options, bool source_comments);
|
@@ -82,19 +85,23 @@ ADDAPI void ADDCALL sass_option_set_source_map_embed (struct Sass_Options* optio
|
|
82
85
|
ADDAPI void ADDCALL sass_option_set_source_map_contents (struct Sass_Options* options, bool source_map_contents);
|
83
86
|
ADDAPI void ADDCALL sass_option_set_omit_source_map_url (struct Sass_Options* options, bool omit_source_map_url);
|
84
87
|
ADDAPI void ADDCALL sass_option_set_is_indented_syntax_src (struct Sass_Options* options, bool is_indented_syntax_src);
|
88
|
+
ADDAPI void ADDCALL sass_option_set_indent (struct Sass_Options* options, const char* indent);
|
89
|
+
ADDAPI void ADDCALL sass_option_set_linefeed (struct Sass_Options* options, const char* linefeed);
|
85
90
|
ADDAPI void ADDCALL sass_option_set_input_path (struct Sass_Options* options, const char* input_path);
|
86
91
|
ADDAPI void ADDCALL sass_option_set_output_path (struct Sass_Options* options, const char* output_path);
|
87
|
-
ADDAPI void ADDCALL
|
92
|
+
ADDAPI void ADDCALL sass_option_set_plugin_path (struct Sass_Options* options, const char* plugin_path);
|
88
93
|
ADDAPI void ADDCALL sass_option_set_include_path (struct Sass_Options* options, const char* include_path);
|
89
94
|
ADDAPI void ADDCALL sass_option_set_source_map_file (struct Sass_Options* options, const char* source_map_file);
|
95
|
+
ADDAPI void ADDCALL sass_option_set_source_map_root (struct Sass_Options* options, const char* source_map_root);
|
90
96
|
ADDAPI void ADDCALL sass_option_set_c_functions (struct Sass_Options* options, Sass_C_Function_List c_functions);
|
91
97
|
ADDAPI void ADDCALL sass_option_set_importer (struct Sass_Options* options, Sass_C_Import_Callback importer);
|
92
98
|
|
93
99
|
|
94
|
-
//
|
100
|
+
// Getters for Sass_Context values
|
95
101
|
ADDAPI const char* ADDCALL sass_context_get_output_string (struct Sass_Context* ctx);
|
96
102
|
ADDAPI int ADDCALL sass_context_get_error_status (struct Sass_Context* ctx);
|
97
103
|
ADDAPI const char* ADDCALL sass_context_get_error_json (struct Sass_Context* ctx);
|
104
|
+
ADDAPI const char* ADDCALL sass_context_get_error_text (struct Sass_Context* ctx);
|
98
105
|
ADDAPI const char* ADDCALL sass_context_get_error_message (struct Sass_Context* ctx);
|
99
106
|
ADDAPI const char* ADDCALL sass_context_get_error_file (struct Sass_Context* ctx);
|
100
107
|
ADDAPI size_t ADDCALL sass_context_get_error_line (struct Sass_Context* ctx);
|
@@ -104,12 +111,14 @@ ADDAPI char** ADDCALL sass_context_get_included_files (struct Sass_Context* ctx)
|
|
104
111
|
|
105
112
|
// Take ownership of memory (value on context is set to 0)
|
106
113
|
ADDAPI char* ADDCALL sass_context_take_error_json (struct Sass_Context* ctx);
|
114
|
+
ADDAPI char* ADDCALL sass_context_take_error_text (struct Sass_Context* ctx);
|
107
115
|
ADDAPI char* ADDCALL sass_context_take_error_message (struct Sass_Context* ctx);
|
108
116
|
ADDAPI char* ADDCALL sass_context_take_error_file (struct Sass_Context* ctx);
|
109
117
|
ADDAPI char* ADDCALL sass_context_take_output_string (struct Sass_Context* ctx);
|
110
118
|
ADDAPI char* ADDCALL sass_context_take_source_map_string (struct Sass_Context* ctx);
|
111
119
|
|
112
|
-
// Push function for
|
120
|
+
// Push function for paths (no manipulation support for now)
|
121
|
+
ADDAPI void ADDCALL sass_option_push_plugin_path (struct Sass_Options* options, const char* path);
|
113
122
|
ADDAPI void ADDCALL sass_option_push_include_path (struct Sass_Options* options, const char* path);
|
114
123
|
|
115
124
|
|
@@ -117,4 +126,4 @@ ADDAPI void ADDCALL sass_option_push_include_path (struct Sass_Options* options,
|
|
117
126
|
} // __cplusplus defined.
|
118
127
|
#endif
|
119
128
|
|
120
|
-
#endif
|
129
|
+
#endif
|
@@ -4,11 +4,14 @@
|
|
4
4
|
#include <unistd.h>
|
5
5
|
#endif
|
6
6
|
|
7
|
+
#include <cstring>
|
8
|
+
#include "util.hpp"
|
7
9
|
#include "context.hpp"
|
8
10
|
#include "sass_functions.h"
|
9
11
|
|
10
12
|
extern "C" {
|
11
13
|
using namespace std;
|
14
|
+
using namespace Sass;
|
12
15
|
|
13
16
|
// Struct to hold custom function callback
|
14
17
|
struct Sass_C_Function_Descriptor {
|
@@ -46,6 +49,10 @@ extern "C" {
|
|
46
49
|
char* base;
|
47
50
|
char* source;
|
48
51
|
char* srcmap;
|
52
|
+
// error handling
|
53
|
+
char* error;
|
54
|
+
size_t line;
|
55
|
+
size_t column;
|
49
56
|
};
|
50
57
|
|
51
58
|
// Struct to hold importer callback
|
@@ -84,10 +91,13 @@ extern "C" {
|
|
84
91
|
{
|
85
92
|
Sass_Import* v = (Sass_Import*) calloc(1, sizeof(Sass_Import));
|
86
93
|
if (v == 0) return 0;
|
87
|
-
v->path = path ?
|
88
|
-
v->base = base ?
|
94
|
+
v->path = path ? sass_strdup(path) : 0;
|
95
|
+
v->base = base ? sass_strdup(base) : 0;
|
89
96
|
v->source = source;
|
90
97
|
v->srcmap = srcmap;
|
98
|
+
v->error = 0;
|
99
|
+
v->line = -1;
|
100
|
+
v->column = -1;
|
91
101
|
return v;
|
92
102
|
}
|
93
103
|
|
@@ -97,6 +107,17 @@ extern "C" {
|
|
97
107
|
return sass_make_import(path, path, source, srcmap);
|
98
108
|
}
|
99
109
|
|
110
|
+
// Upgrade a normal import entry to throw an error (original path can be re-used by error reporting)
|
111
|
+
struct Sass_Import* ADDCALL sass_import_set_error(struct Sass_Import* import, const char* error, size_t line, size_t col)
|
112
|
+
{
|
113
|
+
if (import == 0) return 0;
|
114
|
+
if (import->error) free(import->error);
|
115
|
+
import->error = error ? strdup(error) : 0;
|
116
|
+
import->line = line ? line : -1;
|
117
|
+
import->column = col ? col : -1;
|
118
|
+
return import;
|
119
|
+
}
|
120
|
+
|
100
121
|
// Setters and getters for entries on the import list
|
101
122
|
void ADDCALL sass_import_set_list_entry(struct Sass_Import** list, size_t idx, struct Sass_Import* entry) { list[idx] = entry; }
|
102
123
|
struct Sass_Import* ADDCALL sass_import_get_list_entry(struct Sass_Import** list, size_t idx) { return list[idx]; }
|
@@ -120,6 +141,7 @@ extern "C" {
|
|
120
141
|
free(import->base);
|
121
142
|
free(import->source);
|
122
143
|
free(import->srcmap);
|
144
|
+
free(import->error);
|
123
145
|
free(import);
|
124
146
|
}
|
125
147
|
|
@@ -129,6 +151,11 @@ extern "C" {
|
|
129
151
|
const char* ADDCALL sass_import_get_source(struct Sass_Import* entry) { return entry->source; }
|
130
152
|
const char* ADDCALL sass_import_get_srcmap(struct Sass_Import* entry) { return entry->srcmap; }
|
131
153
|
|
154
|
+
// Getter for import error entry
|
155
|
+
size_t ADDCALL sass_import_get_error_line(struct Sass_Import* entry) { return entry->line; }
|
156
|
+
size_t ADDCALL sass_import_get_error_column(struct Sass_Import* entry) { return entry->column; }
|
157
|
+
const char* ADDCALL sass_import_get_error_message(struct Sass_Import* entry) { return entry->error; }
|
158
|
+
|
132
159
|
// Explicit functions to take ownership of the memory
|
133
160
|
// Resets our own property since we do not know if it is still alive
|
134
161
|
char* ADDCALL sass_import_take_source(struct Sass_Import* entry) { char* ptr = entry->source; entry->source = 0; return ptr; }
|
@@ -1,5 +1,5 @@
|
|
1
|
-
#ifndef
|
2
|
-
#define
|
1
|
+
#ifndef SASS_C_FUNCTIONS_H
|
2
|
+
#define SASS_C_FUNCTIONS_H
|
3
3
|
|
4
4
|
#include <stddef.h>
|
5
5
|
#include <stdbool.h>
|
@@ -37,6 +37,8 @@ ADDAPI struct Sass_Import** ADDCALL sass_make_import_list (size_t length);
|
|
37
37
|
// Creator for a single import entry returned by the custom importer inside the list
|
38
38
|
ADDAPI struct Sass_Import* ADDCALL sass_make_import_entry (const char* path, char* source, char* srcmap);
|
39
39
|
ADDAPI struct Sass_Import* ADDCALL sass_make_import (const char* path, const char* base, char* source, char* srcmap);
|
40
|
+
// set error message to abort import and to print out a message (path from existing object is used in output)
|
41
|
+
ADDAPI struct Sass_Import* ADDCALL sass_import_set_error(struct Sass_Import* import, const char* message, size_t line, size_t col);
|
40
42
|
|
41
43
|
// Setters to insert an entry into the import list (you may also use [] access directly)
|
42
44
|
// Since we are dealing with pointers they should have a guaranteed and fixed size
|
@@ -52,6 +54,10 @@ ADDAPI const char* ADDCALL sass_import_get_srcmap (struct Sass_Import*);
|
|
52
54
|
// The property on our struct will be reset to NULL
|
53
55
|
ADDAPI char* ADDCALL sass_import_take_source (struct Sass_Import*);
|
54
56
|
ADDAPI char* ADDCALL sass_import_take_srcmap (struct Sass_Import*);
|
57
|
+
// Getters from import error entry
|
58
|
+
ADDAPI size_t ADDCALL sass_import_get_error_line (struct Sass_Import*);
|
59
|
+
ADDAPI size_t ADDCALL sass_import_get_error_column (struct Sass_Import*);
|
60
|
+
ADDAPI const char* ADDCALL sass_import_get_error_message (struct Sass_Import*);
|
55
61
|
|
56
62
|
// Deallocator for associated memory (incl. entries)
|
57
63
|
ADDAPI void ADDCALL sass_delete_import_list (struct Sass_Import**);
|
@@ -1,22 +1,23 @@
|
|
1
1
|
#ifdef _WIN32
|
2
2
|
#include <io.h>
|
3
|
+
#define LFEED "\n"
|
3
4
|
#else
|
4
5
|
#include <unistd.h>
|
6
|
+
#define LFEED "\n"
|
5
7
|
#endif
|
6
8
|
|
7
|
-
#include
|
9
|
+
#include <string>
|
10
|
+
#include <cstdlib>
|
11
|
+
#include <cstring>
|
12
|
+
#include <sstream>
|
13
|
+
#include <iostream>
|
14
|
+
|
15
|
+
#include "util.hpp"
|
8
16
|
#include "context.hpp"
|
9
17
|
#include "inspect.hpp"
|
10
|
-
|
11
|
-
#ifndef SASS_ERROR_HANDLING
|
12
18
|
#include "error_handling.hpp"
|
13
|
-
#
|
19
|
+
#include "sass_interface.h"
|
14
20
|
|
15
|
-
#include <iostream>
|
16
|
-
#include <sstream>
|
17
|
-
#include <string>
|
18
|
-
#include <cstdlib>
|
19
|
-
#include <cstring>
|
20
21
|
|
21
22
|
extern "C" {
|
22
23
|
using namespace std;
|
@@ -114,14 +115,19 @@ extern "C" {
|
|
114
115
|
.is_indented_syntax_src(c_ctx->options.is_indented_syntax_src)
|
115
116
|
.source_comments(c_ctx->options.source_comments)
|
116
117
|
.source_map_file(safe_str(c_ctx->options.source_map_file))
|
118
|
+
.source_map_root(safe_str(c_ctx->options.source_map_root))
|
117
119
|
.source_map_embed(c_ctx->options.source_map_embed)
|
118
120
|
.source_map_contents(c_ctx->options.source_map_contents)
|
119
121
|
.omit_source_map_url(c_ctx->options.omit_source_map_url)
|
120
|
-
.image_path(safe_str(c_ctx->options.image_path))
|
121
122
|
.include_paths_c_str(c_ctx->options.include_paths)
|
123
|
+
.plugin_paths_c_str(c_ctx->options.plugin_paths)
|
122
124
|
.include_paths_array(0)
|
125
|
+
.plugin_paths_array(0)
|
123
126
|
.include_paths(vector<string>())
|
127
|
+
.plugin_paths(vector<string>())
|
124
128
|
.precision(c_ctx->options.precision ? c_ctx->options.precision : 5)
|
129
|
+
.indent(c_ctx->options.indent ? c_ctx->options.indent : " ")
|
130
|
+
.linefeed(c_ctx->options.linefeed ? c_ctx->options.linefeed : LFEED)
|
125
131
|
.importer(0)
|
126
132
|
);
|
127
133
|
if (c_ctx->c_functions) {
|
@@ -140,8 +146,8 @@ extern "C" {
|
|
140
146
|
}
|
141
147
|
catch (Sass_Error& e) {
|
142
148
|
stringstream msg_stream;
|
143
|
-
msg_stream << e.path << ":" << e.
|
144
|
-
c_ctx->error_message =
|
149
|
+
msg_stream << e.pstate.path << ":" << e.pstate.line << ": " << e.message << endl;
|
150
|
+
c_ctx->error_message = sass_strdup(msg_stream.str().c_str());
|
145
151
|
c_ctx->error_status = 1;
|
146
152
|
c_ctx->output_string = 0;
|
147
153
|
c_ctx->source_map_string = 0;
|
@@ -149,7 +155,7 @@ extern "C" {
|
|
149
155
|
catch(bad_alloc& ba) {
|
150
156
|
stringstream msg_stream;
|
151
157
|
msg_stream << "Unable to allocate memory: " << ba.what() << endl;
|
152
|
-
c_ctx->error_message =
|
158
|
+
c_ctx->error_message = sass_strdup(msg_stream.str().c_str());
|
153
159
|
c_ctx->error_status = 1;
|
154
160
|
c_ctx->output_string = 0;
|
155
161
|
c_ctx->source_map_string = 0;
|
@@ -157,7 +163,7 @@ extern "C" {
|
|
157
163
|
catch (std::exception& e) {
|
158
164
|
stringstream msg_stream;
|
159
165
|
msg_stream << "Error: " << e.what() << endl;
|
160
|
-
c_ctx->error_message =
|
166
|
+
c_ctx->error_message = sass_strdup(msg_stream.str().c_str());
|
161
167
|
c_ctx->error_status = 1;
|
162
168
|
c_ctx->output_string = 0;
|
163
169
|
c_ctx->source_map_string = 0;
|
@@ -165,7 +171,7 @@ extern "C" {
|
|
165
171
|
catch (string& e) {
|
166
172
|
stringstream msg_stream;
|
167
173
|
msg_stream << "Error: " << e << endl;
|
168
|
-
c_ctx->error_message =
|
174
|
+
c_ctx->error_message = sass_strdup(msg_stream.str().c_str());
|
169
175
|
c_ctx->error_status = 1;
|
170
176
|
c_ctx->output_string = 0;
|
171
177
|
c_ctx->source_map_string = 0;
|
@@ -174,7 +180,7 @@ extern "C" {
|
|
174
180
|
// couldn't find the specified file in the include paths; report an error
|
175
181
|
stringstream msg_stream;
|
176
182
|
msg_stream << "Unknown error occurred" << endl;
|
177
|
-
c_ctx->error_message =
|
183
|
+
c_ctx->error_message = sass_strdup(msg_stream.str().c_str());
|
178
184
|
c_ctx->error_status = 1;
|
179
185
|
c_ctx->output_string = 0;
|
180
186
|
c_ctx->source_map_string = 0;
|
@@ -202,13 +208,16 @@ extern "C" {
|
|
202
208
|
.is_indented_syntax_src(c_ctx->options.is_indented_syntax_src)
|
203
209
|
.source_comments(c_ctx->options.source_comments)
|
204
210
|
.source_map_file(safe_str(c_ctx->options.source_map_file))
|
211
|
+
.source_map_root(safe_str(c_ctx->options.source_map_root))
|
205
212
|
.source_map_embed(c_ctx->options.source_map_embed)
|
206
213
|
.source_map_contents(c_ctx->options.source_map_contents)
|
207
214
|
.omit_source_map_url(c_ctx->options.omit_source_map_url)
|
208
|
-
.image_path(safe_str(c_ctx->options.image_path))
|
209
215
|
.include_paths_c_str(c_ctx->options.include_paths)
|
216
|
+
.plugin_paths_c_str(c_ctx->options.plugin_paths)
|
210
217
|
.include_paths_array(0)
|
218
|
+
.plugin_paths_array(0)
|
211
219
|
.include_paths(vector<string>())
|
220
|
+
.plugin_paths(vector<string>())
|
212
221
|
.precision(c_ctx->options.precision ? c_ctx->options.precision : 5)
|
213
222
|
);
|
214
223
|
if (c_ctx->c_functions) {
|
@@ -227,8 +236,8 @@ extern "C" {
|
|
227
236
|
}
|
228
237
|
catch (Sass_Error& e) {
|
229
238
|
stringstream msg_stream;
|
230
|
-
msg_stream << e.path << ":" << e.
|
231
|
-
c_ctx->error_message =
|
239
|
+
msg_stream << e.path << ":" << e.pstate.line << ": " << e.message << endl;
|
240
|
+
c_ctx->error_message = sass_strdup(msg_stream.str().c_str());
|
232
241
|
c_ctx->error_status = 1;
|
233
242
|
c_ctx->output_string = 0;
|
234
243
|
c_ctx->source_map_string = 0;
|
@@ -236,7 +245,7 @@ extern "C" {
|
|
236
245
|
catch(bad_alloc& ba) {
|
237
246
|
stringstream msg_stream;
|
238
247
|
msg_stream << "Unable to allocate memory: " << ba.what() << endl;
|
239
|
-
c_ctx->error_message =
|
248
|
+
c_ctx->error_message = sass_strdup(msg_stream.str().c_str());
|
240
249
|
c_ctx->error_status = 1;
|
241
250
|
c_ctx->output_string = 0;
|
242
251
|
c_ctx->source_map_string = 0;
|
@@ -244,7 +253,7 @@ extern "C" {
|
|
244
253
|
catch (std::exception& e) {
|
245
254
|
stringstream msg_stream;
|
246
255
|
msg_stream << "Error: " << e.what() << endl;
|
247
|
-
c_ctx->error_message =
|
256
|
+
c_ctx->error_message = sass_strdup(msg_stream.str().c_str());
|
248
257
|
c_ctx->error_status = 1;
|
249
258
|
c_ctx->output_string = 0;
|
250
259
|
c_ctx->source_map_string = 0;
|
@@ -252,7 +261,7 @@ extern "C" {
|
|
252
261
|
catch (string& e) {
|
253
262
|
stringstream msg_stream;
|
254
263
|
msg_stream << "Error: " << e << endl;
|
255
|
-
c_ctx->error_message =
|
264
|
+
c_ctx->error_message = sass_strdup(msg_stream.str().c_str());
|
256
265
|
c_ctx->error_status = 1;
|
257
266
|
c_ctx->output_string = 0;
|
258
267
|
c_ctx->source_map_string = 0;
|
@@ -261,7 +270,7 @@ extern "C" {
|
|
261
270
|
// couldn't find the specified file in the include paths; report an error
|
262
271
|
stringstream msg_stream;
|
263
272
|
msg_stream << "Unknown error occurred" << endl;
|
264
|
-
c_ctx->error_message =
|
273
|
+
c_ctx->error_message = sass_strdup(msg_stream.str().c_str());
|
265
274
|
c_ctx->error_status = 1;
|
266
275
|
c_ctx->output_string = 0;
|
267
276
|
c_ctx->source_map_string = 0;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
#ifndef
|
2
|
-
#define
|
1
|
+
#ifndef SASS_C_INTERFACE_H
|
2
|
+
#define SASS_C_INTERFACE_H
|
3
3
|
|
4
4
|
#include <stddef.h>
|
5
5
|
#include <stdbool.h>
|
@@ -28,13 +28,18 @@ struct sass_options {
|
|
28
28
|
bool source_map_embed;
|
29
29
|
// embed include contents in maps
|
30
30
|
bool source_map_contents;
|
31
|
+
// Pass-through as sourceRoot property
|
32
|
+
const char* source_map_root;
|
31
33
|
// Treat source_string as sass (as opposed to scss)
|
32
34
|
bool is_indented_syntax_src;
|
33
35
|
// Colon-separated list of paths
|
34
36
|
// Semicolon-separated on Windows
|
35
37
|
const char* include_paths;
|
36
|
-
|
37
|
-
|
38
|
+
const char* plugin_paths;
|
39
|
+
// String to be used for indentation
|
40
|
+
const char* indent;
|
41
|
+
// String to be used to for line feeds
|
42
|
+
const char* linefeed;
|
38
43
|
// Precision for outputting fractional numbers
|
39
44
|
int precision;
|
40
45
|
};
|
data/ext/libsass/sass_util.cpp
CHANGED
@@ -1,16 +1,12 @@
|
|
1
|
-
#ifndef SASS_AST
|
2
1
|
#include "node.hpp"
|
3
|
-
#endif
|
4
|
-
|
5
2
|
#include "to_string.hpp"
|
6
3
|
|
7
|
-
|
8
4
|
namespace Sass {
|
9
5
|
|
10
6
|
|
11
7
|
/*
|
12
8
|
This is the equivalent of ruby's Sass::Util.paths.
|
13
|
-
|
9
|
+
|
14
10
|
# Return an array of all possible paths through the given arrays.
|
15
11
|
#
|
16
12
|
# @param arrs [NodeCollection<NodeCollection<Node>>]
|
@@ -22,7 +18,7 @@ namespace Sass {
|
|
22
18
|
# # [2, 3, 5],
|
23
19
|
# # [1, 4, 5],
|
24
20
|
# # [2, 4, 5]]
|
25
|
-
|
21
|
+
|
26
22
|
The following is the modified version of the ruby code that was more portable to C++. You
|
27
23
|
should be able to drop it into ruby 3.2.19 and get the same results from ruby sass.
|
28
24
|
|
@@ -42,55 +38,55 @@ namespace Sass {
|
|
42
38
|
end
|
43
39
|
*/
|
44
40
|
Node paths(const Node& arrs, Context& ctx) {
|
45
|
-
To_String to_string;
|
41
|
+
To_String to_string(&ctx);
|
46
42
|
|
47
43
|
Node loopStart = Node::createCollection();
|
48
44
|
loopStart.collection()->push_back(Node::createCollection());
|
49
|
-
|
45
|
+
|
50
46
|
for (NodeDeque::iterator arrsIter = arrs.collection()->begin(), arrsEndIter = arrs.collection()->end();
|
51
47
|
arrsIter != arrsEndIter; ++arrsIter) {
|
52
|
-
|
48
|
+
|
53
49
|
Node& arr = *arrsIter;
|
54
|
-
|
50
|
+
|
55
51
|
Node permutations = Node::createCollection();
|
56
|
-
|
52
|
+
|
57
53
|
for (NodeDeque::iterator arrIter = arr.collection()->begin(), arrIterEnd = arr.collection()->end();
|
58
54
|
arrIter != arrIterEnd; ++arrIter) {
|
59
|
-
|
55
|
+
|
60
56
|
Node& e = *arrIter;
|
61
|
-
|
57
|
+
|
62
58
|
for (NodeDeque::iterator loopStartIter = loopStart.collection()->begin(), loopStartIterEnd = loopStart.collection()->end();
|
63
59
|
loopStartIter != loopStartIterEnd; ++loopStartIter) {
|
64
|
-
|
60
|
+
|
65
61
|
Node& path = *loopStartIter;
|
66
|
-
|
62
|
+
|
67
63
|
Node newPermutation = Node::createCollection();
|
68
64
|
newPermutation.plus(path);
|
69
65
|
newPermutation.collection()->push_back(e);
|
70
|
-
|
66
|
+
|
71
67
|
permutations.collection()->push_back(newPermutation);
|
72
68
|
}
|
73
69
|
}
|
74
|
-
|
70
|
+
|
75
71
|
loopStart = permutations;
|
76
72
|
}
|
77
|
-
|
73
|
+
|
78
74
|
return loopStart;
|
79
75
|
}
|
80
|
-
|
76
|
+
|
81
77
|
|
82
78
|
/*
|
83
79
|
This is the equivalent of ruby sass' Sass::Util.flatten and [].flatten.
|
84
80
|
Sass::Util.flatten requires the number of levels to flatten, while
|
85
81
|
[].flatten doesn't and will flatten the entire array. This function
|
86
82
|
supports both.
|
87
|
-
|
83
|
+
|
88
84
|
# Flattens the first `n` nested arrays. If n == -1, all arrays will be flattened
|
89
85
|
#
|
90
86
|
# @param arr [NodeCollection] The array to flatten
|
91
87
|
# @param n [int] The number of levels to flatten
|
92
88
|
# @return [NodeCollection] The flattened array
|
93
|
-
|
89
|
+
|
94
90
|
The following is the modified version of the ruby code that was more portable to C++. You
|
95
91
|
should be able to drop it into ruby 3.2.19 and get the same results from ruby sass.
|
96
92
|
|
@@ -118,11 +114,11 @@ namespace Sass {
|
|
118
114
|
}
|
119
115
|
|
120
116
|
Node flattened = Node::createCollection();
|
121
|
-
|
117
|
+
|
122
118
|
for (NodeDeque::iterator iter = arr.collection()->begin(), iterEnd = arr.collection()->end();
|
123
119
|
iter != iterEnd; iter++) {
|
124
120
|
Node& e = *iter;
|
125
|
-
|
121
|
+
|
126
122
|
if (e.isCollection()) {
|
127
123
|
Node recurseFlattened = flatten(e, ctx, n - 1);
|
128
124
|
flattened.collection()->insert(flattened.collection()->end(), recurseFlattened.collection()->begin(), recurseFlattened.collection()->end());
|