Commit b0013a00 by Adeel

Importer: Adds support for previous.

parent eedc835d
...@@ -173,8 +173,8 @@ function getOptions(options) { ...@@ -173,8 +173,8 @@ function getOptions(options) {
}; };
if (importer) { if (importer) {
options.importer = function(file, key) { options.importer = function(file, prev, key) {
importer(file, function(data) { importer(file, prev, function(data) {
binding.importedCallback({ binding.importedCallback({
index: key, index: key,
objectLiteral: data objectLiteral: data
......
...@@ -25,21 +25,23 @@ void dispatched_async_uv_callback(uv_async_t *req){ ...@@ -25,21 +25,23 @@ void dispatched_async_uv_callback(uv_async_t *req){
Handle<Value> argv[] = { Handle<Value> argv[] = {
NanNew<String>(strdup(ctx_w->file)), NanNew<String>(strdup(ctx_w->file)),
NanNew<String>(strdup(ctx_w->prev)),
NanNew<Number>(imports_collection.size() - 1) NanNew<Number>(imports_collection.size() - 1)
}; };
NanNew<Value>(ctx_w->importer_callback->Call(2, argv)); NanNew<Value>(ctx_w->importer_callback->Call(3, argv));
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
node::FatalException(try_catch); node::FatalException(try_catch);
} }
} }
struct Sass_Import** sass_importer(const char* file, void* cookie) struct Sass_Import** sass_importer(const char* file, const char* prev, void* cookie)
{ {
sass_context_wrapper* ctx_w = static_cast<sass_context_wrapper*>(cookie); sass_context_wrapper* ctx_w = static_cast<sass_context_wrapper*>(cookie);
ctx_w->file = strdup(file); ctx_w->file = strdup(file);
ctx_w->prev = strdup(prev);
ctx_w->async.data = (void*)ctx_w; ctx_w->async.data = (void*)ctx_w;
uv_async_send(&ctx_w->async); uv_async_send(&ctx_w->async);
......
...@@ -43,6 +43,7 @@ extern "C" { ...@@ -43,6 +43,7 @@ extern "C" {
delete ctx_w->error_callback; delete ctx_w->error_callback;
delete ctx_w->importer_callback; delete ctx_w->importer_callback;
delete ctx_w->file; delete ctx_w->file;
delete ctx_w->prev;
delete ctx_w->cookie; delete ctx_w->cookie;
uv_mutex_destroy(&ctx_w->importer_mutex); uv_mutex_destroy(&ctx_w->importer_mutex);
......
...@@ -20,6 +20,7 @@ extern "C" { ...@@ -20,6 +20,7 @@ extern "C" {
uv_cond_t importer_condition_variable; uv_cond_t importer_condition_variable;
uv_async_t async; uv_async_t async;
const char* file; const char* file;
const char* prev;
void* cookie; void* cookie;
Sass_Import** imports; Sass_Import** imports;
NanCallback* success_callback; NanCallback* success_callback;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment