The code below should work. You mention both A from B and B from A in
your post. This code implements the former.
void B::F(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Local<v8::FunctionTemplate> function_template =
v8::FunctionTemplate::New(args.GetIsolate(), A::New);
v8::Local<v8::Function> function = function_template->GetFunction();
v8::Local<v8::Value> object_v = function->NewInstance(); // Can pass args.
if (object_v.IsEmpty()) return; // Constructor threw.
assert(object_v->IsObject()); // Should never fail.
v8::Local<v8::Object> object = object_v.As<v8::Object>();
// Do something with |object| here.
args.GetReturnValue().Set(object);
}
You may want to cache the v8::FunctionTemplate or the v8::Function in
a v8::Persistent so you don't have to recreate it all the time. Good
luck!