0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-30 17:34:04 +01:00

ircd::js: Vector construction from Object of array type.

This commit is contained in:
Jason Volk 2016-10-31 12:15:04 -07:00
parent d2b3bedca6
commit 0fbbed7daf

View file

@ -101,6 +101,18 @@ struct vector<value>
infallibleAppend(value(t));
}
vector(const object &obj)
:JS::AutoVectorRooter<jsapi_type>{*cx}
{
if(!is_array(obj))
throw internal_error("Object is not an array");
const auto len(obj.size());
reserve(obj.size());
for(size_t i(0); i < len; ++i)
infallibleAppend(get(obj, i));
}
vector(const size_t &size)
:JS::AutoVectorRooter<jsapi_type>{*cx}
{