sassc 2.0.1 → 2.1.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.gitmodules +1 -1
  4. data/.travis.yml +7 -3
  5. data/CHANGELOG.md +3 -0
  6. data/CODE_OF_CONDUCT.md +1 -1
  7. data/README.md +1 -1
  8. data/Rakefile +23 -8
  9. data/ext/extconf.rb +39 -0
  10. data/ext/libsass/.gitignore +1 -0
  11. data/ext/libsass/GNUmakefile.am +23 -39
  12. data/ext/libsass/Makefile +56 -91
  13. data/ext/libsass/Makefile.conf +16 -2
  14. data/ext/libsass/configure.ac +8 -12
  15. data/ext/libsass/include/sass/base.h +1 -0
  16. data/ext/libsass/include/sass/context.h +1 -1
  17. data/ext/libsass/src/GNUmakefile.am +1 -5
  18. data/ext/libsass/src/ast.cpp +747 -2010
  19. data/ext/libsass/src/ast.hpp +239 -2383
  20. data/ext/libsass/src/{to_c.cpp → ast2c.cpp} +22 -16
  21. data/ext/libsass/src/ast2c.hpp +39 -0
  22. data/ext/libsass/src/ast_def_macros.hpp +62 -10
  23. data/ext/libsass/src/ast_fwd_decl.cpp +1 -0
  24. data/ext/libsass/src/ast_fwd_decl.hpp +43 -165
  25. data/ext/libsass/src/ast_sel_cmp.cpp +909 -0
  26. data/ext/libsass/src/ast_sel_unify.cpp +280 -0
  27. data/ext/libsass/src/ast_selectors.cpp +1475 -0
  28. data/ext/libsass/src/ast_selectors.hpp +568 -0
  29. data/ext/libsass/src/ast_supports.cpp +130 -0
  30. data/ext/libsass/src/ast_supports.hpp +121 -0
  31. data/ext/libsass/src/ast_values.cpp +967 -0
  32. data/ext/libsass/src/ast_values.hpp +489 -0
  33. data/ext/libsass/src/backtrace.cpp +4 -0
  34. data/ext/libsass/src/base64vlq.cpp +3 -0
  35. data/ext/libsass/src/bind.cpp +18 -17
  36. data/ext/libsass/src/bind.hpp +3 -1
  37. data/ext/libsass/src/c2ast.cpp +64 -0
  38. data/ext/libsass/src/c2ast.hpp +14 -0
  39. data/ext/libsass/src/cencode.c +2 -2
  40. data/ext/libsass/src/check_nesting.cpp +52 -56
  41. data/ext/libsass/src/check_nesting.hpp +35 -34
  42. data/ext/libsass/src/color_maps.cpp +156 -153
  43. data/ext/libsass/src/color_maps.hpp +152 -152
  44. data/ext/libsass/src/constants.cpp +15 -0
  45. data/ext/libsass/src/constants.hpp +13 -0
  46. data/ext/libsass/src/context.cpp +24 -14
  47. data/ext/libsass/src/context.hpp +6 -6
  48. data/ext/libsass/src/cssize.cpp +69 -71
  49. data/ext/libsass/src/cssize.hpp +50 -50
  50. data/ext/libsass/src/debugger.hpp +117 -110
  51. data/ext/libsass/src/emitter.cpp +13 -12
  52. data/ext/libsass/src/emitter.hpp +13 -9
  53. data/ext/libsass/src/environment.cpp +15 -1
  54. data/ext/libsass/src/environment.hpp +6 -0
  55. data/ext/libsass/src/error_handling.cpp +36 -59
  56. data/ext/libsass/src/error_handling.hpp +29 -16
  57. data/ext/libsass/src/eval.cpp +302 -323
  58. data/ext/libsass/src/eval.hpp +64 -55
  59. data/ext/libsass/src/expand.cpp +94 -88
  60. data/ext/libsass/src/expand.hpp +33 -37
  61. data/ext/libsass/src/extend.cpp +38 -36
  62. data/ext/libsass/src/extend.hpp +15 -15
  63. data/ext/libsass/src/file.cpp +34 -2
  64. data/ext/libsass/src/fn_colors.cpp +594 -0
  65. data/ext/libsass/src/fn_colors.hpp +85 -0
  66. data/ext/libsass/src/fn_lists.cpp +284 -0
  67. data/ext/libsass/src/fn_lists.hpp +34 -0
  68. data/ext/libsass/src/fn_maps.cpp +94 -0
  69. data/ext/libsass/src/fn_maps.hpp +30 -0
  70. data/ext/libsass/src/fn_miscs.cpp +256 -0
  71. data/ext/libsass/src/fn_miscs.hpp +40 -0
  72. data/ext/libsass/src/fn_numbers.cpp +220 -0
  73. data/ext/libsass/src/fn_numbers.hpp +45 -0
  74. data/ext/libsass/src/fn_selectors.cpp +235 -0
  75. data/ext/libsass/src/fn_selectors.hpp +35 -0
  76. data/ext/libsass/src/fn_strings.cpp +254 -0
  77. data/ext/libsass/src/fn_strings.hpp +34 -0
  78. data/ext/libsass/src/fn_utils.cpp +156 -0
  79. data/ext/libsass/src/fn_utils.hpp +56 -0
  80. data/ext/libsass/src/inspect.cpp +101 -152
  81. data/ext/libsass/src/inspect.hpp +69 -73
  82. data/ext/libsass/src/json.cpp +2 -2
  83. data/ext/libsass/src/lexer.cpp +6 -3
  84. data/ext/libsass/src/listize.cpp +9 -11
  85. data/ext/libsass/src/listize.hpp +11 -7
  86. data/ext/libsass/src/memory/SharedPtr.cpp +2 -83
  87. data/ext/libsass/src/memory/SharedPtr.hpp +127 -143
  88. data/ext/libsass/src/node.cpp +13 -10
  89. data/ext/libsass/src/node.hpp +3 -3
  90. data/ext/libsass/src/operation.hpp +184 -144
  91. data/ext/libsass/src/operators.cpp +43 -17
  92. data/ext/libsass/src/operators.hpp +5 -5
  93. data/ext/libsass/src/output.cpp +21 -18
  94. data/ext/libsass/src/output.hpp +14 -21
  95. data/ext/libsass/src/parser.cpp +215 -183
  96. data/ext/libsass/src/parser.hpp +28 -24
  97. data/ext/libsass/src/plugins.cpp +5 -1
  98. data/ext/libsass/src/position.cpp +3 -0
  99. data/ext/libsass/src/prelexer.cpp +9 -3
  100. data/ext/libsass/src/prelexer.hpp +9 -9
  101. data/ext/libsass/src/remove_placeholders.cpp +14 -11
  102. data/ext/libsass/src/remove_placeholders.hpp +8 -9
  103. data/ext/libsass/src/sass.cpp +9 -3
  104. data/ext/libsass/src/sass.hpp +12 -9
  105. data/ext/libsass/src/sass2scss.cpp +45 -14
  106. data/ext/libsass/src/sass_context.cpp +18 -15
  107. data/ext/libsass/src/sass_functions.cpp +6 -3
  108. data/ext/libsass/src/sass_functions.hpp +1 -1
  109. data/ext/libsass/src/sass_util.cpp +3 -0
  110. data/ext/libsass/src/sass_values.cpp +21 -13
  111. data/ext/libsass/src/source_map.cpp +5 -2
  112. data/ext/libsass/src/source_map.hpp +2 -2
  113. data/ext/libsass/src/subset_map.cpp +4 -1
  114. data/ext/libsass/src/to_value.cpp +23 -21
  115. data/ext/libsass/src/to_value.hpp +18 -22
  116. data/ext/libsass/src/units.cpp +4 -0
  117. data/ext/libsass/src/units.hpp +1 -0
  118. data/ext/libsass/src/utf8/checked.h +12 -10
  119. data/ext/libsass/src/utf8/core.h +3 -0
  120. data/ext/libsass/src/utf8_string.cpp +3 -0
  121. data/ext/libsass/src/util.cpp +67 -75
  122. data/ext/libsass/src/util.hpp +64 -19
  123. data/ext/libsass/src/util_string.cpp +75 -0
  124. data/ext/libsass/src/util_string.hpp +19 -0
  125. data/ext/libsass/src/values.cpp +22 -13
  126. data/ext/libsass/src/values.hpp +2 -2
  127. data/ext/libsass/win/libsass.targets +30 -4
  128. data/ext/libsass/win/libsass.vcxproj.filters +82 -4
  129. data/lib/sassc.rb +24 -0
  130. data/lib/sassc/engine.rb +2 -2
  131. data/lib/sassc/native.rb +8 -1
  132. data/lib/sassc/version.rb +1 -1
  133. data/sassc.gemspec +19 -11
  134. data/test/engine_test.rb +26 -1
  135. data/test/native_test.rb +1 -1
  136. metadata +66 -72
  137. data/ext/Rakefile +0 -3
  138. data/ext/libsass/.github/CONTRIBUTING.md +0 -65
  139. data/ext/libsass/.github/ISSUE_TEMPLATE.md +0 -54
  140. data/ext/libsass/.travis.yml +0 -64
  141. data/ext/libsass/Readme.md +0 -104
  142. data/ext/libsass/SECURITY.md +0 -10
  143. data/ext/libsass/appveyor.yml +0 -91
  144. data/ext/libsass/docs/README.md +0 -20
  145. data/ext/libsass/docs/api-context-example.md +0 -45
  146. data/ext/libsass/docs/api-context-internal.md +0 -163
  147. data/ext/libsass/docs/api-context.md +0 -295
  148. data/ext/libsass/docs/api-doc.md +0 -215
  149. data/ext/libsass/docs/api-function-example.md +0 -67
  150. data/ext/libsass/docs/api-function-internal.md +0 -8
  151. data/ext/libsass/docs/api-function.md +0 -74
  152. data/ext/libsass/docs/api-importer-example.md +0 -112
  153. data/ext/libsass/docs/api-importer-internal.md +0 -20
  154. data/ext/libsass/docs/api-importer.md +0 -86
  155. data/ext/libsass/docs/api-value-example.md +0 -55
  156. data/ext/libsass/docs/api-value-internal.md +0 -76
  157. data/ext/libsass/docs/api-value.md +0 -154
  158. data/ext/libsass/docs/build-on-darwin.md +0 -27
  159. data/ext/libsass/docs/build-on-gentoo.md +0 -55
  160. data/ext/libsass/docs/build-on-windows.md +0 -139
  161. data/ext/libsass/docs/build-shared-library.md +0 -35
  162. data/ext/libsass/docs/build-with-autotools.md +0 -78
  163. data/ext/libsass/docs/build-with-makefiles.md +0 -68
  164. data/ext/libsass/docs/build-with-mingw.md +0 -107
  165. data/ext/libsass/docs/build-with-visual-studio.md +0 -90
  166. data/ext/libsass/docs/build.md +0 -97
  167. data/ext/libsass/docs/compatibility-plan.md +0 -48
  168. data/ext/libsass/docs/contributing.md +0 -17
  169. data/ext/libsass/docs/custom-functions-internal.md +0 -122
  170. data/ext/libsass/docs/dev-ast-memory.md +0 -223
  171. data/ext/libsass/docs/implementations.md +0 -56
  172. data/ext/libsass/docs/plugins.md +0 -47
  173. data/ext/libsass/docs/setup-environment.md +0 -68
  174. data/ext/libsass/docs/source-map-internals.md +0 -51
  175. data/ext/libsass/docs/trace.md +0 -26
  176. data/ext/libsass/docs/triage.md +0 -17
  177. data/ext/libsass/docs/unicode.md +0 -39
  178. data/ext/libsass/extconf.rb +0 -6
  179. data/ext/libsass/script/bootstrap +0 -13
  180. data/ext/libsass/script/branding +0 -10
  181. data/ext/libsass/script/ci-build-libsass +0 -134
  182. data/ext/libsass/script/ci-build-plugin +0 -62
  183. data/ext/libsass/script/ci-install-compiler +0 -6
  184. data/ext/libsass/script/ci-install-deps +0 -20
  185. data/ext/libsass/script/ci-report-coverage +0 -42
  186. data/ext/libsass/script/spec +0 -5
  187. data/ext/libsass/script/tap-driver +0 -652
  188. data/ext/libsass/script/tap-runner +0 -1
  189. data/ext/libsass/script/test-leaks.pl +0 -103
  190. data/ext/libsass/src/functions.cpp +0 -2234
  191. data/ext/libsass/src/functions.hpp +0 -198
  192. data/ext/libsass/src/to_c.hpp +0 -39
  193. data/ext/libsass/test/test_node.cpp +0 -94
  194. data/ext/libsass/test/test_paths.cpp +0 -28
  195. data/ext/libsass/test/test_selector_difference.cpp +0 -25
  196. data/ext/libsass/test/test_specificity.cpp +0 -25
  197. data/ext/libsass/test/test_subset_map.cpp +0 -472
  198. data/ext/libsass/test/test_superselector.cpp +0 -69
  199. data/ext/libsass/test/test_unification.cpp +0 -31
  200. data/lib/tasks/libsass.rb +0 -33
@@ -1,67 +0,0 @@
1
- ## Example main.c
2
-
3
- ```C
4
- #include <stdio.h>
5
- #include <stdint.h>
6
- #include "sass/context.h"
7
-
8
- union Sass_Value* call_fn_foo(const union Sass_Value* s_args, Sass_Function_Entry cb, struct Sass_Compiler* comp)
9
- {
10
- // get context/option struct associated with this compiler
11
- struct Sass_Context* ctx = sass_compiler_get_context(comp);
12
- struct Sass_Options* opts = sass_compiler_get_options(comp);
13
- // get information about previous importer entry from the stack
14
- Sass_Import_Entry import = sass_compiler_get_last_import(comp);
15
- const char* prev_abs_path = sass_import_get_abs_path(import);
16
- const char* prev_imp_path = sass_import_get_imp_path(import);
17
- // get the cookie from function descriptor
18
- void* cookie = sass_function_get_cookie(cb);
19
- // we actually abuse the void* to store an "int"
20
- return sass_make_number((intptr_t)cookie, "px");
21
- }
22
-
23
- int main( int argc, const char* argv[] )
24
- {
25
-
26
- // get the input file from first argument or use default
27
- const char* input = argc > 1 ? argv[1] : "styles.scss";
28
-
29
- // create the file context and get all related structs
30
- struct Sass_File_Context* file_ctx = sass_make_file_context(input);
31
- struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
32
- struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
33
-
34
- // allocate a custom function caller
35
- Sass_Function_Entry fn_foo =
36
- sass_make_function("foo()", call_fn_foo, (void*)42);
37
-
38
- // create list of all custom functions
39
- Sass_Function_List fn_list = sass_make_function_list(1);
40
- sass_function_set_list_entry(fn_list, 0, fn_foo);
41
- sass_option_set_c_functions(ctx_opt, fn_list);
42
-
43
- // context is set up, call the compile step now
44
- int status = sass_compile_file_context(file_ctx);
45
-
46
- // print the result or the error to the stdout
47
- if (status == 0) puts(sass_context_get_output_string(ctx));
48
- else puts(sass_context_get_error_message(ctx));
49
-
50
- // release allocated memory
51
- sass_delete_file_context(file_ctx);
52
-
53
- // exit status
54
- return status;
55
-
56
- }
57
- ```
58
-
59
- ### Compile main.c
60
-
61
- ```bash
62
- gcc -c main.c -o main.o
63
- gcc -o sample main.o -lsass
64
- echo "foo { margin: foo(); }" > foo.scss
65
- ./sample foo.scss => "foo { margin: 42px }"
66
- ```
67
-
@@ -1,8 +0,0 @@
1
- ```C
2
- // Struct to hold custom function callback
3
- struct Sass_Function {
4
- const char* signature;
5
- Sass_Function_Fn function;
6
- void* cookie;
7
- };
8
- ```
@@ -1,74 +0,0 @@
1
- Sass functions are used to define new custom functions callable by Sass code. They are also used to overload debug or error statements. You can also define a fallback function, which is called for every unknown function found in the Sass code. Functions get passed zero or more `Sass_Values` (a `Sass_List` value) and they must also return a `Sass_Value`. Return a `Sass_Error` if you want to signal an error.
2
-
3
- ## Special signatures
4
-
5
- - `*` - Fallback implementation
6
- - `@warn` - Overload warn statements
7
- - `@error` - Overload error statements
8
- - `@debug` - Overload debug statements
9
-
10
- Note: The fallback implementation will be given the name of the called function as the first argument, before all the original function arguments. These features are pretty new and should be considered experimental.
11
-
12
- ### Basic Usage
13
-
14
- ```C
15
- #include "sass/functions.h"
16
- ```
17
-
18
- ## Sass Function API
19
-
20
- ```C
21
- // Forward declaration
22
- struct Sass_Compiler;
23
- struct Sass_Function;
24
-
25
- // Typedef helpers for custom functions lists
26
- typedef struct Sass_Function (*Sass_Function_Entry);
27
- typedef struct Sass_Function* (*Sass_Function_List);
28
- // Typedef defining function signature and return type
29
- typedef union Sass_Value* (*Sass_Function_Fn)
30
- (const union Sass_Value*, Sass_Function_Entry cb, struct Sass_Compiler* compiler);
31
-
32
- // Creators for sass function list and function descriptors
33
- Sass_Function_List sass_make_function_list (size_t length);
34
- Sass_Function_Entry sass_make_function (const char* signature, Sass_Function_Fn cb, void* cookie);
35
- // In case you need to free them yourself
36
- void sass_delete_function (Sass_Function_Entry entry);
37
- void sass_delete_function_list (Sass_Function_List list);
38
-
39
- // Setters and getters for callbacks on function lists
40
- Sass_Function_Entry sass_function_get_list_entry(Sass_Function_List list, size_t pos);
41
- void sass_function_set_list_entry(Sass_Function_List list, size_t pos, Sass_Function_Entry cb);
42
-
43
- // Setters to insert an entry into the import list (you may also use [] access directly)
44
- // Since we are dealing with pointers they should have a guaranteed and fixed size
45
- void sass_import_set_list_entry (Sass_Import_List list, size_t idx, Sass_Import_Entry entry);
46
- Sass_Import_Entry sass_import_get_list_entry (Sass_Import_List list, size_t idx);
47
-
48
- // Getters for custom function descriptors
49
- const char* sass_function_get_signature (Sass_Function_Entry cb);
50
- Sass_Function_Fn sass_function_get_function (Sass_Function_Entry cb);
51
- void* sass_function_get_cookie (Sass_Function_Entry cb);
52
-
53
- // Getters for callee entry
54
- const char* sass_callee_get_name (Sass_Callee_Entry);
55
- const char* sass_callee_get_path (Sass_Callee_Entry);
56
- size_t sass_callee_get_line (Sass_Callee_Entry);
57
- size_t sass_callee_get_column (Sass_Callee_Entry);
58
- enum Sass_Callee_Type sass_callee_get_type (Sass_Callee_Entry);
59
- Sass_Env_Frame sass_callee_get_env (Sass_Callee_Entry);
60
-
61
- // Getters and Setters for environments (lexical, local and global)
62
- union Sass_Value* sass_env_get_lexical (Sass_Env_Frame, const char*);
63
- void sass_env_set_lexical (Sass_Env_Frame, const char*, union Sass_Value*);
64
- union Sass_Value* sass_env_get_local (Sass_Env_Frame, const char*);
65
- void sass_env_set_local (Sass_Env_Frame, const char*, union Sass_Value*);
66
- union Sass_Value* sass_env_get_global (Sass_Env_Frame, const char*);
67
- void sass_env_set_global (Sass_Env_Frame, const char*, union Sass_Value*);
68
- ```
69
-
70
- ### More links
71
-
72
- - [Sass Function Example](api-function-example.md)
73
- - [Sass Function Internal](api-function-internal.md)
74
-
@@ -1,112 +0,0 @@
1
- ## Example importer.c
2
-
3
- ```C
4
- #include <stdio.h>
5
- #include <string.h>
6
- #include "sass/context.h"
7
-
8
- Sass_Import_List sass_importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp)
9
- {
10
- // get the cookie from importer descriptor
11
- void* cookie = sass_importer_get_cookie(cb);
12
- Sass_Import_List list = sass_make_import_list(2);
13
- char* local = sass_copy_c_string("local { color: green; }");
14
- char* remote = sass_copy_c_string("remote { color: red; }");
15
- list[0] = sass_make_import_entry("/tmp/styles.scss", local, 0);
16
- list[1] = sass_make_import_entry("http://www.example.com", remote, 0);
17
- return list;
18
- }
19
-
20
- int main( int argc, const char* argv[] )
21
- {
22
-
23
- // get the input file from first argument or use default
24
- const char* input = argc > 1 ? argv[1] : "styles.scss";
25
-
26
- // create the file context and get all related structs
27
- struct Sass_File_Context* file_ctx = sass_make_file_context(input);
28
- struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
29
- struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
30
-
31
- // allocate custom importer
32
- Sass_Importer_Entry c_imp =
33
- sass_make_importer(sass_importer, 0, 0);
34
- // create list for all custom importers
35
- Sass_Importer_List imp_list = sass_make_importer_list(1);
36
- // put only the importer on to the list
37
- sass_importer_set_list_entry(imp_list, 0, c_imp);
38
- // register list on to the context options
39
- sass_option_set_c_importers(ctx_opt, imp_list);
40
- // context is set up, call the compile step now
41
- int status = sass_compile_file_context(file_ctx);
42
-
43
- // print the result or the error to the stdout
44
- if (status == 0) puts(sass_context_get_output_string(ctx));
45
- else puts(sass_context_get_error_message(ctx));
46
-
47
- // release allocated memory
48
- sass_delete_file_context(file_ctx);
49
-
50
- // exit status
51
- return status;
52
-
53
- }
54
- ```
55
-
56
- Compile importer.c
57
-
58
- ```bash
59
- gcc -c importer.c -o importer.o
60
- gcc -o importer importer.o -lsass
61
- echo "@import 'foobar';" > importer.scss
62
- ./importer importer.scss
63
- ```
64
-
65
- ## Importer Behavior Examples
66
-
67
- ```C
68
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
69
- // let LibSass handle the import request
70
- return NULL;
71
- }
72
-
73
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
74
- // let LibSass handle the request
75
- // swallows »@import "http://…"« pass-through
76
- // (arguably a bug)
77
- Sass_Import_List list = sass_make_import_list(1);
78
- list[0] = sass_make_import_entry(path, 0, 0);
79
- return list;
80
- }
81
-
82
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
83
- // return an error to halt execution
84
- Sass_Import_List list = sass_make_import_list(1);
85
- const char* message = "some error message";
86
- list[0] = sass_make_import_entry(path, 0, 0);
87
- sass_import_set_error(list[0], sass_copy_c_string(message), 0, 0);
88
- return list;
89
- }
90
-
91
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
92
- // let LibSass load the file identifed by the importer
93
- Sass_Import_List list = sass_make_import_list(1);
94
- list[0] = sass_make_import_entry("/tmp/file.scss", 0, 0);
95
- return list;
96
- }
97
-
98
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
99
- // completely hide the import
100
- // (arguably a bug)
101
- Sass_Import_List list = sass_make_import_list(0);
102
- return list;
103
- }
104
-
105
- Sass_Import_List importer(const char* path, Sass_Importer_Entry cb, struct Sass_Compiler* comp) {
106
- // completely hide the import
107
- // (arguably a bug)
108
- Sass_Import_List list = sass_make_import_list(1);
109
- list[0] = sass_make_import_entry(0, 0, 0);
110
- return list;
111
- }
112
- ```
@@ -1,20 +0,0 @@
1
- ```C
2
- // External import entry
3
- struct Sass_Import {
4
- char* imp_path; // path as found in the import statement
5
- char *abs_path; // path after importer has resolved it
6
- char* source;
7
- char* srcmap;
8
- // error handling
9
- char* error;
10
- size_t line;
11
- size_t column;
12
- };
13
-
14
- // Struct to hold importer callback
15
- struct Sass_Importer {
16
- Sass_Importer_Fn importer;
17
- double priority;
18
- void* cookie;
19
- };
20
- ```
@@ -1,86 +0,0 @@
1
- By using custom importers, Sass stylesheets can be implemented in any possible way, such as by being loaded via a remote server. Please note: this feature is experimental and is implemented differently than importers in Ruby Sass. Imports must be relative to the parent import context and therefore we need to pass this information to the importer callback. This is currently done by passing the complete import string/path of the previous import context.
2
-
3
- ## Return Imports
4
-
5
- You actually have to return a list of imports, since some importers may want to import multiple files from one import statement (ie. a glob/star importer). The memory you pass with source and srcmap is taken over by LibSass and freed automatically when the import is done. You are also allowed to return `0` instead of a list, which will tell LibSass to handle the import by itself (as if no custom importer was in use).
6
-
7
- ```C
8
- Sass_Import_Entry* rv = sass_make_import_list(1);
9
- rv[0] = sass_make_import(rel, abs, source, srcmap);
10
- ```
11
-
12
- Every import will then be included in LibSass. You are allowed to only return a file path without any loaded source. This way you can ie. implement rewrite rules for import paths and leave the loading part for LibSass.
13
-
14
- Please note that LibSass doesn't use the srcmap parameter yet. It has been added to not deprecate the C-API once support has been implemented. It will be used to re-map the actual sourcemap with the provided ones.
15
-
16
- ### Basic Usage
17
-
18
- ```C
19
- #include "sass/functions.h"
20
- ```
21
-
22
- ## Sass Importer API
23
-
24
- ```C
25
- // Forward declaration
26
- struct Sass_Import;
27
-
28
- // Forward declaration
29
- struct Sass_C_Import_Descriptor;
30
-
31
- // Typedef defining the custom importer callback
32
- typedef struct Sass_C_Import_Descriptor (*Sass_C_Import_Callback);
33
- // Typedef defining the importer c function prototype
34
- typedef Sass_Import_Entry* (*Sass_C_Import_Fn) (const char* url, const char* prev, void* cookie);
35
-
36
- // Creators for custom importer callback (with some additional pointer)
37
- // The pointer is mostly used to store the callback into the actual function
38
- Sass_C_Import_Callback sass_make_importer (Sass_C_Import_Fn, void* cookie);
39
-
40
- // Getters for import function descriptors
41
- Sass_C_Import_Fn sass_import_get_function (Sass_C_Import_Callback fn);
42
- void* sass_import_get_cookie (Sass_C_Import_Callback fn);
43
-
44
- // Deallocator for associated memory
45
- void sass_delete_importer (Sass_C_Import_Callback fn);
46
-
47
- // Creator for sass custom importer return argument list
48
- Sass_Import_Entry* sass_make_import_list (size_t length);
49
- // Creator for a single import entry returned by the custom importer inside the list
50
- Sass_Import_Entry sass_make_import_entry (const char* path, char* source, char* srcmap);
51
- Sass_Import_Entry sass_make_import (const char* rel, const char* abs, char* source, char* srcmap);
52
-
53
- // set error message to abort import and to print out a message (path from existing object is used in output)
54
- Sass_Import_Entry sass_import_set_error(Sass_Import_Entry import, const char* message, size_t line, size_t col);
55
-
56
- // Setters to insert an entry into the import list (you may also use [] access directly)
57
- // Since we are dealing with pointers they should have a guaranteed and fixed size
58
- void sass_import_set_list_entry (Sass_Import_Entry* list, size_t idx, Sass_Import_Entry entry);
59
- Sass_Import_Entry sass_import_get_list_entry (Sass_Import_Entry* list, size_t idx);
60
-
61
- // Getters for import entry
62
- const char* sass_import_get_imp_path (Sass_Import_Entry);
63
- const char* sass_import_get_abs_path (Sass_Import_Entry);
64
- const char* sass_import_get_source (Sass_Import_Entry);
65
- const char* sass_import_get_srcmap (Sass_Import_Entry);
66
- // Explicit functions to take ownership of these items
67
- // The property on our struct will be reset to NULL
68
- char* sass_import_take_source (Sass_Import_Entry);
69
- char* sass_import_take_srcmap (Sass_Import_Entry);
70
-
71
- // Getters for import error entries
72
- size_t sass_import_get_error_line (Sass_Import_Entry);
73
- size_t sass_import_get_error_column (Sass_Import_Entry);
74
- const char* sass_import_get_error_message (Sass_Import_Entry);
75
-
76
- // Deallocator for associated memory (incl. entries)
77
- void sass_delete_import_list (Sass_Import_Entry*);
78
- // Just in case we have some stray import structs
79
- void sass_delete_import (Sass_Import_Entry);
80
- ```
81
-
82
- ### More links
83
-
84
- - [Sass Importer Example](api-importer-example.md)
85
- - [Sass Importer Internal](api-importer-internal.md)
86
-
@@ -1,55 +0,0 @@
1
- ## Example operation.c
2
-
3
- ```C
4
- #include <stdio.h>
5
- #include <string.h>
6
- #include "sass/values.h"
7
-
8
- int main( int argc, const char* argv[] )
9
- {
10
-
11
- // create two new sass values to be added
12
- union Sass_Value* string = sass_make_string("String");
13
- union Sass_Value* number = sass_make_number(42, "nits");
14
-
15
- // invoke the add operation which returns a new sass value
16
- union Sass_Value* total = sass_value_op(ADD, string, number);
17
-
18
- // no further use for the two operands
19
- sass_delete_value(string);
20
- sass_delete_value(number);
21
-
22
- // this works since libsass will always return a
23
- // string for add operations with a string as the
24
- // left hand side. But you should never rely on it!
25
- puts(sass_string_get_value(total));
26
-
27
- // invoke stringification (uncompressed with precision of 5)
28
- union Sass_Value* result = sass_value_stringify(total, false, 5);
29
-
30
- // no further use for the sum
31
- sass_delete_value(total);
32
-
33
- // print the result - you may want to make
34
- // sure result is indeed a string, altough
35
- // stringify guarantees to return a string
36
- // if (sass_value_is_string(result)) {}
37
- // really depends on your level of paranoia
38
- puts(sass_string_get_value(result));
39
-
40
- // finally free result
41
- sass_delete_value(result);
42
-
43
- // exit status
44
- return 0;
45
-
46
- }
47
- ```
48
-
49
- ## Compile operation.c
50
-
51
- ```bash
52
- gcc -c operation.c -o operation.o
53
- gcc -o operation operation.o -lsass
54
- ./operation # => String42nits
55
- ```
@@ -1,76 +0,0 @@
1
- ```C
2
- struct Sass_Unknown {
3
- enum Sass_Tag tag;
4
- };
5
-
6
- struct Sass_Boolean {
7
- enum Sass_Tag tag;
8
- bool value;
9
- };
10
-
11
- struct Sass_Number {
12
- enum Sass_Tag tag;
13
- double value;
14
- char* unit;
15
- };
16
-
17
- struct Sass_Color {
18
- enum Sass_Tag tag;
19
- double r;
20
- double g;
21
- double b;
22
- double a;
23
- };
24
-
25
- struct Sass_String {
26
- enum Sass_Tag tag;
27
- char* value;
28
- };
29
-
30
- struct Sass_List {
31
- enum Sass_Tag tag;
32
- enum Sass_Separator separator;
33
- size_t length;
34
- // null terminated "array"
35
- union Sass_Value** values;
36
- };
37
-
38
- struct Sass_Map {
39
- enum Sass_Tag tag;
40
- size_t length;
41
- struct Sass_MapPair* pairs;
42
- };
43
-
44
- struct Sass_Null {
45
- enum Sass_Tag tag;
46
- };
47
-
48
- struct Sass_Error {
49
- enum Sass_Tag tag;
50
- char* message;
51
- };
52
-
53
- struct Sass_Warning {
54
- enum Sass_Tag tag;
55
- char* message;
56
- };
57
-
58
- union Sass_Value {
59
- struct Sass_Unknown unknown;
60
- struct Sass_Boolean boolean;
61
- struct Sass_Number number;
62
- struct Sass_Color color;
63
- struct Sass_String string;
64
- struct Sass_List list;
65
- struct Sass_Map map;
66
- struct Sass_Null null;
67
- struct Sass_Error error;
68
- struct Sass_Warning warning;
69
- };
70
-
71
- struct Sass_MapPair {
72
- union Sass_Value* key;
73
- union Sass_Value* value;
74
- };
75
- ```
76
-