MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / convertJSArrayToNumberVector

Function convertJSArrayToNumberVector

system/include/emscripten/val.h:904–918  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

902
903template <typename T>
904std::vector<T> convertJSArrayToNumberVector(const val& v) {
905 const size_t l = v["length"].as<size_t>();
906
907 std::vector<T> rv;
908 rv.resize(l);
909
910 // Copy the array into our vector through the use of typed arrays.
911 // It will try to convert each element through Number().
912 // See https://www.ecma-international.org/ecma-262/6.0/#sec-%typedarray%.prototype.set-array-offset
913 // and https://www.ecma-international.org/ecma-262/6.0/#sec-tonumber
914 val memoryView{ typed_memory_view(l, rv.data()) };
915 internal::_emval_array_to_memory_view(memoryView.as_handle(), v.as_handle());
916
917 return rv;
918}
919
920} // end namespace emscripten

Callers

nothing calls this directly

Calls 3

typed_memory_viewFunction · 0.85
resizeMethod · 0.65
dataMethod · 0.45

Tested by

no test coverage detected