sassc 0.0.1
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 +15 -0
- data/.gitmodules +3 -0
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +24 -0
- data/Rakefile +21 -0
- data/ext/libsass/.editorconfig +15 -0
- data/ext/libsass/.gitattributes +2 -0
- data/ext/libsass/.gitignore +61 -0
- data/ext/libsass/.travis.yml +38 -0
- data/ext/libsass/COPYING +25 -0
- data/ext/libsass/INSTALL +1 -0
- data/ext/libsass/LICENSE +25 -0
- data/ext/libsass/Makefile +223 -0
- data/ext/libsass/Makefile.am +145 -0
- data/ext/libsass/Readme.md +93 -0
- data/ext/libsass/appveyor.yml +76 -0
- data/ext/libsass/ast.cpp +581 -0
- data/ext/libsass/ast.hpp +1949 -0
- data/ext/libsass/ast_def_macros.hpp +16 -0
- data/ext/libsass/ast_factory.hpp +87 -0
- data/ext/libsass/ast_fwd_decl.hpp +72 -0
- data/ext/libsass/b64/cencode.h +32 -0
- data/ext/libsass/b64/encode.h +77 -0
- data/ext/libsass/backtrace.hpp +81 -0
- data/ext/libsass/base64vlq.cpp +43 -0
- data/ext/libsass/base64vlq.hpp +28 -0
- data/ext/libsass/bind.cpp +187 -0
- data/ext/libsass/bind.hpp +18 -0
- data/ext/libsass/cencode.c +102 -0
- data/ext/libsass/color_names.hpp +324 -0
- data/ext/libsass/configure.ac +130 -0
- data/ext/libsass/constants.cpp +144 -0
- data/ext/libsass/constants.hpp +145 -0
- data/ext/libsass/context.cpp +507 -0
- data/ext/libsass/context.hpp +150 -0
- data/ext/libsass/contextualize.cpp +157 -0
- data/ext/libsass/contextualize.hpp +65 -0
- data/ext/libsass/copy_c_str.cpp +13 -0
- data/ext/libsass/copy_c_str.hpp +5 -0
- data/ext/libsass/debug.hpp +39 -0
- data/ext/libsass/environment.hpp +75 -0
- data/ext/libsass/error_handling.cpp +28 -0
- data/ext/libsass/error_handling.hpp +28 -0
- data/ext/libsass/eval.cpp +1149 -0
- data/ext/libsass/eval.hpp +80 -0
- data/ext/libsass/expand.cpp +430 -0
- data/ext/libsass/expand.hpp +77 -0
- data/ext/libsass/extconf.rb +6 -0
- data/ext/libsass/extend.cpp +1962 -0
- data/ext/libsass/extend.hpp +50 -0
- data/ext/libsass/file.cpp +291 -0
- data/ext/libsass/file.hpp +18 -0
- data/ext/libsass/functions.cpp +1565 -0
- data/ext/libsass/functions.hpp +187 -0
- data/ext/libsass/inspect.cpp +727 -0
- data/ext/libsass/inspect.hpp +108 -0
- data/ext/libsass/json.cpp +1411 -0
- data/ext/libsass/json.hpp +117 -0
- data/ext/libsass/kwd_arg_macros.hpp +23 -0
- data/ext/libsass/m4/.gitkeep +0 -0
- data/ext/libsass/mapping.hpp +17 -0
- data/ext/libsass/memory_manager.hpp +54 -0
- data/ext/libsass/node.cpp +251 -0
- data/ext/libsass/node.hpp +122 -0
- data/ext/libsass/operation.hpp +153 -0
- data/ext/libsass/output_compressed.cpp +401 -0
- data/ext/libsass/output_compressed.hpp +95 -0
- data/ext/libsass/output_nested.cpp +364 -0
- data/ext/libsass/output_nested.hpp +108 -0
- data/ext/libsass/parser.cpp +2016 -0
- data/ext/libsass/parser.hpp +264 -0
- data/ext/libsass/paths.hpp +69 -0
- data/ext/libsass/position.hpp +22 -0
- data/ext/libsass/posix/getopt.c +562 -0
- data/ext/libsass/posix/getopt.h +95 -0
- data/ext/libsass/prelexer.cpp +688 -0
- data/ext/libsass/prelexer.hpp +513 -0
- data/ext/libsass/remove_placeholders.cpp +59 -0
- data/ext/libsass/remove_placeholders.hpp +43 -0
- data/ext/libsass/res/resource.rc +35 -0
- data/ext/libsass/sass.cpp +33 -0
- data/ext/libsass/sass.h +60 -0
- data/ext/libsass/sass2scss.cpp +834 -0
- data/ext/libsass/sass2scss.h +110 -0
- data/ext/libsass/sass_context.cpp +709 -0
- data/ext/libsass/sass_context.h +120 -0
- data/ext/libsass/sass_functions.cpp +137 -0
- data/ext/libsass/sass_functions.h +90 -0
- data/ext/libsass/sass_interface.cpp +277 -0
- data/ext/libsass/sass_interface.h +97 -0
- data/ext/libsass/sass_util.cpp +136 -0
- data/ext/libsass/sass_util.hpp +259 -0
- data/ext/libsass/sass_values.cpp +337 -0
- data/ext/libsass/sass_values.h +124 -0
- data/ext/libsass/script/bootstrap +10 -0
- data/ext/libsass/script/branding +10 -0
- data/ext/libsass/script/ci-build-libsass +72 -0
- data/ext/libsass/script/ci-install-compiler +4 -0
- data/ext/libsass/script/ci-install-deps +19 -0
- data/ext/libsass/script/ci-report-coverage +25 -0
- data/ext/libsass/script/coveralls-debug +32 -0
- data/ext/libsass/script/spec +5 -0
- data/ext/libsass/script/tap-driver +652 -0
- data/ext/libsass/script/tap-runner +1 -0
- data/ext/libsass/source_map.cpp +133 -0
- data/ext/libsass/source_map.hpp +46 -0
- data/ext/libsass/subset_map.hpp +145 -0
- data/ext/libsass/support/libsass.pc.in +11 -0
- data/ext/libsass/test-driver +127 -0
- data/ext/libsass/test/test_node.cpp +98 -0
- data/ext/libsass/test/test_paths.cpp +29 -0
- data/ext/libsass/test/test_selector_difference.cpp +28 -0
- data/ext/libsass/test/test_specificity.cpp +28 -0
- data/ext/libsass/test/test_subset_map.cpp +472 -0
- data/ext/libsass/test/test_superselector.cpp +71 -0
- data/ext/libsass/test/test_unification.cpp +33 -0
- data/ext/libsass/to_c.cpp +61 -0
- data/ext/libsass/to_c.hpp +44 -0
- data/ext/libsass/to_string.cpp +29 -0
- data/ext/libsass/to_string.hpp +32 -0
- data/ext/libsass/token.hpp +32 -0
- data/ext/libsass/units.cpp +54 -0
- data/ext/libsass/units.hpp +10 -0
- data/ext/libsass/utf8.h +34 -0
- data/ext/libsass/utf8/checked.h +327 -0
- data/ext/libsass/utf8/core.h +329 -0
- data/ext/libsass/utf8/unchecked.h +228 -0
- data/ext/libsass/utf8_string.cpp +102 -0
- data/ext/libsass/utf8_string.hpp +36 -0
- data/ext/libsass/util.cpp +189 -0
- data/ext/libsass/util.hpp +26 -0
- data/ext/libsass/win/libsass.filters +291 -0
- data/ext/libsass/win/libsass.sln +28 -0
- data/ext/libsass/win/libsass.vcxproj +255 -0
- data/lib/sassc.rb +6 -0
- data/lib/sassc/engine.rb +13 -0
- data/lib/sassc/native.rb +44 -0
- data/lib/sassc/native/native_context_api.rb +140 -0
- data/lib/sassc/native/native_functions_api.rb +41 -0
- data/lib/sassc/native/sass_input_style.rb +11 -0
- data/lib/sassc/native/sass_output_style.rb +10 -0
- data/lib/sassc/native/sass_value.rb +95 -0
- data/lib/sassc/native/string_list.rb +8 -0
- data/lib/sassc/version.rb +3 -0
- data/sassc.gemspec +43 -0
- data/test/smoke_test.rb +171 -0
- data/test/test_helper.rb +4 -0
- metadata +281 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#include "constants.hpp"
|
|
2
|
+
|
|
3
|
+
namespace Sass {
|
|
4
|
+
namespace Constants {
|
|
5
|
+
extern const int SPECIFICITY_BASE = 1000;
|
|
6
|
+
|
|
7
|
+
// hidden variable name for the image path (for the image-url built-in)
|
|
8
|
+
extern const char image_path_var[] = "$[image path]";
|
|
9
|
+
|
|
10
|
+
// sass keywords
|
|
11
|
+
extern const char import_kwd[] = "@import";
|
|
12
|
+
extern const char mixin_kwd[] = "@mixin";
|
|
13
|
+
extern const char function_kwd[] = "@function";
|
|
14
|
+
extern const char return_kwd[] = "@return";
|
|
15
|
+
extern const char include_kwd[] = "@include";
|
|
16
|
+
extern const char content_kwd[] = "@content";
|
|
17
|
+
extern const char extend_kwd[] = "@extend";
|
|
18
|
+
extern const char if_kwd[] = "@if";
|
|
19
|
+
extern const char else_kwd[] = "@else";
|
|
20
|
+
extern const char if_after_else_kwd[] = "if";
|
|
21
|
+
extern const char for_kwd[] = "@for";
|
|
22
|
+
extern const char from_kwd[] = "from";
|
|
23
|
+
extern const char to_kwd[] = "to";
|
|
24
|
+
extern const char through_kwd[] = "through";
|
|
25
|
+
extern const char each_kwd[] = "@each";
|
|
26
|
+
extern const char in_kwd[] = "in";
|
|
27
|
+
extern const char while_kwd[] = "@while";
|
|
28
|
+
extern const char warn_kwd[] = "@warn";
|
|
29
|
+
extern const char error_kwd[] = "@error";
|
|
30
|
+
extern const char debug_kwd[] = "@debug";
|
|
31
|
+
extern const char default_kwd[] = "default";
|
|
32
|
+
extern const char global_kwd[] = "global";
|
|
33
|
+
extern const char null_kwd[] = "null";
|
|
34
|
+
extern const char optional_kwd[] = "optional";
|
|
35
|
+
|
|
36
|
+
// css standard units
|
|
37
|
+
extern const char em_kwd[] = "em";
|
|
38
|
+
extern const char ex_kwd[] = "ex";
|
|
39
|
+
extern const char px_kwd[] = "px";
|
|
40
|
+
extern const char cm_kwd[] = "cm";
|
|
41
|
+
extern const char mm_kwd[] = "mm";
|
|
42
|
+
extern const char pt_kwd[] = "pt";
|
|
43
|
+
extern const char pc_kwd[] = "pc";
|
|
44
|
+
extern const char deg_kwd[] = "deg";
|
|
45
|
+
extern const char rad_kwd[] = "rad";
|
|
46
|
+
extern const char grad_kwd[] = "grad";
|
|
47
|
+
extern const char turn_kwd[] = "turn";
|
|
48
|
+
extern const char ms_kwd[] = "ms";
|
|
49
|
+
extern const char s_kwd[] = "s";
|
|
50
|
+
extern const char Hz_kwd[] = "Hz";
|
|
51
|
+
extern const char kHz_kwd[] = "kHz";
|
|
52
|
+
|
|
53
|
+
// vendor prefixes
|
|
54
|
+
extern const char vendor_opera_kwd[] = "-o-";
|
|
55
|
+
extern const char vendor_webkit_kwd[] = "-webkit-";
|
|
56
|
+
extern const char vendor_mozilla_kwd[] = "-moz-";
|
|
57
|
+
extern const char vendor_ms_kwd[] = "-ms-";
|
|
58
|
+
extern const char vendor_khtml_kwd[] = "-khtml-";
|
|
59
|
+
|
|
60
|
+
// css functions and keywords
|
|
61
|
+
extern const char charset_kwd[] = "@charset";
|
|
62
|
+
extern const char media_kwd[] = "@media";
|
|
63
|
+
extern const char supports_kwd[] = "@supports";
|
|
64
|
+
extern const char keyframes_kwd[] = "keyframes";
|
|
65
|
+
extern const char only_kwd[] = "only";
|
|
66
|
+
extern const char rgb_kwd[] = "rgb(";
|
|
67
|
+
extern const char url_kwd[] = "url(";
|
|
68
|
+
extern const char image_url_kwd[] = "image-url(";
|
|
69
|
+
extern const char important_kwd[] = "important";
|
|
70
|
+
extern const char pseudo_not_kwd[] = ":not(";
|
|
71
|
+
extern const char even_kwd[] = "even";
|
|
72
|
+
extern const char odd_kwd[] = "odd";
|
|
73
|
+
extern const char progid_kwd[] = "progid";
|
|
74
|
+
extern const char expression_kwd[] = "expression";
|
|
75
|
+
extern const char calc_kwd[] = "calc(";
|
|
76
|
+
extern const char moz_calc_kwd[] = "-moz-calc(";
|
|
77
|
+
extern const char webkit_calc_kwd[] = "-webkit-calc(";
|
|
78
|
+
|
|
79
|
+
// css attribute-matching operators
|
|
80
|
+
extern const char tilde_equal[] = "~=";
|
|
81
|
+
extern const char pipe_equal[] = "|=";
|
|
82
|
+
extern const char caret_equal[] = "^=";
|
|
83
|
+
extern const char dollar_equal[] = "$=";
|
|
84
|
+
extern const char star_equal[] = "*=";
|
|
85
|
+
|
|
86
|
+
// relational & logical operators and constants
|
|
87
|
+
extern const char and_kwd[] = "and";
|
|
88
|
+
extern const char or_kwd[] = "or";
|
|
89
|
+
extern const char not_kwd[] = "not";
|
|
90
|
+
extern const char gt[] = ">";
|
|
91
|
+
extern const char gte[] = ">=";
|
|
92
|
+
extern const char lt[] = "<";
|
|
93
|
+
extern const char lte[] = "<=";
|
|
94
|
+
extern const char eq[] = "==";
|
|
95
|
+
extern const char neq[] = "!=";
|
|
96
|
+
extern const char true_kwd[] = "true";
|
|
97
|
+
extern const char false_kwd[] = "false";
|
|
98
|
+
|
|
99
|
+
// miscellaneous punctuation and delimiters
|
|
100
|
+
extern const char percent_str[] = "%";
|
|
101
|
+
extern const char empty_str[] = "";
|
|
102
|
+
extern const char slash_slash[] = "//";
|
|
103
|
+
extern const char slash_star[] = "/*";
|
|
104
|
+
extern const char star_slash[] = "*/";
|
|
105
|
+
extern const char hash_lbrace[] = "#{";
|
|
106
|
+
extern const char rbrace[] = "}";
|
|
107
|
+
extern const char rparen[] = ")";
|
|
108
|
+
extern const char sign_chars[] = "-+";
|
|
109
|
+
extern const char hyphen[] = "-";
|
|
110
|
+
extern const char ellipsis[] = "...";
|
|
111
|
+
extern const char url_space_chars[] = " \t\r\n\f";
|
|
112
|
+
extern const char escape_chars[] = " -~"; // need to include unicode spaces too
|
|
113
|
+
// type names
|
|
114
|
+
extern const char numeric_name[] = "numeric value";
|
|
115
|
+
extern const char number_name[] = "number";
|
|
116
|
+
extern const char percentage_name[] = "percentage";
|
|
117
|
+
extern const char dimension_name[] = "numeric dimension";
|
|
118
|
+
extern const char string_name[] = "string";
|
|
119
|
+
extern const char bool_name[] = "bool";
|
|
120
|
+
extern const char color_name[] = "color";
|
|
121
|
+
extern const char list_name[] = "list";
|
|
122
|
+
extern const char map_name[] = "map";
|
|
123
|
+
extern const char arglist_name[] = "arglist";
|
|
124
|
+
|
|
125
|
+
// byte order marks
|
|
126
|
+
// (taken from http://en.wikipedia.org/wiki/Byte_order_mark)
|
|
127
|
+
extern const unsigned char utf_8_bom[] = { 0xEF, 0xBB, 0xBF };
|
|
128
|
+
extern const unsigned char utf_16_bom_be[] = { 0xFE, 0xFF };
|
|
129
|
+
extern const unsigned char utf_16_bom_le[] = { 0xFF, 0xFE };
|
|
130
|
+
extern const unsigned char utf_32_bom_be[] = { 0x00, 0x00, 0xFE, 0xFF };
|
|
131
|
+
extern const unsigned char utf_32_bom_le[] = { 0xFF, 0xFE, 0x00, 0x00 };
|
|
132
|
+
extern const unsigned char utf_7_bom_1[] = { 0x2B, 0x2F, 0x76, 0x38 };
|
|
133
|
+
extern const unsigned char utf_7_bom_2[] = { 0x2B, 0x2F, 0x76, 0x39 };
|
|
134
|
+
extern const unsigned char utf_7_bom_3[] = { 0x2B, 0x2F, 0x76, 0x2B };
|
|
135
|
+
extern const unsigned char utf_7_bom_4[] = { 0x2B, 0x2F, 0x76, 0x2F };
|
|
136
|
+
extern const unsigned char utf_7_bom_5[] = { 0x2B, 0x2F, 0x76, 0x38, 0x2D };
|
|
137
|
+
extern const unsigned char utf_1_bom[] = { 0xF7, 0x64, 0x4C };
|
|
138
|
+
extern const unsigned char utf_ebcdic_bom[] = { 0xDD, 0x73, 0x66, 0x73 };
|
|
139
|
+
extern const unsigned char scsu_bom[] = { 0x0E, 0xFE, 0xFF };
|
|
140
|
+
extern const unsigned char bocu_1_bom[] = { 0xFB, 0xEE, 0x28 };
|
|
141
|
+
extern const unsigned char gb_18030_bom[] = { 0x84, 0x31, 0x95, 0x33 };
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#define SASS_CONSTANTS
|
|
2
|
+
|
|
3
|
+
namespace Sass {
|
|
4
|
+
namespace Constants {
|
|
5
|
+
extern const int SPECIFICITY_BASE;
|
|
6
|
+
|
|
7
|
+
// hidden variable name for the image path (for the image-url built-in)
|
|
8
|
+
extern const char image_path_var[];
|
|
9
|
+
|
|
10
|
+
// sass keywords
|
|
11
|
+
extern const char import_kwd[];
|
|
12
|
+
extern const char mixin_kwd[];
|
|
13
|
+
extern const char function_kwd[];
|
|
14
|
+
extern const char return_kwd[];
|
|
15
|
+
extern const char include_kwd[];
|
|
16
|
+
extern const char content_kwd[];
|
|
17
|
+
extern const char extend_kwd[];
|
|
18
|
+
extern const char if_kwd[];
|
|
19
|
+
extern const char else_kwd[];
|
|
20
|
+
extern const char if_after_else_kwd[];
|
|
21
|
+
extern const char for_kwd[];
|
|
22
|
+
extern const char from_kwd[];
|
|
23
|
+
extern const char to_kwd[];
|
|
24
|
+
extern const char through_kwd[];
|
|
25
|
+
extern const char each_kwd[];
|
|
26
|
+
extern const char in_kwd[];
|
|
27
|
+
extern const char while_kwd[];
|
|
28
|
+
extern const char warn_kwd[];
|
|
29
|
+
extern const char error_kwd[];
|
|
30
|
+
extern const char debug_kwd[];
|
|
31
|
+
extern const char default_kwd[];
|
|
32
|
+
extern const char global_kwd[];
|
|
33
|
+
extern const char null_kwd[];
|
|
34
|
+
extern const char optional_kwd[];
|
|
35
|
+
|
|
36
|
+
// css standard units
|
|
37
|
+
extern const char em_kwd[];
|
|
38
|
+
extern const char ex_kwd[];
|
|
39
|
+
extern const char px_kwd[];
|
|
40
|
+
extern const char cm_kwd[];
|
|
41
|
+
extern const char mm_kwd[];
|
|
42
|
+
extern const char pt_kwd[];
|
|
43
|
+
extern const char pc_kwd[];
|
|
44
|
+
extern const char deg_kwd[];
|
|
45
|
+
extern const char rad_kwd[];
|
|
46
|
+
extern const char grad_kwd[];
|
|
47
|
+
extern const char turn_kwd[];
|
|
48
|
+
extern const char ms_kwd[];
|
|
49
|
+
extern const char s_kwd[];
|
|
50
|
+
extern const char Hz_kwd[];
|
|
51
|
+
extern const char kHz_kwd[];
|
|
52
|
+
|
|
53
|
+
// vendor prefixes
|
|
54
|
+
extern const char vendor_opera_kwd[];
|
|
55
|
+
extern const char vendor_webkit_kwd[];
|
|
56
|
+
extern const char vendor_mozilla_kwd[];
|
|
57
|
+
extern const char vendor_ms_kwd[];
|
|
58
|
+
extern const char vendor_khtml_kwd[];
|
|
59
|
+
|
|
60
|
+
// css functions and keywords
|
|
61
|
+
extern const char charset_kwd[];
|
|
62
|
+
extern const char media_kwd[];
|
|
63
|
+
extern const char supports_kwd[];
|
|
64
|
+
extern const char keyframes_kwd[];
|
|
65
|
+
extern const char only_kwd[];
|
|
66
|
+
extern const char rgb_kwd[];
|
|
67
|
+
extern const char url_kwd[];
|
|
68
|
+
extern const char image_url_kwd[];
|
|
69
|
+
extern const char important_kwd[];
|
|
70
|
+
extern const char pseudo_not_kwd[];
|
|
71
|
+
extern const char even_kwd[];
|
|
72
|
+
extern const char odd_kwd[];
|
|
73
|
+
extern const char progid_kwd[];
|
|
74
|
+
extern const char expression_kwd[];
|
|
75
|
+
extern const char calc_kwd[];
|
|
76
|
+
extern const char moz_calc_kwd[];
|
|
77
|
+
extern const char webkit_calc_kwd[];
|
|
78
|
+
|
|
79
|
+
// css attribute-matching operators
|
|
80
|
+
extern const char tilde_equal[];
|
|
81
|
+
extern const char pipe_equal[];
|
|
82
|
+
extern const char caret_equal[];
|
|
83
|
+
extern const char dollar_equal[];
|
|
84
|
+
extern const char star_equal[];
|
|
85
|
+
|
|
86
|
+
// relational & logical operators and constants
|
|
87
|
+
extern const char and_kwd[];
|
|
88
|
+
extern const char or_kwd[];
|
|
89
|
+
extern const char not_kwd[];
|
|
90
|
+
extern const char gt[];
|
|
91
|
+
extern const char gte[];
|
|
92
|
+
extern const char lt[];
|
|
93
|
+
extern const char lte[];
|
|
94
|
+
extern const char eq[];
|
|
95
|
+
extern const char neq[];
|
|
96
|
+
extern const char true_kwd[];
|
|
97
|
+
extern const char false_kwd[];
|
|
98
|
+
|
|
99
|
+
// miscellaneous punctuation and delimiters
|
|
100
|
+
extern const char percent_str[];
|
|
101
|
+
extern const char empty_str[];
|
|
102
|
+
extern const char slash_slash[];
|
|
103
|
+
extern const char slash_star[];
|
|
104
|
+
extern const char star_slash[];
|
|
105
|
+
extern const char hash_lbrace[];
|
|
106
|
+
extern const char rbrace[];
|
|
107
|
+
extern const char rparen[];
|
|
108
|
+
extern const char sign_chars[];
|
|
109
|
+
extern const char hyphen[];
|
|
110
|
+
extern const char ellipsis[];
|
|
111
|
+
extern const char url_space_chars[];
|
|
112
|
+
extern const char escape_chars[];
|
|
113
|
+
|
|
114
|
+
// type names
|
|
115
|
+
extern const char numeric_name[];
|
|
116
|
+
extern const char number_name[];
|
|
117
|
+
extern const char percentage_name[];
|
|
118
|
+
extern const char dimension_name[];
|
|
119
|
+
extern const char string_name[];
|
|
120
|
+
extern const char bool_name[];
|
|
121
|
+
extern const char color_name[];
|
|
122
|
+
extern const char list_name[];
|
|
123
|
+
extern const char map_name[];
|
|
124
|
+
extern const char arglist_name[];
|
|
125
|
+
|
|
126
|
+
// byte order marks
|
|
127
|
+
// (taken from http://en.wikipedia.org/wiki/Byte_order_mark)
|
|
128
|
+
extern const unsigned char utf_8_bom[];
|
|
129
|
+
extern const unsigned char utf_16_bom_be[];
|
|
130
|
+
extern const unsigned char utf_16_bom_le[];
|
|
131
|
+
extern const unsigned char utf_32_bom_be[];
|
|
132
|
+
extern const unsigned char utf_32_bom_le[];
|
|
133
|
+
extern const unsigned char utf_7_bom_1[];
|
|
134
|
+
extern const unsigned char utf_7_bom_2[];
|
|
135
|
+
extern const unsigned char utf_7_bom_3[];
|
|
136
|
+
extern const unsigned char utf_7_bom_4[];
|
|
137
|
+
extern const unsigned char utf_7_bom_5[];
|
|
138
|
+
extern const unsigned char utf_1_bom[];
|
|
139
|
+
extern const unsigned char utf_ebcdic_bom[];
|
|
140
|
+
extern const unsigned char scsu_bom[];
|
|
141
|
+
extern const unsigned char bocu_1_bom[];
|
|
142
|
+
extern const unsigned char gb_18030_bom[];
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
#ifdef _WIN32
|
|
2
|
+
#define PATH_SEP ';'
|
|
3
|
+
#else
|
|
4
|
+
#define PATH_SEP ':'
|
|
5
|
+
#endif
|
|
6
|
+
|
|
7
|
+
#ifndef SASS_AST
|
|
8
|
+
#include "ast.hpp"
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
#include "context.hpp"
|
|
12
|
+
#include "constants.hpp"
|
|
13
|
+
#include "parser.hpp"
|
|
14
|
+
#include "file.hpp"
|
|
15
|
+
#include "inspect.hpp"
|
|
16
|
+
#include "output_nested.hpp"
|
|
17
|
+
#include "output_compressed.hpp"
|
|
18
|
+
#include "expand.hpp"
|
|
19
|
+
#include "eval.hpp"
|
|
20
|
+
#include "contextualize.hpp"
|
|
21
|
+
#include "extend.hpp"
|
|
22
|
+
#include "remove_placeholders.hpp"
|
|
23
|
+
#include "copy_c_str.hpp"
|
|
24
|
+
#include "color_names.hpp"
|
|
25
|
+
#include "functions.hpp"
|
|
26
|
+
#include "backtrace.hpp"
|
|
27
|
+
#include "sass2scss.h"
|
|
28
|
+
|
|
29
|
+
#ifndef SASS_PRELEXER
|
|
30
|
+
#include "prelexer.hpp"
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
#include <iomanip>
|
|
34
|
+
#include <iostream>
|
|
35
|
+
#include <cstring>
|
|
36
|
+
#include <sstream>
|
|
37
|
+
|
|
38
|
+
namespace Sass {
|
|
39
|
+
using namespace Constants;
|
|
40
|
+
using namespace File;
|
|
41
|
+
using std::cerr;
|
|
42
|
+
using std::endl;
|
|
43
|
+
|
|
44
|
+
Sass_Queued::Sass_Queued(const string& load_path, const string& abs_path, const char* source)
|
|
45
|
+
{
|
|
46
|
+
this->load_path = load_path;
|
|
47
|
+
this->abs_path = abs_path;
|
|
48
|
+
this->source = source;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
Context::Context(Context::Data initializers)
|
|
53
|
+
: mem(Memory_Manager<AST_Node>()),
|
|
54
|
+
source_c_str (initializers.source_c_str()),
|
|
55
|
+
sources (vector<const char*>()),
|
|
56
|
+
include_paths (initializers.include_paths()),
|
|
57
|
+
queue (vector<Sass_Queued>()),
|
|
58
|
+
style_sheets (map<string, Block*>()),
|
|
59
|
+
source_map (resolve_relative_path(initializers.output_path(), initializers.source_map_file(), get_cwd())),
|
|
60
|
+
c_functions (vector<Sass_C_Function_Callback>()),
|
|
61
|
+
image_path (initializers.image_path()),
|
|
62
|
+
input_path (make_canonical_path(initializers.input_path())),
|
|
63
|
+
output_path (make_canonical_path(initializers.output_path())),
|
|
64
|
+
source_comments (initializers.source_comments()),
|
|
65
|
+
output_style (initializers.output_style()),
|
|
66
|
+
source_map_file (make_canonical_path(initializers.source_map_file())),
|
|
67
|
+
source_map_embed (initializers.source_map_embed()),
|
|
68
|
+
source_map_contents (initializers.source_map_contents()),
|
|
69
|
+
omit_source_map_url (initializers.omit_source_map_url()),
|
|
70
|
+
is_indented_syntax_src (initializers.is_indented_syntax_src()),
|
|
71
|
+
importer (initializers.importer()),
|
|
72
|
+
names_to_colors (map<string, Color*>()),
|
|
73
|
+
colors_to_names (map<int, string>()),
|
|
74
|
+
precision (initializers.precision()),
|
|
75
|
+
_skip_source_map_update (initializers._skip_source_map_update()),
|
|
76
|
+
subset_map (Subset_Map<string, pair<Complex_Selector*, Compound_Selector*> >())
|
|
77
|
+
{
|
|
78
|
+
cwd = get_cwd();
|
|
79
|
+
|
|
80
|
+
// enforce some safe defaults
|
|
81
|
+
// used to create relative file links
|
|
82
|
+
if (input_path == "") input_path = "stdin";
|
|
83
|
+
if (output_path == "") output_path = "stdout";
|
|
84
|
+
|
|
85
|
+
include_paths.push_back(cwd);
|
|
86
|
+
collect_include_paths(initializers.include_paths_c_str());
|
|
87
|
+
collect_include_paths(initializers.include_paths_array());
|
|
88
|
+
|
|
89
|
+
setup_color_map();
|
|
90
|
+
|
|
91
|
+
string entry_point = initializers.entry_point();
|
|
92
|
+
if (!entry_point.empty()) {
|
|
93
|
+
string result(add_file(entry_point));
|
|
94
|
+
if (result.empty()) {
|
|
95
|
+
throw "File to read not found or unreadable: " + entry_point;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Context::~Context()
|
|
101
|
+
{
|
|
102
|
+
// everything that gets put into sources will be freed by us
|
|
103
|
+
for (size_t i = 0; i < sources.size(); ++i) delete[] sources[i];
|
|
104
|
+
for (size_t n = 0; n < import_stack.size(); ++n) sass_delete_import(import_stack[n]);
|
|
105
|
+
sources.clear(); import_stack.clear();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
void Context::setup_color_map()
|
|
109
|
+
{
|
|
110
|
+
size_t i = 0;
|
|
111
|
+
while (color_names[i]) {
|
|
112
|
+
string name(color_names[i]);
|
|
113
|
+
Color* value = new (mem) Color("[COLOR TABLE]", Position(),
|
|
114
|
+
color_values[i*4],
|
|
115
|
+
color_values[i*4+1],
|
|
116
|
+
color_values[i*4+2],
|
|
117
|
+
color_values[i*4+3]);
|
|
118
|
+
names_to_colors[name] = value;
|
|
119
|
+
// only map fully opaque colors
|
|
120
|
+
if (color_values[i*4+3] >= 1) {
|
|
121
|
+
int numval = color_values[i*4]*0x10000;
|
|
122
|
+
numval += color_values[i*4+1]*0x100;
|
|
123
|
+
numval += color_values[i*4+2];
|
|
124
|
+
colors_to_names[numval] = name;
|
|
125
|
+
}
|
|
126
|
+
++i;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
void Context::collect_include_paths(const char* paths_str)
|
|
131
|
+
{
|
|
132
|
+
|
|
133
|
+
if (paths_str) {
|
|
134
|
+
const char* beg = paths_str;
|
|
135
|
+
const char* end = Prelexer::find_first<PATH_SEP>(beg);
|
|
136
|
+
|
|
137
|
+
while (end) {
|
|
138
|
+
string path(beg, end - beg);
|
|
139
|
+
if (!path.empty()) {
|
|
140
|
+
if (*path.rbegin() != '/') path += '/';
|
|
141
|
+
include_paths.push_back(path);
|
|
142
|
+
}
|
|
143
|
+
beg = end + 1;
|
|
144
|
+
end = Prelexer::find_first<PATH_SEP>(beg);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
string path(beg);
|
|
148
|
+
if (!path.empty()) {
|
|
149
|
+
if (*path.rbegin() != '/') path += '/';
|
|
150
|
+
include_paths.push_back(path);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
void Context::collect_include_paths(const char** paths_array)
|
|
156
|
+
{
|
|
157
|
+
if (*include_paths.back().rbegin() != '/') include_paths.back() += '/';
|
|
158
|
+
if (paths_array) {
|
|
159
|
+
for (size_t i = 0; paths_array[i]; i++) {
|
|
160
|
+
collect_include_paths(paths_array[i]);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
void Context::add_source(string load_path, string abs_path, const char* contents)
|
|
166
|
+
{
|
|
167
|
+
sources.push_back(contents);
|
|
168
|
+
included_files.push_back(abs_path);
|
|
169
|
+
queue.push_back(Sass_Queued(load_path, abs_path, contents));
|
|
170
|
+
source_map.source_index.push_back(sources.size() - 1);
|
|
171
|
+
include_links.push_back(resolve_relative_path(abs_path, source_map_file, cwd));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
string Context::add_file(string path)
|
|
175
|
+
{
|
|
176
|
+
using namespace File;
|
|
177
|
+
char* contents = 0;
|
|
178
|
+
string real_path;
|
|
179
|
+
path = make_canonical_path(path);
|
|
180
|
+
for (size_t i = 0, S = include_paths.size(); i < S; ++i) {
|
|
181
|
+
string full_path(join_paths(include_paths[i], path));
|
|
182
|
+
if (style_sheets.count(full_path)) return full_path;
|
|
183
|
+
contents = resolve_and_load(full_path, real_path);
|
|
184
|
+
if (contents) {
|
|
185
|
+
add_source(full_path, real_path, contents);
|
|
186
|
+
style_sheets[full_path] = 0;
|
|
187
|
+
return full_path;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return string();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
string Context::add_file(string dir, string rel_filepath)
|
|
194
|
+
{
|
|
195
|
+
using namespace File;
|
|
196
|
+
char* contents = 0;
|
|
197
|
+
string real_path;
|
|
198
|
+
rel_filepath = make_canonical_path(rel_filepath);
|
|
199
|
+
string full_path(join_paths(dir, rel_filepath));
|
|
200
|
+
if (style_sheets.count(full_path)) return full_path;
|
|
201
|
+
contents = resolve_and_load(full_path, real_path);
|
|
202
|
+
if (contents) {
|
|
203
|
+
add_source(full_path, real_path, contents);
|
|
204
|
+
style_sheets[full_path] = 0;
|
|
205
|
+
return full_path;
|
|
206
|
+
}
|
|
207
|
+
for (size_t i = 0, S = include_paths.size(); i < S; ++i) {
|
|
208
|
+
string full_path(join_paths(include_paths[i], rel_filepath));
|
|
209
|
+
if (style_sheets.count(full_path)) return full_path;
|
|
210
|
+
contents = resolve_and_load(full_path, real_path);
|
|
211
|
+
if (contents) {
|
|
212
|
+
add_source(full_path, real_path, contents);
|
|
213
|
+
style_sheets[full_path] = 0;
|
|
214
|
+
return full_path;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return string();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
void register_function(Context&, Signature sig, Native_Function f, Env* env);
|
|
221
|
+
void register_function(Context&, Signature sig, Native_Function f, size_t arity, Env* env);
|
|
222
|
+
void register_overload_stub(Context&, string name, Env* env);
|
|
223
|
+
void register_built_in_functions(Context&, Env* env);
|
|
224
|
+
void register_c_functions(Context&, Env* env, Sass_C_Function_List);
|
|
225
|
+
void register_c_function(Context&, Env* env, Sass_C_Function_Callback);
|
|
226
|
+
|
|
227
|
+
char* Context::compile_block(Block* root)
|
|
228
|
+
{
|
|
229
|
+
char* result = 0;
|
|
230
|
+
if (!root) return 0;
|
|
231
|
+
switch (output_style) {
|
|
232
|
+
case COMPRESSED: {
|
|
233
|
+
Output_Compressed output_compressed(this);
|
|
234
|
+
root->perform(&output_compressed);
|
|
235
|
+
string output = output_compressed.get_buffer();
|
|
236
|
+
if (source_map_file != "" && !omit_source_map_url) {
|
|
237
|
+
output += format_source_mapping_url(source_map_file);
|
|
238
|
+
}
|
|
239
|
+
result = copy_c_str(output.c_str());
|
|
240
|
+
} break;
|
|
241
|
+
|
|
242
|
+
default: {
|
|
243
|
+
Output_Nested output_nested(source_comments, this);
|
|
244
|
+
root->perform(&output_nested);
|
|
245
|
+
string output = output_nested.get_buffer();
|
|
246
|
+
if (source_map_file != "" && !omit_source_map_url) {
|
|
247
|
+
output += "\n" + format_source_mapping_url(source_map_file);
|
|
248
|
+
}
|
|
249
|
+
result = copy_c_str(output.c_str());
|
|
250
|
+
|
|
251
|
+
} break;
|
|
252
|
+
}
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
Block* Context::parse_file()
|
|
257
|
+
{
|
|
258
|
+
Block* root = 0;
|
|
259
|
+
for (size_t i = 0; i < queue.size(); ++i) {
|
|
260
|
+
struct Sass_Import* import = sass_make_import(
|
|
261
|
+
queue[i].load_path.c_str(),
|
|
262
|
+
queue[i].abs_path.c_str(),
|
|
263
|
+
0, 0
|
|
264
|
+
);
|
|
265
|
+
import_stack.push_back(import);
|
|
266
|
+
Parser p(Parser::from_c_str(queue[i].source, *this, queue[i].abs_path, Position(1 + i, 1, 1)));
|
|
267
|
+
Block* ast = p.parse();
|
|
268
|
+
sass_delete_import(import_stack.back());
|
|
269
|
+
import_stack.pop_back();
|
|
270
|
+
if (i == 0) root = ast;
|
|
271
|
+
style_sheets[queue[i].load_path] = ast;
|
|
272
|
+
}
|
|
273
|
+
if (root == 0) return 0;
|
|
274
|
+
Env tge;
|
|
275
|
+
Backtrace backtrace(0, "", Position(), "");
|
|
276
|
+
register_built_in_functions(*this, &tge);
|
|
277
|
+
for (size_t i = 0, S = c_functions.size(); i < S; ++i) {
|
|
278
|
+
register_c_function(*this, &tge, c_functions[i]);
|
|
279
|
+
}
|
|
280
|
+
Eval eval(*this, &tge, &backtrace);
|
|
281
|
+
Contextualize contextualize(*this, &eval, &tge, &backtrace);
|
|
282
|
+
Expand expand(*this, &eval, &contextualize, &tge, &backtrace);
|
|
283
|
+
// Inspect inspect(this);
|
|
284
|
+
// Output_Nested output_nested(*this);
|
|
285
|
+
|
|
286
|
+
root = root->perform(&expand)->block();
|
|
287
|
+
if (!subset_map.empty()) {
|
|
288
|
+
Extend extend(*this, subset_map);
|
|
289
|
+
root->perform(&extend);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
Remove_Placeholders remove_placeholders(*this);
|
|
293
|
+
root->perform(&remove_placeholders);
|
|
294
|
+
|
|
295
|
+
return root;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
Block* Context::parse_string()
|
|
299
|
+
{
|
|
300
|
+
if (!source_c_str) return 0;
|
|
301
|
+
queue.clear();
|
|
302
|
+
if(is_indented_syntax_src) {
|
|
303
|
+
char * contents = sass2scss(source_c_str, SASS2SCSS_PRETTIFY_1);
|
|
304
|
+
add_source(input_path, input_path, contents);
|
|
305
|
+
return parse_file();
|
|
306
|
+
}
|
|
307
|
+
add_source(input_path, input_path, strdup(source_c_str));
|
|
308
|
+
return parse_file();
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
char* Context::compile_file()
|
|
312
|
+
{
|
|
313
|
+
// returns NULL if something fails
|
|
314
|
+
return compile_block(parse_file());
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
char* Context::compile_string()
|
|
318
|
+
{
|
|
319
|
+
// returns NULL if something fails
|
|
320
|
+
return compile_block(parse_string());
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
string Context::format_source_mapping_url(const string& file)
|
|
324
|
+
{
|
|
325
|
+
string url = resolve_relative_path(file, output_path, cwd);
|
|
326
|
+
if (source_map_embed) {
|
|
327
|
+
string map = source_map.generate_source_map(*this);
|
|
328
|
+
istringstream is( map );
|
|
329
|
+
ostringstream buffer;
|
|
330
|
+
base64::encoder E;
|
|
331
|
+
E.encode(is, buffer);
|
|
332
|
+
url = "data:application/json;base64," + buffer.str();
|
|
333
|
+
url.erase(url.size() - 1);
|
|
334
|
+
}
|
|
335
|
+
return "/*# sourceMappingURL=" + url + " */";
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
char* Context::generate_source_map()
|
|
339
|
+
{
|
|
340
|
+
if (source_map_file == "") return 0;
|
|
341
|
+
char* result = 0;
|
|
342
|
+
string map = source_map.generate_source_map(*this);
|
|
343
|
+
result = copy_c_str(map.c_str());
|
|
344
|
+
return result;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
std::vector<std::string> Context::get_included_files(size_t skip)
|
|
349
|
+
{
|
|
350
|
+
vector<string> includes = included_files;
|
|
351
|
+
std::sort( includes.begin() + skip, includes.end() );
|
|
352
|
+
includes.erase( std::unique( includes.begin(), includes.end() ), includes.end() );
|
|
353
|
+
// the skip solution seems more robust, as we may have real files named stdin
|
|
354
|
+
// includes.erase( std::remove( includes.begin(), includes.end(), "stdin" ), includes.end() );
|
|
355
|
+
return includes;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
string Context::get_cwd()
|
|
359
|
+
{
|
|
360
|
+
return Sass::File::get_cwd();
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
void register_function(Context& ctx, Signature sig, Native_Function f, Env* env)
|
|
364
|
+
{
|
|
365
|
+
Definition* def = make_native_function(sig, f, ctx);
|
|
366
|
+
def->environment(env);
|
|
367
|
+
(*env)[def->name() + "[f]"] = def;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
void register_function(Context& ctx, Signature sig, Native_Function f, size_t arity, Env* env)
|
|
371
|
+
{
|
|
372
|
+
Definition* def = make_native_function(sig, f, ctx);
|
|
373
|
+
stringstream ss;
|
|
374
|
+
ss << def->name() << "[f]" << arity;
|
|
375
|
+
def->environment(env);
|
|
376
|
+
(*env)[ss.str()] = def;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
void register_overload_stub(Context& ctx, string name, Env* env)
|
|
380
|
+
{
|
|
381
|
+
Definition* stub = new (ctx.mem) Definition("[built-in function]",
|
|
382
|
+
Position(),
|
|
383
|
+
0,
|
|
384
|
+
name,
|
|
385
|
+
0,
|
|
386
|
+
0,
|
|
387
|
+
true);
|
|
388
|
+
(*env)[name + "[f]"] = stub;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
void register_built_in_functions(Context& ctx, Env* env)
|
|
393
|
+
{
|
|
394
|
+
using namespace Functions;
|
|
395
|
+
// RGB Functions
|
|
396
|
+
register_function(ctx, rgb_sig, rgb, env);
|
|
397
|
+
register_overload_stub(ctx, "rgba", env);
|
|
398
|
+
register_function(ctx, rgba_4_sig, rgba_4, 4, env);
|
|
399
|
+
register_function(ctx, rgba_2_sig, rgba_2, 2, env);
|
|
400
|
+
register_function(ctx, red_sig, red, env);
|
|
401
|
+
register_function(ctx, green_sig, green, env);
|
|
402
|
+
register_function(ctx, blue_sig, blue, env);
|
|
403
|
+
register_function(ctx, mix_sig, mix, env);
|
|
404
|
+
// HSL Functions
|
|
405
|
+
register_function(ctx, hsl_sig, hsl, env);
|
|
406
|
+
register_function(ctx, hsla_sig, hsla, env);
|
|
407
|
+
register_function(ctx, hue_sig, hue, env);
|
|
408
|
+
register_function(ctx, saturation_sig, saturation, env);
|
|
409
|
+
register_function(ctx, lightness_sig, lightness, env);
|
|
410
|
+
register_function(ctx, adjust_hue_sig, adjust_hue, env);
|
|
411
|
+
register_function(ctx, lighten_sig, lighten, env);
|
|
412
|
+
register_function(ctx, darken_sig, darken, env);
|
|
413
|
+
register_function(ctx, saturate_sig, saturate, env);
|
|
414
|
+
register_function(ctx, desaturate_sig, desaturate, env);
|
|
415
|
+
register_function(ctx, grayscale_sig, grayscale, env);
|
|
416
|
+
register_function(ctx, complement_sig, complement, env);
|
|
417
|
+
register_function(ctx, invert_sig, invert, env);
|
|
418
|
+
// Opacity Functions
|
|
419
|
+
register_function(ctx, alpha_sig, alpha, env);
|
|
420
|
+
register_function(ctx, opacity_sig, alpha, env);
|
|
421
|
+
register_function(ctx, opacify_sig, opacify, env);
|
|
422
|
+
register_function(ctx, fade_in_sig, opacify, env);
|
|
423
|
+
register_function(ctx, transparentize_sig, transparentize, env);
|
|
424
|
+
register_function(ctx, fade_out_sig, transparentize, env);
|
|
425
|
+
// Other Color Functions
|
|
426
|
+
register_function(ctx, adjust_color_sig, adjust_color, env);
|
|
427
|
+
register_function(ctx, scale_color_sig, scale_color, env);
|
|
428
|
+
register_function(ctx, change_color_sig, change_color, env);
|
|
429
|
+
register_function(ctx, ie_hex_str_sig, ie_hex_str, env);
|
|
430
|
+
// String Functions
|
|
431
|
+
register_function(ctx, unquote_sig, sass_unquote, env);
|
|
432
|
+
register_function(ctx, quote_sig, sass_quote, env);
|
|
433
|
+
register_function(ctx, str_length_sig, str_length, env);
|
|
434
|
+
register_function(ctx, str_insert_sig, str_insert, env);
|
|
435
|
+
register_function(ctx, str_index_sig, str_index, env);
|
|
436
|
+
register_function(ctx, str_slice_sig, str_slice, env);
|
|
437
|
+
register_function(ctx, to_upper_case_sig, to_upper_case, env);
|
|
438
|
+
register_function(ctx, to_lower_case_sig, to_lower_case, env);
|
|
439
|
+
// Number Functions
|
|
440
|
+
register_function(ctx, percentage_sig, percentage, env);
|
|
441
|
+
register_function(ctx, round_sig, round, env);
|
|
442
|
+
register_function(ctx, ceil_sig, ceil, env);
|
|
443
|
+
register_function(ctx, floor_sig, floor, env);
|
|
444
|
+
register_function(ctx, abs_sig, abs, env);
|
|
445
|
+
register_function(ctx, min_sig, min, env);
|
|
446
|
+
register_function(ctx, max_sig, max, env);
|
|
447
|
+
register_function(ctx, random_sig, random, env);
|
|
448
|
+
// List Functions
|
|
449
|
+
register_function(ctx, length_sig, length, env);
|
|
450
|
+
register_function(ctx, nth_sig, nth, env);
|
|
451
|
+
register_function(ctx, set_nth_sig, set_nth, env);
|
|
452
|
+
register_function(ctx, index_sig, index, env);
|
|
453
|
+
register_function(ctx, join_sig, join, env);
|
|
454
|
+
register_function(ctx, append_sig, append, env);
|
|
455
|
+
register_function(ctx, compact_sig, compact, env);
|
|
456
|
+
register_function(ctx, zip_sig, zip, env);
|
|
457
|
+
register_function(ctx, list_separator_sig, list_separator, env);
|
|
458
|
+
// Map Functions
|
|
459
|
+
register_function(ctx, map_get_sig, map_get, env);
|
|
460
|
+
register_function(ctx, map_merge_sig, map_merge, env);
|
|
461
|
+
register_function(ctx, map_remove_sig, map_remove, env);
|
|
462
|
+
register_function(ctx, map_keys_sig, map_keys, env);
|
|
463
|
+
register_function(ctx, map_values_sig, map_values, env);
|
|
464
|
+
register_function(ctx, map_has_key_sig, map_has_key, env);
|
|
465
|
+
register_function(ctx, keywords_sig, keywords, env);
|
|
466
|
+
// Introspection Functions
|
|
467
|
+
register_function(ctx, type_of_sig, type_of, env);
|
|
468
|
+
register_function(ctx, unit_sig, unit, env);
|
|
469
|
+
register_function(ctx, unitless_sig, unitless, env);
|
|
470
|
+
register_function(ctx, comparable_sig, comparable, env);
|
|
471
|
+
register_function(ctx, variable_exists_sig, variable_exists, env);
|
|
472
|
+
register_function(ctx, global_variable_exists_sig, global_variable_exists, env);
|
|
473
|
+
register_function(ctx, function_exists_sig, function_exists, env);
|
|
474
|
+
register_function(ctx, mixin_exists_sig, mixin_exists, env);
|
|
475
|
+
register_function(ctx, feature_exists_sig, feature_exists, env);
|
|
476
|
+
register_function(ctx, call_sig, call, env);
|
|
477
|
+
// Boolean Functions
|
|
478
|
+
register_function(ctx, not_sig, sass_not, env);
|
|
479
|
+
register_function(ctx, if_sig, sass_if, env);
|
|
480
|
+
// Path Functions
|
|
481
|
+
register_function(ctx, image_url_sig, image_url, env);
|
|
482
|
+
// Misc Functions
|
|
483
|
+
register_function(ctx, inspect_sig, inspect, env);
|
|
484
|
+
register_function(ctx, unique_id_sig, unique_id, env);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
void register_c_functions(Context& ctx, Env* env, Sass_C_Function_List descrs)
|
|
488
|
+
{
|
|
489
|
+
while (descrs && *descrs) {
|
|
490
|
+
register_c_function(ctx, env, *descrs);
|
|
491
|
+
++descrs;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
void register_c_function(Context& ctx, Env* env, Sass_C_Function_Callback descr)
|
|
495
|
+
{
|
|
496
|
+
Definition* def = make_c_function(
|
|
497
|
+
sass_function_get_signature(descr),
|
|
498
|
+
sass_function_get_function(descr),
|
|
499
|
+
sass_function_get_cookie(descr),
|
|
500
|
+
ctx
|
|
501
|
+
);
|
|
502
|
+
def->environment(env);
|
|
503
|
+
(*env)[def->name() + "[f]"] = def;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
}
|