SungchulCho / v8-juice

Automatically exported from code.google.com/p/v8-juice
Other
0 stars 0 forks source link

bound funcs cannot return references #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
From src/client/shell/shell.cc, based on r705:

struct my_native
{
...
    void someref1( my_native & x )
    {
        CERR << "someref1("<<&x<<")\n";
        return;
    }

    my_native & someref2( my_native & x )
    {
        CERR << "someref2("<<&x<<")\n";
        return x;
    }
    my_native const & someref3( my_native const & x )
    {
        CERR << "someref3("<<&x<<")\n";
        return x;
    }
};

...

    typedef ClassBinder<my_native> WT;
    WT w;
...
    w
...
        .BindMemFunc< void, MY &, &MY::someref1 >( "someref1" )
        .BindMemFunc< MY &, MY &, &MY::someref2 >( "someref2" )
        //.BindMemFunc< MY const &, MY const &, &MY::someref3 >( "someref3" 
)
...

someref1() works, but someref2() and someref3() produce something like:

/home/stephan/cvs/v8-juice/trunk/src/include/v8/juice/ClassBinder-
BindMemFunc.h:11:   instantiated from ‘v8::juice::ClassBinder<WrappedT>& 
v8::juice::ClassBinder<WrappedT>::BindMemFunc(const char*) [with RV = 
my_fwd(V8CxH&)::MY&, A0 = my_fwd(V8CxH&)::MY&, RV 
(v8::juice::WeakJSClassCreator<ParentT>::WrappedType::* Func)(A0) = 
&my_native::someref2, WrappedT = my_native]’
shell.cc:247:   instantiated from here
/home/stephan/cvs/v8-juice/trunk/src/include/v8/juice/convert.h:260: error: 
no match for call to ‘(v8::juice::convert::CastToJS(const T&) [with T = 
my_native&]::F) (my_native&)’
/home/stephan/cvs/v8-juice/trunk/src/include/v8/juice/WeakJSClassCreator-
CastOps.h:30: note: candidates are: v8::Handle<v8::Value> 
v8::juice::convert::NativeToJS<my_native>::operator()(my_native*) const

apparently i'm missing a specialization or two for reference types in the 
CastTo/FromJS operations, or possibly in the function forwarders.

Reminder to self: it is untested whether a non-member function returning a 
reference can be bound as a global function, but testing that will help 
narrow this problem down.

Original issue reported on code.google.com by sgbeal@googlemail.com on 23 Sep 2009 at 6:50

GoogleCodeExporter commented 8 years ago
Fixed in edge branch r952, trunk r963. At least, it works for class types which 
we've 
bound to JS, and that's all that we can home for here.

Original comment by sgbeal@googlemail.com on 29 Oct 2009 at 11:04