mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd::js: Order arguments to call() more intuitively.
This commit is contained in:
parent
42f0c6b06b
commit
bf540caead
3 changed files with 29 additions and 29 deletions
|
@ -26,23 +26,23 @@ namespace ircd {
|
||||||
namespace js {
|
namespace js {
|
||||||
|
|
||||||
value
|
value
|
||||||
call(const object &obj,
|
call(const function::handle &func,
|
||||||
const function::handle &func,
|
const object &that,
|
||||||
const vector<value>::handle &args = {});
|
const vector<value>::handle &args = {});
|
||||||
|
|
||||||
value
|
value
|
||||||
call(const object &obj,
|
call(const value::handle &val,
|
||||||
const value::handle &val,
|
const object &that,
|
||||||
const vector<value>::handle &args = {});
|
const vector<value>::handle &args = {});
|
||||||
|
|
||||||
value
|
value
|
||||||
call(const object &obj,
|
call(const char *const &name,
|
||||||
const char *const &name,
|
const object &that,
|
||||||
const vector<value>::handle &args = {});
|
const vector<value>::handle &args = {});
|
||||||
|
|
||||||
value
|
value
|
||||||
call(const object &obj,
|
call(const std::string &name,
|
||||||
const std::string &name,
|
const object &that,
|
||||||
const vector<value>::handle &args = {});
|
const vector<value>::handle &args = {});
|
||||||
|
|
||||||
} // namespace js
|
} // namespace js
|
||||||
|
|
|
@ -42,7 +42,7 @@ struct function
|
||||||
explicit operator string<L>() const;
|
explicit operator string<L>() const;
|
||||||
|
|
||||||
// js::value/js::object == lifetime::stack
|
// js::value/js::object == lifetime::stack
|
||||||
js::value operator()(const js::object &, const vector<js::value>::handle &args = {}) const;
|
js::value operator()(const js::object &, const vector<js::value>::handle &args) const;
|
||||||
template<class... args> js::value operator()(const js::object &, args&&...) const;
|
template<class... args> js::value operator()(const js::object &, args&&...) const;
|
||||||
|
|
||||||
// new function
|
// new function
|
||||||
|
@ -131,12 +131,12 @@ function<L>::operator()(const js::object &that,
|
||||||
args&&... a)
|
args&&... a)
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
vector<basic::value<lifetime::stack>> v
|
vector<basic::value<lifetime::stack>> argv
|
||||||
{{
|
{{
|
||||||
std::forward<args>(a)...
|
std::forward<args>(a)...
|
||||||
}};
|
}};
|
||||||
|
|
||||||
return call(that, *this, decltype(v)::handle(v));
|
return call(*this, that, decltype(argv)::handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<lifetime L>
|
template<lifetime L>
|
||||||
|
@ -145,7 +145,7 @@ function<L>::operator()(const js::object &that,
|
||||||
const vector<js::value>::handle &args)
|
const vector<js::value>::handle &args)
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
return call(that, *this, args);
|
return call(*this, that, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<lifetime L>
|
template<lifetime L>
|
||||||
|
|
34
ircd/js.cc
34
ircd/js.cc
|
@ -1010,49 +1010,49 @@ noexcept
|
||||||
//
|
//
|
||||||
|
|
||||||
ircd::js::value
|
ircd::js::value
|
||||||
ircd::js::call(const object &obj,
|
ircd::js::call(const std::string &name,
|
||||||
const function::handle &func,
|
const object &that,
|
||||||
|
const vector<value>::handle &args)
|
||||||
|
{
|
||||||
|
return call(name.c_str(), that, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
ircd::js::value
|
||||||
|
ircd::js::call(const char *const &name,
|
||||||
|
const object &that,
|
||||||
const vector<value>::handle &args)
|
const vector<value>::handle &args)
|
||||||
{
|
{
|
||||||
value ret;
|
value ret;
|
||||||
if(!JS_CallFunction(*cx, obj, func, args, &ret))
|
if(!JS_CallFunctionName(*cx, that, name, args, &ret))
|
||||||
throw jserror(jserror::pending);
|
throw jserror(jserror::pending);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::js::value
|
ircd::js::value
|
||||||
ircd::js::call(const object &obj,
|
ircd::js::call(const value::handle &val,
|
||||||
const value::handle &val,
|
const object &that,
|
||||||
const vector<value>::handle &args)
|
const vector<value>::handle &args)
|
||||||
{
|
{
|
||||||
value ret;
|
value ret;
|
||||||
if(!JS_CallFunctionValue(*cx, obj, val, args, &ret))
|
if(!JS_CallFunctionValue(*cx, that, val, args, &ret))
|
||||||
throw jserror(jserror::pending);
|
throw jserror(jserror::pending);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::js::value
|
ircd::js::value
|
||||||
ircd::js::call(const object &obj,
|
ircd::js::call(const function::handle &func,
|
||||||
const char *const &name,
|
const object &that,
|
||||||
const vector<value>::handle &args)
|
const vector<value>::handle &args)
|
||||||
{
|
{
|
||||||
value ret;
|
value ret;
|
||||||
if(!JS_CallFunctionName(*cx, obj, name, args, &ret))
|
if(!JS_CallFunction(*cx, that, func, args, &ret))
|
||||||
throw jserror(jserror::pending);
|
throw jserror(jserror::pending);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::js::value
|
|
||||||
ircd::js::call(const object &obj,
|
|
||||||
const std::string &name,
|
|
||||||
const vector<value>::handle &args)
|
|
||||||
{
|
|
||||||
return call(obj, name.c_str(), args);
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// ircd/js/del.h
|
// ircd/js/del.h
|
||||||
|
|
Loading…
Reference in a new issue