| 713 | } |
| 714 | |
| 715 | void CScriptArray::RemoveRange(asUINT start, asUINT count) |
| 716 | { |
| 717 | if (count == 0) |
| 718 | return; |
| 719 | |
| 720 | if( buffer == 0 || start > buffer->numElements ) |
| 721 | { |
| 722 | // If this is called from a script we raise a script exception |
| 723 | asIScriptContext *ctx = asGetActiveContext(); |
| 724 | if (ctx) |
| 725 | ctx->SetException("Index out of bounds"); |
| 726 | return; |
| 727 | } |
| 728 | |
| 729 | // Cap count to the end of the array |
| 730 | if (start + count > buffer->numElements) |
| 731 | count = buffer->numElements - start; |
| 732 | |
| 733 | // Destroy the elements that are being removed |
| 734 | Destruct(buffer, start, start + count); |
| 735 | |
| 736 | // Compact the elements |
| 737 | // As objects in arrays of objects are not stored inline, it is safe to use memmove here |
| 738 | // since we're just copying the pointers to objects and not the actual objects. |
| 739 | memmove(buffer->data + start*elementSize, buffer->data + (start + count)*elementSize, (buffer->numElements - start - count)*elementSize); |
| 740 | buffer->numElements -= count; |
| 741 | } |
| 742 | |
| 743 | // Internal |
| 744 | void CScriptArray::Resize(int delta, asUINT at) |
no test coverage detected