MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / scanArray

Method scanArray

src/simulate/json_scan.cpp:453–473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

451 // ---- scan dynamic array ----
452
453 bool scanArray(char * dst, TypeInfo * elemTi) {
454 if (!expect('[')) return false;
455 Array * arr = (Array*)dst;
456 int stride = getTypeSize(elemTi);
457 // clear existing content
458 if (arr->size) {
459 array_resize(ctx, *arr, 0, stride, false, at);
460 }
461 if (peek() == ']') { cur++; return true; }
462 while (true) {
463 // grow array by one, zero-initialized
464 uint64_t idx = uint64_t(builtin_array_push_back_zero(*arr, stride, &ctx, (LineInfoArg*)at));
465 char * elem = arr->data + idx * stride;
466 if (!scanValue(elem, elemTi)) return false;
467 skipWS();
468 if (cur >= end) return false;
469 if (*cur == ']') { cur++; return true; }
470 if (*cur != ',') return false;
471 cur++;
472 }
473 }
474
475 // ---- scan fixed-size array ----
476

Callers

nothing calls this directly

Calls 3

getTypeSizeFunction · 0.85
array_resizeFunction · 0.85

Tested by

no test coverage detected