Skip to content
This repository was archived by the owner on Jun 14, 2019. It is now read-only.

Commit 1695a1b

Browse files
committed
Merge pull request sass#59 from asottile/output_styles_simpler
Simplify OUTPUT_STYLES constant
2 parents f02e71c + 54d3b9d commit 1695a1b

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

pysass.cpp

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,6 @@ static union Sass_Value* _error_to_sass_value(PyObject* value);
3535
static union Sass_Value* _unknown_type_to_sass_error(PyObject* value);
3636
static union Sass_Value* _exception_to_sass_error();
3737

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-
};
5038

5139
static PyObject* _to_py_value(const union Sass_Value* value) {
5240
PyObject* retv = NULL;
@@ -522,22 +510,17 @@ static PyMethodDef PySass_methods[] = {
522510

523511
static char PySass_doc[] = "The thin binding of libsass for Python.";
524512

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;
534520
}
535521

536522
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());
541524
}
542525

543526
#if PY_MAJOR_VERSION >= 3

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy