[gjs/mozjs102: 7/14] js: Adapt to new JS::PropertyKey API
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/mozjs102: 7/14] js: Adapt to new JS::PropertyKey API
- Date: Sun, 7 Aug 2022 23:42:40 +0000 (UTC)
commit a0ed043a9f2e75af44d9ccb7db2117cbdf0b828d
Author: Evan Welsh <contact evanwelsh com>
Date: Fri Jul 22 10:35:17 2022 -0700
js: Adapt to new JS::PropertyKey API
See: https://bugzilla.mozilla.org/show_bug.cgi?id=1754405
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 549f0d8fc..b3d23f4ab 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -930,7 +930,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;
@@ -945,8 +945,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 7bceffa0b..c69e42727 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -679,7 +679,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))
@@ -699,7 +699,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());
}
@@ -723,7 +723,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 0985845e9..c2fd4e5d9 100644
--- a/gi/object.h
+++ b/gi/object.h
@@ -170,7 +170,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 a8607dec5..0e64b5d48 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -174,9 +174,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 29e56c9e2..fcef285f7 100644
--- a/gjs/jsapi-util-string.cpp
+++ b/gjs/jsapi-util-string.cpp
@@ -438,7 +438,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;
@@ -475,7 +475,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);
}
@@ -662,6 +662,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]