|
18 | 18 | #define PySass_Bytes_AS_STRING(o) PyString_AS_STRING(o) |
19 | 19 | #endif |
20 | 20 |
|
| 21 | +#ifdef __cplusplus |
| 22 | +extern "C" { |
| 23 | +#endif |
| 24 | + |
21 | 25 | struct PySass_Pair { |
22 | 26 | char *label; |
23 | 27 | int value; |
24 | 28 | }; |
25 | 29 |
|
26 | 30 | static struct PySass_Pair PySass_output_style_enum[] = { |
27 | | - {"nested", SASS_STYLE_NESTED}, |
28 | | - {"expanded", SASS_STYLE_EXPANDED}, |
29 | | - {"compact", SASS_STYLE_COMPACT}, |
30 | | - {"compressed", SASS_STYLE_COMPRESSED}, |
31 | | - {NULL} |
32 | | -}; |
33 | | - |
34 | | -static struct PySass_Pair PySass_source_comments_enum[] = { |
35 | | - {"none", SASS_SOURCE_COMMENTS_NONE}, |
36 | | - {"line_numbers", SASS_SOURCE_COMMENTS_DEFAULT}, /* alias of "default" */ |
37 | | - {"default", SASS_SOURCE_COMMENTS_DEFAULT}, |
38 | | - {"map", SASS_SOURCE_COMMENTS_MAP}, |
| 31 | + {(char *) "nested", SASS_STYLE_NESTED}, |
| 32 | + {(char *) "expanded", SASS_STYLE_EXPANDED}, |
| 33 | + {(char *) "compact", SASS_STYLE_COMPACT}, |
| 34 | + {(char *) "compressed", SASS_STYLE_COMPRESSED}, |
39 | 35 | {NULL} |
40 | 36 | }; |
41 | 37 |
|
@@ -87,17 +83,16 @@ PySass_compile_filename(PyObject *self, PyObject *args) { |
87 | 83 |
|
88 | 84 | context = sass_new_file_context(); |
89 | 85 | context->input_path = filename; |
90 | | - if (source_comments == SASS_SOURCE_COMMENTS_MAP && |
91 | | - PySass_Bytes_Check(source_map_filename)) { |
| 86 | + if (source_comments && PySass_Bytes_Check(source_map_filename)) { |
92 | 87 | size_t source_map_file_len = PySass_Bytes_GET_SIZE(source_map_filename); |
93 | 88 | if (source_map_file_len) { |
94 | | - char *source_map_file = malloc(source_map_file_len + 1); |
| 89 | + char *source_map_file = (char *) malloc(source_map_file_len + 1); |
95 | 90 | strncpy( |
96 | 91 | source_map_file, |
97 | 92 | PySass_Bytes_AS_STRING(source_map_filename), |
98 | 93 | source_map_file_len + 1 |
99 | 94 | ); |
100 | | - context->source_map_file = source_map_file; |
| 95 | + context->options.source_map_file = source_map_file; |
101 | 96 | } |
102 | 97 | } |
103 | 98 | context->options.output_style = output_style; |
@@ -178,13 +173,10 @@ void PySass_make_enum_dict(PyObject *enum_dict, struct PySass_Pair *pairs) { |
178 | 173 | } |
179 | 174 |
|
180 | 175 | void PySass_init_module(PyObject *module) { |
181 | | - PyObject *output_styles, *source_comments; |
| 176 | + PyObject *output_styles; |
182 | 177 | output_styles = PyDict_New(); |
183 | 178 | PySass_make_enum_dict(output_styles, PySass_output_style_enum); |
184 | 179 | PyModule_AddObject(module, "OUTPUT_STYLES", output_styles); |
185 | | - source_comments = PyDict_New(); |
186 | | - PySass_make_enum_dict(source_comments, PySass_source_comments_enum); |
187 | | - PyModule_AddObject(module, "SOURCE_COMMENTS", source_comments); |
188 | 180 | } |
189 | 181 |
|
190 | 182 | #if PY_MAJOR_VERSION >= 3 |
@@ -220,3 +212,7 @@ init_sass() |
220 | 212 | } |
221 | 213 |
|
222 | 214 | #endif |
| 215 | + |
| 216 | +#ifdef __cplusplus |
| 217 | +} |
| 218 | +#endif |
0 commit comments