1 | #include <cstring>
|
2 | #include <iostream>
|
3 | #include <stdint.h>
|
4 | #include <sass.h>
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | extern "C" const char* ADDCALL libsass_get_version() {
|
10 | return libsass_version();
|
11 | }
|
12 |
|
13 | union Sass_Value* custom_function(const union Sass_Value* s_args, Sass_Function_Entry cb, struct Sass_Compiler* comp)
|
14 | {
|
15 |
|
16 | struct Sass_Context* ctx = sass_compiler_get_context(comp);
|
17 | struct Sass_Options* opts = sass_compiler_get_options(comp);
|
18 |
|
19 | void* cookie = sass_function_get_cookie(cb);
|
20 |
|
21 | return sass_make_number((intptr_t)cookie, "px");
|
22 | }
|
23 |
|
24 | extern "C" Sass_Function_List ADDCALL libsass_load_functions()
|
25 | {
|
26 |
|
27 | Sass_Function_Entry c_func =
|
28 | sass_make_function("foo()", custom_function, (void*)42);
|
29 |
|
30 | Sass_Function_List fn_list = sass_make_function_list(1);
|
31 |
|
32 | sass_function_set_list_entry(fn_list, 0, c_func);
|
33 |
|
34 | return fn_list;
|
35 | }
|
36 |
|
37 | Sass_Import_List custom_importer(const char* cur_path, Sass_Importer_Entry cb, struct Sass_Compiler* comp)
|
38 | {
|
39 |
|
40 | void* cookie = sass_importer_get_cookie(cb);
|
41 |
|
42 | Sass_Import_List incs = sass_make_import_list(1);
|
43 |
|
44 | incs[0] = sass_make_import_entry(cur_path, 0, 0);
|
45 |
|
46 | return incs;
|
47 | }
|
48 |
|
49 | extern "C" Sass_Importer_List ADDCALL libsass_load_importers()
|
50 | {
|
51 |
|
52 | Sass_Importer_Entry c_imp =
|
53 | sass_make_importer(custom_importer, - 99, (void*)42);
|
54 |
|
55 | Sass_Importer_List imp_list = sass_make_importer_list(1);
|
56 |
|
57 | sass_importer_set_list_entry(imp_list, 0, c_imp);
|
58 |
|
59 | return imp_list;
|
60 | }
|