diff --git a/include/ircd/js/object.h b/include/ircd/js/object.h index b4c906a73..63da635d6 100644 --- a/include/ircd/js/object.h +++ b/include/ircd/js/object.h @@ -62,6 +62,10 @@ struct object uint32_t size() const; void resize(const uint32_t &); + // Get/set prototype + object prototype() const; + void prototype(object::handle); + // new object object(const JSClass *const &, const handle &ctor, const JS::HandleValueArray &args); object(const JSClass *const &, const JS::CallArgs &args); @@ -211,6 +215,26 @@ object::object(const JSClass *const &clasp, throw internal_error("NULL object (new)"); } +template +void +object::prototype(object::handle obj) +{ + if(!JS_SetPrototype(*cx, *this, obj)) + throw internal_error("Failed to set prototype for object"); +} + +template +object +object::prototype() +const +{ + object ret; + if(!JS_GetPrototype(*cx, *this, &ret)) + throw internal_error("Failed to get prototype for object"); + + return ret; +} + template void object::resize(const uint32_t &length)