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

Method CopyBuffer

external/as_add_on/scriptarray/scriptarray.cpp:1611–1660  ·  view source on GitHub ↗

internal

Source from the content-addressed store, hash-verified

1609
1610// internal
1611void CScriptArray::CopyBuffer(SArrayBuffer *dst, SArrayBuffer *src)
1612{
1613 asIScriptEngine *engine = objType->GetEngine();
1614 if( subTypeId & asTYPEID_OBJHANDLE )
1615 {
1616 // Copy the references and increase the reference counters
1617 if( dst->numElements > 0 && src->numElements > 0 )
1618 {
1619 int count = dst->numElements > src->numElements ? src->numElements : dst->numElements;
1620
1621 void **max = (void**)(dst->data + count * sizeof(void*));
1622 void **d = (void**)dst->data;
1623 void **s = (void**)src->data;
1624
1625 for( ; d < max; d++, s++ )
1626 {
1627 void *tmp = *d;
1628 *d = *s;
1629 if( *d )
1630 engine->AddRefScriptObject(*d, objType->GetSubType());
1631 // Release the old ref after incrementing the new to avoid problem incase it is the same ref
1632 if( tmp )
1633 engine->ReleaseScriptObject(tmp, objType->GetSubType());
1634 }
1635 }
1636 }
1637 else
1638 {
1639 if( dst->numElements > 0 && src->numElements > 0 )
1640 {
1641 int count = dst->numElements > src->numElements ? src->numElements : dst->numElements;
1642 if( subTypeId & asTYPEID_MASK_OBJECT )
1643 {
1644 // Call the assignment operator on all of the objects
1645 void **max = (void**)(dst->data + count * sizeof(void*));
1646 void **d = (void**)dst->data;
1647 void **s = (void**)src->data;
1648
1649 asITypeInfo *subType = objType->GetSubType();
1650 for( ; d < max; d++, s++ )
1651 engine->AssignScriptObject(*d, *s, subType);
1652 }
1653 else
1654 {
1655 // Primitives are copied byte for byte
1656 memcpy(dst->data, src->data, count*elementSize);
1657 }
1658 }
1659 }
1660}
1661
1662// internal
1663// Precache some info

Callers

nothing calls this directly

Calls 1

GetEngineMethod · 0.45

Tested by

no test coverage detected