TestCode:
class A
{
public:
int getVal() const { return m_a; }
private:
int m_a = 10;
};
class B
{
public:
A* getA() {
return &m_a;
}
private:
A m_a;
};
...
static B test;
dukglue_register_method(m_ctx, &A::getVal, "getVal");
dukglue_register_method(m_ctx, &B::getA, "getA");
dukglue_register_global(m_ctx, &test, "test");
...
run script "test.getA().getVal()" get an error.
test.getA() not return the object of type A, return value still B.
the script "test.getA().getA().getA()" is good.
In C++, diffrent object maybe have same address, but when export to dukglue, it buffered address and object, same address always be the object first export.
TestCode:
class A
{
public:
int getVal() const { return m_a; }
private:
int m_a = 10;
};
class B
{
public:
A* getA() {
return &m_a;
}
private:
A m_a;
};
...
static B test;
dukglue_register_method(m_ctx, &A::getVal, "getVal");
dukglue_register_method(m_ctx, &B::getA, "getA");
dukglue_register_global(m_ctx, &test, "test");
...
run script "test.getA().getVal()" get an error.
test.getA() not return the object of type A, return value still B.
the script "test.getA().getA().getA()" is good.
In C++, diffrent object maybe have same address, but when export to dukglue, it buffered address and object, same address always be the object first export.