Commit af72ccc4 by Adeel

Binding: Refurbishes binding to use new API.

parent 816204c9
...@@ -29,8 +29,10 @@ ...@@ -29,8 +29,10 @@
'src/libsass/remove_placeholders.cpp', 'src/libsass/remove_placeholders.cpp',
'src/libsass/sass.cpp', 'src/libsass/sass.cpp',
'src/libsass/sass2scss.cpp', 'src/libsass/sass2scss.cpp',
'src/libsass/sass_interface.cpp', 'src/libsass/sass_context.cpp',
'src/libsass/sass_functions.cpp',
'src/libsass/sass_util.cpp', 'src/libsass/sass_util.cpp',
'src/libsass/sass_values.cpp',
'src/libsass/source_map.cpp', 'src/libsass/source_map.cpp',
'src/libsass/to_c.cpp', 'src/libsass/to_c.cpp',
'src/libsass/to_string.cpp', 'src/libsass/to_string.cpp',
......
#include "sass_context_wrapper.h" #include "sass_context_wrapper.h"
#include <nan.h>
#include <cstdlib>
extern "C" { extern "C" {
using namespace std; using namespace std;
void free_context(sass_context* ctx) { void compile_it(uv_work_t* req) {
delete[] ctx->source_string; sass_context_wrapper* ctx_w = static_cast<sass_context_wrapper*>(req->data);
delete[] ctx->options.include_paths;
delete[] ctx->options.image_path; if (ctx_w->dctx) {
sass_free_context(ctx); compile_data(ctx_w->dctx);
} else if (ctx_w->fctx) {
compile_file(ctx_w->fctx);
}
}
void compile_data(struct Sass_Data_Context* dctx) {
struct Sass_Context* ctx = sass_data_context_get_context(dctx);
struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
sass_compile_data_context(dctx);
}
void compile_file(struct Sass_File_Context* fctx) {
struct Sass_Context* ctx = sass_file_context_get_context(fctx);
struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
sass_compile_file_context(fctx);
}
void free_data_context(struct Sass_Data_Context* dctx) {
// delete[] dctx->source_string;
// delete[] dctx->options.include_paths;
// delete[] dctx->options.image_path;
sass_delete_data_context(dctx);
} }
void free_file_context(sass_file_context* fctx) { void free_file_context(struct Sass_File_Context* fctx) {
delete[] fctx->input_path; // delete[] fctx->input_path;
delete[] fctx->options.include_paths; // delete[] fctx->options.include_paths;
delete[] fctx->options.image_path; // delete[] fctx->options.image_path;
sass_free_file_context(fctx); sass_delete_file_context(fctx);
} }
sass_context_wrapper* sass_new_context_wrapper() { sass_context_wrapper* sass_make_context_wrapper() {
return (sass_context_wrapper*) calloc(1, sizeof(sass_context_wrapper)); return (sass_context_wrapper*) calloc(1, sizeof(sass_context_wrapper));
} }
void sass_free_context_wrapper(sass_context_wrapper* ctx_w) { void sass_free_context_wrapper(sass_context_wrapper* ctx_w) {
if (ctx_w->ctx) { if (ctx_w->dctx) {
free_context(ctx_w->ctx); free_data_context(ctx_w->dctx);
} else if (ctx_w->fctx) { } else if (ctx_w->fctx) {
free_file_context(ctx_w->fctx); free_file_context(ctx_w->fctx);
} }
......
#include "libsass/sass_interface.h"
#include <nan.h> #include <nan.h>
#include "libsass/sass_context.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -7,20 +7,23 @@ extern "C" { ...@@ -7,20 +7,23 @@ extern "C" {
using namespace v8; using namespace v8;
void free_context(sass_context* ctx); void compile_data(struct Sass_Data_Context* dctx);
void free_file_context(sass_file_context* fctx); void compile_file(struct Sass_File_Context* fctx);
void compile_it(uv_work_t* req);
void free_data_context(struct Sass_Data_Context* dctx);
void free_file_context(struct Sass_File_Context* fctx);
struct sass_context_wrapper { struct sass_context_wrapper {
sass_context* ctx; Sass_Data_Context* dctx;
sass_file_context* fctx; Sass_File_Context* fctx;
Persistent<Object> stats; Persistent<Object> stats;
uv_work_t request; uv_work_t request;
NanCallback* callback; NanCallback* callback;
NanCallback* errorCallback; NanCallback* errorCallback;
}; };
struct sass_context_wrapper* sass_new_context_wrapper(void); struct sass_context_wrapper* sass_make_context_wrapper(void);
void sass_free_context_wrapper(struct sass_context_wrapper* ctx); void sass_free_context_wrapper(struct sass_context_wrapper* ctx_w);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -187,8 +187,7 @@ describe('api', function() { ...@@ -187,8 +187,7 @@ describe('api', function() {
var stats = {}; var stats = {};
var expected = [ var expected = [
fixture('include-files/bar.scss').replace(/\\/g, '/'), fixture('include-files/bar.scss').replace(/\\/g, '/'),
fixture('include-files/foo.scss').replace(/\\/g, '/'), fixture('include-files/foo.scss').replace(/\\/g, '/')
'stdin'
]; ];
sass.render({ sass.render({
......
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