| 620 | } |
| 621 | |
| 622 | void CScriptArray::RemoveRange(std::uint32_t start, std::uint32_t count) |
| 623 | { |
| 624 | if (count == 0) { |
| 625 | return; |
| 626 | } |
| 627 | |
| 628 | if (buffer == nullptr || start > buffer->numElements) { |
| 629 | // If this is called from a script we raise a script exception |
| 630 | asIScriptContext* ctx = asGetActiveContext(); |
| 631 | if (ctx) { |
| 632 | ctx->SetException("Index out of bounds"); |
| 633 | } |
| 634 | return; |
| 635 | } |
| 636 | |
| 637 | // Cap count to the end of the array |
| 638 | if (start + count > buffer->numElements) { |
| 639 | count = buffer->numElements - start; |
| 640 | } |
| 641 | |
| 642 | // Destroy the elements that are being removed |
| 643 | Destruct(buffer, start, start + count); |
| 644 | |
| 645 | // Compact the elements |
| 646 | // As objects in arrays of objects are not stored inline, it is safe to use memmove here |
| 647 | // since we're just copying the pointers to objects and not the actual objects. |
| 648 | std::memmove(buffer->data + start * elementSize, buffer->data + (start + count) * elementSize, (buffer->numElements - start - count) * elementSize); |
| 649 | buffer->numElements -= count; |
| 650 | } |
| 651 | |
| 652 | // Internal |
| 653 | void CScriptArray::Resize(std::int32_t delta, std::uint32_t at) |
nothing calls this directly
no test coverage detected