summaryrefslogtreecommitdiff
path: root/gi
diff options
context:
space:
mode:
authorEvan Welsh <contact@evanwelsh.com>2022-07-22 10:49:35 -0700
committerPhilip Chimento <philip.chimento@gmail.com>2022-08-07 16:42:03 -0700
commitfdcfc12272d0b25a4c028ffbe7ef1f4063db88f3 (patch)
tree04e3f438d5c77003767ade46168b7d1c7303836d /gi
parent1deacb549cc91a2e57aac0e484c4301a0a1b1e82 (diff)
downloadgjs-fdcfc12272d0b25a4c028ffbe7ef1f4063db88f3.tar.gz
js: Replace JSFreeOp with JS::GCContext
In particular, in finalize operations.
Diffstat (limited to 'gi')
-rw-r--r--gi/cwrapper.h6
-rw-r--r--gi/function.cpp4
-rw-r--r--gi/gtype.cpp2
-rw-r--r--gi/ns.cpp2
-rw-r--r--gi/object.cpp4
-rw-r--r--gi/object.h2
-rw-r--r--gi/param.cpp2
-rw-r--r--gi/wrapperutils.h10
8 files changed, 16 insertions, 16 deletions
diff --git a/gi/cwrapper.h b/gi/cwrapper.h
index bbcd216c..47c8e29a 100644
--- a/gi/cwrapper.h
+++ b/gi/cwrapper.h
@@ -204,7 +204,7 @@ class CWrapperPointerOps {
* class_spec's flags member.
* - static constexpr unsigned constructor_nargs: number of arguments that the
* constructor takes. If you implement constructor_impl() then also add this.
- * - void finalize_impl(JSFreeOp*, Wrapped*): called when the JS object is
+ * - void finalize_impl(JS::GCContext*, Wrapped*): called when the JS object is
* garbage collected, use this to free the C pointer and do any other cleanup
*
* Add optional functionality by setting members of class_spec:
@@ -291,14 +291,14 @@ class CWrapper : public CWrapperPointerOps<Base, Wrapped> {
debug_jsprop(message, gjs_debug_id(id).c_str(), obj);
}
- static void finalize(JSFreeOp* fop, JSObject* obj) {
+ static void finalize(JS::GCContext* gcx, JSObject* obj) {
Wrapped* priv = Base::for_js_nocheck(obj);
// Call only CWrapper's original method here, not any overrides; e.g.,
// we don't want to deal with a read barrier.
CWrapper::debug_lifecycle(priv, obj, "Finalize");
- Base::finalize_impl(fop, priv);
+ Base::finalize_impl(gcx, priv);
CWrapperPointerOps<Base, Wrapped>::unset_private(obj);
}
diff --git a/gi/function.cpp b/gi/function.cpp
index 8cce6834..08a0ea25 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -109,7 +109,7 @@ class Function : public CWrapper<Function> {
GJS_JSAPI_RETURN_CONVENTION
static bool call(JSContext* cx, unsigned argc, JS::Value* vp);
- static void finalize_impl(JSFreeOp*, Function* priv);
+ static void finalize_impl(JS::GCContext*, Function* priv);
GJS_JSAPI_RETURN_CONVENTION
static bool get_length(JSContext* cx, unsigned argc, JS::Value* vp);
@@ -1154,7 +1154,7 @@ Function::~Function() {
GJS_DEC_COUNTER(function);
}
-void Function::finalize_impl(JSFreeOp*, Function* priv) {
+void Function::finalize_impl(JS::GCContext*, Function* priv) {
if (priv == NULL)
return; /* we are the prototype, not a real instance, so constructor never called */
delete priv;
diff --git a/gi/gtype.cpp b/gi/gtype.cpp
index 58efef00..8f5bf38a 100644
--- a/gi/gtype.cpp
+++ b/gi/gtype.cpp
@@ -48,7 +48,7 @@ class GTypeObj : public CWrapper<GTypeObj, void> {
// No private data is allocated, it's stuffed directly in the private field
// of JSObject, so nothing to free
- static void finalize_impl(JSFreeOp*, void*) {}
+ static void finalize_impl(JS::GCContext*, void*) {}
// Properties
diff --git a/gi/ns.cpp b/gi/ns.cpp
index 1b546c3d..3ba019ba 100644
--- a/gi/ns.cpp
+++ b/gi/ns.cpp
@@ -152,7 +152,7 @@ class Ns : private GjsAutoChar, public CWrapper<Ns> {
return true;
}
- static void finalize_impl(JSFreeOp* fop [[maybe_unused]], Ns* priv) {
+ static void finalize_impl(JS::GCContext*, Ns* priv) {
g_assert(priv && "Finalize called on wrong object");
delete priv;
}
diff --git a/gi/object.cpp b/gi/object.cpp
index ed98ac50..3ced434f 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -1902,14 +1902,14 @@ void ObjectPrototype::trace_impl(JSTracer* tracer) {
Gjs::Closure::for_gclosure(closure)->trace(tracer);
}
-void ObjectInstance::finalize_impl(JSFreeOp* fop, JSObject* obj) {
+void ObjectInstance::finalize_impl(JS::GCContext* gcx, JSObject* obj) {
GTypeQuery query;
type_query_dynamic_safe(&query);
if (G_LIKELY(query.type))
JS::RemoveAssociatedMemory(obj, query.instance_size,
MemoryUse::GObjectInstanceStruct);
- GIWrapperInstance::finalize_impl(fop, obj);
+ GIWrapperInstance::finalize_impl(gcx, obj);
}
ObjectInstance::~ObjectInstance() {
diff --git a/gi/object.h b/gi/object.h
index cb9af171..e6016cb7 100644
--- a/gi/object.h
+++ b/gi/object.h
@@ -419,7 +419,7 @@ class ObjectInstance : public GIWrapperInstance<ObjectBase, ObjectPrototype,
GJS_JSAPI_RETURN_CONVENTION
bool add_property_impl(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
JS::HandleValue value);
- void finalize_impl(JSFreeOp* fop, JSObject* obj);
+ void finalize_impl(JS::GCContext*, JSObject* obj);
void trace_impl(JSTracer* trc);
/* JS property getters/setters */
diff --git a/gi/param.cpp b/gi/param.cpp
index 0c4e0409..089b7572 100644
--- a/gi/param.cpp
+++ b/gi/param.cpp
@@ -123,7 +123,7 @@ static bool gjs_param_constructor(JSContext* cx, unsigned argc, JS::Value* vp) {
return true;
}
-static void param_finalize(JSFreeOp*, JSObject* obj) {
+static void param_finalize(JS::GCContext*, JSObject* obj) {
Param* priv = Gjs::maybe_get_private<Param>(obj, POINTER);
gjs_debug_lifecycle(GJS_DEBUG_GPARAM, "finalize, obj %p priv %p", obj,
priv);
diff --git a/gi/wrapperutils.h b/gi/wrapperutils.h
index 719a78cc..16c55f11 100644
--- a/gi/wrapperutils.h
+++ b/gi/wrapperutils.h
@@ -395,7 +395,7 @@ class GIWrapperBase : public CWrapperPointerOps<Base> {
* necessary to include a finalize_impl() function in Prototype or Instance.
* Any needed finalization should be done in ~Prototype() and ~Instance().
*/
- static void finalize(JSFreeOp* fop, JSObject* obj) {
+ static void finalize(JS::GCContext* gcx, JSObject* obj) {
Base* priv = Base::for_js_nocheck(obj);
if (!priv)
return; // construction didn't finish
@@ -405,9 +405,9 @@ class GIWrapperBase : public CWrapperPointerOps<Base> {
static_cast<GIWrapperBase*>(priv)->debug_lifecycle(obj, "Finalize");
if (priv->is_prototype())
- priv->to_prototype()->finalize_impl(fop, obj);
+ priv->to_prototype()->finalize_impl(gcx, obj);
else
- priv->to_instance()->finalize_impl(fop, obj);
+ priv->to_instance()->finalize_impl(gcx, obj);
Base::unset_private(obj);
}
@@ -1013,7 +1013,7 @@ class GIWrapperPrototype : public Base {
// JSClass operations
protected:
- void finalize_impl(JSFreeOp*, JSObject*) { release(); }
+ void finalize_impl(JS::GCContext*, JSObject*) { release(); }
// Override if necessary
void trace_impl(JSTracer*) {}
@@ -1108,7 +1108,7 @@ class GIWrapperInstance : public Base {
// JSClass operations
protected:
- void finalize_impl(JSFreeOp*, JSObject*) {
+ void finalize_impl(JS::GCContext*, JSObject*) {
delete static_cast<Instance*>(this);
}