Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning references from C++ #23

Open
xemjeff opened this issue Apr 19, 2020 · 0 comments
Open

Returning references from C++ #23

xemjeff opened this issue Apr 19, 2020 · 0 comments

Comments

@xemjeff
Copy link

xemjeff commented Apr 19, 2020

I am able to return pointers to objects from C++ through dukglue, but I can't seem to return references:

//this function registers and works fine
// m_position is type Vector3

Vector3* Robot::pos()
{
    return &m_position;
}

//this fails to compile if I try to register
Vector3& Robot::position()
{
    return m_position;
}

I register like this:

	dukglue_register_method(ctx, &Robot::position, "position")

and get these compile errors (below), which seems to indicate that references for my Vector3 class are not supported.

../include/dukglue/register_class.h:113:53:   required from ‘void dukglue_register_method(duk_context*, RetType (Cls::*)(Ts ...), const char*) [with Cls = Robot; RetType = Vector3&; Ts = {}; duk_context = duk_hthread]’

dukglue/tests/test_robot.cpp:21:59:   required from here

dukglue/tests/../include/dukglue/detail_method.h:129:67: error: no matching function for call to ‘dukglue::types::DukType<Vector3>::push<Vector3&>(duk_context*&, std::remove_reference<Vector3&>::type)’
      DukType<typename Bare<RetType>::type>::template push<RetType>(ctx, std::move(return_val));

Is this a bug, a limitation of dukglue, or am I just not registering correctly?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant