11
11
#define COLLECTIONS_ABC_MOD "collections"
12
12
#endif
13
13
14
- #ifdef __cplusplus
15
- extern " C" {
16
- #endif
17
-
18
14
static PyObject * _to_py_value (const union Sass_Value * value );
19
15
static union Sass_Value * _to_sass_value (PyObject * value );
20
16
@@ -156,7 +152,7 @@ static union Sass_Value* _list_to_sass_value(PyObject* value) {
156
152
PyObject * items = PyObject_GetAttrString (value , "items" );
157
153
PyObject * separator = PyObject_GetAttrString (value , "separator" );
158
154
PyObject * bracketed = PyObject_GetAttrString (value , "bracketed" );
159
- Sass_Separator sep = SASS_COMMA;
155
+ enum Sass_Separator sep = SASS_COMMA ;
160
156
if (separator == sass_comma ) {
161
157
sep = SASS_COMMA ;
162
158
} else if (separator == sass_space ) {
@@ -168,7 +164,7 @@ static union Sass_Value* _list_to_sass_value(PyObject* value) {
168
164
retv = sass_make_list (PyTuple_Size (items ), sep , is_bracketed );
169
165
for (i = 0 ; i < PyTuple_Size (items ); i += 1 ) {
170
166
sass_list_set_value (
171
- retv, i, _to_sass_value (PyTuple_GET_ITEM (items, i))
167
+ retv , i , _to_sass_value (PyTuple_GetItem (items , i ))
172
168
);
173
169
}
174
170
Py_DECREF (types_mod );
@@ -204,7 +200,7 @@ static union Sass_Value* _number_to_sass_value(PyObject* value) {
204
200
PyObject * unit = PyObject_GetAttrString (value , "unit" );
205
201
PyObject * bytes = PyUnicode_AsEncodedString (unit , "UTF-8" , "strict" );
206
202
retv = sass_make_number (
207
- PyFloat_AsDouble (d_value), PyBytes_AS_STRING (bytes)
203
+ PyFloat_AsDouble (d_value ), PyBytes_AsString (bytes )
208
204
);
209
205
Py_DECREF (d_value );
210
206
Py_DECREF (unit );
@@ -215,7 +211,7 @@ static union Sass_Value* _number_to_sass_value(PyObject* value) {
215
211
static union Sass_Value * _unicode_to_sass_value (PyObject * value ) {
216
212
union Sass_Value * retv = NULL ;
217
213
PyObject * bytes = PyUnicode_AsEncodedString (value , "UTF-8" , "strict" );
218
- retv = sass_make_string (PyBytes_AS_STRING (bytes));
214
+ retv = sass_make_string (PyBytes_AsString (bytes ));
219
215
Py_DECREF (bytes );
220
216
return retv ;
221
217
}
@@ -224,7 +220,7 @@ static union Sass_Value* _warning_to_sass_value(PyObject* value) {
224
220
union Sass_Value * retv = NULL ;
225
221
PyObject * msg = PyObject_GetAttrString (value , "msg" );
226
222
PyObject * bytes = PyUnicode_AsEncodedString (msg , "UTF-8" , "strict" );
227
- retv = sass_make_warning (PyBytes_AS_STRING (bytes));
223
+ retv = sass_make_warning (PyBytes_AsString (bytes ));
228
224
Py_DECREF (msg );
229
225
Py_DECREF (bytes );
230
226
return retv ;
@@ -234,7 +230,7 @@ static union Sass_Value* _error_to_sass_value(PyObject* value) {
234
230
union Sass_Value * retv = NULL ;
235
231
PyObject * msg = PyObject_GetAttrString (value , "msg" );
236
232
PyObject * bytes = PyUnicode_AsEncodedString (msg , "UTF-8" , "strict" );
237
- retv = sass_make_error (PyBytes_AS_STRING (bytes));
233
+ retv = sass_make_error (PyBytes_AsString (bytes ));
238
234
Py_DECREF (msg );
239
235
Py_DECREF (bytes );
240
236
return retv ;
@@ -263,7 +259,7 @@ static union Sass_Value* _unknown_type_to_sass_error(PyObject* value) {
263
259
format_meth , type_name , NULL
264
260
);
265
261
PyObject * bytes = PyUnicode_AsEncodedString (result , "UTF-8" , "strict" );
266
- retv = sass_make_error (PyBytes_AS_STRING (bytes));
262
+ retv = sass_make_error (PyBytes_AsString (bytes ));
267
263
Py_DECREF (type );
268
264
Py_DECREF (type_name );
269
265
Py_DECREF (fmt );
@@ -302,7 +298,7 @@ static PyObject* _exception_to_bytes() {
302
298
303
299
static union Sass_Value * _exception_to_sass_error () {
304
300
PyObject * bytes = _exception_to_bytes ();
305
- union Sass_Value* retv = sass_make_error (PyBytes_AS_STRING (bytes));
301
+ union Sass_Value * retv = sass_make_error (PyBytes_AsString (bytes ));
306
302
Py_DECREF (bytes );
307
303
return retv ;
308
304
}
@@ -311,7 +307,7 @@ static Sass_Import_List _exception_to_sass_import_error(const char* path) {
311
307
PyObject * bytes = _exception_to_bytes ();
312
308
Sass_Import_List import_list = sass_make_import_list (1 );
313
309
import_list [0 ] = sass_make_import_entry (path , 0 , 0 );
314
- sass_import_set_error (import_list[0 ], PyBytes_AS_STRING (bytes), 0 , 0 );
310
+ sass_import_set_error (import_list [0 ], PyBytes_AsString (bytes ), 0 , 0 );
315
311
Py_DECREF (bytes );
316
312
return import_list ;
317
313
}
@@ -334,7 +330,7 @@ static union Sass_Value* _to_sass_value(PyObject* value) {
334
330
} else if (PyUnicode_Check (value )) {
335
331
retv = _unicode_to_sass_value (value );
336
332
} else if (PyBytes_Check (value )) {
337
- retv = sass_make_string (PyBytes_AS_STRING (value));
333
+ retv = sass_make_string (PyBytes_AsString (value ));
338
334
/* XXX: PyMapping_Check returns true for lists and tuples in python3 :( */
339
335
/* XXX: pypy derps on dicts: https://bitbucket.org/pypy/pypy/issue/1970 */
340
336
} else if (PyDict_Check (value ) || PyObject_IsInstance (value , mapping_t )) {
@@ -404,11 +400,11 @@ static void _add_custom_functions(
404
400
Sass_Function_List fn_list = sass_make_function_list (
405
401
PyList_Size (custom_functions )
406
402
);
407
- for (i = 0 ; i < PyList_GET_SIZE (custom_functions); i += 1 ) {
408
- PyObject* sass_function = PyList_GET_ITEM (custom_functions, i);
403
+ for (i = 0 ; i < PyList_Size (custom_functions ); i += 1 ) {
404
+ PyObject * sass_function = PyList_GetItem (custom_functions , i );
409
405
PyObject * signature = PySass_Object_Bytes (sass_function );
410
406
Sass_Function_Entry fn = sass_make_function (
411
- PyBytes_AS_STRING (signature),
407
+ PyBytes_AsString (signature ),
412
408
_call_py_f ,
413
409
sass_function
414
410
);
@@ -443,13 +439,13 @@ static Sass_Import_List _call_py_importer_f(
443
439
444
440
/* Otherwise, we know our importer is well formed (because we wrap it)
445
441
* The return value will be a tuple of 1, 2, or 3 tuples */
446
- sass_imports = sass_make_import_list (PyTuple_GET_SIZE (py_result));
447
- for (i = 0 ; i < PyTuple_GET_SIZE (py_result); i += 1 ) {
442
+ sass_imports = sass_make_import_list (PyTuple_Size (py_result ));
443
+ for (i = 0 ; i < PyTuple_Size (py_result ); i += 1 ) {
448
444
char * path_str = NULL ; /* XXX: Memory leak? */
449
445
char * source_str = NULL ;
450
446
char * sourcemap_str = NULL ;
451
- PyObject* tup = PyTuple_GET_ITEM (py_result, i);
452
- Py_ssize_t size = PyTuple_GET_SIZE (tup);
447
+ PyObject * tup = PyTuple_GetItem (py_result , i );
448
+ Py_ssize_t size = PyTuple_Size (tup );
453
449
454
450
if (size == 1 ) {
455
451
PyArg_ParseTuple (tup , PySass_IF_PY3 ("y" , "s" ), & path_str );
@@ -495,10 +491,10 @@ static void _add_custom_importers(
495
491
return ;
496
492
}
497
493
498
- importer_list = sass_make_importer_list (PyTuple_GET_SIZE (custom_importers));
494
+ importer_list = sass_make_importer_list (PyTuple_Size (custom_importers ));
499
495
500
- for (i = 0 ; i < PyTuple_GET_SIZE (custom_importers); i += 1 ) {
501
- PyObject* item = PyTuple_GET_ITEM (custom_importers, i);
496
+ for (i = 0 ; i < PyTuple_Size (custom_importers ); i += 1 ) {
497
+ PyObject * item = PyTuple_GetItem (custom_importers , i );
502
498
int priority = 0 ;
503
499
PyObject * import_function = NULL ;
504
500
@@ -517,11 +513,11 @@ PySass_compile_string(PyObject *self, PyObject *args) {
517
513
struct Sass_Context * ctx ;
518
514
struct Sass_Data_Context * context ;
519
515
struct Sass_Options * options ;
520
- char *string, *include_paths, *source_map_file ;
516
+ char * string , * include_paths ;
521
517
const char * error_message , * output_string ;
522
- Sass_Output_Style output_style;
518
+ enum Sass_Output_Style output_style ;
523
519
int source_comments , error_status , precision , indented ,
524
- source_map_embed, source_map_contents, source_map_file_urls,
520
+ source_map_embed , source_map_contents ,
525
521
omit_source_map_url ;
526
522
PyObject * custom_functions ;
527
523
PyObject * custom_importers ;
@@ -549,9 +545,9 @@ PySass_compile_string(PyObject *self, PyObject *args) {
549
545
sass_option_set_source_map_embed (options , source_map_embed );
550
546
sass_option_set_omit_source_map_url (options , omit_source_map_url );
551
547
552
- if (PyBytes_Check (source_map_root) && PyBytes_GET_SIZE (source_map_root)) {
548
+ if (PyBytes_Check (source_map_root ) && PyBytes_Size (source_map_root )) {
553
549
sass_option_set_source_map_root (
554
- options, PyBytes_AS_STRING (source_map_root)
550
+ options , PyBytes_AsString (source_map_root )
555
551
);
556
552
}
557
553
@@ -579,9 +575,9 @@ PySass_compile_filename(PyObject *self, PyObject *args) {
579
575
struct Sass_Options * options ;
580
576
char * filename , * include_paths ;
581
577
const char * error_message , * output_string , * source_map_string ;
582
- Sass_Output_Style output_style;
578
+ enum Sass_Output_Style output_style ;
583
579
int source_comments , error_status , precision , source_map_embed ,
584
- source_map_contents, source_map_file_urls, omit_source_map_url;
580
+ source_map_contents , omit_source_map_url ;
585
581
PyObject * source_map_filename , * custom_functions , * custom_importers ,
586
582
* result , * output_filename_hint , * source_map_root ;
587
583
@@ -600,23 +596,23 @@ PySass_compile_filename(PyObject *self, PyObject *args) {
600
596
options = sass_file_context_get_options (context );
601
597
602
598
if (PyBytes_Check (source_map_filename )) {
603
- if (PyBytes_GET_SIZE (source_map_filename)) {
599
+ if (PyBytes_Size (source_map_filename )) {
604
600
sass_option_set_source_map_file (
605
- options, PyBytes_AS_STRING (source_map_filename)
601
+ options , PyBytes_AsString (source_map_filename )
606
602
);
607
603
}
608
604
}
609
605
if (PyBytes_Check (output_filename_hint )) {
610
- if (PyBytes_GET_SIZE (output_filename_hint)) {
606
+ if (PyBytes_Size (output_filename_hint )) {
611
607
sass_option_set_output_path (
612
- options, PyBytes_AS_STRING (output_filename_hint)
608
+ options , PyBytes_AsString (output_filename_hint )
613
609
);
614
610
}
615
611
}
616
612
617
- if (PyBytes_Check (source_map_root) && PyBytes_GET_SIZE (source_map_root)) {
613
+ if (PyBytes_Check (source_map_root ) && PyBytes_Size (source_map_root )) {
618
614
sass_option_set_source_map_root (
619
- options, PyBytes_AS_STRING (source_map_root)
615
+ options , PyBytes_AsString (source_map_root )
620
616
);
621
617
}
622
618
@@ -703,7 +699,3 @@ init_sass()
703
699
}
704
700
705
701
#endif
706
-
707
- #ifdef __cplusplus
708
- }
709
- #endif
0 commit comments