[gjs/mozjs91: 2/10] JSID_* macros have been replaced with a class-based API




commit 60e2f1bead43b40077c4368c76c7adca3a5942fb
Author: Evan Welsh <contact evanwelsh com>
Date:   Sat Jul 10 20:49:11 2021 -0700

    JSID_* macros have been replaced with a class-based API
    
    See https://bugzilla.mozilla.org/show_bug.cgi?id=1717279
    See https://bugzilla.mozilla.org/show_bug.cgi?id=1695736

 gi/boxed.cpp              |  4 ++--
 gi/ns.cpp                 |  4 ++--
 gi/object.cpp             |  8 ++++----
 gi/object.h               | 10 +++++-----
 gi/private.cpp            |  4 ++--
 gi/repo.cpp               |  4 ++--
 gjs/importer.cpp          |  6 +++---
 gjs/jsapi-util-string.cpp |  6 +++---
 8 files changed, 23 insertions(+), 23 deletions(-)
---
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 7327c317..b7ac7d0c 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -229,13 +229,13 @@ bool BoxedInstance::init_from_props(JSContext* context, JS::Value props_value) {
 
     JS::RootedValue value(context);
     for (ix = 0, length = ids.length(); ix < length; ix++) {
-        if (!JSID_IS_STRING(ids[ix])) {
+        if (!ids[ix].isString()) {
             gjs_throw(context, "Fields hash contained a non-string field");
             return false;
         }
 
         GIFieldInfo* field_info =
-            get_prototype()->lookup_field(context, JSID_TO_STRING(ids[ix]));
+            get_prototype()->lookup_field(context, ids[ix].toString());
         if (!field_info)
             return false;
 
diff --git a/gi/ns.cpp b/gi/ns.cpp
index ba08b19c..f14d4d21 100644
--- a/gi/ns.cpp
+++ b/gi/ns.cpp
@@ -10,7 +10,7 @@
 #include <js/CallArgs.h>
 #include <js/Class.h>
 #include <js/ComparisonOperators.h>
-#include <js/Id.h>  // for JSID_IS_STRING
+#include <js/Id.h>
 #include <js/PropertyDescriptor.h>  // for JSPROP_READONLY
 #include <js/PropertySpec.h>
 #include <js/RootingAPI.h>
@@ -80,7 +80,7 @@ class Ns : private GjsAutoChar, public CWrapper<Ns> {
     GJS_JSAPI_RETURN_CONVENTION
     bool resolve_impl(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
                       bool* resolved) {
-        if (!JSID_IS_STRING(id)) {
+        if (!id.isString()) {
             *resolved = false;
             return true;  // not resolved, but no error
         }
diff --git a/gi/object.cpp b/gi/object.cpp
index 7594b00d..c05804c1 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -627,7 +627,7 @@ bool ObjectPrototype::lazy_define_gobject_property(JSContext* cx,
 
     debug_jsprop("Defining lazy GObject property", id, obj);
 
-    JS::RootedValue private_id(cx, JS::StringValue(JSID_TO_STRING(id)));
+    JS::RootedValue private_id(cx, JS::StringValue(id.toString()));
     if (!gjs_define_property_dynamic(
             cx, obj, name, "gobject_prop", &ObjectBase::prop_getter,
             &ObjectBase::prop_setter, private_id,
@@ -849,7 +849,7 @@ bool ObjectPrototype::uncached_resolve(JSContext* context, JS::HandleObject obj,
         if (!(g_field_info_get_flags(field_info) & GI_FIELD_IS_WRITABLE))
             flags |= JSPROP_READONLY;
 
-        JS::RootedString key(context, JSID_TO_STRING(id));
+        JS::RootedString key(context, id.toString());
         if (!m_field_cache.putNew(key, field_info.release())) {
             JS_ReportOutOfMemory(context);
             return false;
@@ -1023,11 +1023,11 @@ bool ObjectPrototype::props_to_g_parameters(JSContext* context,
          * doesn't know that */
         prop_id = ids[ix];
 
-        if (!JSID_IS_STRING(prop_id))
+        if (!prop_id.isString())
             return gjs_wrapper_throw_nonexistent_field(
                 context, m_gtype, gjs_debug_id(prop_id).c_str());
 
-        JS::RootedString js_prop_name(context, JSID_TO_STRING(prop_id));
+        JS::RootedString js_prop_name(context, prop_id.toString());
         GParamSpec *param_spec = find_param_spec_from_id(context, js_prop_name);
         if (!param_spec)
             return false;
diff --git a/gi/object.h b/gi/object.h
index 0d9d40fe..6367663d 100644
--- a/gi/object.h
+++ b/gi/object.h
@@ -23,7 +23,7 @@
 #include <js/PropertySpec.h>
 #include <js/RootingAPI.h>
 #include <js/TypeDecls.h>
-#include <jsfriendapi.h>            // for JSID_IS_ATOM, JSID_TO_ATOM
+#include <jsfriendapi.h>
 #include <mozilla/HashFunctions.h>  // for HashGeneric, HashNumber
 #include <mozilla/Likely.h>         // for MOZ_LIKELY
 
@@ -169,10 +169,10 @@ class ObjectBase
 struct IdHasher {
     typedef jsid Lookup;
     static mozilla::HashNumber hash(jsid id) {
-        if (MOZ_LIKELY(JSID_IS_ATOM(id)))
-            return js::DefaultHasher<JSAtom*>::hash(JSID_TO_ATOM(id));
-        if (JSID_IS_SYMBOL(id))
-            return js::DefaultHasher<JS::Symbol*>::hash(JSID_TO_SYMBOL(id));
+        if (MOZ_LIKELY(id.isAtom()))
+            return js::DefaultHasher<JSAtom*>::hash(id.toAtom());
+        if (id.isSymbol())
+            return js::DefaultHasher<JS::Symbol*>::hash(id.toSymbol());
         return mozilla::HashGeneric(JSID_BITS(id));
     }
     static bool match(jsid id1, jsid id2) { return id1 == id2; }
diff --git a/gi/private.cpp b/gi/private.cpp
index a6ecc723..7029d215 100644
--- a/gi/private.cpp
+++ b/gi/private.cpp
@@ -12,7 +12,7 @@
 
 #include <js/Array.h>  // for JS::GetArrayLength,
 #include <js/CallArgs.h>
-#include <js/Id.h>  // for JSID_TO_SYMBOL
+#include <js/Id.h>
 #include <js/PropertySpec.h>
 #include <js/RootingAPI.h>
 #include <js/TypeDecls.h>
@@ -399,7 +399,7 @@ GJS_JSAPI_RETURN_CONVENTION static bool symbol_getter(JSContext* cx,
                                                       JS::Value* vp) {
     JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     const GjsAtoms& atoms = GjsContextPrivate::atoms(cx);
-    args.rval().setSymbol(JSID_TO_SYMBOL((atoms.*member)()));
+    args.rval().setSymbol((atoms.*member)().toSymbol());
     return true;
 }
 
diff --git a/gi/repo.cpp b/gi/repo.cpp
index 2435f647..df78f263 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -17,7 +17,7 @@
 
 #include <js/Class.h>
 #include <js/ComparisonOperators.h>
-#include <js/Id.h>                  // for JSID_IS_STRING, JSID_VOID
+#include <js/Id.h>                  // for JSID_VOID
 #include <js/PropertyDescriptor.h>  // for JSPROP_PERMANENT, JSPROP_RESOLVING
 #include <js/RootingAPI.h>
 #include <js/TypeDecls.h>
@@ -156,7 +156,7 @@ repo_resolve(JSContext       *context,
              JS::HandleId     id,
              bool            *resolved)
 {
-    if (!JSID_IS_STRING(id)) {
+    if (!id.isString()) {
         *resolved = false;
         return true; /* not resolved, but no error */
     }
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index 23947198..7b48dad6 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -23,7 +23,7 @@
 #include <js/CharacterEncoding.h>
 #include <js/Class.h>
 #include <js/ComparisonOperators.h>
-#include <js/Id.h>        // for PropertyKey, JSID_IS_STRING
+#include <js/Id.h>  // for PropertyKey
 #include <js/PropertyDescriptor.h>
 #include <js/PropertySpec.h>
 #include <js/RootingAPI.h>
@@ -724,7 +724,7 @@ importer_resolve(JSContext        *context,
                  JS::HandleId      id,
                  bool             *resolved)
 {
-    if (!JSID_IS_STRING(id)) {
+    if (!id.isString()) {
         *resolved = false;
         return true;
     }
@@ -739,7 +739,7 @@ importer_resolve(JSContext        *context,
     gjs_debug_jsprop(GJS_DEBUG_IMPORTER, "Resolve prop '%s' hook, obj %s",
                      gjs_debug_id(id).c_str(), gjs_debug_object(obj).c_str());
 
-    if (!JSID_IS_STRING(id)) {
+    if (!id.isString()) {
         *resolved = false;
         return true;
     }
diff --git a/gjs/jsapi-util-string.cpp b/gjs/jsapi-util-string.cpp
index 3119d05a..4e9fe51a 100644
--- a/gjs/jsapi-util-string.cpp
+++ b/gjs/jsapi-util-string.cpp
@@ -21,7 +21,7 @@
 #include <js/Class.h>
 #include <js/ComparisonOperators.h>
 #include <js/GCAPI.h>  // for AutoCheckCannotGC
-#include <js/Id.h>     // for JSID_IS_STRING...
+#include <js/Id.h>
 #include <js/Promise.h>
 #include <js/RootingAPI.h>
 #include <js/String.h>
@@ -350,7 +350,7 @@ gjs_string_from_ucs4(JSContext             *cx,
  * Returns: false on error, otherwise true
  **/
 bool gjs_get_string_id(JSContext* cx, jsid id, JS::UniqueChars* name_p) {
-    if (!JSID_IS_STRING(id)) {
+    if (!id.isString()) {
         name_p->reset();
         return true;
     }
@@ -573,7 +573,7 @@ gjs_debug_value(JS::Value v)
 std::string
 gjs_debug_id(jsid id)
 {
-    if (JSID_IS_STRING(id))
+    if (id.isString())
         return gjs_debug_linear_string(JSID_TO_LINEAR_STRING(id), NoQuotes);
     return gjs_debug_value(js::IdToValue(id));
 }


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