Skip to content

Question: function that returns object by value #39

@jcmonnin

Description

@jcmonnin

Hi,

First, I'm not sure if the issue tracker is the right way to ask questions about the project. I haven't seen a mailing list, so I guess it's ok?

Please consider the example based on 'wrapping.md':

struct X
{
    bool b;
    X(bool b) : b(b) {}
};

static bool test1()
{
    return true;
}

static X test2()
{
    return X(true);
}

void v8ppTestBind(v8::Isolate* isolate)
{
    v8pp::class_<X> X_class(isolate);
    X_class
        .ctor<bool>()
        .set("b", &X::b);
    
    v8pp::module module(isolate);
    module
        .set("X", X_class)
        .set("test1", test1)
        .set("test2", test2);

    isolate->GetCurrentContext()->Global()->Set(v8::String::NewFromUtf8(isolate, "module"), module.new_instance());
}

Executing module.X(true) gives [object X].

Executing module.test1() gives true.

Executing module.test2() gives undefined.

Why is test2 not returning a wrapped object of type X?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions