Commit 4bea0703 by Adeel Mujahid

Merge pull request #576 from am11/importer

Feature: Custom importer (#530)
parents 7c354bf6 5a6bd67f
......@@ -150,6 +150,7 @@ function getOptions(options) {
var error = options.error;
var success = options.success;
var importer = options.importer;
options.error = function(err, code) {
try {
......@@ -173,6 +174,17 @@ function getOptions(options) {
}
};
if (importer) {
options.importer = function(file, prev, key) {
importer(file, prev, function(data) {
binding.importedCallback({
index: key,
objectLiteral: data
});
});
};
}
delete options.image_path;
delete options.include_paths;
delete options.includePaths;
......
Subproject commit 5f3558d7ce36bb61202f1585ed8e32a52209e940
Subproject commit 7aaa45a979ce65d50b3158ff50bf9409f8955063
......@@ -8,7 +8,8 @@ extern "C" {
if (ctx_w->dctx) {
compile_data(ctx_w->dctx);
} else if (ctx_w->fctx) {
}
else if (ctx_w->fctx) {
compile_file(ctx_w->fctx);
}
}
......@@ -22,19 +23,31 @@ extern "C" {
}
sass_context_wrapper* sass_make_context_wrapper() {
return (sass_context_wrapper*) calloc(1, sizeof(sass_context_wrapper));
auto ctx_w = (sass_context_wrapper*)calloc(1, sizeof(sass_context_wrapper));
uv_mutex_init(&ctx_w->importer_mutex);
uv_cond_init(&ctx_w->importer_condition_variable);
return ctx_w;
}
void sass_free_context_wrapper(sass_context_wrapper* ctx_w) {
if (ctx_w->dctx) {
sass_delete_data_context(ctx_w->dctx);
} else if (ctx_w->fctx) {
}
else if (ctx_w->fctx) {
sass_delete_file_context(ctx_w->fctx);
}
NanDisposePersistent(ctx_w->stats);
delete ctx_w->callback;
delete ctx_w->errorCallback;
delete ctx_w->success_callback;
delete ctx_w->error_callback;
delete ctx_w->importer_callback;
delete ctx_w->file;
delete ctx_w->prev;
delete ctx_w->cookie;
uv_mutex_destroy(&ctx_w->importer_mutex);
uv_cond_destroy(&ctx_w->importer_condition_variable);
free(ctx_w);
}
......
......@@ -5,23 +5,31 @@
extern "C" {
#endif
using namespace v8;
using namespace v8;
void compile_data(struct Sass_Data_Context* dctx);
void compile_file(struct Sass_File_Context* fctx);
void compile_it(uv_work_t* req);
void compile_data(struct Sass_Data_Context* dctx);
void compile_file(struct Sass_File_Context* fctx);
void compile_it(uv_work_t* req);
struct sass_context_wrapper {
Sass_Data_Context* dctx;
Sass_File_Context* fctx;
Persistent<Object> stats;
uv_work_t request;
NanCallback* callback;
NanCallback* errorCallback;
};
struct sass_context_wrapper {
Sass_Data_Context* dctx;
Sass_File_Context* fctx;
Persistent<Object> stats;
uv_work_t request;
uv_mutex_t importer_mutex;
uv_cond_t importer_condition_variable;
uv_async_t async;
const char* file;
const char* prev;
void* cookie;
Sass_Import** imports;
NanCallback* success_callback;
NanCallback* error_callback;
NanCallback* importer_callback;
};
struct sass_context_wrapper* sass_make_context_wrapper(void);
void sass_free_context_wrapper(struct sass_context_wrapper* ctx_w);
struct sass_context_wrapper* sass_make_context_wrapper(void);
void sass_free_context_wrapper(struct sass_context_wrapper* ctx_w);
#ifdef __cplusplus
}
......
Subproject commit b85c617a0e7e5367dd347b0b301ad1c15b6d5087
Subproject commit 074ae3b24bfc3ff19a98efdec02415ed6fd5759a
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