0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 23:44:01 +01:00

ircd::js: Add vector CallArgs related conversions.

This commit is contained in:
Jason Volk 2016-11-25 22:52:11 -08:00
parent 8b0fe0318f
commit f2340367be
3 changed files with 5 additions and 2 deletions

View file

@ -28,6 +28,8 @@ namespace js {
struct args struct args
:JS::CallArgs :JS::CallArgs
{ {
operator vector<value>::handle() const { return { *this }; }
bool empty() const { return length() == 0; } bool empty() const { return length() == 0; }
size_t size() const { return length(); } size_t size() const { return length(); }
bool has(const size_t &at) const { return size() > at; } bool has(const size_t &at) const { return size() > at; }

View file

@ -120,6 +120,6 @@ template<class... args>
ircd::js::object ircd::js::object
ircd::js::trap::operator()(args&&... a) ircd::js::trap::operator()(args&&... a)
{ {
vector<value> argv{{std::forward<args>(a)...}}; vector<value> argv{std::forward<args>(a)...};
return construct(argv); return construct(argv);
} }

View file

@ -65,6 +65,7 @@ struct vector<value>
:JS::HandleValueArray :JS::HandleValueArray
{ {
using JS::HandleValueArray::HandleValueArray; using JS::HandleValueArray::HandleValueArray;
handle(const JS::CallArgs &args): JS::HandleValueArray{args} {}
handle(): JS::HandleValueArray{JS::HandleValueArray::empty()} {} handle(): JS::HandleValueArray{JS::HandleValueArray::empty()} {}
}; };
@ -103,7 +104,7 @@ struct vector<value>
infallibleAppend(value(t)); infallibleAppend(value(t));
} }
*/ */
vector(const object &obj) explicit vector(const object &obj)
:JS::AutoVectorRooter<jsapi_type>{*cx} :JS::AutoVectorRooter<jsapi_type>{*cx}
{ {
if(!is_array(obj)) if(!is_array(obj))