mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 00:34:18 +01:00
ircd::js: Get/Set object prototype.
This commit is contained in:
parent
67d9f11fbc
commit
292b3fc8e8
1 changed files with 24 additions and 0 deletions
|
@ -62,6 +62,10 @@ struct object
|
||||||
uint32_t size() const;
|
uint32_t size() const;
|
||||||
void resize(const uint32_t &);
|
void resize(const uint32_t &);
|
||||||
|
|
||||||
|
// Get/set prototype
|
||||||
|
object prototype() const;
|
||||||
|
void prototype(object::handle);
|
||||||
|
|
||||||
// new object
|
// new object
|
||||||
object(const JSClass *const &, const handle &ctor, const JS::HandleValueArray &args);
|
object(const JSClass *const &, const handle &ctor, const JS::HandleValueArray &args);
|
||||||
object(const JSClass *const &, const JS::CallArgs &args);
|
object(const JSClass *const &, const JS::CallArgs &args);
|
||||||
|
@ -211,6 +215,26 @@ object<L>::object(const JSClass *const &clasp,
|
||||||
throw internal_error("NULL object (new)");
|
throw internal_error("NULL object (new)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<lifetime L>
|
||||||
|
void
|
||||||
|
object<L>::prototype(object::handle obj)
|
||||||
|
{
|
||||||
|
if(!JS_SetPrototype(*cx, *this, obj))
|
||||||
|
throw internal_error("Failed to set prototype for object");
|
||||||
|
}
|
||||||
|
|
||||||
|
template<lifetime L>
|
||||||
|
object<L>
|
||||||
|
object<L>::prototype()
|
||||||
|
const
|
||||||
|
{
|
||||||
|
object ret;
|
||||||
|
if(!JS_GetPrototype(*cx, *this, &ret))
|
||||||
|
throw internal_error("Failed to get prototype for object");
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
template<lifetime L>
|
template<lifetime L>
|
||||||
void
|
void
|
||||||
object<L>::resize(const uint32_t &length)
|
object<L>::resize(const uint32_t &length)
|
||||||
|
|
Loading…
Reference in a new issue