joyent/node — pull request #2219 by arturadib (2011-11-29 01:46:55+00:00)
Title: New macros, methods, and unit tests for native addons

As per IRC chat with @bnoordhuis. (Ben: Note I've added a new method `NODE_SET_CONSTRUCTOR`).

There are two new macros and one new method. I've found them helpful when defining setters/getters, and more generally when dealing with constructors/prototypes.

See `test.cc` in `test/addons/prototype` for example of usage.

The method `ObjectWrap::IsWrapped` is useful to avoid assertion fails in `ObjectWrap::Unwrap` in some circumstances. (Sometimes setter/getters are called when there's no wrapped object, e.g. when you test the value of a getter from within the constructor itself, like `MyClass.prototype.method`).

The test files are not yet integrated with the remaining unit tests; the directory is pretty much standalone now. Since the build system is undergoing changes (#2136), I can revisit this when the dust settles.