[gjs/mozjs91: 3/17] JS_[Get,Set]Private is now JS::[Get,Set]Private




commit c72697ec6755a674525ff2d139f341cf195aff46
Author: Evan Welsh <contact evanwelsh com>
Date:   Sat Jul 10 20:14:56 2021 -0700

    JS_[Get,Set]Private is now JS::[Get,Set]Private
    
    See https://bugzilla.mozilla.org/show_bug.cgi?id=1663365

 gi/cwrapper.h             | 10 +++++-----
 gi/function.cpp           |  4 ++--
 gi/gtype.cpp              |  2 +-
 gi/ns.cpp                 |  6 +++---
 gi/param.cpp              |  6 +++---
 gi/wrapperutils.h         | 10 +++++-----
 gjs/context.cpp           |  2 +-
 gjs/module.cpp            |  4 ++--
 modules/cairo-context.cpp |  2 +-
 modules/cairo-path.cpp    |  4 ++--
 modules/cairo-pattern.cpp |  4 ++--
 modules/cairo-surface.cpp |  4 ++--
 test/gjs-test-rooting.cpp |  6 +++---
 13 files changed, 32 insertions(+), 32 deletions(-)
---
diff --git a/gi/cwrapper.h b/gi/cwrapper.h
index 6a0b24f0..55324380 100644
--- a/gi/cwrapper.h
+++ b/gi/cwrapper.h
@@ -135,7 +135,7 @@ class CWrapperPointerOps {
      * (It can return null if no private data has been set yet on the wrapper.)
      */
     [[nodiscard]] static Wrapped* for_js_nocheck(JSObject* wrapper) {
-        return static_cast<Wrapped*>(JS_GetPrivate(wrapper));
+        return static_cast<Wrapped*>(JS::GetPrivate(wrapper));
     }
 };
 
@@ -214,7 +214,7 @@ class CWrapper : public CWrapperPointerOps<Base, Wrapped> {
         Wrapped* priv = Base::constructor_impl(cx, args);
         if (!priv)
             return false;
-        JS_SetPrivate(object, priv);
+        JS::SetPrivate(object, priv);
 
         args.rval().setObject(*object);
         return true;
@@ -259,7 +259,7 @@ class CWrapper : public CWrapperPointerOps<Base, Wrapped> {
         Base::finalize_impl(fop, priv);
 
         // Remove the pointer from the JSObject
-        JS_SetPrivate(obj, nullptr);
+        JS::SetPrivate(obj, nullptr);
     }
 
     static constexpr JSClassOps class_ops = {
@@ -495,8 +495,8 @@ class CWrapper : public CWrapperPointerOps<Base, Wrapped> {
         if (!wrapper)
             return nullptr;
 
-        assert(!JS_GetPrivate(wrapper));
-        JS_SetPrivate(wrapper, Base::copy_ptr(ptr));
+        assert(!JS::GetPrivate(wrapper));
+        JS::SetPrivate(wrapper, Base::copy_ptr(ptr));
 
         debug_lifecycle(ptr, wrapper, "from_c_ptr");
 
diff --git a/gi/function.cpp b/gi/function.cpp
index 4c9c649a..9f74a257 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -1292,8 +1292,8 @@ JSObject* Function::create(JSContext* context, GType gtype,
 
     auto* priv = new Function(info);
 
-    g_assert(!JS_GetPrivate(function) && "Function should be a fresh object");
-    JS_SetPrivate(function, priv);
+    g_assert(!JS::GetPrivate(function) && "Function should be a fresh object");
+    JS::SetPrivate(function, priv);
 
     debug_lifecycle(function, priv, "Constructor");
 
diff --git a/gi/gtype.cpp b/gi/gtype.cpp
index 7ccb8099..28eb0acd 100644
--- a/gi/gtype.cpp
+++ b/gi/gtype.cpp
@@ -170,7 +170,7 @@ class GTypeObj : public CWrapper<GTypeObj, void> {
         if (!gtype_wrapper)
             return nullptr;
 
-        JS_SetPrivate(gtype_wrapper, GSIZE_TO_POINTER(gtype));
+        JS::SetPrivate(gtype_wrapper, GSIZE_TO_POINTER(gtype));
 
         gjs->gtype_table().put(gtype, gtype_wrapper);
 
diff --git a/gi/ns.cpp b/gi/ns.cpp
index 54ab994d..ba08b19c 100644
--- a/gi/ns.cpp
+++ b/gi/ns.cpp
@@ -16,7 +16,7 @@
 #include <js/RootingAPI.h>
 #include <js/TypeDecls.h>
 #include <js/Utility.h>  // for UniqueChars
-#include <jsapi.h>       // for JS_GetPrivate, JS_NewObjectWithGivenProto
+#include <jsapi.h>       // for JS::GetPrivate, JS_NewObjectWithGivenProto
 
 #include "gi/cwrapper.h"
 #include "gi/ns.h"
@@ -217,8 +217,8 @@ class Ns : private GjsAutoChar, public CWrapper<Ns> {
             return nullptr;
 
         auto* priv = new Ns(ns_name);
-        g_assert(!JS_GetPrivate(ns));
-        JS_SetPrivate(ns, priv);
+        g_assert(!JS::GetPrivate(ns));
+        JS::SetPrivate(ns, priv);
 
         gjs_debug_lifecycle(GJS_DEBUG_GNAMESPACE,
                             "ns constructor, obj %p priv %p", ns.get(), priv);
diff --git a/gi/param.cpp b/gi/param.cpp
index 29d2e6f0..9bc43be7 100644
--- a/gi/param.cpp
+++ b/gi/param.cpp
@@ -113,14 +113,14 @@ static bool gjs_param_constructor(JSContext* cx, unsigned argc, JS::Value* vp) {
 }
 
 static void param_finalize(JSFreeOp*, JSObject* obj) {
-    Param* priv = static_cast<Param*>(JS_GetPrivate(obj));
+    Param* priv = static_cast<Param*>(JS::GetPrivate(obj));
     gjs_debug_lifecycle(GJS_DEBUG_GPARAM, "finalize, obj %p priv %p", obj,
                         priv);
     if (!priv)
         return; /* wrong class? */
 
     GJS_DEC_COUNTER(param);
-    JS_SetPrivate(obj, nullptr);
+    JS::SetPrivate(obj, nullptr);
     delete priv;
 }
 
@@ -219,7 +219,7 @@ gjs_param_from_g_param(JSContext    *context,
 
     GJS_INC_COUNTER(param);
     auto* priv = new Param(gparam);
-    JS_SetPrivate(obj, priv);
+    JS::SetPrivate(obj, priv);
 
     gjs_debug(GJS_DEBUG_GPARAM,
               "JSObject created with param instance %p type %s", gparam,
diff --git a/gi/wrapperutils.h b/gi/wrapperutils.h
index 777fb72c..15f50c90 100644
--- a/gi/wrapperutils.h
+++ b/gi/wrapperutils.h
@@ -22,7 +22,7 @@
 #include <js/MemoryFunctions.h>
 #include <js/RootingAPI.h>
 #include <js/TypeDecls.h>
-#include <jsapi.h>       // for JS_GetPrivate, JS_SetPrivate, JS_Ge...
+#include <jsapi.h>       // for JS::GetPrivate, JS::SetPrivate, JS_Ge...
 #include <jspubtd.h>     // for JSProto_TypeError
 
 #include "gi/arg-inl.h"
@@ -369,7 +369,7 @@ class GIWrapperBase : public CWrapperPointerOps<Base> {
             priv->to_instance()->finalize_impl(fop, obj);
 
         // Remove the pointer from the JSObject
-        JS_SetPrivate(obj, nullptr);
+        JS::SetPrivate(obj, nullptr);
     }
 
     /*
@@ -852,7 +852,7 @@ class GIWrapperPrototype : public Base {
         // a garbage collection or error happens subsequently, then this object
         // might be traced and we would end up dereferencing a null pointer.
         Prototype* proto = priv.release();
-        JS_SetPrivate(prototype, proto);
+        JS::SetPrivate(prototype, proto);
 
         if (!gjs_wrapper_define_gtype_prop(cx, constructor, gtype))
             return nullptr;
@@ -970,13 +970,13 @@ class GIWrapperInstance : public Base {
      */
     [[nodiscard]] static Instance* new_for_js_object(JSContext* cx,
                                                      JS::HandleObject obj) {
-        g_assert(!JS_GetPrivate(obj));
+        g_assert(!JS::GetPrivate(obj));
         auto* priv = new Instance(cx, obj);
 
         // Init the private variable before we do anything else. If a garbage
         // collection happens when calling the constructor, then this object
         // might be traced and we would end up dereferencing a null pointer.
-        JS_SetPrivate(obj, priv);
+        JS::SetPrivate(obj, priv);
 
         return priv;
     }
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 8930502d..6ed6dd62 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -420,7 +420,7 @@ void GjsContextPrivate::dispose(void) {
         m_gtype_table->clear();
 
         /* Do a full GC here before tearing down, since once we do
-         * that we may not have the JS_GetPrivate() to access the
+         * that we may not have the JS::GetPrivate() to access the
          * context
          */
         gjs_debug(GJS_DEBUG_CONTEXT, "Final triggered GC");
diff --git a/gjs/module.cpp b/gjs/module.cpp
index 2c0840f7..b831cfcd 100644
--- a/gjs/module.cpp
+++ b/gjs/module.cpp
@@ -63,13 +63,13 @@ class GjsScriptModule {
     /* Private data accessors */
 
     [[nodiscard]] static inline GjsScriptModule* priv(JSObject* module) {
-        return static_cast<GjsScriptModule*>(JS_GetPrivate(module));
+        return static_cast<GjsScriptModule*>(JS::GetPrivate(module));
     }
 
     /* Creates a JS module object. Use instead of the class's constructor */
     [[nodiscard]] static JSObject* create(JSContext* cx, const char* name) {
         JSObject* module = JS_NewObject(cx, &GjsScriptModule::klass);
-        JS_SetPrivate(module, new GjsScriptModule(name));
+        JS::SetPrivate(module, new GjsScriptModule(name));
         return module;
     }
 
diff --git a/modules/cairo-context.cpp b/modules/cairo-context.cpp
index 803b9e19..d1176481 100644
--- a/modules/cairo-context.cpp
+++ b/modules/cairo-context.cpp
@@ -368,7 +368,7 @@ dispose_func(JSContext *context,
     _GJS_CAIRO_CONTEXT_GET_PRIV_CR_CHECKED(context, argc, vp, rec, obj);
 
     cairo_destroy(cr);
-    JS_SetPrivate(obj, nullptr);
+    JS::SetPrivate(obj, nullptr);
 
     rec.rval().setUndefined();
     return true;
diff --git a/modules/cairo-path.cpp b/modules/cairo-path.cpp
index a4a82725..e581f9c1 100644
--- a/modules/cairo-path.cpp
+++ b/modules/cairo-path.cpp
@@ -37,8 +37,8 @@ JSObject* CairoPath::take_c_ptr(JSContext* cx, cairo_path_t* ptr) {
     if (!wrapper)
         return nullptr;
 
-    g_assert(!JS_GetPrivate(wrapper));
-    JS_SetPrivate(wrapper, ptr);
+    g_assert(!JS::GetPrivate(wrapper));
+    JS::SetPrivate(wrapper, ptr);
 
     debug_lifecycle(ptr, wrapper, "take_c_ptr");
 
diff --git a/modules/cairo-pattern.cpp b/modules/cairo-pattern.cpp
index 093e6fd8..679200d4 100644
--- a/modules/cairo-pattern.cpp
+++ b/modules/cairo-pattern.cpp
@@ -13,7 +13,7 @@
 #include <js/PropertySpec.h>
 #include <js/RootingAPI.h>
 #include <js/TypeDecls.h>
-#include <jsapi.h>  // for JS_GetPrivate, JS_GetClass, ...
+#include <jsapi.h>  // for JS::GetPrivate, JS_GetClass, ...
 
 #include "gjs/jsapi-class.h"
 #include "gjs/jsapi-util.h"
@@ -136,5 +136,5 @@ cairo_pattern_t* CairoPattern::for_js(JSContext* cx,
         return nullptr;
     }
 
-    return static_cast<cairo_pattern_t*>(JS_GetPrivate(pattern_wrapper));
+    return static_cast<cairo_pattern_t*>(JS::GetPrivate(pattern_wrapper));
 }
diff --git a/modules/cairo-surface.cpp b/modules/cairo-surface.cpp
index 287598e4..c93955bb 100644
--- a/modules/cairo-surface.cpp
+++ b/modules/cairo-surface.cpp
@@ -15,7 +15,7 @@
 #include <js/RootingAPI.h>
 #include <js/TypeDecls.h>
 #include <js/Value.h>
-#include <jsapi.h>  // for JS_GetPrivate, JS_GetClass, ...
+#include <jsapi.h>  // for JS::GetPrivate, JS_GetClass, ...
 
 #include "gi/arg-inl.h"
 #include "gi/arg.h"
@@ -170,7 +170,7 @@ cairo_surface_t* CairoSurface::for_js(JSContext* cx,
         return nullptr;
     }
 
-    return static_cast<cairo_surface_t*>(JS_GetPrivate(surface_wrapper));
+    return static_cast<cairo_surface_t*>(JS::GetPrivate(surface_wrapper));
 }
 
 [[nodiscard]] static bool surface_to_g_argument(
diff --git a/test/gjs-test-rooting.cpp b/test/gjs-test-rooting.cpp
index a58753da..380e80f7 100644
--- a/test/gjs-test-rooting.cpp
+++ b/test/gjs-test-rooting.cpp
@@ -10,7 +10,7 @@
 #include <js/RootingAPI.h>
 #include <js/TypeDecls.h>
 #include <js/Value.h>
-#include <jsapi.h>  // for JS_GetPrivate, JS_NewObject, JS_Set...
+#include <jsapi.h>  // for JS::GetPrivate, JS_NewObject, JS_Set...
 
 #include "gjs/context-private.h"
 #include "gjs/jsapi-util-root.h"
@@ -37,7 +37,7 @@ struct GjsRootingFixture {
 };
 
 static void test_obj_finalize(JSFreeOp*, JSObject* obj) {
-    bool *finalized_p = static_cast<bool *>(JS_GetPrivate(obj));
+    bool* finalized_p = static_cast<bool*>(JS::GetPrivate(obj));
     g_assert_false(*finalized_p);
     *finalized_p = true;
 }
@@ -61,7 +61,7 @@ static JSObject *
 test_obj_new(GjsRootingFixture *fx)
 {
     JSObject *retval = JS_NewObject(PARENT(fx)->cx, &test_obj_class);
-    JS_SetPrivate(retval, &fx->finalized);
+    JS::SetPrivate(retval, &fx->finalized);
     return retval;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]