2018-02-04 03:22:01 +01:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
2016-10-24 07:44:41 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_JS_SET_H
|
|
|
|
|
|
|
|
namespace ircd {
|
|
|
|
namespace js {
|
|
|
|
|
2016-11-14 00:08:03 +01:00
|
|
|
// Set the reserved data slots
|
2016-11-07 08:06:07 +01:00
|
|
|
void set(JSObject *const &obj, const reserved &slot, const JS::Value &);
|
2016-11-14 00:08:03 +01:00
|
|
|
|
|
|
|
// Set the private data (see: priv.h) Proper delete of any existing on overwrite.
|
|
|
|
void set(JSObject *const &obj, priv_data &);
|
|
|
|
void set(JSObject *const &obj, const std::shared_ptr<priv_data> &);
|
|
|
|
|
2016-11-25 03:21:46 +01:00
|
|
|
void set(const object::handle &obj, const id::handle &id, const value::handle &val);
|
2016-10-25 07:14:39 +02:00
|
|
|
void set(const object::handle &obj, const id::handle &id, const value &val);
|
2016-11-04 00:44:04 +01:00
|
|
|
void set(const object::handle &obj, const id &id, const value &val);
|
2016-10-31 20:29:37 +01:00
|
|
|
template<class T> void set(const object::handle &obj, const uint32_t &idx, T&& t);
|
2016-10-25 07:14:39 +02:00
|
|
|
void set(const object::handle &src, const char *const path, const value &val);
|
2016-10-24 07:44:41 +02:00
|
|
|
|
2016-10-31 20:29:37 +01:00
|
|
|
template<class T>
|
|
|
|
void
|
|
|
|
set(const object::handle &obj,
|
|
|
|
const uint32_t &idx,
|
|
|
|
T&& t)
|
|
|
|
{
|
|
|
|
if(!JS_SetElement(*cx, obj, idx, std::forward<T>(t)))
|
|
|
|
throw jserror(jserror::pending);
|
|
|
|
}
|
|
|
|
|
2016-10-24 07:44:41 +02:00
|
|
|
} // namespace js
|
|
|
|
} // namespace ircd
|