MCPcopy Create free account
hub / github.com/CytopiaTeam/Cytopia / EnumReferences

Method EnumReferences

external/as_add_on/scriptarray/scriptarray.cpp:1782–1813  ·  view source on GitHub ↗

GC behaviour

Source from the content-addressed store, hash-verified

1780
1781// GC behaviour
1782void CScriptArray::EnumReferences(asIScriptEngine *engine)
1783{
1784 // TODO: If garbage collection can be done from a separate thread, then this method must be
1785 // protected so that it doesn't get lost during the iteration if the array is modified
1786
1787 // If the array is holding handles, then we need to notify the GC of them
1788 if( subTypeId & asTYPEID_MASK_OBJECT )
1789 {
1790 void **d = (void**)buffer->data;
1791
1792 asITypeInfo *subType = engine->GetTypeInfoById(subTypeId);
1793 if ((subType->GetFlags() & asOBJ_REF))
1794 {
1795 // For reference types we need to notify the GC of each instance
1796 for (asUINT n = 0; n < buffer->numElements; n++)
1797 {
1798 if (d[n])
1799 engine->GCEnumCallback(d[n]);
1800 }
1801 }
1802 else if ((subType->GetFlags() & asOBJ_VALUE) && (subType->GetFlags() & asOBJ_GC))
1803 {
1804 // For value types we need to forward the enum callback
1805 // to the object so it can decide what to do
1806 for (asUINT n = 0; n < buffer->numElements; n++)
1807 {
1808 if (d[n])
1809 engine->ForwardGCEnumReferences(d[n], subType);
1810 }
1811 }
1812 }
1813}
1814
1815// GC behaviour
1816void CScriptArray::ReleaseAllHandles(asIScriptEngine *)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected