Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added NAN_CONSTRUCTOR method. #1

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 19 additions & 1 deletion README.md
Expand Up @@ -135,6 +135,7 @@ NAN_METHOD(CalculateAsync) {
<a name="api"></a>
## API

* <a href="#api_nan_constructor"><b><code>NAN_CONSTRUCTOR</code></b></a>
* <a href="#api_nan_method"><b><code>NAN_METHOD</code></b></a>
* <a href="#api_nan_getter"><b><code>NAN_GETTER</code></b></a>
* <a href="#api_nan_setter"><b><code>NAN_SETTER</code></b></a>
Expand All @@ -156,6 +157,23 @@ NAN_METHOD(CalculateAsync) {
* <a href="#api_nan_async_worker"><b><code>NanAsyncWorker</code></b></a>
* <a href="#api_nan_async_queue_worker"><b><code>NanAsyncQueueWorker</code></b></a>

<a name="api_nan_constructor"></a>
### NAN_CONSTRUCTOR(methodname)
Use `NAN_CONSTRUCTOR` to define constructors used by your V8 accessible methods:

```c++
struct Foo {
NAN_CONSTRUCTOR(Foo);
...
};

NAN_CONSTRUCTOR(Foo::Foo) {
...
}
```

The reason for this macro is that constructors have no explicit return type and cannot thus be declared the way methods are.

<a name="api_nan_method"></a>
### NAN_METHOD(methodname)

Expand Down Expand Up @@ -452,4 +470,4 @@ Licence &amp; copyright

Copyright (c) 2013 Rod Vagg

Native Abstractions for Node.js is licensed under an MIT +no-false-attribs license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
Native Abstractions for Node.js is licensed under an MIT +no-false-attribs license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
4 changes: 4 additions & 0 deletions nan.h
Expand Up @@ -79,6 +79,8 @@ static v8::Isolate* nan_isolate = v8::Isolate::GetCurrent();

# define NAN_METHOD(name) \
void name(const v8::FunctionCallbackInfo<v8::Value>& args)
# define NAN_CONSTRUCTOR(name) \
name(const v8::FunctionCallbackInfo<v8::Value>& args)
# define NAN_GETTER(name) \
void name( \
v8::Local<v8::String> property \
Expand Down Expand Up @@ -153,6 +155,8 @@ static v8::Isolate* nan_isolate = v8::Isolate::GetCurrent();

# define NAN_METHOD(name) \
v8::Handle<v8::Value> name(const v8::Arguments& args)
# define NAN_CONSTRUCTOR(name) \
name(const v8::Arguments& args)
# define NAN_GETTER(name) \
v8::Handle<v8::Value> name( \
v8::Local<v8::String> property \
Expand Down