What is the best way to expose a Reference Type as an Object Property?
class TypeA // asOBJ_REF
{
};
class TypeB // asOBJ_REF
{
TypeA m_A; // ... RegisterObjectProperty("TypeB", "TypeA A", asOFFSET(TypeB, m_A), ...
};
class TypeC // asOBJ_REF | asOBJ_GC
{
TypeA* m_pA; // ... RegisterObjectProperty("TypeC", "TypeA@ A", asOFFSET(TypeC, m_pA), ...
};
If a script gets a handle to TypeB::m_A and the TypeB object goes out of scope, it seems like m_A would be prematurely destroyed. How does one inform the garbage collector to not destroy the TypeB object until all references to it's member m_A have been released?
The TypeC scenario looks more straight forward, but there is no garuntee that m_pA points to a valid object since the script could assign to it an empty handle.
Thanks for the help.