MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / At

Method At

Sources/Jazz2/Scripting/RegisterArray.cpp:846–862  ·  view source on GitHub ↗

Return a pointer to the array element. Returns 0 if the index is out of bounds

Source from the content-addressed store, hash-verified

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));

Callers 4

OnActivatedAsyncMethod · 0.80
GetKeysMethod · 0.80
InsertAtMethod · 0.80
operator==Method · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected