inheritanceC ++中的JavaScript函数

我有一个JavaScript的基本function:

function Animal { } Animal.prototype.move = function () { //... } 

我也有一个派生的JavaScript函数,像这样:

 function Dog { Dog.super_.call(this); } util.inherits(Dog, Animal); Dog.prototype.bark = function () { // ... } 

现在我想创build一个与派生的Dog JavaScript函数完全相同的C ++插件:

 void Dog::Init(Handle<Object> exports, Handle<Object> module) { Isolate* isolate = Isolate::GetCurrent(); Local<Function> require = Local<Function>::Cast(module->Get( String::NewFromUtf8(isolate, "require"))); Local<Value> args[] = { String::NewFromUtf8(isolate, "./animal") }; Local<Value> animalModule = require->Call(module, 1, args); Local<Function> animalFunc = Local<Function>::Cast(animalModule); Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New); // tpl->Inherit(animalFunc); // <-- HERE tpl->SetClassName(String::NewFromUtf8(isolate, "Dog")); tpl->InstanceTemplate()->SetInternalFieldCount(1); NODE_SET_PROTOTYPE_METHOD(tpl, "bark", Bark); constructor.Reset(isolate, tpl->GetFunction()); exports->Set(String::NewFromUtf8(isolate, "Dog"), tpl->GetFunction()); } 

如何从animalFunc / animalModule获取FunctionTemplate以便能够在tpl函数模板中inheritance它? 或者,也许我应该以某种方式将animalFunc.prototype分配给tpl.prototype