@@ -35,18 +35,6 @@ static union Sass_Value* _error_to_sass_value(PyObject* value);
35
35
static union Sass_Value* _unknown_type_to_sass_error (PyObject* value);
36
36
static union Sass_Value* _exception_to_sass_error ();
37
37
38
- struct PySass_Pair {
39
- char *label;
40
- int value;
41
- };
42
-
43
- static struct PySass_Pair PySass_output_style_enum[] = {
44
- {(char *) " nested" , SASS_STYLE_NESTED},
45
- {(char *) " expanded" , SASS_STYLE_EXPANDED},
46
- {(char *) " compact" , SASS_STYLE_COMPACT},
47
- {(char *) " compressed" , SASS_STYLE_COMPRESSED},
48
- {NULL }
49
- };
50
38
51
39
static PyObject* _to_py_value (const union Sass_Value* value) {
52
40
PyObject* retv = NULL ;
@@ -362,10 +350,12 @@ static union Sass_Value* _to_sass_value(PyObject* value) {
362
350
}
363
351
364
352
static union Sass_Value* _call_py_f (
365
- const union Sass_Value* sass_args, void * cookie
353
+ const union Sass_Value* sass_args,
354
+ Sass_Function_Entry cb,
355
+ struct Sass_Options * opts
366
356
) {
367
357
size_t i;
368
- PyObject* pyfunc = (PyObject*)cookie ;
358
+ PyObject* pyfunc = (PyObject*)sass_function_get_cookie (cb) ;
369
359
PyObject* py_args = PyTuple_New (sass_list_get_length (sass_args));
370
360
PyObject* py_result = NULL ;
371
361
union Sass_Value* sass_result = NULL ;
@@ -394,13 +384,13 @@ static void _add_custom_functions(
394
384
struct Sass_Options * options, PyObject* custom_functions
395
385
) {
396
386
Py_ssize_t i;
397
- Sass_C_Function_List fn_list = sass_make_function_list (
387
+ Sass_Function_List fn_list = sass_make_function_list (
398
388
PyList_Size (custom_functions)
399
389
);
400
390
for (i = 0 ; i < PyList_GET_SIZE (custom_functions); i += 1 ) {
401
391
PyObject* sass_function = PyList_GET_ITEM (custom_functions, i);
402
392
PyObject* signature = PySass_Object_Bytes (sass_function);
403
- Sass_C_Function_Callback fn = sass_make_function (
393
+ Sass_Function_Entry fn = sass_make_function (
404
394
PySass_Bytes_AS_STRING (signature),
405
395
_call_py_f,
406
396
sass_function
@@ -415,27 +405,26 @@ PySass_compile_string(PyObject *self, PyObject *args) {
415
405
struct Sass_Context *ctx;
416
406
struct Sass_Data_Context *context;
417
407
struct Sass_Options *options;
418
- char *string, *include_paths, *image_path ;
408
+ char *string, *include_paths;
419
409
const char *error_message, *output_string;
420
410
Sass_Output_Style output_style;
421
411
int source_comments, error_status, precision;
422
412
PyObject *custom_functions;
423
413
PyObject *result;
424
414
425
415
if (!PyArg_ParseTuple (args,
426
- PySass_IF_PY3 (" yiiyyiO " , " siissiO " ),
416
+ PySass_IF_PY3 (" yiiyiO " , " siisiO " ),
427
417
&string, &output_style, &source_comments,
428
- &include_paths, &image_path, & precision,
418
+ &include_paths, &precision,
429
419
&custom_functions)) {
430
420
return NULL ;
431
421
}
432
422
433
- context = sass_make_data_context (string);
423
+ context = sass_make_data_context (strdup ( string) );
434
424
options = sass_data_context_get_options (context);
435
425
sass_option_set_output_style (options, output_style);
436
426
sass_option_set_source_comments (options, source_comments);
437
427
sass_option_set_include_path (options, include_paths);
438
- sass_option_set_image_path (options, image_path);
439
428
sass_option_set_precision (options, precision);
440
429
_add_custom_functions (options, custom_functions);
441
430
@@ -459,16 +448,16 @@ PySass_compile_filename(PyObject *self, PyObject *args) {
459
448
struct Sass_Context *ctx;
460
449
struct Sass_File_Context *context;
461
450
struct Sass_Options *options;
462
- char *filename, *include_paths, *image_path ;
451
+ char *filename, *include_paths;
463
452
const char *error_message, *output_string, *source_map_string;
464
453
Sass_Output_Style output_style;
465
454
int source_comments, error_status, precision;
466
455
PyObject *source_map_filename, *custom_functions, *result;
467
456
468
457
if (!PyArg_ParseTuple (args,
469
- PySass_IF_PY3 (" yiiyyiOO " , " siissiOO " ),
458
+ PySass_IF_PY3 (" yiiyiOO " , " siisiOO " ),
470
459
&filename, &output_style, &source_comments,
471
- &include_paths, &image_path, & precision,
460
+ &include_paths, &precision,
472
461
&source_map_filename, &custom_functions)) {
473
462
return NULL ;
474
463
}
@@ -491,7 +480,6 @@ PySass_compile_filename(PyObject *self, PyObject *args) {
491
480
sass_option_set_output_style (options, output_style);
492
481
sass_option_set_source_comments (options, source_comments);
493
482
sass_option_set_include_path (options, include_paths);
494
- sass_option_set_image_path (options, image_path);
495
483
sass_option_set_precision (options, precision);
496
484
_add_custom_functions (options, custom_functions);
497
485
@@ -522,22 +510,17 @@ static PyMethodDef PySass_methods[] = {
522
510
523
511
static char PySass_doc[] = " The thin binding of libsass for Python." ;
524
512
525
- void PySass_make_enum_dict (PyObject *enum_dict, struct PySass_Pair *pairs) {
526
- size_t i;
527
- for (i = 0 ; pairs[i].label ; ++i) {
528
- PyDict_SetItemString (
529
- enum_dict,
530
- pairs[i].label ,
531
- PySass_Int_FromLong ((long ) pairs[i].value )
532
- );
533
- }
513
+ PyObject* PySass_make_enum_dict () {
514
+ PyObject* dct = PyDict_New ();
515
+ PyDict_SetItemString (dct, " nested" , PySass_Int_FromLong (SASS_STYLE_NESTED));
516
+ PyDict_SetItemString (dct, " expected" , PySass_Int_FromLong (SASS_STYLE_EXPANDED));
517
+ PyDict_SetItemString (dct, " compact" , PySass_Int_FromLong (SASS_STYLE_COMPACT));
518
+ PyDict_SetItemString (dct, " compressed" , PySass_Int_FromLong (SASS_STYLE_COMPRESSED));
519
+ return dct;
534
520
}
535
521
536
522
void PySass_init_module (PyObject *module ) {
537
- PyObject *output_styles;
538
- output_styles = PyDict_New ();
539
- PySass_make_enum_dict (output_styles, PySass_output_style_enum);
540
- PyModule_AddObject (module , " OUTPUT_STYLES" , output_styles);
523
+ PyModule_AddObject (module , " OUTPUT_STYLES" , PySass_make_enum_dict ());
541
524
}
542
525
543
526
#if PY_MAJOR_VERSION >= 3
0 commit comments