MCPcopy Create free account
hub / github.com/Snapchat/Valdi / setArrayItem

Method setArrayItem

valdi_core/src/valdi_core/cpp/Utils/Marshaller.cpp:339–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

337}
338
339void Marshaller::setArrayItem(int index, int arrayIndex) {
340 auto array = getArray(index);
341 if (!_exceptionTracker) {
342 return;
343 }
344
345 auto valueToPlace = get(-1);
346 if (!_exceptionTracker) {
347 return;
348 }
349 pop();
350
351 auto arrayIndexSizeT = static_cast<size_t>(arrayIndex);
352 if (arrayIndex < 0 || arrayIndexSizeT >= array->size()) {
353 _exceptionTracker.onError(
354 Error(STRING_FORMAT("Out of bounds index {}, array size is {}", arrayIndex, array->size())));
355 return;
356 }
357
358 array->emplace(static_cast<int>(arrayIndex), std::move(valueToPlace));
359}
360
361int Marshaller::pushMap(int expectedCapacity) {
362 auto map = makeShared<ValueMap>();

Callers 3

TESTFunction · 0.80
nativeSetArrayItemFunction · 0.80

Calls 5

ErrorClass · 0.70
onErrorMethod · 0.65
getFunction · 0.50
sizeMethod · 0.45
emplaceMethod · 0.45

Tested by 1

TESTFunction · 0.64