[gjs/mozjs102: 53/59] js: Adapt to new JS::PropertyKey API




commit 119ff8a0e00eec1582da7afc8a8fdcce0db917b0
Author: Evan Welsh <contact evanwelsh com>
Date:   Fri Jul 22 10:35:17 2022 -0700

    js: Adapt to new JS::PropertyKey API

 gi/boxed.cpp              | 6 +++---
 gi/object.cpp             | 6 +++---
 gi/object.h               | 2 +-
 gjs/atoms.cpp             | 2 +-
 gjs/importer.cpp          | 6 +++---
 gjs/jsapi-util-string.cpp | 6 +++---
 6 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 0ab097b0a..88b4699ed 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -927,7 +927,7 @@ BoxedPrototype::BoxedPrototype(GIStructInfo* info, GType gtype)
     : GIWrapperPrototype(info, gtype),
       m_zero_args_constructor(-1),
       m_default_constructor(-1),
-      m_default_constructor_name(JSID_VOID),
+      m_default_constructor_name(JS::PropertyKey::Void()),
       m_can_allocate_directly(struct_is_simple(info)) {
     if (!m_can_allocate_directly) {
         m_can_allocate_directly_without_pointers = false;
@@ -942,8 +942,8 @@ BoxedPrototype::BoxedPrototype(GIStructInfo* info, GType gtype)
 bool BoxedPrototype::init(JSContext* context) {
     int i, n_methods;
     int first_constructor = -1;
-    jsid first_constructor_name = JSID_VOID;
-    jsid zero_args_constructor_name = JSID_VOID;
+    jsid first_constructor_name = JS::PropertyKey::Void();
+    jsid zero_args_constructor_name = JS::PropertyKey::Void();
 
     if (m_gtype != G_TYPE_NONE) {
         /* If the structure is registered as a boxed, we can create a new instance by
diff --git a/gi/object.cpp b/gi/object.cpp
index 1e56437f9..debe80083 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -676,7 +676,7 @@ static bool interface_getter(JSContext* cx, unsigned argc, JS::Value* vp) {
         g_assert(v_override_symbol.isSymbol() &&
                  "override symbol must be a symbol");
         JS::RootedSymbol override_symbol(cx, v_override_symbol.toSymbol());
-        JS::RootedId override_id(cx, SYMBOL_TO_JSID(override_symbol));
+        JS::RootedId override_id(cx, JS::PropertyKey::Symbol(override_symbol));
 
         JS::RootedObject this_obj(cx);
         if (!args.computeThis(cx, &this_obj))
@@ -696,7 +696,7 @@ static bool interface_getter(JSContext* cx, unsigned argc, JS::Value* vp) {
     g_assert(v_prototype.isObject() && "prototype must be an object");
 
     JS::RootedObject prototype(cx, &v_prototype.toObject());
-    JS::RootedId id(cx, JS::PropertyKey::fromNonIntAtom(JS_GetFunctionId(
+    JS::RootedId id(cx, JS::PropertyKey::NonIntAtom(JS_GetFunctionId(
                             JS_GetObjectFunction(&args.callee()))));
     return JS_GetPropertyById(cx, prototype, id, args.rval());
 }
@@ -720,7 +720,7 @@ static bool interface_setter(JSContext* cx, unsigned argc, JS::Value* vp) {
     JS::RootedObject this_obj(cx);
     if (!args.computeThis(cx, &this_obj))
         return false;
-    JS::RootedId override_id(cx, SYMBOL_TO_JSID(symbol));
+    JS::RootedId override_id(cx, JS::PropertyKey::Symbol(symbol));
 
     return JS_SetPropertyById(cx, this_obj, override_id, args[0]);
 }
diff --git a/gi/object.h b/gi/object.h
index 886f13eaf..00e51d6fc 100644
--- a/gi/object.h
+++ b/gi/object.h
@@ -173,7 +173,7 @@ struct IdHasher {
             return js::DefaultHasher<JSString*>::hash(id.toString());
         if (id.isSymbol())
             return js::DefaultHasher<JS::Symbol*>::hash(id.toSymbol());
-        return mozilla::HashGeneric(JSID_BITS(id));
+        return mozilla::HashGeneric(id.asRawBits());
     }
     static bool match(jsid id1, jsid id2) { return id1 == id2; }
 };
diff --git a/gjs/atoms.cpp b/gjs/atoms.cpp
index 6cb04f89b..46dae1444 100644
--- a/gjs/atoms.cpp
+++ b/gjs/atoms.cpp
@@ -31,7 +31,7 @@ bool GjsSymbolAtom::init(JSContext* cx, const char* str) {
     JS::Symbol* symbol = JS::NewSymbol(cx, descr);
     if (!symbol)
         return false;
-    m_jsid = JS::Heap<jsid>{SYMBOL_TO_JSID(symbol)};
+    m_jsid = JS::Heap<jsid>{JS::PropertyKey::Symbol(symbol)};
     return true;
 }
 
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index bac4ea8aa..1a3118a30 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -171,9 +171,9 @@ define_meta_properties(JSContext       *context,
                                module_path, attrs))
         return false;
 
-    JS::RootedId to_string_tag_name(context,
-        SYMBOL_TO_JSID(JS::GetWellKnownSymbol(context,
-                                              JS::SymbolCode::toStringTag)));
+    JS::RootedId to_string_tag_name(
+        context, JS::PropertyKey::Symbol(JS::GetWellKnownSymbol(
+                     context, JS::SymbolCode::toStringTag)));
     return JS_DefinePropertyById(context, module_obj, to_string_tag_name,
                                  to_string_tag, attrs);
 }
diff --git a/gjs/jsapi-util-string.cpp b/gjs/jsapi-util-string.cpp
index a39a0c055..89abe087e 100644
--- a/gjs/jsapi-util-string.cpp
+++ b/gjs/jsapi-util-string.cpp
@@ -437,7 +437,7 @@ bool gjs_get_string_id(JSContext* cx, jsid id, JS::UniqueChars* name_p) {
         return true;
     }
 
-    JSLinearString* lstr = JSID_TO_LINEAR_STRING(id);
+    JSLinearString* lstr = id.toLinearString();
     JS::RootedString s(cx, JS_FORGET_STRING_LINEARNESS(lstr));
     *name_p = JS_EncodeStringToUTF8(cx, s);
     return !!*name_p;
@@ -474,7 +474,7 @@ gjs_intern_string_to_id(JSContext  *cx,
 {
     JS::RootedString str(cx, JS_AtomizeAndPinString(cx, string));
     if (!str)
-        return JSID_VOID;
+        return JS::PropertyKey::Void();
     return JS::PropertyKey::fromPinnedString(str);
 }
 
@@ -661,6 +661,6 @@ std::string
 gjs_debug_id(jsid id)
 {
     if (id.isString())
-        return gjs_debug_linear_string(JSID_TO_LINEAR_STRING(id), NoQuotes);
+        return gjs_debug_linear_string(id.toLinearString(), NoQuotes);
     return gjs_debug_value(js::IdToValue(id));
 }


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