Skip to content

Returning a wrapped class from another class #2273

@zbjornson

Description

@zbjornson

I have two C++ classes. A method on one of them is supposed to return a new instance of b. I tried to follow the pattern described here:

// foo.cc
const int argc = 3;
Local<Value> argv[argc] = { NanNew(*arr), NanNew(sw), NanNew(sh) };
Local<Function> cons = Local<Function>::New(Isolate::GetCurrent(), Bar::constructor);
NanReturnValue(cons->NewInstance(argc, argv));

but then:

No instance of overloaded function "v8::Local<T>::New [with T=v8::Function]" matches the argument list. Argument types are: (v8:Isolate *(), v8::Persistent<v8::FunctionTemplate, v8::NonCopyablePersistentTraits<V8::Functiontemplate>>)

I can't find an example of this pattern in the io.js source, and the closest google result is an unanswered SO question. I found one example where a factory method was added to Bar but that seems like it should be unnecessary. Any tips on the pattern to use here? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++Issues and PRs that require attention from people who are familiar with C++.questionIssues that look for answers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions