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
a8c67109
Commit
a8c67109
authored
Nov 17, 2014
by
Adeel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code: Brings more optimizations.
Credit goes to @mgreter.
parent
9e436db7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
52 deletions
+14
-52
binding.cpp
src/binding.cpp
+12
-36
sass_context_wrapper.cpp
src/sass_context_wrapper.cpp
+2
-14
sass_context_wrapper.h
src/sass_context_wrapper.h
+0
-2
No files found.
src/binding.cpp
View file @
a8c67109
...
@@ -13,8 +13,6 @@ char* CreateString(Local<Value> value) {
...
@@ -13,8 +13,6 @@ char* CreateString(Local<Value> value) {
}
}
void
ExtractOptions
(
Local
<
Object
>
options
,
void
*
cptr
,
sass_context_wrapper
*
ctx_w
,
bool
isFile
)
{
void
ExtractOptions
(
Local
<
Object
>
options
,
void
*
cptr
,
sass_context_wrapper
*
ctx_w
,
bool
isFile
)
{
bool
source_comments
;
if
(
ctx_w
)
{
if
(
ctx_w
)
{
NanAssignPersistent
(
ctx_w
->
stats
,
options
->
Get
(
NanNew
(
"stats"
))
->
ToObject
());
NanAssignPersistent
(
ctx_w
->
stats
,
options
->
Get
(
NanNew
(
"stats"
))
->
ToObject
());
...
@@ -31,24 +29,21 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx
...
@@ -31,24 +29,21 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx
ctx_w
->
errorCallback
=
new
NanCallback
(
errorCallback
);
ctx_w
->
errorCallback
=
new
NanCallback
(
errorCallback
);
}
}
struct
Sass_
Options
*
sass_options
;
struct
Sass_
Context
*
ctx
;
if
(
isFile
)
{
if
(
isFile
)
{
struct
Sass_File_Context
*
fctx
=
(
struct
Sass_File_Context
*
)
cptr
;
ctx
=
sass_file_context_get_context
((
struct
Sass_File_Context
*
)
cptr
);
struct
Sass_Context
*
ctx
=
sass_file_context_get_context
(
fctx
);
sass_options
=
sass_context_get_options
(
ctx
);
}
else
{
}
else
{
struct
Sass_Data_Context
*
dctx
=
(
struct
Sass_Data_Context
*
)
cptr
;
ctx
=
sass_data_context_get_context
((
struct
Sass_Data_Context
*
)
cptr
);
struct
Sass_Context
*
ctx
=
sass_data_context_get_context
(
dctx
);
sass_options
=
sass_context_get_options
(
ctx
);
sass_option_set_is_indented_syntax_src
(
sass_options
,
options
->
Get
(
NanNew
(
"indentedSyntax"
))
->
BooleanValue
());
}
}
struct
Sass_Options
*
sass_options
=
sass_context_get_options
(
ctx
);
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
());
sass_option_set_source_comments
(
sass_options
,
source_comments
=
options
->
Get
(
NanNew
(
"comments"
))
->
BooleanValue
());
sass_option_set_is_indented_syntax_src
(
sass_options
,
options
->
Get
(
NanNew
(
"indentedSyntax"
))
->
BooleanValue
());
sass_option_set_source_comments
(
sass_options
,
options
->
Get
(
NanNew
(
"comments"
))
->
BooleanValue
());
sass_option_set_omit_source_map_url
(
sass_options
,
options
->
Get
(
NanNew
(
"omitSourceMapUrl"
))
->
BooleanValue
());
sass_option_set_omit_source_map_url
(
sass_options
,
options
->
Get
(
NanNew
(
"omitSourceMapUrl"
))
->
BooleanValue
());
sass_option_set_source_map_file
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"sourceMap"
))));
sass_option_set_source_map_file
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"sourceMap"
))));
sass_option_set_include_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"paths"
))));
sass_option_set_include_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"paths"
))));
...
@@ -82,24 +77,6 @@ void FillStatsObj(Handle<Object> stats, Sass_Context* ctx) {
...
@@ -82,24 +77,6 @@ void FillStatsObj(Handle<Object> stats, Sass_Context* ctx) {
(
*
stats
)
->
Set
(
NanNew
(
"sourceMap"
),
source_map
);
(
*
stats
)
->
Set
(
NanNew
(
"sourceMap"
),
source_map
);
}
}
void
FillStatsObj
(
Handle
<
Object
>
stats
,
struct
Sass_File_Context
*
fctx
)
{
Handle
<
Value
>
source_map
;
struct
Sass_Context
*
ctx
=
sass_file_context_get_context
(
fctx
);
FillStatsObj
(
stats
,
ctx
);
if
(
sass_context_get_error_status
(
ctx
))
{
return
;
}
if
(
sass_context_get_source_map_string
(
ctx
))
{
source_map
=
NanNew
<
String
>
(
sass_context_get_source_map_string
(
ctx
));
}
else
{
source_map
=
NanNull
();
}
(
*
stats
)
->
Set
(
NanNew
(
"sourceMap"
),
source_map
);
}
void
MakeCallback
(
uv_work_t
*
req
)
{
void
MakeCallback
(
uv_work_t
*
req
)
{
NanScope
();
NanScope
();
...
@@ -176,13 +153,13 @@ NAN_METHOD(RenderSync) {
...
@@ -176,13 +153,13 @@ NAN_METHOD(RenderSync) {
if
(
sass_context_get_error_status
(
ctx
)
==
0
)
{
if
(
sass_context_get_error_status
(
ctx
)
==
0
)
{
Local
<
String
>
output
=
NanNew
<
String
>
(
sass_context_get_output_string
(
ctx
));
Local
<
String
>
output
=
NanNew
<
String
>
(
sass_context_get_output_string
(
ctx
));
fre
e_data_context
(
dctx
);
sass_delet
e_data_context
(
dctx
);
NanReturnValue
(
output
);
NanReturnValue
(
output
);
}
}
Local
<
String
>
error
=
NanNew
<
String
>
(
sass_context_get_error_json
(
ctx
));
Local
<
String
>
error
=
NanNew
<
String
>
(
sass_context_get_error_json
(
ctx
));
fre
e_data_context
(
dctx
);
sass_delet
e_data_context
(
dctx
);
NanThrowError
(
error
);
NanThrowError
(
error
);
NanReturnUndefined
();
NanReturnUndefined
();
...
@@ -200,8 +177,8 @@ NAN_METHOD(RenderFile) {
...
@@ -200,8 +177,8 @@ NAN_METHOD(RenderFile) {
ExtractOptions
(
options
,
fctx
,
ctx_w
,
true
);
ExtractOptions
(
options
,
fctx
,
ctx_w
,
true
);
int
status
=
uv_queue_work
(
uv_default_loop
(),
&
ctx_w
->
request
,
compile_it
,
(
uv_after_work_cb
)
MakeCallback
);
int
status
=
uv_queue_work
(
uv_default_loop
(),
&
ctx_w
->
request
,
compile_it
,
(
uv_after_work_cb
)
MakeCallback
);
assert
(
status
==
0
);
assert
(
status
==
0
);
free
(
input_path
);
free
(
input_path
);
NanReturnUndefined
();
NanReturnUndefined
();
...
@@ -218,19 +195,18 @@ NAN_METHOD(RenderFileSync) {
...
@@ -218,19 +195,18 @@ NAN_METHOD(RenderFileSync) {
ExtractOptions
(
options
,
fctx
,
NULL
,
true
);
ExtractOptions
(
options
,
fctx
,
NULL
,
true
);
compile_file
(
fctx
);
compile_file
(
fctx
);
FillStatsObj
(
options
->
Get
(
NanNew
(
"stats"
))
->
ToObject
(),
ctx
);
FillStatsObj
(
options
->
Get
(
NanNew
(
"stats"
))
->
ToObject
(),
ctx
);
free
(
input_path
);
free
(
input_path
);
if
(
sass_context_get_error_status
(
ctx
)
==
0
)
{
if
(
sass_context_get_error_status
(
ctx
)
==
0
)
{
Local
<
String
>
output
=
NanNew
<
String
>
(
sass_context_get_output_string
(
ctx
));
Local
<
String
>
output
=
NanNew
<
String
>
(
sass_context_get_output_string
(
ctx
));
fre
e_file_context
(
fctx
);
sass_delet
e_file_context
(
fctx
);
NanReturnValue
(
output
);
NanReturnValue
(
output
);
}
}
Local
<
String
>
error
=
NanNew
<
String
>
(
sass_context_get_error_json
(
ctx
));
Local
<
String
>
error
=
NanNew
<
String
>
(
sass_context_get_error_json
(
ctx
));
fre
e_file_context
(
fctx
);
sass_delet
e_file_context
(
fctx
);
NanThrowError
(
error
);
NanThrowError
(
error
);
NanReturnUndefined
();
NanReturnUndefined
();
...
...
src/sass_context_wrapper.cpp
View file @
a8c67109
...
@@ -14,34 +14,22 @@ extern "C" {
...
@@ -14,34 +14,22 @@ extern "C" {
}
}
void
compile_data
(
struct
Sass_Data_Context
*
dctx
)
{
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
);
sass_compile_data_context
(
dctx
);
}
}
void
compile_file
(
struct
Sass_File_Context
*
fctx
)
{
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
);
sass_compile_file_context
(
fctx
);
}
}
void
free_data_context
(
struct
Sass_Data_Context
*
dctx
)
{
sass_delete_data_context
(
dctx
);
}
void
free_file_context
(
struct
Sass_File_Context
*
fctx
)
{
sass_delete_file_context
(
fctx
);
}
sass_context_wrapper
*
sass_make_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
->
dctx
)
{
if
(
ctx_w
->
dctx
)
{
fre
e_data_context
(
ctx_w
->
dctx
);
sass_delet
e_data_context
(
ctx_w
->
dctx
);
}
else
if
(
ctx_w
->
fctx
)
{
}
else
if
(
ctx_w
->
fctx
)
{
fre
e_file_context
(
ctx_w
->
fctx
);
sass_delet
e_file_context
(
ctx_w
->
fctx
);
}
}
NanDisposePersistent
(
ctx_w
->
stats
);
NanDisposePersistent
(
ctx_w
->
stats
);
...
...
src/sass_context_wrapper.h
View file @
a8c67109
...
@@ -10,8 +10,6 @@ using namespace v8;
...
@@ -10,8 +10,6 @@ using namespace v8;
void
compile_data
(
struct
Sass_Data_Context
*
dctx
);
void
compile_data
(
struct
Sass_Data_Context
*
dctx
);
void
compile_file
(
struct
Sass_File_Context
*
fctx
);
void
compile_file
(
struct
Sass_File_Context
*
fctx
);
void
compile_it
(
uv_work_t
*
req
);
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_Data_Context
*
dctx
;
Sass_Data_Context
*
dctx
;
...
...
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