Handle<Value> MultiPolygon::New(const Arguments& args) { HandleScope scope; MultiPolygon *f; if (!args.IsConstructCall()) { return NODE_THROW("Cannot call constructor as function, you need to use 'new' keyword"); } if (args[0]->IsExternal()) { Local<External> ext = Local<External>::Cast(args[0]); void* ptr = ext->Value(); f = static_cast<MultiPolygon *>(ptr); } else { if (args.Length() != 0) { return NODE_THROW("MultiPolygon constructor doesn't take any arguments"); } f = new MultiPolygon(new OGRMultiPolygon()); } Handle<Value> children = GeometryCollectionChildren::New(args.This()); args.This()->SetHiddenValue(String::NewSymbol("children_"), children); f->Wrap(args.This()); return args.This(); }