nodejs / nan Goto Github PK
View Code? Open in Web Editor NEWNative Abstractions for Node.js
License: MIT License
Native Abstractions for Node.js
License: MIT License
Assuming everything works consistently, it is time to release.
In README.md, NanUInt32OptionValue is documented as:
uint32_t NanUInt32OptionValue(v8::Handle<v8::Value>, v8::Handle<v8::String>[, uint32_t])
Similar to NanBooleanOptionValue
, use NanUInt32OptionValue
to fetch an integer option from your options object. Requires all 3 arguments as a default is not optional.
As the default is not optional, shouldn't it be documented as
uint32_t NanUInt32OptionValue(v8::Handle<v8::Value>, v8::Handle<v8::String>, uint32_t)?
@kkoopa would you mind adding documentation for the new NanFromV8String()
arguments please? I'm pretty sure you have a much better handle on what's going on there than I. Also, short docs for NanGetPointerSafe()
and NanSetPointerSafe()
would be nice too.
I'm tidying up 0.2.0 and will merge to master in a moment for a "release", so just do it straight in master when that's done.
It's not really possible right now to find out if a callback has been assigned. Suggestion: add a bool NanCallback::IsEmpty() const
method
I say 'not really' because while in theory you can do nan_callback->GetFunction()->IsFunction()
, that will assert in debug builds because of the cast from Undefined to Function.
I'm not sure if this is a NAN issue or something in v8, but I have the following problem on node v0.11.9.
I am defining a method through NAN as follows (pretty standard):
#include <node.h>
#include "nan.h"
NAN_METHOD(my_function)
{
printf("Ran my function.\n");
}
void Init(Handle<Object> exports)
{
exports->Set(NanSymbol("my_function"),
FunctionTemplate::New(my_function)->GetFunction());
}
NODE_MODULE(my_module, Init)
Now, if I load this module and use it as the callback to Object.observe
, I get the following somewhat weird behavior:
var my_module = require('my_module');
console.log(my_module.my_function); // Prints "[Function]", as expected
my_module.my_function(); // Prints "Ran my function."
// Create a dummy object
var foo = {}
// Let's hook up an observer to my object
Object.observe(foo, my_module.my_function);
foo.bar = true; // change object
// Nothing happens! my_function isn't called, and no exception is thrown
// Ok, let's just wrap the same function in an anonymous function
Object.observe(foo, function(changes) { my_module.my_function(changes); } );
foo.baz = true; // change object
// Prints "Ran my function."
Other than Object.observe
, anything else I can think to do with my_function
works normally. Any ideas what this could be?
I want to execute the NanAsyncWorker again after HandleOKCallback, to do a async loop.
For example to read from a device ;-)
How would you recommend to do that? Sorry I'm not really good in C++... :-(
PS. thanks for nan, it's cool...
This fails for me on Nan 1.0.0 and Node 0.10 (it does not cause problems on Node 0.11)
Could you give me any tip?
(...)
v8::Local<v8::Function> fun = funTpl->GetFunction();
(...)
fun = NanMakeCallback(fun, bind, 1, argv).As<v8::Function>();
error: no match for ‘operator=’ (operand types are ‘v8::Local<v8::Function>’ and ‘v8::Handle<v8::Function>’)
fun = NanMakeCallback(fun, bind, 1, argv).As<v8::Function>();
nan
already have an alias NanSymbol
for v8::String::NewSymbol
, is it convenient to have NanString
for v8::String::New
?
The upgrade to V8 3.24 just landed in joyent/node (good) and that means nan needs to upgrade as well (bad). The main changes:
Persistent<T>::MakeWeak()
is replaced with Persistent<T>::SetWeak()
(and the callback takes a single argument.)Array::New()
, FunctionTemplate::New()
, Object::New()
take an isolate as their first argument.Integer::New(value, isolate)
is now Integer::New(isolate, value)
(arguments have been swapped)String::New(s)
is gone, replaced with String::NewFromUtf8Value(isolate, s)
.Thoughts on how to upgrade? Do we want to keep on supporting older node.js v0.11 (a.k.a. V8 3.22) versions?
v0.11 added proper support for using the original char*
by adding node::Buffer::Use()
.
The same effect can be accomplished pre-v0.11 by passing a callback to Buffer::New()
and just freeing the data passed to the callback. For an example check out the use of SessionDataFree
here: https://github.com/joyent/node/blob/v0.10/src/node_crypto.cc#L271-L294
There have been some changes to libuv as well. uv_idle_cb
and others have had the status argument removed. Might be other breaking changes as well. Should we address this somehow?
0.11.11 was just released so I added it to .dntrc and ran the tests ... then this ... I don't even ...
I don't have time to even begin to understand what's going on with this or whether it's even a NAN problem.
asyncworker.cpp
, asyncworkererror.cpp
, bufferworkerpersistent.cpp
are currently not cross-compatible due to usleep()
function. Nothing important I think, but maybe this can be fixed for the next release.
I know it's not officially supported, but everything seemed to work nicely previously. I've figured out that MakeCallback used to be a whole lot different in 0.6. Can we add something to rectify this deviation, at least until 0.12 is released?
void MakeCallback(Handle<Object> object,
const char* method,
int argc,
Handle<Value> argv[]) {
HandleScope scope;
Local<Value> callback_v = object->Get(String::New(method));
if (!callback_v->IsFunction()) {
fprintf(stderr, "method = %s", method);
}
assert(callback_v->IsFunction());
Local<Function> callback = Local<Function>::Cast(callback_v);
// TODO Hook for long stack traces to be made here.
TryCatch try_catch;
callback->Call(object, argc, argv);
if (try_catch.HasCaught()) {
FatalException(try_catch);
}
}
This is error was found in module geoip
, the original issue can be found in here.
Quoted from original issue
We are experiencing a new error (very infrequently) since upgrading to node v0.10.22. The following message is displayed and the process exits immediately.
node: /opt/pre-publish/star/node_modules/orion/node_modules/geoip/node_modules/nan/nan.h:809: bool _NanGetExternalParts(v8::Handle<v8::Value>, const char**, size_t*): Assertion `val->IsString()' failed.
Aborted
I suspect it may have something to do with the infamous WalMart memory leak on closed handles fix.
Hi,
first, this project is awesome! I'm a hobbyist programmer, writing a node addon. What do you think about a NanSetPrototypeTemplate() helper function?
NAN_INLINE void NanSetPrototypeTemplate(
v8::Handle<v8::Template> templ
, const char *name
, v8::Handle<v8::Data> value) {
templ->PrototypeTemplate()->Set(name, value);
}
Kind of related to #29, as NanFromV8String
is the only converter. This could be helpful to have converters from
and to
V8 for primitives in both worlds.
Taking example from: https://github.com/rectalogic/v8-webgl/blob/420977691cb07efd956146443d61f23f5b5dcf53/src/converters.h, it could use of templates.
For the string
case, this could be for c-strings
:
char* str = NanFromV8<char*>(v8Str);
// opposite
v8::Handle<v8::Value> v8Str = NanToV8(str);
and this for std::string
:
std::string = NanFromV8<std::string>(v8Str);
// opposite
v8::Handle<v8::Value> v8Str = NanToV8(str);
Templates would be available for all useful primitives: char
, int
, uint8_t
, uint64_t
, ...
Would you be interested in a pull request for that?
I had such code that was previously working okay:
Handle<Object> obj; = NanNew<Object>();
return obj;
Now I wanted to transform it to the new NanEscapeScope
as advised by @kkoopa:
NanEscapableScope();
Handle<Object> obj; = NanNew<Object>();
return NanEscapeScope(obj);
but this triggers an errors because NanEscapeScope takes only Local
handles.
I had to do:
NanEscapableScope();
Local<Object> obj; = NanNew<Object>();
return NanEscapeScope(obj);
Shouldn't NanEscapeScope take Handle? It will automatically work for Local as well.
Two things are going to kick you:
utf8
is going to kill performance. I might allow users to pass enum encoding
in node.h
to allow a specific encoding output.memcpy
.A lot of this is properly addressed in node::StringBytes::Encode
. But since that doesn't exist pre v0.11, maybe just use it for a reference.
This API really bothers me:
# define NAN_WEAK_CALLBACK(type, name) \
void name( \
v8::Isolate* isolate \
, v8::Persistent<v8::Object>* object \
, type data)
# define NAN_WEAK_CALLBACK_OBJECT (*object)
# define NAN_WEAK_CALLBACK_DATA(type) ((type) data)
...
# define NanAssignPersistent(type, handle, obj) handle.Reset(nan_isolate, obj)
# define NanInitPersistent(type, name, obj) \
v8::Persistent<type> name(nan_isolate, obj)
Supplying a "type" argument is a style-smell. As far as I'm aware there isn't a clever way to make a macro accept a generic type parameter so perhaps these things should be turned into proper functions? Of the template<class T> static NAN_INLINE(...)
variety.
Thoughts? It'd mean API breakage but it feels odd whenever I have to put the type as an argument like that.
If you try to pass in a NAN_WEAK_CALLBACK function to NanNewBufferHandle()
, then you get a build error. The actual function signature looks like:
void fn(char *data, void *hint)
This issue is to correct the documentation, most likely.
I like what you are doing here. Unfortunately there is still a huge amount of cruft one has to write manually to do simple things. Do you think there is a will to have some kind of high level wrapper over all those APIs to do common tasks like exposing native objects?
I have been going from leveldown codebase and I am amazed you are able to even maintain it because there is more v8 bindings then actual code. :) I was thinking one could do much better with wrapping around those APIs, particularly utilizing C++11. Did you have any thoughts in this area?
Hi,
I'm trying to use nan for sophia binary addon. I use NanCallback
with async workers and have been running into the following crash:
dyld: lazy symbol binding failed: Symbol not found: __ZN6sophia3SetEPvPKvmS2_mP11NanCallback
Referenced from: /Users/maciej/dev/js/sophia/build/Debug/sophia.node
Expected in: dynamic lookup
dyld: Symbol not found: __ZN6sophia3SetEPvPKvmS2_mP11NanCallback
Referenced from: /Users/maciej/dev/js/sophia/build/Debug/sophia.node
Expected in: dynamic lookup
Trace/BPT trap: 5
Piece of code which (I think) is responsible for that:
sophia::Set(
wrap->db,
key,
strlen(key),
value,
strlen(value),
new NanCallback(callback)
);
NanReturnUndefined();
Which is weird, since I use the exact same invocation of NanCallback
somewhere else in the same file and it works.
Full code is here, the piece of code in question is here.
Way to reproduce (works on node 0.10):
git clone https://github.com/mmalecki/node-sophia.git
cd node-sophia
git checkout put
npm i
node test/simple-test.js
Hi,
I am looking at passing a V8 Buffer args[1].As<v8::Object>()
to a char
cannot seem to find an easy way to do so.
I am fairly new to working with v8 and libuv so I assume that this would be a valid use case.
I would appreciate any insight into this,
Thanks
#include "nan.h"
#include "v8.h"
NAN_WEAK_CALLBACK(WeakCallback) {
}
void Test() {
NanMakeWeakPersistent(NanNew<v8::Object>(), "", WeakCallback);
}
Compiles okay with node.js master but fails with v0.10:
$ g++-4.2 -Wall -Wextra -Wno-unused-parameter -I$PWD -I../v0.10/src -I../v0.10/deps/uv/include -I../v0.10/deps/v8/include -c tmp/t.cc
tmp/t.cc: In function ‘void Test()’:
tmp/t.cc:8: error: no matches converting function ‘WeakCallback’ to type ‘void (*)(struct v8::Persistent<v8::Value>, void*)’
tmp/t.cc:4: error: candidates are: template<class T, class P> void WeakCallback(v8::Persistent<v8::Value>, void*)
$ g++-4.8 -Wall -Wextra -Wno-unused-parameter -I$PWD -I../v0.10/src -I../v0.10/deps/uv/include -I../v0.10/deps/v8/include -c tmp/t.cc
tmp/t.cc: In function 'void Test()':
tmp/t.cc:8:63: error: no matches converting function 'WeakCallback' to type '_NanWeakCallbackInfo<v8::Object, const char>::Callback {aka void (*)(class v8::Persistent<v8::Value>, void*)}'
NanMakeWeakPersistent(NanNew<v8::Object>(), "", WeakCallback);
^
In file included from tmp/t.cc:1:0:
tmp/t.cc:4:19: note: candidate is: template<class T, class P> void WeakCallback(v8::Persistent<v8::Value>, void*)
NAN_WEAK_CALLBACK(WeakCallback) {
^
/Users/bnoordhuis/src/nan/nan.h:1393:17: note: in definition of macro 'NAN_WEAK_CALLBACK'
static void name( \
Affects 1.0.0 and master. I suggest doing a 1.0.1 point release for this.
On a related note, opinions on making _Nan_Weak_Callback_ ## name
static in 1.0.x, like it is in master? You currently can't use NAN_WEAK_CALLBACK() inside a class.
Please tag release 0.3.2 (if it is already released). I am currently preparing this project as a Debian package and for proper upstream versioning in Debian I rely on Git tags of upstream projects pulled from Github.
Thanks!
Mike (aka [email protected])
errmsg
is defined as const char*
here, yet we call delete
on it here. That's okay, but I think that in most cases errmsg
is set like errmsg = "Not found"
, in which case trying to free
it causes:
*** Error in `node': free(): invalid pointer: 0x00007f4b1e2dccc7 ***
If this shouldn't be delete
d, mmalecki/nan@30c9c66 is a fix.
Trying to adapt node-snappy for NAN, I cannot get the asynchronous callbacks to work. All asynchronous tests fail with 'Callback not called', where all synchronous tests pass. What am I doing wrong?
Hi,
I generate the v8 documentation locally. Would there be a place where nodejs and other projects could link to v8 documentation online for discussion sake?
Hello,
In a C++ addon I maintain (https://github.com/santigimeno/node-unix-stream), up to version 0.8.x I was able to access the file descriptor from the uv handle by doing:
handle->fd;
Now in 0.10.x I have to do:
handle->io_watcher.fd
Would a macro abstracting this make sense in nan?
Thanks
I am looking at example of NanMakeWeakPersistent
but I fail to see the exact purpose... why and when would one need it? I have made a lot of progress in node-cbind
but I yet to touch asynchronous stuff - maybe this is the use case?
I reviewed changes of v8 and node today, and found many changes at v8-profiler.h
between with 0.10
and 0.11
. Then did we need a bundle of functions to do the compatible works? If yes, I prefer to do this ASAP, if not, I'm so sad to hear that, and do this in library-land.
:)
../src/response.cc:99:71: error: no member named 'NewInstance' in
'v8::FunctionTemplate'; did you mean 'HasInstance'?
...= NanPersistentToLocal(responseTemplate)->NewInstance();
^~~~~~~~~~~
HasInstance
Hi, I'm using nan
to improve libetpan.node to v0.11, but I get this error at this function: https://github.com/dinhviethoa/libetpan.node/blob/master/src/response.cc#L65-L86, I don't know clearly what is the culprit of this problem :(
/cc @rvagg
The inconsistency here bugs me a little, what do you guys think about deprecating NanDispose()
in favour of NanDisposePersistent()
? It can stay in the code for a while but marked NAN_DEPRECATED
.
I think we have enough for a new release. It ought to be 1.2.0 due to the addition of NanSetPrototypeTemplate
. Nothing else added, just fixes and improvements.
../node_modules/nan/nan.h: In function `v8::Local<v8::Object> NanNewBufferHandle(char*, size_t, void (*)(char*, void*), void*)':
../node_modules/nan/nan.h:1320: error: call of overloaded `NanNew(v8::Persistent<v8::Object>&)' is ambiguous
../node_modules/nan/nan.h:923: note: candidates are: v8::Local<T> NanNew(v8::Handle<T>) [with T = v8::Object]
../node_modules/nan/nan.h:944: note: v8::Local<T> NanNew(const v8::Persistent<S>&) [with T = v8::Object]
../node_modules/nan/nan.h:949: note: v8::Local<T> NanNew(P) [with T = v8::Object, P = v8::Persistent<v8::Object>]
../node_modules/nan/nan.h: In function `v8::Local<v8::Object> NanNewBufferHandle(const char*, uint32_t)':
../node_modules/nan/nan.h:1328: error: call of overloaded `NanNew(v8::Persistent<v8::Object>&)' is ambiguous
../node_modules/nan/nan.h:923: note: candidates are: v8::Local<T> NanNew(v8::Handle<T>) [with T = v8::Object]
../node_modules/nan/nan.h:944: note: v8::Local<T> NanNew(const v8::Persistent<S>&) [with T = v8::Object]
../node_modules/nan/nan.h:949: note: v8::Local<T> NanNew(P) [with T = v8::Object, P = v8::Persistent<v8::Object>]
../node_modules/nan/nan.h: In function `v8::Local<v8::Object> NanNewBufferHandle(uint32_t)':
../node_modules/nan/nan.h:1336: error: call of overloaded `NanNew(v8::Persistent<v8::Object>&)' is ambiguous
../node_modules/nan/nan.h:923: note: candidates are: v8::Local<T> NanNew(v8::Handle<T>) [with T = v8::Object]
../node_modules/nan/nan.h:944: note: v8::Local<T> NanNew(const v8::Persistent<S>&) [with T = v8::Object]
../node_modules/nan/nan.h:949: note: v8::Local<T> NanNew(P) [with T = v8::Object, P = v8::Persistent<v8::Object>]
../node_modules/nan/nan.h: In function `v8::Local<v8::Object> NanBufferUse(char*, uint32_t)':
../node_modules/nan/nan.h:1348: error: call of overloaded `NanNew(v8::Persistent<v8::Object>&)' is ambiguous
../node_modules/nan/nan.h:923: note: candidates are: v8::Local<T> NanNew(v8::Handle<T>) [with T = v8::Object]
../node_modules/nan/nan.h:944: note: v8::Local<T> NanNew(const v8::Persistent<S>&) [with T = v8::Object]
../node_modules/nan/nan.h:949: note: v8::Local<T> NanNew(P) [with T = v8::Object, P = v8::Persistent<v8::Object>]
../node_modules/nan/nan.h: In function `v8::Local<v8::Context> NanNewContextHandle(v8::ExtensionConfiguration*, v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Value>)':
../node_modules/nan/nan.h:1364: error: call of overloaded `NanNew(v8::Persistent<v8::Context>&)' is ambiguous
../node_modules/nan/nan.h:923: note: candidates are: v8::Local<T> NanNew(v8::Handle<T>) [with T = v8::Context]
../node_modules/nan/nan.h:944: note: v8::Local<T> NanNew(const v8::Persistent<S>&) [with T = v8::Context]
../node_modules/nan/nan.h:949: note: v8::Local<T> NanNew(P) [with T = v8::Context, P = v8::Persistent<v8::Context>]
../node_modules/nan/nan.h: In function `bool _NanGetExternalParts(v8::Handle<v8::Value>, const char**, size_t*)':
../node_modules/nan/nan.h:1726: error: call of overloaded `NanNew(v8::Handle<v8::String>)' is ambiguous
../node_modules/nan/nan.h:923: note: candidates are: v8::Local<T> NanNew(v8::Handle<T>) [with T = v8::String]
../node_modules/nan/nan.h:949: note: v8::Local<T> NanNew(P) [with T = v8::String, P = v8::Handle<v8::String>]
Hi,
I'm currently writing bindings for a C++ library which has a class that I want to expose to JS land, and this class has a char* buffer that I would also like to expose.
This is a problem currently because if the user does something like this:
var object = new MyPrimitiveObject();
var buffer = object.getBuffer();
buffer = null;
Then this will delete data that is owned by an object that is still active.
Would it make sense to provide a version of NanBufferUse that does not automatically free the backing data when the weak callback is called?
Basically I'm trying to figure out how to avoid the below here.
#if (NODE_MODULE_VERSION > 0x000B) /* node 0.11 */
instance->SetInternalField(0, External::New(v8::Isolate::GetCurrent(), this));
#else
instance->SetInternalField(0, External::New(this));
#endif
As you can see External::New
takes an Isolate*
for node 0.11 but not before.
I couldn't find anywhere how nan allows me to wrap this.
If it's not there yet, but would be good to have I'd be happy to PR to add something like NanExternalNew()
somehow.
Hi,
I'm using nan
and it's great :)
But today, I got stuck a couple of hours, before understanding that it came from NanFromV8String
.
When calling twice in a row NanFromV8String
with a second string shorter than the first one, the second string gets appended with old characters from the first one, as if it uses the same buffer, without null
terminating the string correctly.
For example:
char* str = NanFromV8String(String::New("hello"));
printf("%s ", str);
delete[] str;
str = NanFromV8String(String::New("hell"));
printf("%s ", str);
delete[] str;
Gives:
hello hello
However, by passing explicit parameters, this works fine:
char* str = NanFromV8String(v8Str, Nan::UTF8, NULL, NULL, 0, v8::String::HINT_MANY_WRITES_EXPECTED);
printf("%s ", str);
delete[] str;
str = NanFromV8String(v8Str, Nan::UTF8, NULL, NULL, 0, v8::String::HINT_MANY_WRITES_EXPECTED);
printf("%s ", str);
delete[] str;
If this is not the default behavior, it should be I guess, or at least be specified in the docs to avoid missunderstanding.
If there is something I do wrong, please also tell me.
Thanks!
Is it on purpose, that bufferworkerpersistent.js
test is excluded from testing? Due to tap --gc js/*-test.js
in package.json
the suffix -test
is missing.
I assume these missing symbols are due to upstream still releasing broken builds.
/home/kkoopa/dev/node-v0.11.12-linux-x64/bin/node: symbol lookup error: /home/kkoopa/dev/nan/test/build/Release/asyncworker.node: undefined symbol: _ZN4node12MakeCallbackEN2v86HandleINS0_6ObjectEEENS1_INS0_8FunctionEEEiPNS1_INS0_5ValueEEE
not ok js/asyncworker-test.js ........................... 0/1
Command: "/home/kkoopa/dev/node-v0.11.12-linux-x64/bin/node --expose-gc asyncworker-test.js"
TAP version 13
not ok 1 js/asyncworker-test.js
---
exit: 127
stderr: /home/kkoopa/dev/node-v0.11.12-linux-x64/bin/node: symbol lookup error: /home/kkoopa/dev/nan/test/build/Release/asyncworker.node: undefined symbol: _ZN4node12MakeCallbackEN2v86HandleINS0_6ObjectEEENS1_INS0_8FunctionEEEiPNS1_INS0_5ValueEEE
command: "/home/kkoopa/dev/node-v0.11.12-linux-x64/bin/node --expose-gc asyncworker-test.js"
...
1..1
# tests 1
# fail 1
Just thought I'd fire up an osx vm and try that node-snappy problem and came across this warning:
In file included from ../src/binding.cc:21:
In file included from ../src/./binding.h:26:
../src/nan.h:706:46: warning: variable 'sz_' is uninitialized when used here
[-Wuninitialized]
sz_ = _nan_base64_decoded_size(*value, sz_);
^~~
../src/nan.h:673:13: note: initialize the variable 'sz_' to silence this warning
size_t sz_;
^
= 0
1 warning generated.
I looked at https://travis-ci.org/rvagg/nan and saw, that the last build is 5 month ago. Is there somthing corrupt with Travis access to the nan repo? And further what about adding badges to the Readme file?
Doing #123 probably screwed this over, the declaration probably gets interpreted as a definition, causing the actual definition to become a redefinition.
I don't know a good way to fix this, breaking it up into multiple macros seems ugly.
I tried this and it doesn't work, because Worker
is destroyed when it's done.
For some months, I've been thinking of writing a small tool to do semi-automatic porting of existing code to NAN, but I have not yet found the time or motivation. I have, however, constructed a set of regular expression substitutions, which I use myself when porting code, among with a good text editor. These substitutions deal with most of the common cases that can be done without much or any manual intervention.
The regular expressions need to be evaluated in the order provided and some of them (the scope.Close()
thing) may produce false positives and are better done interactively. The observant reader notices that some of the expressions contain explicit parameter names, like the NAN_METHOD
substitution. This is intentional, as NAN assumes standard argument names, and safe renaming of parameters may require contextual knowledge.
(v8\:\:)?Handle<(v8\:\:)?Value>\s*(\S+)\s*\(\s*const\s+(v8\:\:)?Arguments\s*&\s*args\s*\)
NAN_METHOD(\3)
(v8\:\:)?Handle<(v8\:\:)?Value>\s*(\S+)\s*\(\s*(v8\:\:)?Local<(v8\:\:)?String>\s*property\s*,\s*const\s*(v8\:\:)?AccessorInfo\s*&\s*info\s*\)
NAN_GETTER(\3)
void\s*(\S+)\s*\(\s*(v8\:\:)?Local<(v8\:\:)?String>\s*property\s*,\s*(v8\:\:)?Local<(v8\:\:)?Value>\s*value\s*,\s*const\s*(v8\:\:)?AccessorInfo\s*&\s*info\s*\)
NAN_SETTER(\1)
(v8\:\:)?HandleScope\s+scope
NanScope()
(v8\:\:)?String\:\:NewSymbol
NanNew
(v8\:\:)?Null\(\)
NanNull()
(v8\:\:)?Undefined\(\)
NanUndefined()
(v8\:\:)?True\(\)
NanTrue()
(v8\:\:)?False\(\)
NanFalse()
return\s+(v8\:\:)?ThrowException\s*\(\s*(v8\:\:)?Exception::Error\s*\(\s*(v8\:\:)?String::New\s*\((.*)\)\)\)
return NanThrowError(\4)
return\s+(v8\:\:)?ThrowException\s*\(\s*(v8\:\:)?Exception::TypeError\s*\(\s*(v8\:\:)?String::New\s*\((.*)\)\)\)
return NanThrowTypeError(\4)
return\s+(v8\:\:)?ThrowException\s*\(\s*(v8\:\:)?Exception::RangeError\s*\(\s*(v8\:\:)?String::New\s*\((.*)\)\)\)
return NanThrowRangeError(\4)
return\s+scope.Close\((v8\:\:)?ThrowException\((v8\:\:)?String::New\((.*)\)\)\)
return NanThrowError(\3)
return scope.Close
NanReturnValue
(\S+)\.Dispose\(\)
NanDisposePersistent(\1)
(\S+)\s*=\s*(v8\:\:)?Persistent<(v8\:\:)?(\S+)>::New\((.+)\)
NanAssignPersistent(\3\4, \1, \5)
(v8\:\:)?Local\s*<\s*(\S*)>\s*\:\:\s*New\s*\(
NanNew<\2>(
(v8\:\:)?(\S+)\:\:\s*New\s*\(
NanNew<\2>(
This seems to work for me:
uv_async_init(uv_default_loop(), &async_handle, [](uv_async_t* handle) {
NanScope();
realCallback(); // call things calling node.js
uv_close((uv_handle_t*)&async_handle, NULL);
});
but this function should not return anything and I see no other way to close the scope without value. Can I simply leave it up to HandleScope's destructor?
Apparently Debian decided it was a good idea to rename node to nodejs. This causes problems with the current include-voodoo.
"include_dirs" : [
"<!(node -e \"require('nan')\")"
]
serialport/node-serialport#301
Based on crypto-utils/keygrip#7, it seems a possible fix is something like
"[ -x /usr/bin/nodejs ] && /usr/bin/nodejs ./install.js || node ./install.js"
But, I suspect that will not work with Windows. So, how to make a cross-platform solution?
FYI I've updated the travis config and now have a built matrix for various versions of Node. Currently the latest 0.8, the last 5 versions of 0.5 and 0.11.4, 0.11.5 and 0.11.6. unfortunately 0.11.7 and 0.11.8 come with a consistently buggy npm that causes the builds to fail so I've removed them for now. Perhaps 0.11.9 will sort that out. We'll have to manually add new versions in as they are released.
I would like to contribute an example addon to nan, maybe more complex than adding numbers and possibly useful in other circumstances (if it was faster or v8 was slower:P)
Please review my code:
https://github.com/CodeCharmLtd/nan-example-eol
I am aware of its deficiencies (too complex code in places) but it is testable and may be useful for testing regressions in nan/v8/node. Just do node-gyp rebuild && npm test
.
I initially wrote it out of curiosity, whether it would be faster than carrier
and well .. after feature-parity it is the same speed! Totally not worth it but still ... uses Nan's buffers, and other stuff. Could be also extended to doing stuff in threads etc.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.