From f2340367be7d2170ee351ad97565f5beb246f6fe Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 25 Nov 2016 22:52:11 -0800 Subject: [PATCH] ircd::js: Add vector CallArgs related conversions. --- include/ircd/js/args.h | 2 ++ include/ircd/js/trap.h | 2 +- include/ircd/js/vector.h | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/ircd/js/args.h b/include/ircd/js/args.h index 1f3d7e1f3..9accb4edf 100644 --- a/include/ircd/js/args.h +++ b/include/ircd/js/args.h @@ -28,6 +28,8 @@ namespace js { struct args :JS::CallArgs { + operator vector::handle() const { return { *this }; } + bool empty() const { return length() == 0; } size_t size() const { return length(); } bool has(const size_t &at) const { return size() > at; } diff --git a/include/ircd/js/trap.h b/include/ircd/js/trap.h index 1af438087..a4589900f 100644 --- a/include/ircd/js/trap.h +++ b/include/ircd/js/trap.h @@ -120,6 +120,6 @@ template ircd::js::object ircd::js::trap::operator()(args&&... a) { - vector argv{{std::forward(a)...}}; + vector argv{std::forward(a)...}; return construct(argv); } diff --git a/include/ircd/js/vector.h b/include/ircd/js/vector.h index 24bc008b0..bc06617e9 100644 --- a/include/ircd/js/vector.h +++ b/include/ircd/js/vector.h @@ -65,6 +65,7 @@ struct vector :JS::HandleValueArray { using JS::HandleValueArray::HandleValueArray; + handle(const JS::CallArgs &args): JS::HandleValueArray{args} {} handle(): JS::HandleValueArray{JS::HandleValueArray::empty()} {} }; @@ -103,7 +104,7 @@ struct vector infallibleAppend(value(t)); } */ - vector(const object &obj) + explicit vector(const object &obj) :JS::AutoVectorRooter{*cx} { if(!is_array(obj))