1
0
Fork 0

[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) {