0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 08:12:37 +01:00

ircd::js: Variadic arguments for object construction via trap.

This commit is contained in:
Jason Volk 2016-10-31 12:17:49 -07:00
parent 0fbbed7daf
commit f2b59a57dc
2 changed files with 20 additions and 19 deletions

View file

@ -83,7 +83,7 @@ class trap
operator const JSClass &() const { return jsclass(); }
operator const JSClass *() const { return &jsclass(); }
object operator()(const object &parent = {}, const object &parent_proto = {});
template<class... args> object operator()(const object &parent, args&&...);
trap(const std::string &path, const uint32_t &flags = 0);
trap(trap &&) = delete;
@ -93,5 +93,24 @@ class trap
extern __thread trap *tree;
template<class... args>
object
trap::operator()(const object &parent,
args&&... a)
{
object proto(JS_InitClass(*cx,
parent,
object{},
_class.get(),
nullptr,
0,
ps,
fs,
nullptr,
nullptr));
return JS_New(*cx, proto, vector<value>{std::forward<args>(a)...});
}
} // namespace js
} // namespace ircd

View file

@ -472,24 +472,6 @@ catch(const std::exception &e)
throw;
}
ircd::js::object
ircd::js::trap::operator()(const object &parent,
const object &parent_proto)
{
object proto(JS_InitClass(*cx,
parent,
parent_proto,
_class.get(),
nullptr,
0,
ps,
fs,
nullptr,
nullptr));
return JS_New(*cx, proto, JS::HandleValueArray::empty());
}
ircd::js::trap &
ircd::js::trap::find(const std::string &path)
{