sassc4 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 +7 -0
- data/.gitignore +18 -0
- data/.gitmodules +3 -0
- data/.travis.yml +16 -0
- data/CHANGELOG.md +97 -0
- data/CODE_OF_CONDUCT.md +10 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +80 -0
- data/Rakefile +51 -0
- data/ext/depend +4 -0
- data/ext/extconf.rb +92 -0
- data/ext/libsass/VERSION +1 -0
- data/ext/libsass/contrib/plugin.cpp +60 -0
- data/ext/libsass/include/sass/base.h +97 -0
- data/ext/libsass/include/sass/context.h +174 -0
- data/ext/libsass/include/sass/functions.h +139 -0
- data/ext/libsass/include/sass/values.h +145 -0
- data/ext/libsass/include/sass/version.h +12 -0
- data/ext/libsass/include/sass.h +15 -0
- data/ext/libsass/include/sass2scss.h +120 -0
- data/ext/libsass/src/MurmurHash2.hpp +91 -0
- data/ext/libsass/src/ast.cpp +953 -0
- data/ext/libsass/src/ast.hpp +1064 -0
- data/ext/libsass/src/ast2c.cpp +80 -0
- data/ext/libsass/src/ast2c.hpp +39 -0
- data/ext/libsass/src/ast_def_macros.hpp +140 -0
- data/ext/libsass/src/ast_fwd_decl.cpp +31 -0
- data/ext/libsass/src/ast_fwd_decl.hpp +274 -0
- data/ext/libsass/src/ast_helpers.hpp +316 -0
- data/ext/libsass/src/ast_sel_cmp.cpp +396 -0
- data/ext/libsass/src/ast_sel_super.cpp +539 -0
- data/ext/libsass/src/ast_sel_unify.cpp +275 -0
- data/ext/libsass/src/ast_sel_weave.cpp +616 -0
- data/ext/libsass/src/ast_selectors.cpp +1070 -0
- data/ext/libsass/src/ast_selectors.hpp +523 -0
- data/ext/libsass/src/ast_supports.cpp +114 -0
- data/ext/libsass/src/ast_supports.hpp +121 -0
- data/ext/libsass/src/ast_values.cpp +1154 -0
- data/ext/libsass/src/ast_values.hpp +498 -0
- data/ext/libsass/src/b64/cencode.h +32 -0
- data/ext/libsass/src/b64/encode.h +79 -0
- data/ext/libsass/src/backtrace.cpp +50 -0
- data/ext/libsass/src/backtrace.hpp +29 -0
- data/ext/libsass/src/base64vlq.cpp +47 -0
- data/ext/libsass/src/base64vlq.hpp +30 -0
- data/ext/libsass/src/bind.cpp +312 -0
- data/ext/libsass/src/bind.hpp +15 -0
- data/ext/libsass/src/c2ast.cpp +64 -0
- data/ext/libsass/src/c2ast.hpp +14 -0
- data/ext/libsass/src/c99func.c +54 -0
- data/ext/libsass/src/cencode.c +106 -0
- data/ext/libsass/src/check_nesting.cpp +393 -0
- data/ext/libsass/src/check_nesting.hpp +70 -0
- data/ext/libsass/src/color_maps.cpp +652 -0
- data/ext/libsass/src/color_maps.hpp +323 -0
- data/ext/libsass/src/color_spaces.cpp +241 -0
- data/ext/libsass/src/color_spaces.hpp +227 -0
- data/ext/libsass/src/constants.cpp +199 -0
- data/ext/libsass/src/constants.hpp +200 -0
- data/ext/libsass/src/context.cpp +870 -0
- data/ext/libsass/src/context.hpp +140 -0
- data/ext/libsass/src/cssize.cpp +521 -0
- data/ext/libsass/src/cssize.hpp +71 -0
- data/ext/libsass/src/dart_helpers.hpp +199 -0
- data/ext/libsass/src/debug.hpp +43 -0
- data/ext/libsass/src/debugger.hpp +964 -0
- data/ext/libsass/src/emitter.cpp +297 -0
- data/ext/libsass/src/emitter.hpp +101 -0
- data/ext/libsass/src/environment.cpp +260 -0
- data/ext/libsass/src/environment.hpp +124 -0
- data/ext/libsass/src/error_handling.cpp +239 -0
- data/ext/libsass/src/error_handling.hpp +248 -0
- data/ext/libsass/src/eval.cpp +1543 -0
- data/ext/libsass/src/eval.hpp +110 -0
- data/ext/libsass/src/eval_selectors.cpp +75 -0
- data/ext/libsass/src/expand.cpp +875 -0
- data/ext/libsass/src/expand.hpp +98 -0
- data/ext/libsass/src/extender.cpp +1226 -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 +531 -0
- data/ext/libsass/src/file.hpp +124 -0
- data/ext/libsass/src/fn_colors.cpp +836 -0
- data/ext/libsass/src/fn_colors.hpp +99 -0
- data/ext/libsass/src/fn_lists.cpp +285 -0
- data/ext/libsass/src/fn_lists.hpp +34 -0
- data/ext/libsass/src/fn_maps.cpp +94 -0
- data/ext/libsass/src/fn_maps.hpp +30 -0
- data/ext/libsass/src/fn_miscs.cpp +248 -0
- data/ext/libsass/src/fn_miscs.hpp +40 -0
- data/ext/libsass/src/fn_numbers.cpp +246 -0
- data/ext/libsass/src/fn_numbers.hpp +45 -0
- data/ext/libsass/src/fn_selectors.cpp +205 -0
- data/ext/libsass/src/fn_selectors.hpp +35 -0
- data/ext/libsass/src/fn_strings.cpp +268 -0
- data/ext/libsass/src/fn_strings.hpp +34 -0
- data/ext/libsass/src/fn_utils.cpp +159 -0
- data/ext/libsass/src/fn_utils.hpp +62 -0
- data/ext/libsass/src/inspect.cpp +1126 -0
- data/ext/libsass/src/inspect.hpp +101 -0
- data/ext/libsass/src/json.cpp +1436 -0
- data/ext/libsass/src/json.hpp +117 -0
- data/ext/libsass/src/kwd_arg_macros.hpp +28 -0
- data/ext/libsass/src/lexer.cpp +122 -0
- data/ext/libsass/src/lexer.hpp +304 -0
- data/ext/libsass/src/listize.cpp +70 -0
- data/ext/libsass/src/listize.hpp +37 -0
- data/ext/libsass/src/mapping.hpp +19 -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/shared_ptr.cpp +33 -0
- data/ext/libsass/src/memory/shared_ptr.hpp +332 -0
- data/ext/libsass/src/memory.hpp +12 -0
- data/ext/libsass/src/operation.hpp +223 -0
- data/ext/libsass/src/operators.cpp +267 -0
- data/ext/libsass/src/operators.hpp +30 -0
- data/ext/libsass/src/ordered_map.hpp +112 -0
- data/ext/libsass/src/output.cpp +320 -0
- data/ext/libsass/src/output.hpp +47 -0
- data/ext/libsass/src/parser.cpp +3059 -0
- data/ext/libsass/src/parser.hpp +395 -0
- data/ext/libsass/src/parser_selectors.cpp +189 -0
- data/ext/libsass/src/permutate.hpp +164 -0
- data/ext/libsass/src/plugins.cpp +188 -0
- data/ext/libsass/src/plugins.hpp +57 -0
- data/ext/libsass/src/position.cpp +163 -0
- data/ext/libsass/src/position.hpp +147 -0
- data/ext/libsass/src/prelexer.cpp +1780 -0
- data/ext/libsass/src/prelexer.hpp +484 -0
- data/ext/libsass/src/remove_placeholders.cpp +86 -0
- data/ext/libsass/src/remove_placeholders.hpp +37 -0
- data/ext/libsass/src/sass.cpp +156 -0
- data/ext/libsass/src/sass.hpp +147 -0
- data/ext/libsass/src/sass2scss.cpp +895 -0
- data/ext/libsass/src/sass_context.cpp +742 -0
- data/ext/libsass/src/sass_context.hpp +129 -0
- data/ext/libsass/src/sass_functions.cpp +210 -0
- data/ext/libsass/src/sass_functions.hpp +50 -0
- data/ext/libsass/src/sass_values.cpp +362 -0
- data/ext/libsass/src/sass_values.hpp +82 -0
- 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 +202 -0
- data/ext/libsass/src/source_map.hpp +65 -0
- data/ext/libsass/src/stylesheet.cpp +22 -0
- data/ext/libsass/src/stylesheet.hpp +57 -0
- data/ext/libsass/src/to_value.cpp +114 -0
- data/ext/libsass/src/to_value.hpp +46 -0
- data/ext/libsass/src/units.cpp +507 -0
- data/ext/libsass/src/units.hpp +110 -0
- data/ext/libsass/src/utf8/checked.h +336 -0
- data/ext/libsass/src/utf8/core.h +332 -0
- data/ext/libsass/src/utf8/unchecked.h +235 -0
- data/ext/libsass/src/utf8.h +34 -0
- data/ext/libsass/src/utf8_string.cpp +104 -0
- data/ext/libsass/src/utf8_string.hpp +38 -0
- data/ext/libsass/src/util.cpp +723 -0
- data/ext/libsass/src/util.hpp +105 -0
- data/ext/libsass/src/util_string.cpp +125 -0
- data/ext/libsass/src/util_string.hpp +73 -0
- data/ext/libsass/src/values.cpp +140 -0
- data/ext/libsass/src/values.hpp +12 -0
- data/lib/sassc/dependency.rb +17 -0
- data/lib/sassc/engine.rb +141 -0
- data/lib/sassc/error.rb +37 -0
- data/lib/sassc/functions_handler.rb +73 -0
- data/lib/sassc/import_handler.rb +50 -0
- data/lib/sassc/importer.rb +31 -0
- data/lib/sassc/native/native_context_api.rb +147 -0
- data/lib/sassc/native/native_functions_api.rb +159 -0
- data/lib/sassc/native/sass2scss_api.rb +10 -0
- data/lib/sassc/native/sass_input_style.rb +13 -0
- data/lib/sassc/native/sass_output_style.rb +12 -0
- data/lib/sassc/native/sass_value.rb +97 -0
- data/lib/sassc/native/string_list.rb +10 -0
- data/lib/sassc/native.rb +64 -0
- data/lib/sassc/sass_2_scss.rb +9 -0
- data/lib/sassc/script/functions.rb +8 -0
- data/lib/sassc/script/value/bool.rb +32 -0
- data/lib/sassc/script/value/color.rb +95 -0
- data/lib/sassc/script/value/list.rb +136 -0
- data/lib/sassc/script/value/map.rb +69 -0
- data/lib/sassc/script/value/number.rb +389 -0
- data/lib/sassc/script/value/string.rb +96 -0
- data/lib/sassc/script/value.rb +137 -0
- data/lib/sassc/script/value_conversion/base.rb +13 -0
- data/lib/sassc/script/value_conversion/bool.rb +13 -0
- data/lib/sassc/script/value_conversion/color.rb +18 -0
- data/lib/sassc/script/value_conversion/list.rb +25 -0
- data/lib/sassc/script/value_conversion/map.rb +21 -0
- data/lib/sassc/script/value_conversion/number.rb +13 -0
- data/lib/sassc/script/value_conversion/string.rb +17 -0
- data/lib/sassc/script/value_conversion.rb +69 -0
- data/lib/sassc/script.rb +17 -0
- data/lib/sassc/util/normalized_map.rb +117 -0
- data/lib/sassc/util.rb +231 -0
- data/lib/sassc/version.rb +5 -0
- data/lib/sassc.rb +57 -0
- data/sassc.gemspec +69 -0
- data/test/css_color_level4_test.rb +168 -0
- data/test/custom_importer_test.rb +127 -0
- data/test/engine_test.rb +314 -0
- data/test/error_test.rb +29 -0
- data/test/fixtures/paths.scss +10 -0
- data/test/functions_test.rb +340 -0
- data/test/native_test.rb +213 -0
- data/test/output_style_test.rb +107 -0
- data/test/sass_2_scss_test.rb +14 -0
- data/test/test_helper.rb +45 -0
- metadata +396 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#ifndef SASS_SASS_CONTEXT_H
|
|
2
|
+
#define SASS_SASS_CONTEXT_H
|
|
3
|
+
|
|
4
|
+
#include "sass/base.h"
|
|
5
|
+
#include "sass/context.h"
|
|
6
|
+
#include "ast_fwd_decl.hpp"
|
|
7
|
+
|
|
8
|
+
// sass config options structure
|
|
9
|
+
struct Sass_Options : Sass_Output_Options {
|
|
10
|
+
|
|
11
|
+
// embed sourceMappingUrl as data uri
|
|
12
|
+
bool source_map_embed;
|
|
13
|
+
|
|
14
|
+
// embed include contents in maps
|
|
15
|
+
bool source_map_contents;
|
|
16
|
+
|
|
17
|
+
// create file urls for sources
|
|
18
|
+
bool source_map_file_urls;
|
|
19
|
+
|
|
20
|
+
// Disable sourceMappingUrl in css output
|
|
21
|
+
bool omit_source_map_url;
|
|
22
|
+
|
|
23
|
+
// Treat source_string as sass (as opposed to scss)
|
|
24
|
+
bool is_indented_syntax_src;
|
|
25
|
+
|
|
26
|
+
// The input path is used for source map
|
|
27
|
+
// generation. It can be used to define
|
|
28
|
+
// something with string compilation or to
|
|
29
|
+
// overload the input file path. It is
|
|
30
|
+
// set to "stdin" for data contexts and
|
|
31
|
+
// to the input file on file contexts.
|
|
32
|
+
char* input_path;
|
|
33
|
+
|
|
34
|
+
// The output path is used for source map
|
|
35
|
+
// generation. LibSass will not write to
|
|
36
|
+
// this file, it is just used to create
|
|
37
|
+
// information in source-maps etc.
|
|
38
|
+
char* output_path;
|
|
39
|
+
|
|
40
|
+
// Colon-separated list of paths
|
|
41
|
+
// Semicolon-separated on Windows
|
|
42
|
+
// Maybe use array interface instead?
|
|
43
|
+
char* include_path;
|
|
44
|
+
char* plugin_path;
|
|
45
|
+
|
|
46
|
+
// Include paths (linked string list)
|
|
47
|
+
struct string_list* include_paths;
|
|
48
|
+
// Plugin paths (linked string list)
|
|
49
|
+
struct string_list* plugin_paths;
|
|
50
|
+
|
|
51
|
+
// Path to source map file
|
|
52
|
+
// Enables source map generation
|
|
53
|
+
// Used to create sourceMappingUrl
|
|
54
|
+
char* source_map_file;
|
|
55
|
+
|
|
56
|
+
// Directly inserted in source maps
|
|
57
|
+
char* source_map_root;
|
|
58
|
+
|
|
59
|
+
// Custom functions that can be called from sccs code
|
|
60
|
+
Sass_Function_List c_functions;
|
|
61
|
+
|
|
62
|
+
// List of custom importers
|
|
63
|
+
Sass_Importer_List c_importers;
|
|
64
|
+
|
|
65
|
+
// List of custom headers
|
|
66
|
+
Sass_Importer_List c_headers;
|
|
67
|
+
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
// base for all contexts
|
|
72
|
+
struct Sass_Context : Sass_Options
|
|
73
|
+
{
|
|
74
|
+
|
|
75
|
+
// store context type info
|
|
76
|
+
enum Sass_Input_Style type;
|
|
77
|
+
|
|
78
|
+
// generated output data
|
|
79
|
+
char* output_string;
|
|
80
|
+
|
|
81
|
+
// generated source map json
|
|
82
|
+
char* source_map_string;
|
|
83
|
+
|
|
84
|
+
// error status
|
|
85
|
+
int error_status;
|
|
86
|
+
char* error_json;
|
|
87
|
+
char* error_text;
|
|
88
|
+
char* error_message;
|
|
89
|
+
// error position
|
|
90
|
+
char* error_file;
|
|
91
|
+
size_t error_line;
|
|
92
|
+
size_t error_column;
|
|
93
|
+
char* error_src;
|
|
94
|
+
|
|
95
|
+
// report imported files
|
|
96
|
+
char** included_files;
|
|
97
|
+
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// struct for file compilation
|
|
101
|
+
struct Sass_File_Context : Sass_Context {
|
|
102
|
+
|
|
103
|
+
// no additional fields required
|
|
104
|
+
// input_path is already on options
|
|
105
|
+
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// struct for data compilation
|
|
109
|
+
struct Sass_Data_Context : Sass_Context {
|
|
110
|
+
|
|
111
|
+
// provided source string
|
|
112
|
+
char* source_string;
|
|
113
|
+
char* srcmap_string;
|
|
114
|
+
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// link c and cpp context
|
|
118
|
+
struct Sass_Compiler {
|
|
119
|
+
// progress status
|
|
120
|
+
Sass_Compiler_State state;
|
|
121
|
+
// original c context
|
|
122
|
+
Sass_Context* c_ctx;
|
|
123
|
+
// Sass::Context
|
|
124
|
+
Sass::Context* cpp_ctx;
|
|
125
|
+
// Sass::Block
|
|
126
|
+
Sass::Block_Obj root;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
#endif
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
// sass.hpp must go before all system headers to get the
|
|
2
|
+
// __EXTENSIONS__ fix on Solaris.
|
|
3
|
+
#include "sass.hpp"
|
|
4
|
+
|
|
5
|
+
#include <cstring>
|
|
6
|
+
#include "util.hpp"
|
|
7
|
+
#include "context.hpp"
|
|
8
|
+
#include "values.hpp"
|
|
9
|
+
#include "sass/functions.h"
|
|
10
|
+
#include "sass_functions.hpp"
|
|
11
|
+
|
|
12
|
+
extern "C" {
|
|
13
|
+
using namespace Sass;
|
|
14
|
+
|
|
15
|
+
Sass_Function_List ADDCALL sass_make_function_list(size_t length)
|
|
16
|
+
{
|
|
17
|
+
return (Sass_Function_List) calloc(length + 1, sizeof(Sass_Function_Entry));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Sass_Function_Entry ADDCALL sass_make_function(const char* signature, Sass_Function_Fn function, void* cookie)
|
|
21
|
+
{
|
|
22
|
+
Sass_Function_Entry cb = (Sass_Function_Entry) calloc(1, sizeof(Sass_Function));
|
|
23
|
+
if (cb == 0) return 0;
|
|
24
|
+
cb->signature = sass_copy_c_string(signature);
|
|
25
|
+
cb->function = function;
|
|
26
|
+
cb->cookie = cookie;
|
|
27
|
+
return cb;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
void ADDCALL sass_delete_function(Sass_Function_Entry entry)
|
|
31
|
+
{
|
|
32
|
+
free(entry->signature);
|
|
33
|
+
free(entry);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Deallocator for the allocated memory
|
|
37
|
+
void ADDCALL sass_delete_function_list(Sass_Function_List list)
|
|
38
|
+
{
|
|
39
|
+
Sass_Function_List it = list;
|
|
40
|
+
if (list == 0) return;
|
|
41
|
+
while(*list) {
|
|
42
|
+
sass_delete_function(*list);
|
|
43
|
+
++list;
|
|
44
|
+
}
|
|
45
|
+
free(it);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Setters and getters for callbacks on function lists
|
|
49
|
+
Sass_Function_Entry ADDCALL sass_function_get_list_entry(Sass_Function_List list, size_t pos) { return list[pos]; }
|
|
50
|
+
void sass_function_set_list_entry(Sass_Function_List list, size_t pos, Sass_Function_Entry cb) { list[pos] = cb; }
|
|
51
|
+
|
|
52
|
+
const char* ADDCALL sass_function_get_signature(Sass_Function_Entry cb) { return cb->signature; }
|
|
53
|
+
Sass_Function_Fn ADDCALL sass_function_get_function(Sass_Function_Entry cb) { return cb->function; }
|
|
54
|
+
void* ADDCALL sass_function_get_cookie(Sass_Function_Entry cb) { return cb->cookie; }
|
|
55
|
+
|
|
56
|
+
Sass_Importer_Entry ADDCALL sass_make_importer(Sass_Importer_Fn importer, double priority, void* cookie)
|
|
57
|
+
{
|
|
58
|
+
Sass_Importer_Entry cb = (Sass_Importer_Entry) calloc(1, sizeof(Sass_Importer));
|
|
59
|
+
if (cb == 0) return 0;
|
|
60
|
+
cb->importer = importer;
|
|
61
|
+
cb->priority = priority;
|
|
62
|
+
cb->cookie = cookie;
|
|
63
|
+
return cb;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
Sass_Importer_Fn ADDCALL sass_importer_get_function(Sass_Importer_Entry cb) { return cb->importer; }
|
|
67
|
+
double ADDCALL sass_importer_get_priority (Sass_Importer_Entry cb) { return cb->priority; }
|
|
68
|
+
void* ADDCALL sass_importer_get_cookie(Sass_Importer_Entry cb) { return cb->cookie; }
|
|
69
|
+
|
|
70
|
+
// Just in case we have some stray import structs
|
|
71
|
+
void ADDCALL sass_delete_importer (Sass_Importer_Entry cb)
|
|
72
|
+
{
|
|
73
|
+
free(cb);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Creator for sass custom importer function list
|
|
77
|
+
Sass_Importer_List ADDCALL sass_make_importer_list(size_t length)
|
|
78
|
+
{
|
|
79
|
+
return (Sass_Importer_List) calloc(length + 1, sizeof(Sass_Importer_Entry));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Deallocator for the allocated memory
|
|
83
|
+
void ADDCALL sass_delete_importer_list(Sass_Importer_List list)
|
|
84
|
+
{
|
|
85
|
+
Sass_Importer_List it = list;
|
|
86
|
+
if (list == 0) return;
|
|
87
|
+
while(*list) {
|
|
88
|
+
sass_delete_importer(*list);
|
|
89
|
+
++list;
|
|
90
|
+
}
|
|
91
|
+
free(it);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
Sass_Importer_Entry ADDCALL sass_importer_get_list_entry(Sass_Importer_List list, size_t idx) { return list[idx]; }
|
|
95
|
+
void ADDCALL sass_importer_set_list_entry(Sass_Importer_List list, size_t idx, Sass_Importer_Entry cb) { list[idx] = cb; }
|
|
96
|
+
|
|
97
|
+
// Creator for sass custom importer return argument list
|
|
98
|
+
Sass_Import_List ADDCALL sass_make_import_list(size_t length)
|
|
99
|
+
{
|
|
100
|
+
return (Sass_Import**) calloc(length + 1, sizeof(Sass_Import*));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Creator for a single import entry returned by the custom importer inside the list
|
|
104
|
+
// We take ownership of the memory for source and srcmap (freed when context is destroyed)
|
|
105
|
+
Sass_Import_Entry ADDCALL sass_make_import(const char* imp_path, const char* abs_path, char* source, char* srcmap)
|
|
106
|
+
{
|
|
107
|
+
Sass_Import* v = (Sass_Import*) calloc(1, sizeof(Sass_Import));
|
|
108
|
+
if (v == 0) return 0;
|
|
109
|
+
v->imp_path = imp_path ? sass_copy_c_string(imp_path) : 0;
|
|
110
|
+
v->abs_path = abs_path ? sass_copy_c_string(abs_path) : 0;
|
|
111
|
+
v->source = source;
|
|
112
|
+
v->srcmap = srcmap;
|
|
113
|
+
v->error = 0;
|
|
114
|
+
v->line = -1;
|
|
115
|
+
v->column = -1;
|
|
116
|
+
return v;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Older style, but somehow still valid - keep around or deprecate?
|
|
120
|
+
Sass_Import_Entry ADDCALL sass_make_import_entry(const char* path, char* source, char* srcmap)
|
|
121
|
+
{
|
|
122
|
+
return sass_make_import(path, path, source, srcmap);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Upgrade a normal import entry to throw an error (original path can be re-used by error reporting)
|
|
126
|
+
Sass_Import_Entry ADDCALL sass_import_set_error(Sass_Import_Entry import, const char* error, size_t line, size_t col)
|
|
127
|
+
{
|
|
128
|
+
if (import == 0) return 0;
|
|
129
|
+
if (import->error) free(import->error);
|
|
130
|
+
import->error = error ? sass_copy_c_string(error) : 0;
|
|
131
|
+
import->line = line ? line : -1;
|
|
132
|
+
import->column = col ? col : -1;
|
|
133
|
+
return import;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Setters and getters for entries on the import list
|
|
137
|
+
void ADDCALL sass_import_set_list_entry(Sass_Import_List list, size_t idx, Sass_Import_Entry entry) { list[idx] = entry; }
|
|
138
|
+
Sass_Import_Entry ADDCALL sass_import_get_list_entry(Sass_Import_List list, size_t idx) { return list[idx]; }
|
|
139
|
+
|
|
140
|
+
// Deallocator for the allocated memory
|
|
141
|
+
void ADDCALL sass_delete_import_list(Sass_Import_List list)
|
|
142
|
+
{
|
|
143
|
+
Sass_Import_List it = list;
|
|
144
|
+
if (list == 0) return;
|
|
145
|
+
while(*list) {
|
|
146
|
+
sass_delete_import(*list);
|
|
147
|
+
++list;
|
|
148
|
+
}
|
|
149
|
+
free(it);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Just in case we have some stray import structs
|
|
153
|
+
void ADDCALL sass_delete_import(Sass_Import_Entry import)
|
|
154
|
+
{
|
|
155
|
+
free(import->imp_path);
|
|
156
|
+
free(import->abs_path);
|
|
157
|
+
free(import->source);
|
|
158
|
+
free(import->srcmap);
|
|
159
|
+
free(import->error);
|
|
160
|
+
free(import);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Getter for callee entry
|
|
164
|
+
const char* ADDCALL sass_callee_get_name(Sass_Callee_Entry entry) { return entry->name; }
|
|
165
|
+
const char* ADDCALL sass_callee_get_path(Sass_Callee_Entry entry) { return entry->path; }
|
|
166
|
+
size_t ADDCALL sass_callee_get_line(Sass_Callee_Entry entry) { return entry->line; }
|
|
167
|
+
size_t ADDCALL sass_callee_get_column(Sass_Callee_Entry entry) { return entry->column; }
|
|
168
|
+
enum Sass_Callee_Type ADDCALL sass_callee_get_type(Sass_Callee_Entry entry) { return entry->type; }
|
|
169
|
+
Sass_Env_Frame ADDCALL sass_callee_get_env (Sass_Callee_Entry entry) { return &entry->env; }
|
|
170
|
+
|
|
171
|
+
// Getters and Setters for environments (lexical, local and global)
|
|
172
|
+
union Sass_Value* ADDCALL sass_env_get_lexical (Sass_Env_Frame env, const char* name) {
|
|
173
|
+
Expression* ex = Cast<Expression>((*env->frame)[name]);
|
|
174
|
+
return ex != NULL ? ast_node_to_sass_value(ex) : NULL;
|
|
175
|
+
}
|
|
176
|
+
void ADDCALL sass_env_set_lexical (Sass_Env_Frame env, const char* name, union Sass_Value* val) {
|
|
177
|
+
(*env->frame)[name] = sass_value_to_ast_node(val);
|
|
178
|
+
}
|
|
179
|
+
union Sass_Value* ADDCALL sass_env_get_local (Sass_Env_Frame env, const char* name) {
|
|
180
|
+
Expression* ex = Cast<Expression>(env->frame->get_local(name));
|
|
181
|
+
return ex != NULL ? ast_node_to_sass_value(ex) : NULL;
|
|
182
|
+
}
|
|
183
|
+
void ADDCALL sass_env_set_local (Sass_Env_Frame env, const char* name, union Sass_Value* val) {
|
|
184
|
+
env->frame->set_local(name, sass_value_to_ast_node(val));
|
|
185
|
+
}
|
|
186
|
+
union Sass_Value* ADDCALL sass_env_get_global (Sass_Env_Frame env, const char* name) {
|
|
187
|
+
Expression* ex = Cast<Expression>(env->frame->get_global(name));
|
|
188
|
+
return ex != NULL ? ast_node_to_sass_value(ex) : NULL;
|
|
189
|
+
}
|
|
190
|
+
void ADDCALL sass_env_set_global (Sass_Env_Frame env, const char* name, union Sass_Value* val) {
|
|
191
|
+
env->frame->set_global(name, sass_value_to_ast_node(val));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Getter for import entry
|
|
195
|
+
const char* ADDCALL sass_import_get_imp_path(Sass_Import_Entry entry) { return entry->imp_path; }
|
|
196
|
+
const char* ADDCALL sass_import_get_abs_path(Sass_Import_Entry entry) { return entry->abs_path; }
|
|
197
|
+
const char* ADDCALL sass_import_get_source(Sass_Import_Entry entry) { return entry->source; }
|
|
198
|
+
const char* ADDCALL sass_import_get_srcmap(Sass_Import_Entry entry) { return entry->srcmap; }
|
|
199
|
+
|
|
200
|
+
// Getter for import error entry
|
|
201
|
+
size_t ADDCALL sass_import_get_error_line(Sass_Import_Entry entry) { return entry->line; }
|
|
202
|
+
size_t ADDCALL sass_import_get_error_column(Sass_Import_Entry entry) { return entry->column; }
|
|
203
|
+
const char* ADDCALL sass_import_get_error_message(Sass_Import_Entry entry) { return entry->error; }
|
|
204
|
+
|
|
205
|
+
// Explicit functions to take ownership of the memory
|
|
206
|
+
// Resets our own property since we do not know if it is still alive
|
|
207
|
+
char* ADDCALL sass_import_take_source(Sass_Import_Entry entry) { char* ptr = entry->source; entry->source = 0; return ptr; }
|
|
208
|
+
char* ADDCALL sass_import_take_srcmap(Sass_Import_Entry entry) { char* ptr = entry->srcmap; entry->srcmap = 0; return ptr; }
|
|
209
|
+
|
|
210
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#ifndef SASS_SASS_FUNCTIONS_H
|
|
2
|
+
#define SASS_SASS_FUNCTIONS_H
|
|
3
|
+
|
|
4
|
+
#include "sass.h"
|
|
5
|
+
#include "environment.hpp"
|
|
6
|
+
#include "fn_utils.hpp"
|
|
7
|
+
|
|
8
|
+
// Struct to hold custom function callback
|
|
9
|
+
struct Sass_Function {
|
|
10
|
+
char* signature;
|
|
11
|
+
Sass_Function_Fn function;
|
|
12
|
+
void* cookie;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// External import entry
|
|
16
|
+
struct Sass_Import {
|
|
17
|
+
char* imp_path; // path as found in the import statement
|
|
18
|
+
char *abs_path; // path after importer has resolved it
|
|
19
|
+
char* source;
|
|
20
|
+
char* srcmap;
|
|
21
|
+
// error handling
|
|
22
|
+
char* error;
|
|
23
|
+
size_t line;
|
|
24
|
+
size_t column;
|
|
25
|
+
};
|
|
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
|
+
|
|
43
|
+
// Struct to hold importer callback
|
|
44
|
+
struct Sass_Importer {
|
|
45
|
+
Sass_Importer_Fn importer;
|
|
46
|
+
double priority;
|
|
47
|
+
void* cookie;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
#endif
|