Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Commit 649b1d4

Browse files
committed
feat(wrapoptionsinterface): initial implementation
1 parent e084fe5 commit 649b1d4

File tree

1 file changed

+108
-3
lines changed

1 file changed

+108
-3
lines changed

src/interop/context.ts

Lines changed: 108 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { cwrapSignature, SassAsmModule } from '../SassAsmModule';
22

3+
/**
4+
* Creates cwrapped interface for context api.
5+
*/
36
const wrapContextInterface = (cwrap: cwrapSignature) => ({
47
//struct Sass_Options* sass_make_options (void);
58
make_options: cwrap<() => number>(`sass_make_options`, 'number', []),
@@ -99,6 +102,108 @@ const wrapContextInterface = (cwrap: cwrapSignature) => ({
99102
context_take_source_map_string: null
100103
});
101104

105+
/**
106+
* Creates cwrapped interface for options api.
107+
*/
108+
const wrapOptionsInterface = (cwrap: cwrapSignature) => ({
109+
//int sass_option_get_precision (struct Sass_Options* options);
110+
option_get_precision: null,
111+
//enum Sass_Output_Style sass_option_get_output_style (struct Sass_Options* options);
112+
option_get_output_style: null,
113+
//bool sass_option_get_source_comments (struct Sass_Options* options);
114+
option_get_source_comments: cwrap<(sassOptionsPtr: number) => boolean>(`sass_option_get_source_comments`, 'number', [
115+
'number'
116+
]),
117+
//bool sass_option_get_source_map_embed (struct Sass_Options* options);
118+
option_get_source_map_embed: null,
119+
//bool sass_option_get_source_map_contents (struct Sass_Options* options);
120+
option_get_source_map_contents: null,
121+
//bool sass_option_get_source_map_file_urls (struct Sass_Options* options);
122+
option_get_source_map_file_urls: null,
123+
//bool sass_option_get_omit_source_map_url (struct Sass_Options* options);
124+
option_get_omit_source_map_url: null,
125+
//bool sass_option_get_is_indented_syntax_src (struct Sass_Options* options);
126+
option_get_is_indented_syntax_src: null,
127+
//const char* sass_option_get_indent (struct Sass_Options* options);
128+
option_get_indent: null,
129+
//const char* sass_option_get_linefeed (struct Sass_Options* options);
130+
option_get_linefeed: null,
131+
//const char* sass_option_get_input_path (struct Sass_Options* options);
132+
option_get_input_path: null,
133+
//const char* sass_option_get_output_path (struct Sass_Options* options);
134+
option_get_output_path: null,
135+
//const char* sass_option_get_source_map_file (struct Sass_Options* options);
136+
option_get_source_map_file: null,
137+
//const char* sass_option_get_source_map_root (struct Sass_Options* options);
138+
option_get_source_map_root: null,
139+
//Sass_C_Function_List sass_option_get_c_functions (struct Sass_Options* options);
140+
option_get_c_functions: null,
141+
//Sass_C_Import_Callback sass_option_get_importer (struct Sass_Options* options);
142+
option_get_importer: null,
143+
144+
//size_t sass_option_get_include_path_size(struct Sass_Options* options);
145+
option_get_include_path_size: null,
146+
//const char* sass_option_get_include_path(struct Sass_Options* options, size_t i);
147+
option_get_include_path: null,
148+
149+
//size_t sass_option_get_plugin_path_size(struct Sass_Options* options);
150+
option_get_plugin_path_size: null,
151+
//const char* sass_option_get_plugin_path(struct Sass_Options* options, size_t i);
152+
option_get_plugin_path: null,
153+
154+
//void sass_option_set_precision (struct Sass_Options* options, int precision);
155+
option_set_precision: null,
156+
//void sass_option_set_output_style (struct Sass_Options* options, enum Sass_Output_Style output_style);
157+
option_set_output_style: null,
158+
//void sass_option_set_source_comments (struct Sass_Options* options, bool source_comments);
159+
option_set_source_comments: null,
160+
//void sass_option_set_source_map_embed (struct Sass_Options* options, bool source_map_embed);
161+
option_set_source_map_embed: null,
162+
//void sass_option_set_source_map_contents (struct Sass_Options* options, bool source_map_contents);
163+
option_set_source_map_contents: null,
164+
//void sass_option_set_source_map_file_urls (struct Sass_Options* options, bool source_map_file_urls);
165+
option_set_source_map_file_urls: null,
166+
//void sass_option_set_omit_source_map_url (struct Sass_Options* options, bool omit_source_map_url);
167+
option_set_omit_source_map_url: null,
168+
//void sass_option_set_is_indented_syntax_src (struct Sass_Options* options, bool is_indented_syntax_src);
169+
option_set_is_indented_syntax_src: null,
170+
//void sass_option_set_indent (struct Sass_Options* options, const char* indent);
171+
option_set_indent: null,
172+
//void sass_option_set_linefeed (struct Sass_Options* options, const char* linefeed);
173+
option_set_linefeed: null,
174+
//void sass_option_set_input_path (struct Sass_Options* options, const char* input_path);
175+
option_set_input_path: null,
176+
//void sass_option_set_output_path (struct Sass_Options* options, const char* output_path);
177+
option_set_output_path: null,
178+
//void sass_option_set_plugin_path (struct Sass_Options* options, const char* plugin_path);
179+
option_set_plugin_path: null,
180+
//void sass_option_set_include_path (struct Sass_Options* options, const char* include_path);
181+
option_set_include_path: null,
182+
//void sass_option_set_source_map_file (struct Sass_Options* options, const char* source_map_file);
183+
option_set_source_map_file: null,
184+
//void sass_option_set_source_map_root (struct Sass_Options* options, const char* source_map_root);
185+
option_set_source_map_root: null,
186+
//void sass_option_set_c_functions (struct Sass_Options* options, Sass_C_Function_List c_functions);
187+
option_set_c_functions: null,
188+
//void sass_option_set_importer (struct Sass_Options* options, Sass_C_Import_Callback importer);
189+
option_set_importer: null,
190+
191+
//void sass_option_push_plugin_path (struct Sass_Options* options, const char* path);
192+
option_push_plugin_path: null,
193+
//void sass_option_push_include_path (struct Sass_Options* options, const char* path);
194+
option_push_include_path: null,
195+
196+
//char* sass_find_file (const char* path, struct Sass_Options* opt);
197+
find_file: null,
198+
//char* sass_find_include (const char* path, struct Sass_Options* opt);
199+
find_include: null,
200+
201+
//char* sass_compiler_find_file (const char* path, struct Sass_Compiler* compiler);
202+
compiler_find_file: null,
203+
//char* sass_compiler_find_include (const char* path, struct Sass_Compiler* compiler);
204+
compiler_find_include: null
205+
});
206+
102207
const buildOptionInterface = (_asmModule: SassAsmModule, wrapped: ReturnType<typeof wrapContextInterface>) => {
103208
const { make_options, delete_options } = wrapped;
104209

@@ -123,10 +228,10 @@ const buildOptionInterface = (_asmModule: SassAsmModule, wrapped: ReturnType<typ
123228
*/
124229
const buildContext = (asmModule: SassAsmModule) => {
125230
const { cwrap } = asmModule;
126-
const wrapped = wrapContextInterface(cwrap);
127-
//noop
231+
const wrappedContext = wrapContextInterface(cwrap);
232+
wrapOptionsInterface(cwrap);
128233

129-
const options = buildOptionInterface(asmModule, wrapped);
234+
const options = buildOptionInterface(asmModule, wrappedContext);
130235

131236
return {
132237
options

0 commit comments

Comments
 (0)