1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-20 00:15:31 +00:00

[ecmascript] Migrated to mozjs-102.

This commit is contained in:
Witold Filipczyk 2022-10-01 19:59:24 +02:00
parent a71160bdd2
commit b0cc7b00d4
22 changed files with 197 additions and 264 deletions

View File

@ -787,8 +787,8 @@ SPIDERMONKEY_FOUND=
if test "x$CONFIG_SPIDERMONKEY" = xyes ||
test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
package=mozjs-91
AC_MSG_CHECKING([for SpiderMonkey (mozjs-91) in pkg-config $package])
package=mozjs-102
AC_MSG_CHECKING([for SpiderMonkey (mozjs-102) in pkg-config $package])
if $PKG_CONFIG $pkg_config_static --cflags --libs $package > /dev/null 2>&AS_MESSAGE_LOG_FD; then
DB_LOCALSTORAGE_LIBS="$($PKG_CONFIG $pkg_config_static --libs sqlite3)"
XMLPLUSPLUS_LIBS="$($PKG_CONFIG $pkg_config_static --libs libxml++-5.0)"

View File

@ -379,7 +379,7 @@ if conf_data.get('CONFIG_BZIP2')
endif
if conf_data.get('CONFIG_ECMASCRIPT_SMJS') or conf_data.get('CONFIG_SCRIPTING_SPIDERMONKEY')
mozjsdeps = dependency('mozjs-91', static: st)
mozjsdeps = dependency('mozjs-102', static: st)
deps += mozjsdeps
endif

View File

@ -249,7 +249,7 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter)
if (!menubar_obj) {
goto release_and_fail;
}
JS::SetPrivate(menubar_obj, (char *)"t"); /* to @menubar_class */
JS::SetReservedSlot(menubar_obj, 0, JS::PrivateValue((char *)"t")); /* to @menubar_class */
statusbar_obj = JS_InitClass(ctx, window_obj, nullptr,
&statusbar_class, NULL, 0,
@ -258,7 +258,7 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter)
if (!statusbar_obj) {
goto release_and_fail;
}
JS::SetPrivate(statusbar_obj, (char *)"s"); /* to @statusbar_class */
JS::SetReservedSlot(statusbar_obj, 0, JS::PrivateValue((char *)"s")); /* to @statusbar_class */
navigator_obj = JS_InitClass(ctx, window_obj, nullptr,
&navigator_class, NULL, 0,

View File

@ -57,7 +57,7 @@
static bool attr_get_property_name(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool attr_get_property_value(JSContext *ctx, unsigned int argc, JS::Value *vp);
static void attr_finalize(JSFreeOp *op, JSObject *obj)
static void attr_finalize(JS::GCContext *op, JSObject *obj)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
@ -74,14 +74,13 @@ JSClassOps attr_ops = {
nullptr, // mayResolve
attr_finalize, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
JSClass attr_class = {
"attr",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&attr_ops
};
@ -130,7 +129,7 @@ attr_get_property_name(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::AttributeNode *attr = static_cast<xmlpp::AttributeNode *>(JS::GetPrivate(hobj));
xmlpp::AttributeNode *attr = JS::GetMaybePtrFromReservedSlot<xmlpp::AttributeNode>(hobj, 0);
if (!attr) {
args.rval().setNull();
@ -182,7 +181,7 @@ attr_get_property_value(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::AttributeNode *attr = static_cast<xmlpp::AttributeNode *>(JS::GetPrivate(hobj));
xmlpp::AttributeNode *attr = JS::GetMaybePtrFromReservedSlot<xmlpp::AttributeNode>(hobj, 0);
if (!attr) {
args.rval().setNull();
@ -209,7 +208,7 @@ getAttr(JSContext *ctx, void *node)
JS_DefineProperties(ctx, r_el, (JSPropertySpec *) attr_props);
// spidermonkey_DefineFunctions(ctx, el, attributes_funcs);
JS::SetPrivate(el, node);
JS::SetReservedSlot(el, 0, JS::PrivateValue(node));
return el;
}

View File

@ -60,7 +60,7 @@ static bool attributes_getNamedItem(JSContext *ctx, unsigned int argc, JS::Value
static bool attributes_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::MutableHandleValue hvp);
static bool attributes_namedItem2(JSContext *ctx, JS::HandleObject hobj, char *str, JS::MutableHandleValue hvp);
static void attributes_finalize(JSFreeOp *op, JSObject *obj)
static void attributes_finalize(JS::GCContext *op, JSObject *obj)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
@ -76,14 +76,13 @@ JSClassOps attributes_ops = {
nullptr, // mayResolve
attributes_finalize, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
JSClass attributes_class = {
"attributes",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&attributes_ops
};
@ -126,7 +125,7 @@ attributes_set_items(JSContext *ctx, JS::HandleObject hobj, void *node)
return false;
}
xmlpp::Element::AttributeList *al = static_cast<xmlpp::Element::AttributeList *>(JS::GetPrivate(hobj));
xmlpp::Element::AttributeList *al = JS::GetMaybePtrFromReservedSlot<xmlpp::Element::AttributeList>(hobj, 0);
if (!al) {
return true;
@ -201,7 +200,7 @@ attributes_get_property_length(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Element::AttributeList *al = static_cast<xmlpp::Element::AttributeList *>(JS::GetPrivate(hobj));
xmlpp::Element::AttributeList *al = JS::GetMaybePtrFromReservedSlot<xmlpp::Element::AttributeList>(hobj, 0);
if (!al) {
args.rval().setInt32(0);
@ -275,7 +274,7 @@ attributes_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::MutableHa
hvp.setUndefined();
xmlpp::Element::AttributeList *al = static_cast<xmlpp::Element::AttributeList *>(JS::GetPrivate(hobj));
xmlpp::Element::AttributeList *al = JS::GetMaybePtrFromReservedSlot<xmlpp::Element::AttributeList>(hobj, 0);
if (!al) {
return true;
@ -320,7 +319,7 @@ attributes_namedItem2(JSContext *ctx, JS::HandleObject hobj, char *str, JS::Muta
return false;
}
xmlpp::Element::AttributeList *al = static_cast<xmlpp::Element::AttributeList *>(JS::GetPrivate(hobj));
xmlpp::Element::AttributeList *al = JS::GetMaybePtrFromReservedSlot<xmlpp::Element::AttributeList>(hobj, 0);
hvp.setUndefined();
@ -364,7 +363,7 @@ getAttributes(JSContext *ctx, void *node)
JS_DefineProperties(ctx, r_el, (JSPropertySpec *) attributes_props);
spidermonkey_DefineFunctions(ctx, el, attributes_funcs);
JS::SetPrivate(el, node);
JS::SetReservedSlot(el, 0, JS::PrivateValue(node));
attributes_set_items(ctx, r_el, node);
return el;

View File

@ -61,7 +61,7 @@ static bool htmlCollection_namedItem(JSContext *ctx, unsigned int argc, JS::Valu
static bool htmlCollection_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::MutableHandleValue hvp);
static bool htmlCollection_namedItem2(JSContext *ctx, JS::HandleObject hobj, char *str, JS::MutableHandleValue hvp);
static void htmlCollection_finalize(JSFreeOp *op, JSObject *obj)
static void htmlCollection_finalize(JS::GCContext *op, JSObject *obj)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
@ -78,14 +78,13 @@ JSClassOps htmlCollection_ops = {
nullptr, // mayResolve
htmlCollection_finalize, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
JSClass htmlCollection_class = {
"htmlCollection",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&htmlCollection_ops
};
@ -141,7 +140,7 @@ htmlCollection_get_property_length(JSContext *ctx, unsigned int argc, JS::Value
return false;
}
xmlpp::Node::NodeSet *ns = static_cast<xmlpp::Node::NodeSet *>(JS::GetPrivate(hobj));
xmlpp::Node::NodeSet *ns = JS::GetMaybePtrFromReservedSlot<xmlpp::Node::NodeSet>(hobj, 0);
if (!ns) {
args.rval().setInt32(0);
@ -216,7 +215,7 @@ htmlCollection_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::Mutab
hvp.setUndefined();
xmlpp::Node::NodeSet *ns = static_cast<xmlpp::Node::NodeSet *>(JS::GetPrivate(hobj));
xmlpp::Node::NodeSet *ns = JS::GetMaybePtrFromReservedSlot<xmlpp::Node::NodeSet>(hobj, 0);
if (!ns) {
return true;
@ -260,7 +259,7 @@ htmlCollection_namedItem2(JSContext *ctx, JS::HandleObject hobj, char *str, JS::
return false;
}
xmlpp::Node::NodeSet *ns = static_cast<xmlpp::Node::NodeSet *>(JS::GetPrivate(hobj));
xmlpp::Node::NodeSet *ns = JS::GetMaybePtrFromReservedSlot<xmlpp::Node::NodeSet>(hobj, 0);
if (!ns) {
return true;
@ -316,7 +315,7 @@ htmlCollection_set_items(JSContext *ctx, JS::HandleObject hobj, void *node)
}
int counter = 0;
xmlpp::Node::NodeSet *ns = static_cast<xmlpp::Node::NodeSet *>(JS::GetPrivate(hobj));
xmlpp::Node::NodeSet *ns = JS::GetMaybePtrFromReservedSlot<xmlpp::Node::NodeSet>(hobj, 0);
if (!ns) {
return true;
@ -373,7 +372,7 @@ getCollection(JSContext *ctx, void *node)
JS_DefineProperties(ctx, r_el, (JSPropertySpec *) htmlCollection_props);
spidermonkey_DefineFunctions(ctx, el, htmlCollection_funcs);
JS::SetPrivate(el, node);
JS::SetReservedSlot(el, 0, JS::PrivateValue(node));
htmlCollection_set_items(ctx, r_el, node);
return el;

View File

@ -42,7 +42,6 @@ JSClassOps console_ops = {
nullptr, // mayResolve
nullptr, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
@ -50,7 +49,7 @@ JSClassOps console_ops = {
/* Each @console_class object must have a @window_class parent. */
const JSClass console_class = {
"console",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&console_ops
};

View File

@ -65,7 +65,7 @@ static xmlpp::Document emptyDoc;
static JSObject *getDoctype(JSContext *ctx, void *node);
static void document_finalize(JSFreeOp *op, JSObject *obj)
static void document_finalize(JS::GCContext *op, JSObject *obj)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
@ -81,7 +81,6 @@ JSClassOps document_ops = {
nullptr, // mayResolve
document_finalize, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
@ -90,7 +89,7 @@ JSClassOps document_ops = {
/* Each @document_class object must have a @window_class parent. */
JSClass document_class = {
"document",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&document_ops
};
@ -2016,14 +2015,13 @@ JSClassOps doctype_ops = {
nullptr, // mayResolve
nullptr, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
JSClass doctype_class = {
"doctype",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&doctype_ops
};
@ -2054,7 +2052,7 @@ doctype_get_property_name(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Dtd *dtd = static_cast<xmlpp::Dtd *>(JS::GetPrivate(hobj));
xmlpp::Dtd *dtd = JS::GetMaybePtrFromReservedSlot<xmlpp::Dtd>(hobj, 0);
if (!dtd) {
args.rval().setNull();
@ -2094,7 +2092,7 @@ doctype_get_property_publicId(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Dtd *dtd = static_cast<xmlpp::Dtd *>(JS::GetPrivate(hobj));
xmlpp::Dtd *dtd = JS::GetMaybePtrFromReservedSlot<xmlpp::Dtd>(hobj, 0);
if (!dtd) {
args.rval().setNull();
@ -2134,7 +2132,7 @@ doctype_get_property_systemId(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Dtd *dtd = static_cast<xmlpp::Dtd *>(JS::GetPrivate(hobj));
xmlpp::Dtd *dtd = JS::GetMaybePtrFromReservedSlot<xmlpp::Dtd>(hobj, 0);
if (!dtd) {
args.rval().setNull();
@ -2168,7 +2166,7 @@ getDoctype(JSContext *ctx, void *node)
JS::RootedObject r_el(ctx, el);
JS_DefineProperties(ctx, r_el, (JSPropertySpec *) doctype_props);
JS::SetPrivate(el, node);
JS::SetReservedSlot(el, 0, JS::PrivateValue(node));
return el;
}
@ -2190,7 +2188,7 @@ getDocument(JSContext *ctx, void *doc)
JS_DefineProperties(ctx, r_el, (JSPropertySpec *) document_props);
spidermonkey_DefineFunctions(ctx, el, document_funcs);
JS::SetPrivate(el, doc);
JS::SetReservedSlot(el, 0, JS::PrivateValue(doc));
return el;
}

View File

@ -97,7 +97,7 @@ static bool element_set_property_textContent(JSContext *ctx, unsigned int argc,
static bool element_get_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool element_set_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp);
static void element_finalize(JSFreeOp *op, JSObject *obj);
static void element_finalize(JS::GCContext *op, JSObject *obj);
JSClassOps element_ops = {
nullptr, // addProperty
@ -108,14 +108,13 @@ JSClassOps element_ops = {
nullptr, // mayResolve
element_finalize, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
JSClass element_class = {
"element",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&element_ops
};
@ -151,7 +150,7 @@ JSPropertySpec element_props[] = {
JS_PS_END
};
static void element_finalize(JSFreeOp *op, JSObject *obj)
static void element_finalize(JS::GCContext *op, JSObject *obj)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
@ -198,7 +197,7 @@ element_get_property_attributes(JSContext *ctx, unsigned int argc, JS::Value *vp
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -258,7 +257,7 @@ element_get_property_children(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -334,7 +333,7 @@ element_get_property_childElementCount(JSContext *ctx, unsigned int argc, JS::Va
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -385,7 +384,7 @@ element_get_property_childNodes(JSContext *ctx, unsigned int argc, JS::Value *vp
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -445,7 +444,7 @@ element_get_property_className(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -498,7 +497,7 @@ element_get_property_dir(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -554,7 +553,7 @@ element_get_property_firstChild(JSContext *ctx, unsigned int argc, JS::Value *vp
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -613,7 +612,7 @@ element_get_property_firstElementChild(JSContext *ctx, unsigned int argc, JS::Va
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -681,7 +680,7 @@ element_get_property_id(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -733,7 +732,7 @@ element_get_property_lang(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -785,7 +784,7 @@ element_get_property_lastChild(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -843,7 +842,7 @@ element_get_property_lastElementChild(JSContext *ctx, unsigned int argc, JS::Val
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -911,7 +910,7 @@ element_get_property_nextElementSibling(JSContext *ctx, unsigned int argc, JS::V
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -979,7 +978,7 @@ element_get_property_nodeName(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Node *node = static_cast<xmlpp::Node *>(JS::GetPrivate(hobj));
xmlpp::Node *node = JS::GetMaybePtrFromReservedSlot<xmlpp::Node>(hobj, 0);
xmlpp::ustring v;
@ -1047,7 +1046,7 @@ element_get_property_nodeType(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Node *node = static_cast<xmlpp::Node *>(JS::GetPrivate(hobj));
xmlpp::Node *node = JS::GetMaybePtrFromReservedSlot<xmlpp::Node>(hobj, 0);
if (!node) {
args.rval().setNull();
@ -1109,7 +1108,7 @@ element_get_property_nodeValue(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Node *node = static_cast<xmlpp::Node *>(JS::GetPrivate(hobj));
xmlpp::Node *node = JS::GetMaybePtrFromReservedSlot<xmlpp::Node>(hobj, 0);
if (!node) {
args.rval().setNull();
@ -1188,7 +1187,7 @@ element_get_property_nextSibling(JSContext *ctx, unsigned int argc, JS::Value *v
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -1290,7 +1289,7 @@ element_get_property_parentElement(JSContext *ctx, unsigned int argc, JS::Value
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -1349,7 +1348,7 @@ element_get_property_parentNode(JSContext *ctx, unsigned int argc, JS::Value *vp
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -1408,7 +1407,7 @@ element_get_property_previousElementSibling(JSContext *ctx, unsigned int argc, J
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -1476,7 +1475,7 @@ element_get_property_previousSibling(JSContext *ctx, unsigned int argc, JS::Valu
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -1535,7 +1534,7 @@ element_get_property_tagName(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -1588,7 +1587,7 @@ element_get_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -1723,7 +1722,7 @@ element_get_property_innerHtml(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -1780,7 +1779,7 @@ element_get_property_outerHtml(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -1836,7 +1835,7 @@ element_get_property_textContent(JSContext *ctx, unsigned int argc, JS::Value *v
#endif
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -1891,7 +1890,7 @@ element_set_property_className(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
return true;
}
@ -1940,7 +1939,7 @@ element_set_property_dir(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
return true;
}
@ -1993,7 +1992,7 @@ element_set_property_id(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
return true;
}
@ -2043,7 +2042,7 @@ element_set_property_innerHtml(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
return true;
}
@ -2114,7 +2113,7 @@ element_set_property_innerText(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
return true;
}
@ -2169,7 +2168,7 @@ element_set_property_lang(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
return true;
}
@ -2296,7 +2295,7 @@ element_set_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
return true;
}
@ -2413,7 +2412,7 @@ element_appendChild(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -2421,7 +2420,7 @@ element_appendChild(JSContext *ctx, unsigned int argc, JS::Value *rval)
}
JS::RootedObject node(ctx, &args[0].toObject());
xmlpp::Node *el2 = static_cast<xmlpp::Node *>(JS::GetPrivate(node));
xmlpp::Node *el2 = JS::GetMaybePtrFromReservedSlot<xmlpp::Node>(node, 0);
el->import_node(el2);
interpreter->changed = true;
@ -2462,7 +2461,7 @@ element_cloneNode(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -2536,7 +2535,7 @@ element_closest(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setNull();
@ -2611,7 +2610,7 @@ element_contains(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setBoolean(false);
@ -2620,7 +2619,7 @@ element_contains(JSContext *ctx, unsigned int argc, JS::Value *rval)
JS::RootedObject node(ctx, &args[0].toObject());
xmlpp::Element *el2 = static_cast<xmlpp::Element *>(JS::GetPrivate(node));
xmlpp::Element *el2 = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(node, 0);
if (!el2) {
args.rval().setBoolean(false);
@ -2661,7 +2660,7 @@ element_getAttribute(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setBoolean(false);
@ -2712,7 +2711,7 @@ element_getAttributeNode(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setUndefined();
@ -2754,7 +2753,7 @@ element_hasAttribute(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setBoolean(false);
@ -2792,7 +2791,7 @@ element_hasAttributes(JSContext *ctx, unsigned int argc, JS::Value *rval)
args.rval().setBoolean(false);
return true;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setBoolean(false);
@ -2826,7 +2825,7 @@ element_hasChildNodes(JSContext *ctx, unsigned int argc, JS::Value *rval)
args.rval().setBoolean(false);
return true;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setBoolean(false);
@ -2862,7 +2861,7 @@ element_insertBefore(JSContext *ctx, unsigned int argc, JS::Value *rval)
args.rval().setBoolean(false);
return true;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
return true;
@ -2871,14 +2870,14 @@ element_insertBefore(JSContext *ctx, unsigned int argc, JS::Value *rval)
JS::RootedObject next_sibling1(ctx, &args[1].toObject());
JS::RootedObject child1(ctx, &args[0].toObject());
xmlpp::Node *next_sibling = static_cast<xmlpp::Node *>(JS::GetPrivate(next_sibling1));
xmlpp::Node *next_sibling = JS::GetMaybePtrFromReservedSlot<xmlpp::Node>(next_sibling1, 0);
if (!next_sibling) {
args.rval().setNull();
return true;
}
xmlpp::Node *child = static_cast<xmlpp::Node *>(JS::GetPrivate(child1));
xmlpp::Node *child = JS::GetMaybePtrFromReservedSlot<xmlpp::Node>(child1, 0);
auto node = xmlAddPrevSibling(next_sibling->cobj(), child->cobj());
auto res = el_add_child_element_common(child->cobj(), node);
@ -2914,7 +2913,7 @@ element_isEqualNode(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setBoolean(false);
@ -2923,7 +2922,7 @@ element_isEqualNode(JSContext *ctx, unsigned int argc, JS::Value *rval)
JS::RootedObject node(ctx, &args[0].toObject());
xmlpp::Element *el2 = static_cast<xmlpp::Element *>(JS::GetPrivate(node));
xmlpp::Element *el2 = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(node, 0);
struct string first;
struct string second;
@ -2972,7 +2971,7 @@ element_isSameNode(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setBoolean(false);
@ -2981,7 +2980,7 @@ element_isSameNode(JSContext *ctx, unsigned int argc, JS::Value *rval)
JS::RootedObject node(ctx, &args[0].toObject());
xmlpp::Element *el2 = static_cast<xmlpp::Element *>(JS::GetPrivate(node));
xmlpp::Element *el2 = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(node, 0);
args.rval().setBoolean(el == el2);
return true;
@ -3008,7 +3007,7 @@ element_matches(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setBoolean(false);
@ -3065,7 +3064,7 @@ element_querySelector(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setBoolean(false);
@ -3128,7 +3127,7 @@ element_querySelectorAll(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
args.rval().setBoolean(false);
@ -3200,7 +3199,7 @@ element_remove(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
return true;
@ -3239,7 +3238,7 @@ element_removeChild(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el || !args[0].isObject()) {
args.rval().setNull();
@ -3251,7 +3250,7 @@ element_removeChild(JSContext *ctx, unsigned int argc, JS::Value *rval)
auto children = el->get_children();
auto it = children.begin();
auto end = children.end();
xmlpp::Element *el2 = static_cast<xmlpp::Element *>(JS::GetPrivate(node));
xmlpp::Element *el2 = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(node, 0);
for (;it != end; ++it) {
if (*it == el2) {
@ -3297,7 +3296,7 @@ element_setAttribute(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
xmlpp::Element *el = static_cast<xmlpp::Element *>(JS::GetPrivate(hobj));
xmlpp::Element *el = JS::GetMaybePtrFromReservedSlot<xmlpp::Element>(hobj, 0);
if (!el) {
return true;
@ -3331,7 +3330,7 @@ getElement(JSContext *ctx, void *node)
JS_DefineProperties(ctx, r_el, (JSPropertySpec *) element_props);
spidermonkey_DefineFunctions(ctx, el, element_funcs);
JS::SetPrivate(el, node);
JS::SetReservedSlot(el, 0, JS::PrivateValue(node));
return el;
}

View File

@ -66,7 +66,7 @@ static bool form_set_property_name(JSContext *ctx, unsigned int argc, JS::Value
static bool form_get_property_target(JSContext *ctx, unsigned int argc, JS::Value *vp);
static bool form_set_property_target(JSContext *ctx, unsigned int argc, JS::Value *vp);
static void form_finalize(JSFreeOp *op, JSObject *obj);
static void form_finalize(JS::GCContext *op, JSObject *obj);
static JSClassOps form_ops = {
nullptr, // addProperty
@ -77,7 +77,6 @@ static JSClassOps form_ops = {
nullptr, // mayResolve
form_finalize, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
@ -85,7 +84,7 @@ static JSClassOps form_ops = {
/* Each @form_class object must have a @document_class parent. */
JSClass form_class = {
"form",
JSCLASS_HAS_PRIVATE, /* struct form_view *, or NULL if detached */
JSCLASS_HAS_RESERVED_SLOTS(1), /* struct form_view *, or NULL if detached */
&form_ops
};
@ -98,21 +97,7 @@ spidermonkey_detach_form_state(struct form_state *fs)
JSObject *jsinput = (JSObject *)fs->ecmascript_obj;
if (jsinput) {
// JS::RootedObject r_jsinput(spidermonkey_empty_context, jsinput);
/* This assumes JS_GetInstancePrivate and JS::SetPrivate
* cannot GC. */
/* If this assertion fails, it is not clear whether
* the private pointer of jsinput should be reset;
* crashes seem possible either way. Resetting it is
* easiest. */
// assert(JS_GetInstancePrivate(spidermonkey_empty_context,
// r_jsinput,
// &input_class, NULL)
// == fs);
// if_assert_failed {}
JS::SetPrivate(jsinput, NULL);
JS::SetReservedSlot(jsinput, 0, JS::UndefinedValue());
fs->ecmascript_obj = NULL;
}
}
@ -131,7 +116,7 @@ spidermonkey_moved_form_state(struct form_state *fs)
* other object whose struct form_state has also been
* reallocated, and an assertion would fail in
* input_finalize. */
JS::SetPrivate(jsinput, fs);
JS::SetReservedSlot(jsinput, 0, JS::PrivateValue(fs));
}
}
@ -167,7 +152,7 @@ get_form_control_object(JSContext *ctx,
}
}
static void elements_finalize(JSFreeOp *op, JSObject *obj);
static void elements_finalize(JS::GCContext *op, JSObject *obj);
static JSClassOps form_elements_ops = {
nullptr, // addProperty
@ -178,7 +163,6 @@ static JSClassOps form_elements_ops = {
nullptr, // mayResolve
elements_finalize, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
@ -186,7 +170,7 @@ static JSClassOps form_elements_ops = {
/* Each @form_elements_class object must have a @form_class parent. */
static JSClass form_elements_class = {
"elements",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&form_elements_ops
};
@ -220,12 +204,12 @@ static JSPropertySpec form_elements_props[] = {
};
static void
elements_finalize(JSFreeOp *op, JSObject *obj)
elements_finalize(JS::GCContext *op, JSObject *obj)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
struct form_view *fv = (struct form_view *)JS::GetPrivate(obj);
struct form_view *fv = JS::GetMaybePtrFromReservedSlot<struct form_view>(obj, 0);
if (fv) {
/* If this assertion fails, leave fv->ecmascript_obj
@ -277,7 +261,7 @@ form_set_items(JSContext *ctx, JS::HandleObject hobj, void *node)
doc_view = vs->doc_view;
document = doc_view->document;
form_view = (struct form_view *)JS_GetInstancePrivate(ctx, hobj, &form_elements_class, nullptr);
form_view = JS::GetMaybePtrFromReservedSlot<struct form_view>(hobj, 0);
if (!form_view) {
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s %d\n", __FILE__, __FUNCTION__, __LINE__);
@ -417,7 +401,7 @@ form_elements_get_property_length(JSContext *ctx, unsigned int argc, JS::Value *
doc_view = vs->doc_view;
document = doc_view->document;
form_view = (struct form_view *)JS_GetInstancePrivate(ctx, hobj, &form_elements_class, nullptr);
form_view = JS::GetMaybePtrFromReservedSlot<struct form_view>(hobj, 0);
if (!form_view) {
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s %d\n", __FILE__, __FUNCTION__, __LINE__);
@ -489,7 +473,7 @@ form_elements_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::Mutabl
doc_view = vs->doc_view;
document = doc_view->document;
form_view = (struct form_view *)JS_GetInstancePrivate(ctx, hobj, &form_elements_class, nullptr);
form_view = JS::GetMaybePtrFromReservedSlot<struct form_view>(hobj, 0);
if (!form_view) {
#ifdef ECMASCRIPT_DEBUG
@ -581,7 +565,7 @@ form_elements_namedItem2(JSContext *ctx, JS::HandleObject hobj, char *string, JS
doc_view = vs->doc_view;
document = doc_view->document;
form_view = (struct form_view *)JS_GetInstancePrivate(ctx, hobj, &form_elements_class, nullptr);
form_view = JS::GetMaybePtrFromReservedSlot<struct form_view>(hobj, 0);
if (!form_view) {
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s %d\n", __FILE__, __FUNCTION__, __LINE__);
@ -687,7 +671,7 @@ form_get_property_action(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
form = (struct form *)JS_GetInstancePrivate(ctx, hobj, &form_class, nullptr);
form = JS::GetMaybePtrFromReservedSlot<struct form>(hobj, 0);
assert(form);
args.rval().setString(JS_NewStringCopyZ(ctx, form->action));
@ -734,7 +718,7 @@ form_set_property_action(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
return false;
}
form = (struct form *)JS_GetInstancePrivate(ctx, hobj, &form_class, nullptr);
form = JS::GetMaybePtrFromReservedSlot<struct form>(hobj, 0);
assert(form);
string = jsval_to_string(ctx, args[0]);
@ -777,7 +761,7 @@ form_get_property_elements(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
struct form *form = (struct form *)JS_GetInstancePrivate(ctx, hobj, &form_class, nullptr);
struct form *form = JS::GetMaybePtrFromReservedSlot<struct form>(hobj, 0);
if (!form) {
#ifdef ECMASCRIPT_DEBUG
@ -810,7 +794,7 @@ form_get_property_elements(JSContext *ctx, unsigned int argc, JS::Value *vp)
JS_DefineProperties(ctx, r_jsform_elems, (JSPropertySpec *) form_elements_props);
spidermonkey_DefineFunctions(ctx, jsform_elems,
form_elements_funcs);
JS::SetPrivate(jsform_elems, fv);
JS::SetReservedSlot(jsform_elems, 0, JS::PrivateValue(fv));
fv->ecmascript_obj = jsform_elems;
form_set_items(ctx, r_jsform_elems, fv);
@ -859,7 +843,7 @@ form_get_property_encoding(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
return false;
}
form = (struct form *)JS_GetInstancePrivate(ctx, hobj, &form_class, nullptr);
form = JS::GetMaybePtrFromReservedSlot<struct form>(hobj, 0);
assert(form);
switch (form->method) {
@ -919,7 +903,7 @@ form_set_property_encoding(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
return false;
}
form = (struct form *)JS_GetInstancePrivate(ctx, hobj, &form_class, nullptr);
form = JS::GetMaybePtrFromReservedSlot<struct form>(hobj, 0);
assert(form);
string = jsval_to_string(ctx, args[0]);
@ -979,7 +963,7 @@ form_get_property_length(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
form = (struct form *)JS_GetInstancePrivate(ctx, hobj, &form_class, nullptr);
form = JS::GetMaybePtrFromReservedSlot<struct form>(hobj, 0);
assert(form);
args.rval().setInt32(list_size(&form->items));
@ -1026,7 +1010,7 @@ form_get_property_method(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
return false;
}
form = (struct form *)JS_GetInstancePrivate(ctx, hobj, &form_class, nullptr);
form = JS::GetMaybePtrFromReservedSlot<struct form>(hobj, 0);
assert(form);
switch (form->method) {
@ -1085,7 +1069,7 @@ form_set_property_method(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
return false;
}
form = (struct form *)JS_GetInstancePrivate(ctx, hobj, &form_class, nullptr);
form = JS::GetMaybePtrFromReservedSlot<struct form>(hobj, 0);
assert(form);
string = jsval_to_string(ctx, args[0]);
@ -1141,7 +1125,7 @@ form_get_property_name(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
return false;
}
form = (struct form *)JS_GetInstancePrivate(ctx, hobj, &form_class, nullptr);
form = JS::GetMaybePtrFromReservedSlot<struct form>(hobj, 0);
assert(form);
args.rval().setString(JS_NewStringCopyZ(ctx, form->name));
@ -1189,7 +1173,7 @@ form_set_property_name(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
return false;
}
form = (struct form *)JS_GetInstancePrivate(ctx, hobj, &form_class, nullptr);
form = JS::GetMaybePtrFromReservedSlot<struct form>(hobj, 0);
assert(form);
mem_free_set(&form->name, jsval_to_string(ctx, args[0]));
@ -1235,7 +1219,7 @@ form_get_property_target(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
return false;
}
form = (struct form *)JS_GetInstancePrivate(ctx, hobj, &form_class, nullptr);
form = JS::GetMaybePtrFromReservedSlot<struct form>(hobj, 0);
assert(form);
args.rval().setString(JS_NewStringCopyZ(ctx, form->target));
@ -1281,7 +1265,7 @@ form_set_property_target(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
return false;
}
form = (struct form *)JS_GetInstancePrivate(ctx, hobj, &form_class, nullptr);
form = JS::GetMaybePtrFromReservedSlot<struct form>(hobj, 0);
assert(form);
mem_free_set(&form->target, jsval_to_string(ctx, args[0]));
@ -1324,7 +1308,7 @@ form_reset(JSContext *ctx, unsigned int argc, JS::Value *rval)
vs = interpreter->vs;
doc_view = vs->doc_view;
form = (struct form *)JS_GetInstancePrivate(ctx, hobj, &form_class, nullptr);
form = JS::GetMaybePtrFromReservedSlot<struct form>(hobj, 0);
assert(form);
do_reset_form(doc_view, form);
@ -1373,7 +1357,7 @@ form_submit(JSContext *ctx, unsigned int argc, JS::Value *rval)
doc_view = vs->doc_view;
ses = doc_view->session;
form = (struct form *)JS_GetInstancePrivate(ctx, hobj, &form_class, nullptr);
form = JS::GetMaybePtrFromReservedSlot<struct form>(hobj, 0);
assert(form);
submit_given_form(ses, doc_view, form, 0);
@ -1392,13 +1376,6 @@ get_form_object(JSContext *ctx, JSObject *jsdoc, struct form *form)
JSObject *jsform = (JSObject *)form->ecmascript_obj;
if (jsform) {
JS::RootedObject r_jsform(ctx, jsform);
/* This assumes JS_GetInstancePrivate cannot GC. */
assert(JS_GetInstancePrivate(ctx, r_jsform,
&form_class, NULL)
== form);
if_assert_failed return NULL;
return jsform;
}
@ -1411,7 +1388,7 @@ get_form_object(JSContext *ctx, JSObject *jsdoc, struct form *form)
JS::RootedObject r_jsform(ctx, jsform);
JS_DefineProperties(ctx, r_jsform, form_props);
spidermonkey_DefineFunctions(ctx, jsform, form_funcs);
JS::SetPrivate(jsform, form); /* to @form_class */
JS::SetReservedSlot(jsform, 0, JS::PrivateValue(form)); /* to @form_class */
form->ecmascript_obj = jsform;
form_set_items2(ctx, r_jsform, form);
@ -1419,12 +1396,12 @@ get_form_object(JSContext *ctx, JSObject *jsdoc, struct form *form)
}
static void
form_finalize(JSFreeOp *op, JSObject *jsform)
form_finalize(JS::GCContext *op, JSObject *jsform)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
struct form *form = (struct form *)JS::GetPrivate(jsform);
struct form *form = JS::GetMaybePtrFromReservedSlot<struct form>(jsform, 0);
if (form) {
/* If this assertion fails, leave fv->ecmascript_obj
@ -1449,21 +1426,7 @@ spidermonkey_detach_form_view(struct form_view *fv)
JSObject *jsform = (JSObject *)fv->ecmascript_obj;
if (jsform) {
// JS::RootedObject r_jsform(spidermonkey_empty_context, jsform);
/* This assumes JS_GetInstancePrivate and JS::SetPrivate
* cannot GC. */
/* If this assertion fails, it is not clear whether
* the private pointer of jsform should be reset;
* crashes seem possible either way. Resetting it is
* easiest. */
// assert(JS_GetInstancePrivate(spidermonkey_empty_context,
// r_jsform,
// &form_class, NULL)
// == fv);
// if_assert_failed {}
JS::SetPrivate(jsform, NULL);
JS::SetReservedSlot(jsform, 0, JS::UndefinedValue());
fv->ecmascript_obj = NULL;
}
}

View File

@ -63,7 +63,6 @@ JSClassOps forms_ops = {
nullptr, // mayResolve
nullptr, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
@ -71,7 +70,7 @@ JSClassOps forms_ops = {
/* Each @forms_class object must have a @document_class parent. */
JSClass forms_class = {
"forms",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&forms_ops
};
@ -387,7 +386,7 @@ getForms(JSContext *ctx, void *node)
JS_DefineProperties(ctx, r_el, (JSPropertySpec *) forms_props);
spidermonkey_DefineFunctions(ctx, el, forms_funcs);
JS::SetPrivate(el, node);
JS::SetReservedSlot(el, 0, JS::PrivateValue(node));
forms_set_items(ctx, r_el, node);
return r_el;

View File

@ -58,14 +58,13 @@ JSClassOps history_ops = {
nullptr, // mayResolve
nullptr, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
JSClass history_class = {
"history",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&history_ops
};

View File

@ -29,14 +29,13 @@ static JSClassOps implementation_ops = {
nullptr, // mayResolve
nullptr, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
static JSClass implementation_class = {
"implementation",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&implementation_ops
};

View File

@ -56,7 +56,7 @@
* HTMLInputElement. The difference could be spotted only by some clever tricky
* JS code, but I hope it doesn't matter anywhere. --pasky */
static void input_finalize(JSFreeOp *op, JSObject *obj);
static void input_finalize(JS::GCContext *op, JSObject *obj);
static JSClassOps input_ops = {
nullptr, // addProperty
@ -67,7 +67,6 @@ static JSClassOps input_ops = {
nullptr, // mayResolve
input_finalize, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
@ -75,7 +74,7 @@ static JSClassOps input_ops = {
/* Each @input_class object must have a @form_class parent. */
static JSClass input_class = {
"input", /* here, we unleash ourselves */
JSCLASS_HAS_PRIVATE, /* struct form_state *, or NULL if detached */
JSCLASS_HAS_RESERVED_SLOTS(1), /* struct form_state *, or NULL if detached */
&input_ops
};
@ -1654,10 +1653,7 @@ input_get_form_state(JSContext *ctx, JSObject *jsinput)
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
JS::RootedObject r_jsinput(ctx, jsinput);
struct form_state *fs = (struct form_state *)JS_GetInstancePrivate(ctx, r_jsinput,
&input_class,
NULL);
struct form_state *fs = JS::GetMaybePtrFromReservedSlot<struct form_state>(jsinput, 0);
if (!fs) return NULL; /* detached */
@ -1834,13 +1830,6 @@ get_input_object(JSContext *ctx, struct form_state *fs)
JSObject *jsinput = (JSObject *)fs->ecmascript_obj;
if (jsinput) {
JS::RootedObject r_jsinput(ctx, jsinput);
/* This assumes JS_GetInstancePrivate cannot GC. */
assert(JS_GetInstancePrivate(ctx, r_jsinput,
&input_class, NULL)
== fs);
if_assert_failed return NULL;
return jsinput;
}
@ -1856,19 +1845,19 @@ get_input_object(JSContext *ctx, struct form_state *fs)
JS_DefineProperties(ctx, r_jsinput, (JSPropertySpec *) input_props);
spidermonkey_DefineFunctions(ctx, jsinput, input_funcs);
JS::SetPrivate(jsinput, fs); /* to @input_class */
JS::SetReservedSlot(jsinput, 0, JS::PrivateValue(fs)); /* to @input_class */
fs->ecmascript_obj = jsinput;
return jsinput;
}
static void
input_finalize(JSFreeOp *op, JSObject *jsinput)
input_finalize(JS::GCContext *op, JSObject *jsinput)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
struct form_state *fs = (struct form_state *)JS::GetPrivate(jsinput);
struct form_state *fs = JS::GetMaybePtrFromReservedSlot<struct form_state>(jsinput, 0);
if (fs) {
/* If this assertion fails, leave fs->ecmascript_obj

View File

@ -116,7 +116,6 @@ JSClassOps localstorage_ops = {
nullptr, // mayResolve
nullptr, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
@ -124,7 +123,7 @@ JSClassOps localstorage_ops = {
/* Each @localstorage_class object must have a @window_class parent. */
const JSClass localstorage_class = {
"localStorage",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&localstorage_ops
};

View File

@ -65,7 +65,7 @@ static bool location_get_property_search(JSContext *ctx, unsigned int argc, JS::
static bool location_set_property_search(JSContext *ctx, unsigned int argc, JS::Value *vp);
static void
location_finalize(JSFreeOp *op, JSObject *obj)
location_finalize(JS::GCContext *op, JSObject *obj)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
@ -81,14 +81,13 @@ JSClassOps location_ops = {
nullptr, // mayResolve
location_finalize, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
/* Each @location_class object must have a @window_class parent. */
JSClass location_class = {
"location",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&location_ops
};

View File

@ -52,7 +52,7 @@ static bool navigator_get_property_platform(JSContext *ctx, unsigned int argc, J
static bool navigator_get_property_userAgent(JSContext *ctx, unsigned int argc, JS::Value *vp);
static void
navigator_finalize(JSFreeOp *op, JSObject *obj)
navigator_finalize(JS::GCContext *op, JSObject *obj)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
@ -68,14 +68,13 @@ JSClassOps navigator_ops = {
nullptr, // mayResolve
navigator_finalize, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
JSClass navigator_class = {
"navigator",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&navigator_ops
};

View File

@ -59,7 +59,7 @@
static bool nodeList_item(JSContext *ctx, unsigned int argc, JS::Value *rval);
static bool nodeList_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::MutableHandleValue hvp);
static void nodeList_finalize(JSFreeOp *op, JSObject *obj)
static void nodeList_finalize(JS::GCContext *op, JSObject *obj)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
@ -75,14 +75,13 @@ JSClassOps nodeList_ops = {
nullptr, // mayResolve
nodeList_finalize, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
JSClass nodeList_class = {
"nodeList",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&nodeList_ops
};
@ -137,7 +136,7 @@ nodeList_get_property_length(JSContext *ctx, unsigned int argc, JS::Value *vp)
return false;
}
xmlpp::Node::NodeList *nl = static_cast<xmlpp::Node::NodeList *>(JS::GetPrivate(hobj));
xmlpp::Node::NodeList *nl = JS::GetMaybePtrFromReservedSlot<xmlpp::Node::NodeList>(hobj, 0);
if (!nl) {
args.rval().setInt32(0);
@ -190,7 +189,7 @@ nodeList_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::MutableHand
hvp.setUndefined();
xmlpp::Node::NodeList *nl = static_cast<xmlpp::Node::NodeList *>(JS::GetPrivate(hobj));
xmlpp::Node::NodeList *nl = JS::GetMaybePtrFromReservedSlot<xmlpp::Node::NodeList>(hobj, 0);
if (!nl) {
return true;
@ -241,7 +240,7 @@ nodeList_set_items(JSContext *ctx, JS::HandleObject hobj, void *node)
#endif
return false;
}
xmlpp::Node::NodeList *nl = static_cast<xmlpp::Node::NodeList *>(JS::GetPrivate(hobj));
xmlpp::Node::NodeList *nl = JS::GetMaybePtrFromReservedSlot<xmlpp::Node::NodeList>(hobj, 0);
if (!nl) {
return true;
@ -286,7 +285,7 @@ getNodeList(JSContext *ctx, void *node)
JS_DefineProperties(ctx, r_el, (JSPropertySpec *) nodeList_props);
spidermonkey_DefineFunctions(ctx, el, nodeList_funcs);
JS::SetPrivate(el, node);
JS::SetReservedSlot(el, 0, JS::PrivateValue(node));
nodeList_set_items(ctx, r_el, node);
return el;

View File

@ -46,7 +46,7 @@
#include "viewer/text/vs.h"
static void
screen_finalize(JSFreeOp *op, JSObject *obj)
screen_finalize(JS::GCContext *op, JSObject *obj)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
@ -63,14 +63,13 @@ JSClassOps screen_ops = {
nullptr, // mayResolve
screen_finalize, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
JSClass screen_class = {
"screen",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&screen_ops
};

View File

@ -49,7 +49,7 @@ static bool unibar_get_property_visible(JSContext *ctx, unsigned int argc, JS::V
static bool unibar_set_property_visible(JSContext *ctx, unsigned int argc, JS::Value *vp);
static void
menubar_finalize(JSFreeOp *op, JSObject *obj)
menubar_finalize(JS::GCContext *op, JSObject *obj)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
@ -65,7 +65,6 @@ JSClassOps menubar_ops = {
nullptr, // mayResolve
menubar_finalize, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
@ -73,12 +72,12 @@ JSClassOps menubar_ops = {
/* Each @menubar_class object must have a @window_class parent. */
JSClass menubar_class = {
"menubar",
JSCLASS_HAS_PRIVATE, /* const char * "t" */
JSCLASS_HAS_RESERVED_SLOTS(1), /* const char * "t" */
&menubar_ops
};
static void
statusbar_finalize(JSFreeOp *op, JSObject *obj)
statusbar_finalize(JS::GCContext *op, JSObject *obj)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
@ -94,14 +93,13 @@ JSClassOps statusbar_ops = {
nullptr, // mayResolve
statusbar_finalize, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
/* Each @statusbar_class object must have a @window_class parent. */
JSClass statusbar_class = {
"statusbar",
JSCLASS_HAS_PRIVATE, /* const char * "s" */
JSCLASS_HAS_RESERVED_SLOTS(1), /* const char * "s" */
&statusbar_ops
};
@ -163,7 +161,7 @@ unibar_get_property_visible(JSContext *ctx, unsigned int argc, JS::Value *vp)
}
doc_view = vs->doc_view;
status = &doc_view->session->status;
bar = (char *)JS::GetPrivate(hobj); /* from @menubar_class or @statusbar_class */
bar = JS::GetMaybePtrFromReservedSlot<char>(hobj, 0); /* from @menubar_class or @statusbar_class */
#define unibar_fetch(bar) \
status->force_show_##bar##_bar >= 0 \
@ -229,7 +227,7 @@ unibar_set_property_visible(JSContext *ctx, unsigned int argc, JS::Value *vp)
}
doc_view = vs->doc_view;
status = &doc_view->session->status;
bar = (char *)JS::GetPrivate(hobj); /* from @menubar_class or @statusbar_class */
bar = JS::GetMaybePtrFromReservedSlot<char>(hobj, 0); /* from @menubar_class or @statusbar_class */
switch (*bar) {
case 's':

View File

@ -56,7 +56,7 @@ static bool window_set_property_status(JSContext *ctx, unsigned int argc, JS::Va
static bool window_get_property_top(JSContext *ctx, unsigned int argc, JS::Value *vp);
static void
window_finalize(JSFreeOp *op, JSObject *obj)
window_finalize(JS::GCContext *op, JSObject *obj)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
@ -73,14 +73,13 @@ JSClassOps window_ops = {
nullptr, // mayResolve
window_finalize, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook
};
JSClass window_class = {
"window",
JSCLASS_HAS_PRIVATE | JSCLASS_GLOBAL_FLAGS, /* struct view_state * */
JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_GLOBAL_FLAGS, /* struct view_state * */
&window_ops
};

View File

@ -147,12 +147,12 @@ static void onreadystatechange_run(void *data);
static void ontimeout_run(void *data);
static void
xhr_finalize(JSFreeOp *op, JSObject *xhr_obj)
xhr_finalize(JS::GCContext *op, JSObject *xhr_obj)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
struct xhr *xhr = (struct xhr *)JS::GetPrivate(xhr_obj);
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(xhr_obj, 0);
if (xhr) {
if (xhr->uri) {
@ -168,7 +168,7 @@ xhr_finalize(JSFreeOp *op, JSObject *xhr_obj)
xhr->requestHeaders.clear();
mem_free(xhr);
JS::SetPrivate(xhr_obj, nullptr);
JS::SetReservedSlot(xhr_obj, 0, JS::UndefinedValue());
}
}
@ -181,14 +181,13 @@ JSClassOps xhr_ops = {
nullptr, // mayResolve
xhr_finalize, // finalize
nullptr, // call
nullptr, // hasInstance
nullptr, // construct
JS_GlobalObjectTraceHook // trace
};
JSClass xhr_class = {
"XMLHttpRequest",
JSCLASS_HAS_PRIVATE,
JSCLASS_HAS_RESERVED_SLOTS(1),
&xhr_ops
};
@ -217,7 +216,7 @@ xhr_constructor(JSContext* ctx, unsigned argc, JS::Value* vp)
xhr->interpreter = interpreter;
xhr->thisval = newObj;
xhr->async = true;
JS::SetPrivate(newObj, xhr);
JS::SetReservedSlot(newObj, 0, JS::PrivateValue(xhr));
args.rval().setObject(*newObj);
return true;
@ -281,7 +280,7 @@ xhr_abort(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS::GetRealmPrivate(comp);
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (xhr && xhr->download.conn) {
abort_connection(xhr->download.conn, connection_state(S_INTERRUPTED));
@ -308,7 +307,7 @@ xhr_getAllResponseHeaders(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS::GetRealmPrivate(comp);
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
struct view_state *vs = interpreter->vs;
if (!xhr) {
@ -340,7 +339,7 @@ xhr_getResponseHeader(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS::GetRealmPrivate(comp);
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
struct view_state *vs = interpreter->vs;
if (!xhr || argc == 0) {
@ -387,7 +386,7 @@ xhr_open(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS::GetRealmPrivate(comp);
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
struct view_state *vs = interpreter->vs;
if (!xhr) {
@ -701,7 +700,7 @@ xhr_send(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS::GetRealmPrivate(comp);
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
struct view_state *vs;
struct document_view *doc_view;
vs = interpreter->vs;
@ -867,7 +866,7 @@ xhr_setRequestHeader(JSContext *ctx, unsigned int argc, JS::Value *rval)
return false;
}
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS::GetRealmPrivate(comp);
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
struct view_state *vs;
struct document_view *doc_view;
vs = interpreter->vs;
@ -933,7 +932,7 @@ xhr_get_property_onabort(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -951,7 +950,7 @@ xhr_set_property_onabort(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -970,7 +969,7 @@ xhr_get_property_onerror(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -988,7 +987,7 @@ xhr_set_property_onerror(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -1007,7 +1006,7 @@ xhr_get_property_onload(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -1025,7 +1024,7 @@ xhr_set_property_onload(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -1044,7 +1043,7 @@ xhr_get_property_onloadend(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -1062,7 +1061,7 @@ xhr_set_property_onloadend(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -1081,7 +1080,7 @@ xhr_get_property_onloadstart(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -1099,7 +1098,7 @@ xhr_set_property_onloadstart(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -1118,7 +1117,7 @@ xhr_get_property_onprogress(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -1136,7 +1135,7 @@ xhr_set_property_onprogress(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -1155,7 +1154,7 @@ xhr_get_property_onreadystatechange(JSContext *ctx, unsigned int argc, JS::Value
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -1173,7 +1172,7 @@ xhr_set_property_onreadystatechange(JSContext *ctx, unsigned int argc, JS::Value
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -1192,7 +1191,7 @@ xhr_get_property_ontimeout(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -1210,7 +1209,7 @@ xhr_set_property_ontimeout(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -1229,7 +1228,7 @@ xhr_get_property_readyState(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
args.rval().setNull();
@ -1248,7 +1247,7 @@ xhr_get_property_response(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr || !xhr->response) {
args.rval().setNull();
@ -1267,7 +1266,7 @@ xhr_get_property_responseText(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr || !xhr->responseType) {
return false;
@ -1294,7 +1293,7 @@ xhr_get_property_responseType(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr || !xhr->responseType) {
args.rval().setNull();
@ -1313,7 +1312,7 @@ xhr_get_property_responseURL(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr || !xhr->responseURL) {
args.rval().setNull();
@ -1332,7 +1331,7 @@ xhr_get_property_status(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
args.rval().setNull();
@ -1351,7 +1350,7 @@ xhr_get_property_statusText(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr || !xhr->statusText) {
args.rval().setNull();
@ -1370,7 +1369,7 @@ xhr_get_property_upload(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr || !xhr->upload) {
args.rval().setNull();
@ -1389,7 +1388,7 @@ xhr_get_property_timeout(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
args.rval().setNull();
@ -1408,7 +1407,7 @@ xhr_get_property_withCredentials(JSContext *ctx, unsigned int argc, JS::Value *v
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
args.rval().setNull();
@ -1427,7 +1426,7 @@ xhr_set_property_responseType(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -1445,7 +1444,7 @@ xhr_set_property_timeout(JSContext *ctx, unsigned int argc, JS::Value *vp)
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;
@ -1468,7 +1467,7 @@ xhr_set_property_withCredentials(JSContext *ctx, unsigned int argc, JS::Value *v
#endif
JS::CallArgs args = CallArgsFromVp(argc, vp);
JS::RootedObject hobj(ctx, &args.thisv().toObject());
struct xhr *xhr = (struct xhr *)(JS::GetPrivate(hobj));
struct xhr *xhr = JS::GetMaybePtrFromReservedSlot<struct xhr>(hobj, 0);
if (!xhr) {
return false;