I am writing a node.js addon and I am having problems with implementing a clone method that returns a copy of the object.
var p = new Point(1, -2);
var copyOfP = p.clone();
Here's my implementation, which is not correct as it does not call the destructor when it has no handles:
static v8::Handle<v8::Value> Clone(const v8::Arguments& args)
{
HandleScope scope;
Point* in = ObjectWrap::Unwrap<Point>(args.This());
Point* out = new Point(in->x_, in->y_);
out->Wrap(args.Holder());
return args.Holder();
}