MCPcopy Create free account
hub / github.com/anjo76/angelscript / EnumReferences

Method EnumReferences

sdk/add_on/scriptarray/scriptarray.cpp:1905–1936  ·  view source on GitHub ↗

GC behaviour

Source from the content-addressed store, hash-verified

1903
1904// GC behaviour
1905void CScriptArray::EnumReferences(asIScriptEngine *engine)
1906{
1907 // TODO: If garbage collection can be done from a separate thread, then this method must be
1908 // protected so that it doesn't get lost during the iteration if the array is modified
1909
1910 // If the array is holding handles, then we need to notify the GC of them
1911 if( subTypeId & asTYPEID_MASK_OBJECT )
1912 {
1913 void **d = (void**)buffer->data;
1914
1915 asITypeInfo *subType = engine->GetTypeInfoById(subTypeId);
1916 if ((subType->GetFlags() & asOBJ_REF))
1917 {
1918 // For reference types we need to notify the GC of each instance
1919 for (asUINT n = 0; n < buffer->numElements; n++)
1920 {
1921 if (d[n])
1922 engine->GCEnumCallback(d[n]);
1923 }
1924 }
1925 else if ((subType->GetFlags() & asOBJ_VALUE) && (subType->GetFlags() & asOBJ_GC))
1926 {
1927 // For value types we need to forward the enum callback
1928 // to the object so it can decide what to do
1929 for (asUINT n = 0; n < buffer->numElements; n++)
1930 {
1931 if (d[n])
1932 engine->ForwardGCEnumReferences(d[n], subType);
1933 }
1934 }
1935 }
1936}
1937
1938// GC behaviour
1939void CScriptArray::ReleaseAllHandles(asIScriptEngine *)

Callers 1

Calls 4

GetTypeInfoByIdMethod · 0.80
GetFlagsMethod · 0.80
GCEnumCallbackMethod · 0.45

Tested by

no test coverage detected