Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
fc1d4e6e
Commit
fc1d4e6e
authored
Jan 04, 2015
by
vagrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Binding: Prevents setting option for file for fctx.
parent
f2996039
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
16 deletions
+31
-16
binding.cpp
src/binding.cpp
+19
-14
sass_context_wrapper.cpp
src/sass_context_wrapper.cpp
+9
-1
sass_context_wrapper.h
src/sass_context_wrapper.h
+3
-1
No files found.
src/binding.cpp
View file @
fc1d4e6e
...
@@ -75,15 +75,16 @@ struct Sass_Import** sass_importer(const char* file, const char* prev, void* coo
...
@@ -75,15 +75,16 @@ struct Sass_Import** sass_importer(const char* file, const char* prev, void* coo
{
{
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
=
file
?
strdup
(
file
)
:
0
;
if
(
!
ctx_w
->
is_sync
)
{
ctx_w
->
prev
=
prev
?
strdup
(
prev
)
:
0
;
if
(
ctx_w
->
success_callback
)
{
/* that is async: Render() or RenderFile(),
/* that is async: Render() or RenderFile(),
* the default even loop is unblocked so it
* the default even loop is unblocked so it
* can run uv_async_send without a push.
* can run uv_async_send without a push.
*/
*/
ctx_w
->
file
=
file
?
strdup
(
file
)
:
0
;
ctx_w
->
prev
=
prev
?
strdup
(
prev
)
:
0
;
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
);
uv_cond_wait
(
&
ctx_w
->
importer_condition_variable
,
&
ctx_w
->
importer_mutex
);
uv_cond_wait
(
&
ctx_w
->
importer_condition_variable
,
&
ctx_w
->
importer_mutex
);
}
}
...
@@ -91,8 +92,8 @@ struct Sass_Import** sass_importer(const char* file, const char* prev, void* coo
...
@@ -91,8 +92,8 @@ struct Sass_Import** sass_importer(const char* file, const char* prev, void* coo
NanScope
();
NanScope
();
Handle
<
Value
>
argv
[]
=
{
Handle
<
Value
>
argv
[]
=
{
NanNew
<
String
>
(
strdup
(
ctx_w
->
file
?
ctx_w
->
file
:
0
)
),
NanNew
<
String
>
(
file
),
NanNew
<
String
>
(
strdup
(
ctx_w
->
prev
?
ctx_w
->
prev
:
0
)
),
NanNew
<
String
>
(
prev
),
NanNew
<
Number
>
(
imports_collection
.
size
()
-
1
)
NanNew
<
Number
>
(
imports_collection
.
size
()
-
1
)
};
};
...
@@ -122,6 +123,9 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx
...
@@ -122,6 +123,9 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx
struct
Sass_Options
*
sass_options
=
sass_context_get_options
(
ctx
);
struct
Sass_Options
*
sass_options
=
sass_context_get_options
(
ctx
);
ctx_w
->
importer_callback
=
NULL
;
ctx_w
->
is_sync
=
isSync
;
if
(
!
isSync
)
{
if
(
!
isSync
)
{
ctx_w
->
request
.
data
=
ctx_w
;
ctx_w
->
request
.
data
=
ctx_w
;
...
@@ -135,15 +139,16 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx
...
@@ -135,15 +139,16 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx
Local
<
Function
>
importer_callback
=
Local
<
Function
>::
Cast
(
options
->
Get
(
NanNew
(
"importer"
)));
Local
<
Function
>
importer_callback
=
Local
<
Function
>::
Cast
(
options
->
Get
(
NanNew
(
"importer"
)));
ctx_w
->
importer_callback
=
NULL
;
if
(
importer_callback
->
IsFunction
())
{
if
(
!
importer_callback
->
IsUndefined
())
{
ctx_w
->
importer_callback
=
new
NanCallback
(
importer_callback
);
ctx_w
->
importer_callback
=
new
NanCallback
(
importer_callback
);
uv_async_init
(
uv_default_loop
(),
&
ctx_w
->
async
,
(
uv_async_cb
)
dispatched_async_uv_callback
);
uv_async_init
(
uv_default_loop
(),
&
ctx_w
->
async
,
(
uv_async_cb
)
dispatched_async_uv_callback
);
sass_option_set_importer
(
sass_options
,
sass_make_importer
(
sass_importer
,
ctx_w
));
sass_option_set_importer
(
sass_options
,
sass_make_importer
(
sass_importer
,
ctx_w
));
}
}
sass_option_set_input_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"file"
))));
if
(
!
isFile
)
{
sass_option_set_input_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"file"
))));
}
sass_option_set_output_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"outFile"
))));
sass_option_set_output_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"outFile"
))));
sass_option_set_image_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"imagePath"
))));
sass_option_set_image_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"imagePath"
))));
sass_option_set_output_style
(
sass_options
,
(
Sass_Output_Style
)
options
->
Get
(
NanNew
(
"style"
))
->
Int32Value
());
sass_option_set_output_style
(
sass_options
,
(
Sass_Output_Style
)
options
->
Get
(
NanNew
(
"style"
))
->
Int32Value
());
...
@@ -222,11 +227,11 @@ void make_callback(uv_work_t* req) {
...
@@ -222,11 +227,11 @@ void make_callback(uv_work_t* req) {
int
status
=
GetResult
(
ctx_w
,
ctx
);
int
status
=
GetResult
(
ctx_w
,
ctx
);
if
(
status
==
0
)
{
if
(
status
==
0
&&
ctx_w
->
success_callback
)
{
// if no error, do callback(null, result)
// if no error, do callback(null, result)
ctx_w
->
success_callback
->
Call
(
0
,
0
);
ctx_w
->
success_callback
->
Call
(
0
,
0
);
}
}
else
{
else
if
(
ctx_w
->
error_callback
)
{
// if error, do callback(error)
// if error, do callback(error)
const
char
*
err
=
sass_context_get_error_json
(
ctx
);
const
char
*
err
=
sass_context_get_error_json
(
ctx
);
Local
<
Value
>
argv
[]
=
{
Local
<
Value
>
argv
[]
=
{
...
@@ -283,7 +288,7 @@ NAN_METHOD(RenderSync) {
...
@@ -283,7 +288,7 @@ NAN_METHOD(RenderSync) {
error
=
NanNew
<
String
>
(
sass_context_get_error_json
(
ctx
));
error
=
NanNew
<
String
>
(
sass_context_get_error_json
(
ctx
));
}
}
sass_
free_context_wrapper
(
ctx_w
);
sass_
wrapper_dispose
(
ctx_w
,
source_string
);
if
(
result
!=
0
)
{
if
(
result
!=
0
)
{
NanThrowError
(
error
);
NanThrowError
(
error
);
...
@@ -328,7 +333,7 @@ NAN_METHOD(RenderFileSync) {
...
@@ -328,7 +333,7 @@ NAN_METHOD(RenderFileSync) {
error
=
NanNew
<
String
>
(
sass_context_get_error_json
(
ctx
));
error
=
NanNew
<
String
>
(
sass_context_get_error_json
(
ctx
));
}
}
sass_
free_context_wrapper
(
ctx_w
);
sass_
wrapper_dispose
(
ctx_w
,
input_path
);
if
(
result
!=
0
)
{
if
(
result
!=
0
)
{
NanThrowError
(
error
);
NanThrowError
(
error
);
...
...
src/sass_context_wrapper.cpp
View file @
fc1d4e6e
...
@@ -30,7 +30,7 @@ extern "C" {
...
@@ -30,7 +30,7 @@ extern "C" {
return
ctx_w
;
return
ctx_w
;
}
}
void
sass_
free_context_wrapper
(
sass_context_wrapper
*
ctx_w
)
{
void
sass_
wrapper_dispose
(
struct
sass_context_wrapper
*
ctx_w
,
char
*
string
=
0
)
{
if
(
ctx_w
->
dctx
)
{
if
(
ctx_w
->
dctx
)
{
sass_delete_data_context
(
ctx_w
->
dctx
);
sass_delete_data_context
(
ctx_w
->
dctx
);
}
}
...
@@ -49,6 +49,14 @@ extern "C" {
...
@@ -49,6 +49,14 @@ extern "C" {
NanDisposePersistent
(
ctx_w
->
result
);
NanDisposePersistent
(
ctx_w
->
result
);
if
(
string
)
{
free
(
string
);
}
}
void
sass_free_context_wrapper
(
sass_context_wrapper
*
ctx_w
)
{
sass_wrapper_dispose
(
ctx_w
);
free
(
ctx_w
);
free
(
ctx_w
);
}
}
}
}
src/sass_context_wrapper.h
View file @
fc1d4e6e
...
@@ -22,6 +22,7 @@ extern "C" {
...
@@ -22,6 +22,7 @@ extern "C" {
const
char
*
file
;
const
char
*
file
;
const
char
*
prev
;
const
char
*
prev
;
void
*
cookie
;
void
*
cookie
;
bool
is_sync
;
Sass_Import
**
imports
;
Sass_Import
**
imports
;
NanCallback
*
success_callback
;
NanCallback
*
success_callback
;
NanCallback
*
error_callback
;
NanCallback
*
error_callback
;
...
@@ -29,7 +30,8 @@ extern "C" {
...
@@ -29,7 +30,8 @@ extern "C" {
};
};
struct
sass_context_wrapper
*
sass_make_context_wrapper
(
void
);
struct
sass_context_wrapper
*
sass_make_context_wrapper
(
void
);
void
sass_free_context_wrapper
(
struct
sass_context_wrapper
*
ctx_w
);
void
sass_wrapper_dispose
(
struct
sass_context_wrapper
*
,
char
*
);
void
sass_free_context_wrapper
(
struct
sass_context_wrapper
*
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment