Skip to content

Returning references from C++ #23

@xemjeff

Description

@xemjeff

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.

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