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
36fb64ab
Commit
36fb64ab
authored
Aug 28, 2015
by
Marcin Cieslak
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'libcxx609'
parents
c6c67acc
d178927f
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
43 additions
and
27 deletions
+43
-27
binding.gyp
binding.gyp
+1
-4
binding.cpp
src/binding.cpp
+7
-6
callback_bridge.h
src/callback_bridge.h
+17
-10
custom_function_bridge.cpp
src/custom_function_bridge.cpp
+1
-0
custom_function_bridge.h
src/custom_function_bridge.h
+1
-1
custom_importer_bridge.cpp
src/custom_importer_bridge.cpp
+1
-0
custom_importer_bridge.h
src/custom_importer_bridge.h
+1
-1
sass_context_wrapper.cpp
src/sass_context_wrapper.cpp
+12
-2
sass_context_wrapper.h
src/sass_context_wrapper.h
+2
-3
No files found.
binding.gyp
View file @
36fb64ab
...
@@ -57,12 +57,10 @@
...
@@ -57,12 +57,10 @@
['OS=="mac"', {
['OS=="mac"', {
'xcode_settings': {
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS': [
'OTHER_CPLUSPLUSFLAGS': [
'-std=c++11',
'-std=c++11'
'-stdlib=libc++'
],
],
'OTHER_LDFLAGS': [],
'OTHER_LDFLAGS': [],
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'GCC_ENABLE_CPP_RTTI': 'YES',
'MACOSX_DEPLOYMENT_TARGET': '10.7'
'MACOSX_DEPLOYMENT_TARGET': '10.7'
}
}
}],
}],
...
@@ -70,7 +68,6 @@
...
@@ -70,7 +68,6 @@
'msvs_settings': {
'msvs_settings': {
'VCCLCompilerTool': {
'VCCLCompilerTool': {
'AdditionalOptions': [
'AdditionalOptions': [
'/GR',
'/EHsc'
'/EHsc'
]
]
}
}
...
...
src/binding.cpp
View file @
36fb64ab
...
@@ -123,11 +123,12 @@ int ExtractOptions(v8::Local<v8::Object> options, void* cptr, sass_context_wrapp
...
@@ -123,11 +123,12 @@ int ExtractOptions(v8::Local<v8::Object> options, void* cptr, sass_context_wrapp
if
(
importer_callback
->
IsFunction
())
{
if
(
importer_callback
->
IsFunction
())
{
v8
::
Local
<
v8
::
Function
>
importer
=
importer_callback
.
As
<
v8
::
Function
>
();
v8
::
Local
<
v8
::
Function
>
importer
=
importer_callback
.
As
<
v8
::
Function
>
();
auto
bridge
=
std
::
make_shared
<
CustomImporterBridge
>
(
new
Nan
::
Callback
(
importer
),
ctx_w
->
is_sync
);
CustomImporterBridge
*
bridge
=
new
CustomImporterBridge
(
importer
,
ctx_w
->
is_sync
);
ctx_w
->
importer_bridges
.
push_back
(
bridge
);
ctx_w
->
importer_bridges
.
push_back
(
bridge
);
Sass_Importer_List
c_importers
=
sass_make_importer_list
(
1
);
Sass_Importer_List
c_importers
=
sass_make_importer_list
(
1
);
c_importers
[
0
]
=
sass_make_importer
(
sass_importer
,
0
,
bridge
.
get
()
);
c_importers
[
0
]
=
sass_make_importer
(
sass_importer
,
0
,
bridge
);
sass_option_set_c_importers
(
sass_options
,
c_importers
);
sass_option_set_c_importers
(
sass_options
,
c_importers
);
}
}
...
@@ -138,10 +139,10 @@ int ExtractOptions(v8::Local<v8::Object> options, void* cptr, sass_context_wrapp
...
@@ -138,10 +139,10 @@ int ExtractOptions(v8::Local<v8::Object> options, void* cptr, sass_context_wrapp
for
(
size_t
i
=
0
;
i
<
importers
->
Length
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
importers
->
Length
();
++
i
)
{
v8
::
Local
<
v8
::
Function
>
callback
=
v8
::
Local
<
v8
::
Function
>::
Cast
(
Nan
::
Get
(
importers
,
static_cast
<
uint32_t
>
(
i
)).
ToLocalChecked
());
v8
::
Local
<
v8
::
Function
>
callback
=
v8
::
Local
<
v8
::
Function
>::
Cast
(
Nan
::
Get
(
importers
,
static_cast
<
uint32_t
>
(
i
)).
ToLocalChecked
());
auto
bridge
=
std
::
make_shared
<
CustomImporterBridge
>
(
new
Nan
::
Callback
(
callback
)
,
ctx_w
->
is_sync
);
CustomImporterBridge
*
bridge
=
new
CustomImporterBridge
(
callback
,
ctx_w
->
is_sync
);
ctx_w
->
importer_bridges
.
push_back
(
bridge
);
ctx_w
->
importer_bridges
.
push_back
(
bridge
);
c_importers
[
i
]
=
sass_make_importer
(
sass_importer
,
importers
->
Length
()
-
i
-
1
,
bridge
.
get
()
);
c_importers
[
i
]
=
sass_make_importer
(
sass_importer
,
importers
->
Length
()
-
i
-
1
,
bridge
);
}
}
sass_option_set_c_importers
(
sass_options
,
c_importers
);
sass_option_set_c_importers
(
sass_options
,
c_importers
);
...
@@ -159,10 +160,10 @@ int ExtractOptions(v8::Local<v8::Object> options, void* cptr, sass_context_wrapp
...
@@ -159,10 +160,10 @@ int ExtractOptions(v8::Local<v8::Object> options, void* cptr, sass_context_wrapp
v8
::
Local
<
v8
::
String
>
signature
=
v8
::
Local
<
v8
::
String
>::
Cast
(
Nan
::
Get
(
signatures
,
Nan
::
New
(
i
)).
ToLocalChecked
());
v8
::
Local
<
v8
::
String
>
signature
=
v8
::
Local
<
v8
::
String
>::
Cast
(
Nan
::
Get
(
signatures
,
Nan
::
New
(
i
)).
ToLocalChecked
());
v8
::
Local
<
v8
::
Function
>
callback
=
v8
::
Local
<
v8
::
Function
>::
Cast
(
Nan
::
Get
(
functions
,
signature
).
ToLocalChecked
());
v8
::
Local
<
v8
::
Function
>
callback
=
v8
::
Local
<
v8
::
Function
>::
Cast
(
Nan
::
Get
(
functions
,
signature
).
ToLocalChecked
());
auto
bridge
=
std
::
make_shared
<
CustomFunctionBridge
>
(
new
Nan
::
Callback
(
callback
)
,
ctx_w
->
is_sync
);
CustomFunctionBridge
*
bridge
=
new
CustomFunctionBridge
(
callback
,
ctx_w
->
is_sync
);
ctx_w
->
function_bridges
.
push_back
(
bridge
);
ctx_w
->
function_bridges
.
push_back
(
bridge
);
Sass_Function_Entry
fn
=
sass_make_function
(
create_string
(
signature
),
sass_custom_function
,
bridge
.
get
()
);
Sass_Function_Entry
fn
=
sass_make_function
(
create_string
(
signature
),
sass_custom_function
,
bridge
);
sass_function_set_list_entry
(
fn_list
,
i
,
fn
);
sass_function_set_list_entry
(
fn_list
,
i
,
fn
);
}
}
...
...
src/callback_bridge.h
View file @
36fb64ab
...
@@ -3,15 +3,15 @@
...
@@ -3,15 +3,15 @@
#include <vector>
#include <vector>
#include <nan.h>
#include <nan.h>
#include <condition_variable>
#include <algorithm>
#include <algorithm>
#include <uv.h>
#define COMMA ,
#define COMMA ,
template
<
typename
T
,
typename
L
=
void
*>
template
<
typename
T
,
typename
L
=
void
*>
class
CallbackBridge
{
class
CallbackBridge
{
public
:
public
:
CallbackBridge
(
Nan
::
Callback
*
,
bool
);
CallbackBridge
(
v8
::
Local
<
v8
::
Function
>
,
bool
);
virtual
~
CallbackBridge
();
virtual
~
CallbackBridge
();
// Executes the callback
// Executes the callback
...
@@ -42,8 +42,8 @@ class CallbackBridge {
...
@@ -42,8 +42,8 @@ class CallbackBridge {
Nan
::
Callback
*
callback
;
Nan
::
Callback
*
callback
;
bool
is_sync
;
bool
is_sync
;
std
::
mutex
cv_mutex
;
uv_mutex_t
cv_mutex
;
std
::
condition_variable
condition_variable
;
uv_cond_t
condition_variable
;
uv_async_t
*
async
;
uv_async_t
*
async
;
std
::
vector
<
L
>
argv
;
std
::
vector
<
L
>
argv
;
bool
has_returned
;
bool
has_returned
;
...
@@ -54,12 +54,14 @@ template <typename T, typename L>
...
@@ -54,12 +54,14 @@ template <typename T, typename L>
Nan
::
Persistent
<
v8
::
Function
>
CallbackBridge
<
T
,
L
>::
wrapper_constructor
;
Nan
::
Persistent
<
v8
::
Function
>
CallbackBridge
<
T
,
L
>::
wrapper_constructor
;
template
<
typename
T
,
typename
L
>
template
<
typename
T
,
typename
L
>
CallbackBridge
<
T
,
L
>::
CallbackBridge
(
Nan
::
Callback
*
callback
,
bool
is_sync
)
:
callback
(
callback
),
is_sync
(
is_sync
)
{
CallbackBridge
<
T
,
L
>::
CallbackBridge
(
v8
::
Local
<
v8
::
Function
>
callback
,
bool
is_sync
)
:
callback
(
new
Nan
::
Callback
(
callback
)
),
is_sync
(
is_sync
)
{
/*
/*
* This is invoked from the main JavaScript thread.
* This is invoked from the main JavaScript thread.
* V8 context is available.
* V8 context is available.
*/
*/
Nan
::
HandleScope
scope
;
Nan
::
HandleScope
scope
;
uv_mutex_init
(
&
this
->
cv_mutex
);
uv_cond_init
(
&
this
->
condition_variable
);
if
(
!
is_sync
)
{
if
(
!
is_sync
)
{
this
->
async
=
new
uv_async_t
;
this
->
async
=
new
uv_async_t
;
this
->
async
->
data
=
(
void
*
)
this
;
this
->
async
->
data
=
(
void
*
)
this
;
...
@@ -75,6 +77,8 @@ template <typename T, typename L>
...
@@ -75,6 +77,8 @@ template <typename T, typename L>
CallbackBridge
<
T
,
L
>::~
CallbackBridge
()
{
CallbackBridge
<
T
,
L
>::~
CallbackBridge
()
{
delete
this
->
callback
;
delete
this
->
callback
;
this
->
wrapper
.
Reset
();
this
->
wrapper
.
Reset
();
uv_cond_destroy
(
&
this
->
condition_variable
);
uv_mutex_destroy
(
&
this
->
cv_mutex
);
if
(
!
is_sync
)
{
if
(
!
is_sync
)
{
uv_close
((
uv_handle_t
*
)
this
->
async
,
&
async_gone
);
uv_close
((
uv_handle_t
*
)
this
->
async
,
&
async_gone
);
...
@@ -117,11 +121,13 @@ T CallbackBridge<T, L>::operator()(std::vector<void*> argv) {
...
@@ -117,11 +121,13 @@ T CallbackBridge<T, L>::operator()(std::vector<void*> argv) {
*/
*/
this
->
argv
=
argv
;
this
->
argv
=
argv
;
std
::
unique_lock
<
std
::
mutex
>
lock
(
this
->
cv_mutex
);
uv_mutex_lock
(
&
this
->
cv_mutex
);
this
->
has_returned
=
false
;
this
->
has_returned
=
false
;
uv_async_send
(
this
->
async
);
uv_async_send
(
this
->
async
);
this
->
condition_variable
.
wait
(
lock
,
[
this
]
{
return
this
->
has_returned
;
});
while
(
!
this
->
has_returned
)
{
uv_cond_wait
(
&
this
->
condition_variable
,
&
this
->
cv_mutex
);
}
uv_mutex_unlock
(
&
this
->
cv_mutex
);
return
this
->
return_value
;
return
this
->
return_value
;
}
}
}
}
...
@@ -168,11 +174,12 @@ NAN_METHOD(CallbackBridge<T COMMA L>::ReturnCallback) {
...
@@ -168,11 +174,12 @@ NAN_METHOD(CallbackBridge<T COMMA L>::ReturnCallback) {
bridge
->
return_value
=
bridge
->
post_process_return_value
(
info
[
0
]);
bridge
->
return_value
=
bridge
->
post_process_return_value
(
info
[
0
]);
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
bridge
->
cv_mutex
);
uv_mutex_lock
(
&
bridge
->
cv_mutex
);
bridge
->
has_returned
=
true
;
bridge
->
has_returned
=
true
;
uv_mutex_unlock
(
&
bridge
->
cv_mutex
);
}
}
bridge
->
condition_variable
.
notify_all
(
);
uv_cond_broadcast
(
&
bridge
->
condition_variable
);
if
(
try_catch
.
HasCaught
())
{
if
(
try_catch
.
HasCaught
())
{
Nan
::
FatalException
(
try_catch
);
Nan
::
FatalException
(
try_catch
);
...
...
src/custom_function_bridge.cpp
View file @
36fb64ab
#include <nan.h>
#include <nan.h>
#include <stdexcept>
#include "custom_function_bridge.h"
#include "custom_function_bridge.h"
#include "sass_types/factory.h"
#include "sass_types/factory.h"
...
...
src/custom_function_bridge.h
View file @
36fb64ab
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
class
CustomFunctionBridge
:
public
CallbackBridge
<
Sass_Value
*>
{
class
CustomFunctionBridge
:
public
CallbackBridge
<
Sass_Value
*>
{
public
:
public
:
CustomFunctionBridge
(
Nan
::
Callback
*
cb
,
bool
is_sync
)
:
CallbackBridge
<
Sass_Value
*>
(
cb
,
is_sync
)
{}
CustomFunctionBridge
(
v8
::
Local
<
v8
::
Function
>
cb
,
bool
is_sync
)
:
CallbackBridge
<
Sass_Value
*>
(
cb
,
is_sync
)
{}
private
:
private
:
Sass_Value
*
post_process_return_value
(
v8
::
Local
<
v8
::
Value
>
)
const
;
Sass_Value
*
post_process_return_value
(
v8
::
Local
<
v8
::
Value
>
)
const
;
...
...
src/custom_importer_bridge.cpp
View file @
36fb64ab
#include <nan.h>
#include <nan.h>
#include <stdexcept>
#include "custom_importer_bridge.h"
#include "custom_importer_bridge.h"
#include "create_string.h"
#include "create_string.h"
...
...
src/custom_importer_bridge.h
View file @
36fb64ab
...
@@ -9,7 +9,7 @@ typedef Sass_Import_List SassImportList;
...
@@ -9,7 +9,7 @@ typedef Sass_Import_List SassImportList;
class
CustomImporterBridge
:
public
CallbackBridge
<
SassImportList
>
{
class
CustomImporterBridge
:
public
CallbackBridge
<
SassImportList
>
{
public
:
public
:
CustomImporterBridge
(
Nan
::
Callback
*
cb
,
bool
is_sync
)
:
CallbackBridge
<
SassImportList
>
(
cb
,
is_sync
)
{}
CustomImporterBridge
(
v8
::
Local
<
v8
::
Function
>
cb
,
bool
is_sync
)
:
CallbackBridge
<
SassImportList
>
(
cb
,
is_sync
)
{}
private
:
private
:
SassImportList
post_process_return_value
(
v8
::
Local
<
v8
::
Value
>
)
const
;
SassImportList
post_process_return_value
(
v8
::
Local
<
v8
::
Value
>
)
const
;
...
...
src/sass_context_wrapper.cpp
View file @
36fb64ab
...
@@ -46,8 +46,18 @@ extern "C" {
...
@@ -46,8 +46,18 @@ extern "C" {
free
(
ctx_w
->
source_map_root
);
free
(
ctx_w
->
source_map_root
);
free
(
ctx_w
->
indent
);
free
(
ctx_w
->
indent
);
ctx_w
->
importer_bridges
.
resize
(
0
);
std
::
vector
<
CustomImporterBridge
*>::
iterator
imp_it
=
ctx_w
->
importer_bridges
.
begin
();
ctx_w
->
function_bridges
.
resize
(
0
);
while
(
imp_it
!=
ctx_w
->
importer_bridges
.
end
())
{
CustomImporterBridge
*
p
=
*
imp_it
;
imp_it
=
ctx_w
->
importer_bridges
.
erase
(
imp_it
);
delete
p
;
}
std
::
vector
<
CustomFunctionBridge
*>::
iterator
func_it
=
ctx_w
->
function_bridges
.
begin
();
while
(
func_it
!=
ctx_w
->
function_bridges
.
end
())
{
CustomFunctionBridge
*
p
=
*
func_it
;
func_it
=
ctx_w
->
function_bridges
.
erase
(
func_it
);
delete
p
;
}
free
(
ctx_w
);
free
(
ctx_w
);
}
}
...
...
src/sass_context_wrapper.h
View file @
36fb64ab
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
#include <memory>
#include <memory>
#include <nan.h>
#include <nan.h>
#include <stdlib.h>
#include <stdlib.h>
#include <condition_variable>
#include <sass_context.h>
#include <sass_context.h>
#include "custom_function_bridge.h"
#include "custom_function_bridge.h"
#include "custom_importer_bridge.h"
#include "custom_importer_bridge.h"
...
@@ -43,8 +42,8 @@ extern "C" {
...
@@ -43,8 +42,8 @@ extern "C" {
Nan
::
Callback
*
error_callback
;
Nan
::
Callback
*
error_callback
;
Nan
::
Callback
*
success_callback
;
Nan
::
Callback
*
success_callback
;
std
::
vector
<
std
::
shared_ptr
<
CustomFunctionBridge
>
>
function_bridges
;
std
::
vector
<
CustomFunctionBridge
*
>
function_bridges
;
std
::
vector
<
std
::
shared_ptr
<
CustomImporterBridge
>
>
importer_bridges
;
std
::
vector
<
CustomImporterBridge
*
>
importer_bridges
;
};
};
struct
sass_context_wrapper
*
sass_make_context_wrapper
(
void
);
struct
sass_context_wrapper
*
sass_make_context_wrapper
(
void
);
...
...
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