Return a pointer to the array element. Returns 0 if the index is out of bounds
| 844 | |
| 845 | // Return a pointer to the array element. Returns 0 if the index is out of bounds |
| 846 | const void* CScriptArray::At(std::uint32_t index) const |
| 847 | { |
| 848 | if (buffer == nullptr || index >= buffer->numElements) { |
| 849 | // If this is called from a script we raise a script exception |
| 850 | asIScriptContext* ctx = asGetActiveContext(); |
| 851 | if (ctx != nullptr) { |
| 852 | ctx->SetException("Index out of bounds"); |
| 853 | } |
| 854 | return 0; |
| 855 | } |
| 856 | |
| 857 | if ((subTypeId & asTYPEID_MASK_OBJECT) && !(subTypeId & asTYPEID_OBJHANDLE)) { |
| 858 | return *(void**)(buffer->data + elementSize * index); |
| 859 | } else { |
| 860 | return buffer->data + elementSize * index; |
| 861 | } |
| 862 | } |
| 863 | void* CScriptArray::At(std::uint32_t index) |
| 864 | { |
| 865 | return const_cast<void*>(const_cast<const CScriptArray*>(this)->At(index)); |
no outgoing calls
no test coverage detected