Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Libsass 3.2.0 #12

Merged
merged 8 commits into from
Apr 7, 2015
2 changes: 1 addition & 1 deletion lib/libsass
2 changes: 0 additions & 2 deletions src/php_sass.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ PHP_METHOD(Sass, getStyle);
PHP_METHOD(Sass, setStyle);
PHP_METHOD(Sass, getIncludePath);
PHP_METHOD(Sass, setIncludePath);
PHP_METHOD(Sass, getImagePath);
PHP_METHOD(Sass, setImagePath);
PHP_METHOD(Sass, getPrecision);
PHP_METHOD(Sass, setPrecision);

Expand Down
43 changes: 1 addition & 42 deletions src/sass.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ typedef struct sass_object {
zend_object zo;
int style;
char* include_paths;
char* image_path;
long precision;
} sass_object;

Expand All @@ -34,8 +33,6 @@ void sass_free_storage(void *object TSRMLS_DC)
sass_object *obj = (sass_object *)object;
if (obj->include_paths != NULL)
efree(obj->include_paths);
if (obj->image_path != NULL)
efree(obj->image_path);

zend_hash_destroy(obj->zo.properties);
FREE_HASHTABLE(obj->zo.properties);
Expand Down Expand Up @@ -77,7 +74,6 @@ PHP_METHOD(Sass, __construct)
sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC);
obj->style = SASS_STYLE_NESTED;
obj->include_paths = NULL;
obj->image_path = NULL;
obj->precision = 5;

}
Expand Down Expand Up @@ -105,13 +101,12 @@ PHP_METHOD(Sass, compile)
struct sass_context* context = sass_new_context();

context->options.include_paths = this->include_paths != NULL ? this->include_paths : "";
context->options.image_path = this->include_paths != NULL ? this->image_path : "";
context->options.precision = this->precision;
context->options.output_style = this->style;

// "Hand over the source, buddy!"
// "Which one, béchamel or arrabbiata?"
context->source_string = source;
context->source_string = strdup(source);

// Compile it!
sass_compile(context);
Expand Down Expand Up @@ -172,7 +167,6 @@ PHP_METHOD(Sass, compile_file)
struct sass_file_context* context = sass_new_file_context();

context->options.include_paths = this->include_paths != NULL ? this->include_paths : "";
context->options.image_path = this->include_paths != NULL ? this->image_path : "";
context->options.precision = this->precision;
context->options.output_style = this->style;

Expand Down Expand Up @@ -291,38 +285,6 @@ PHP_METHOD(Sass, setPrecision)
RETURN_NULL();
}

PHP_METHOD(Sass, getImagePath)
{
zval *this = getThis();

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "", NULL) == FAILURE) {
RETURN_FALSE;
}

sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC);
if (obj->image_path == NULL) RETURN_STRING("", 1)
RETURN_STRING(obj->image_path, 1)
}

PHP_METHOD(Sass, setImagePath)
{
zval *this = getThis();

char *path;
int path_len;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &path_len) == FAILURE)
RETURN_FALSE;

sass_object *obj = (sass_object *)zend_object_store_get_object(this TSRMLS_CC);
if (obj->image_path != NULL)
efree(obj->image_path);
obj->image_path = estrndup(path, path_len);

RETURN_NULL();
}


/* --------------------------------------------------------------
* EXCEPTION HANDLING
* ------------------------------------------------------------ */
Expand All @@ -344,8 +306,6 @@ zend_function_entry sass_methods[] = {
PHP_ME(Sass, setStyle, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Sass, getIncludePath, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Sass, setIncludePath, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Sass, getImagePath, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Sass, setImagePath, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Sass, getPrecision, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Sass, setPrecision, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
Expand Down Expand Up @@ -374,7 +334,6 @@ static PHP_MINIT_FUNCTION(sass)
REGISTER_SASS_CLASS_CONST_LONG(STYLE_EXPANDED, SASS_STYLE_EXPANDED);
REGISTER_SASS_CLASS_CONST_LONG(STYLE_COMPACT, SASS_STYLE_COMPACT);
REGISTER_SASS_CLASS_CONST_LONG(STYLE_COMPRESSED, SASS_STYLE_COMPRESSED);
REGISTER_SASS_CLASS_CONST_LONG(STYLE_FORMATTED, SASS_OUTPUT_FORMATTED);

REGISTER_STRING_CONSTANT("SASS_FLAVOR", SASS_FLAVOR, CONST_CS | CONST_PERSISTENT);

Expand Down
6 changes: 1 addition & 5 deletions tests/handles_style.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ echo $sass->getStyle();
$sass->setStyle(Sass::STYLE_COMPRESSED);
echo $sass->getStyle();

// test SASS_OUTPUT_FORMATTED
$sass->setStyle(Sass::STYLE_FORMATTED);
echo $sass->getStyle();

?>
--EXPECT--
001234
00123
2 changes: 1 addition & 1 deletion tests/parse_file_parses_file.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ echo $css;
--EXPECT--
@import url(../blahblah/blah.blah);
div {
blah: "hello 4 world px bloo\n blah"; }
blah: "hello 4 world px bloo blah"; }

div {
blah: "foo iphone"; }
2 changes: 1 addition & 1 deletion tests/support/test.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import url(../blahblah/blah.blah);

div {
blah: "hello #{2+2} world #{unit(23px)} #{'bloo\n'} blah";
blah: "hello #{2+2} world #{unit(23px)} #{'bloo'} blah";
}

$foo: iphone;
Expand Down