diff --git a/README.md b/README.md index 5e2ea2cd..05ba9663 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,7 @@ NAN_METHOD(CalculateAsync) { ## API + * NAN_CONSTRUCTOR * NAN_METHOD * NAN_GETTER * NAN_SETTER @@ -156,6 +157,23 @@ NAN_METHOD(CalculateAsync) { * NanAsyncWorker * NanAsyncQueueWorker + +### 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. + ### NAN_METHOD(methodname) @@ -452,4 +470,4 @@ Licence & 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. \ No newline at end of file +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. diff --git a/nan.h b/nan.h index ead7d658..b36bf0d3 100644 --- a/nan.h +++ b/nan.h @@ -79,6 +79,8 @@ static v8::Isolate* nan_isolate = v8::Isolate::GetCurrent(); # define NAN_METHOD(name) \ void name(const v8::FunctionCallbackInfo& args) +# define NAN_CONSTRUCTOR(name) \ + name(const v8::FunctionCallbackInfo& args) # define NAN_GETTER(name) \ void name( \ v8::Local property \ @@ -153,6 +155,8 @@ static v8::Isolate* nan_isolate = v8::Isolate::GetCurrent(); # define NAN_METHOD(name) \ v8::Handle name(const v8::Arguments& args) +# define NAN_CONSTRUCTOR(name) \ + name(const v8::Arguments& args) # define NAN_GETTER(name) \ v8::Handle name( \ v8::Local property \