0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-29 07:18:20 +02:00

ircd::js: Fix unconditional cast of this to object type in trap::on_call handlers.

This commit is contained in:
Jason Volk 2016-11-06 14:40:03 -08:00
parent fcc654699d
commit 84383d41d8
2 changed files with 8 additions and 5 deletions

View file

@ -36,7 +36,7 @@ class trap
std::map<persist_string, trap *, persist_string::less> children;
// Override these to define JS objects in C
virtual value on_call(object::handle, object::handle, const args &);
virtual value on_call(object::handle, value::handle, const args &);
virtual value on_set(object::handle, id::handle, value::handle);
virtual value on_get(object::handle, id::handle, value::handle);
virtual void on_add(object::handle, id::handle, value::handle);

View file

@ -734,13 +734,13 @@ noexcept try
assert(!pending_exception(*cx));
const struct args args(argc, argv);
object that(args.computeThis(c));
value that(args.computeThis(c));
object func(args.callee());
auto &trap_that(from(that));
//auto &trap_that(from(that));
auto &trap_func(from(func));
trap_that.debug("call: '%s'", trap_func.name().c_str());
//trap_that.debug("call: '%s'", trap_func.name().c_str());
trap_func.debug("call");
args.rval().set(trap_func.on_call(func, that, args));
@ -1091,6 +1091,9 @@ ircd::js::trap::on_get(object::handle obj,
id::handle id,
value::handle val)
{
if(!undefined(val))
return val;
const string name(id);
const auto it(children.find(name));
if(it == end(children))
@ -1110,7 +1113,7 @@ ircd::js::trap::on_set(object::handle,
ircd::js::value
ircd::js::trap::on_call(object::handle,
object::handle,
value::handle,
const args &)
{
return {};