[gjs/mozjs78] Add 'Symbol.toStringTag' to internal objects' prototypes.
- From: Evan Welsh <ewlsh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/mozjs78] Add 'Symbol.toStringTag' to internal objects' prototypes.
- Date: Sun, 5 Jul 2020 23:59:59 +0000 (UTC)
commit c6f779f71b257093cc6752e0d544a2d9045072d9
Author: Evan Welsh <noreply evanwelsh com>
Date: Sun Jul 5 18:58:44 2020 -0500
Add 'Symbol.toStringTag' to internal objects' prototypes.
gi/function.cpp | 5 ++---
gi/gtype.cpp | 1 +
gi/ns.cpp | 1 +
gi/repo.cpp | 4 +++-
gi/wrapperutils.h | 5 +++--
gjs/importer.cpp | 5 ++++-
modules/cairo-context.cpp | 3 +--
modules/cairo-gradient.cpp | 3 +--
modules/cairo-image-surface.cpp | 3 +--
modules/cairo-linear-gradient.cpp | 4 ++--
modules/cairo-path.cpp | 3 +--
modules/cairo-pattern.cpp | 3 +--
modules/cairo-pdf-surface.cpp | 3 +--
modules/cairo-ps-surface.cpp | 3 +--
modules/cairo-radial-gradient.cpp | 4 ++--
modules/cairo-region.cpp | 3 +--
modules/cairo-solid-pattern.cpp | 3 +--
modules/cairo-surface-pattern.cpp | 4 ++--
modules/cairo-surface.cpp | 3 +--
modules/cairo-svg-surface.cpp | 3 +--
20 files changed, 31 insertions(+), 35 deletions(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index 01b93e33..3be2c4e1 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -1596,9 +1596,8 @@ struct JSClass gjs_function_class = {
};
static JSPropertySpec gjs_function_proto_props[] = {
- JS_PSG("length", get_num_arguments, JSPROP_PERMANENT),
- JS_PS_END
-};
+ JS_STRING_SYM_PS(toStringTag, "GIRepositoryFunction", JSPROP_READONLY),
+ JS_PSG("length", get_num_arguments, JSPROP_PERMANENT), JS_PS_END};
/* The original Function.prototype.toString complains when
given a GIRepository function as an argument */
diff --git a/gi/gtype.cpp b/gi/gtype.cpp
index 70cbe245..b17d2419 100644
--- a/gi/gtype.cpp
+++ b/gi/gtype.cpp
@@ -106,6 +106,7 @@ get_name_func (JSContext *context,
/* Properties */
JSPropertySpec gjs_gtype_proto_props[] = {
JS_PSG("name", get_name_func, JSPROP_PERMANENT),
+ JS_STRING_SYM_PS(toStringTag, "GIRepositoryGType", JSPROP_READONLY),
JS_PS_END,
};
diff --git a/gi/ns.cpp b/gi/ns.cpp
index 4f6f4f0f..79681f7e 100644
--- a/gi/ns.cpp
+++ b/gi/ns.cpp
@@ -200,6 +200,7 @@ struct JSClass gjs_ns_class = {
};
static JSPropertySpec gjs_ns_proto_props[] = {
+ JS_STRING_SYM_PS(toStringTag, "GIRepositoryNamespace", JSPROP_READONLY),
JS_PSG("__name__", get_name, GJS_MODULE_PROP_FLAGS),
JS_PS_END
};
diff --git a/gi/repo.cpp b/gi/repo.cpp
index 08df95e1..3cfecde0 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -250,10 +250,12 @@ struct JSClass gjs_repo_class = {
&gjs_repo_class_ops,
};
-static JSPropertySpec *gjs_repo_proto_props = nullptr;
static JSFunctionSpec *gjs_repo_proto_funcs = nullptr;
static JSFunctionSpec *gjs_repo_static_funcs = nullptr;
+static JSPropertySpec gjs_repo_proto_props[] = {
+ JS_STRING_SYM_PS(toStringTag, "GIRepository", JSPROP_READONLY), JS_PS_END};
+
GJS_DEFINE_PROTO_FUNCS(repo)
GJS_JSAPI_RETURN_CONVENTION
diff --git a/gi/wrapperutils.h b/gi/wrapperutils.h
index 8ec8b6ba..b5298959 100644
--- a/gi/wrapperutils.h
+++ b/gi/wrapperutils.h
@@ -159,6 +159,7 @@ class GIWrapperBase {
// These three can be overridden in subclasses. See define_jsclass().
static constexpr JSPropertySpec* proto_properties = nullptr;
+ static constexpr JSPropertySpec* static_properties = nullptr;
static constexpr JSFunctionSpec* proto_methods = nullptr;
static constexpr JSFunctionSpec* static_methods = nullptr;
@@ -299,7 +300,6 @@ class GIWrapperBase {
const char* name(void) const {
return info() ? g_base_info_get_name(info()) : type_name();
}
-
private:
// Accessor for Instance member. Used only in debug methods and toString().
GJS_USE
@@ -867,7 +867,8 @@ class GIWrapperPrototype : public Base {
cx, in_object, parent_proto, gi_namespace, Base::name(),
&Base::klass, &Base::constructor, nargs, Base::proto_properties,
parent_proto ? nullptr : Base::proto_methods,
- nullptr, // static properties, MyClass.myprop; not yet needed
+ Base::static_properties, // static properties, MyClass.myprop;
+ // not yet needed
Base::static_methods, prototype, constructor))
return false;
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index d43130d9..c2b18cc2 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -810,7 +810,10 @@ const JSClass gjs_importer_class = {
&gjs_importer_class_ops,
};
-static JSPropertySpec *gjs_importer_proto_props = nullptr;
+JSPropertySpec gjs_importer_proto_props[] = {
+ JS_STRING_SYM_PS(toStringTag, "GjsFileImporter", JSPROP_READONLY),
+ JS_PS_END};
+
static JSFunctionSpec *gjs_importer_static_funcs = nullptr;
JSFunctionSpec gjs_importer_proto_funcs[] = {
diff --git a/modules/cairo-context.cpp b/modules/cairo-context.cpp
index a6e8bd2d..c78052f8 100644
--- a/modules/cairo-context.cpp
+++ b/modules/cairo-context.cpp
@@ -307,8 +307,7 @@ static void gjs_cairo_context_finalize(JSFreeOp*, JSObject* obj) {
/* Properties */
JSPropertySpec gjs_cairo_context_proto_props[] = {
- JS_PS_END
-};
+ JS_STRING_SYM_PS(toStringTag, "Context", JSPROP_READONLY), JS_PS_END};
/* Methods */
diff --git a/modules/cairo-gradient.cpp b/modules/cairo-gradient.cpp
index 183725ff..76015e6d 100644
--- a/modules/cairo-gradient.cpp
+++ b/modules/cairo-gradient.cpp
@@ -49,8 +49,7 @@ gjs_cairo_gradient_finalize(JSFreeOp *fop,
/* Properties */
JSPropertySpec gjs_cairo_gradient_proto_props[] = {
- JS_PS_END
-};
+ JS_STRING_SYM_PS(toStringTag, "Gradient", JSPROP_READONLY), JS_PS_END};
/* Methods */
diff --git a/modules/cairo-image-surface.cpp b/modules/cairo-image-surface.cpp
index 407b9a7e..282ea925 100644
--- a/modules/cairo-image-surface.cpp
+++ b/modules/cairo-image-surface.cpp
@@ -80,8 +80,7 @@ gjs_cairo_image_surface_finalize(JSFreeOp *fop,
}
JSPropertySpec gjs_cairo_image_surface_proto_props[] = {
- JS_PS_END
-};
+ JS_STRING_SYM_PS(toStringTag, "ImageSurface", JSPROP_READONLY), JS_PS_END};
GJS_JSAPI_RETURN_CONVENTION
static bool
diff --git a/modules/cairo-linear-gradient.cpp b/modules/cairo-linear-gradient.cpp
index 3b50011b..5264f756 100644
--- a/modules/cairo-linear-gradient.cpp
+++ b/modules/cairo-linear-gradient.cpp
@@ -79,8 +79,8 @@ gjs_cairo_linear_gradient_finalize(JSFreeOp *fop,
}
JSPropertySpec gjs_cairo_linear_gradient_proto_props[] = {
- JS_PS_END
-};
+ JS_STRING_SYM_PS(toStringTag, "LinearGradient", JSPROP_READONLY),
+ JS_PS_END};
JSFunctionSpec gjs_cairo_linear_gradient_proto_funcs[] = {
// getLinearPoints
diff --git a/modules/cairo-path.cpp b/modules/cairo-path.cpp
index 2d95318f..4e4d0ad0 100644
--- a/modules/cairo-path.cpp
+++ b/modules/cairo-path.cpp
@@ -49,8 +49,7 @@ static void gjs_cairo_path_finalize(JSFreeOp*, JSObject* obj) {
/* Properties */
JSPropertySpec gjs_cairo_path_proto_props[] = {
- JS_PS_END
-};
+ JS_STRING_SYM_PS(toStringTag, "Path", JSPROP_READONLY), JS_PS_END};
JSFunctionSpec gjs_cairo_path_proto_funcs[] = {
JS_FS_END
diff --git a/modules/cairo-pattern.cpp b/modules/cairo-pattern.cpp
index 8669a338..4754a3c6 100644
--- a/modules/cairo-pattern.cpp
+++ b/modules/cairo-pattern.cpp
@@ -51,8 +51,7 @@ static void gjs_cairo_pattern_finalize(JSFreeOp*, JSObject* obj) {
/* Properties */
JSPropertySpec gjs_cairo_pattern_proto_props[] = {
- JS_PS_END
-};
+ JS_STRING_SYM_PS(toStringTag, "Pattern", JSPROP_READONLY), JS_PS_END};
/* Methods */
diff --git a/modules/cairo-pdf-surface.cpp b/modules/cairo-pdf-surface.cpp
index 546509a0..381c552a 100644
--- a/modules/cairo-pdf-surface.cpp
+++ b/modules/cairo-pdf-surface.cpp
@@ -86,8 +86,7 @@ gjs_cairo_pdf_surface_finalize(JSFreeOp *fop,
}
JSPropertySpec gjs_cairo_pdf_surface_proto_props[] = {
- JS_PS_END
-};
+ JS_STRING_SYM_PS(toStringTag, "PDFSurface", JSPROP_READONLY), JS_PS_END};
JSFunctionSpec gjs_cairo_pdf_surface_proto_funcs[] = {
JS_FS_END
diff --git a/modules/cairo-ps-surface.cpp b/modules/cairo-ps-surface.cpp
index a83e7fc8..3e033c94 100644
--- a/modules/cairo-ps-surface.cpp
+++ b/modules/cairo-ps-surface.cpp
@@ -86,8 +86,7 @@ gjs_cairo_ps_surface_finalize(JSFreeOp *fop,
}
JSPropertySpec gjs_cairo_ps_surface_proto_props[] = {
- JS_PS_END
-};
+ JS_STRING_SYM_PS(toStringTag, "PSSurface", JSPROP_READONLY), JS_PS_END};
JSFunctionSpec gjs_cairo_ps_surface_proto_funcs[] = {
// restrictToLevel
diff --git a/modules/cairo-radial-gradient.cpp b/modules/cairo-radial-gradient.cpp
index 3d0e71fc..caf02e8b 100644
--- a/modules/cairo-radial-gradient.cpp
+++ b/modules/cairo-radial-gradient.cpp
@@ -81,8 +81,8 @@ gjs_cairo_radial_gradient_finalize(JSFreeOp *fop,
}
JSPropertySpec gjs_cairo_radial_gradient_proto_props[] = {
- JS_PS_END
-};
+ JS_STRING_SYM_PS(toStringTag, "RadialGradient", JSPROP_READONLY),
+ JS_PS_END};
JSFunctionSpec gjs_cairo_radial_gradient_proto_funcs[] = {
// getRadialCircles
diff --git a/modules/cairo-region.cpp b/modules/cairo-region.cpp
index f291732a..1b04d505 100644
--- a/modules/cairo-region.cpp
+++ b/modules/cairo-region.cpp
@@ -223,8 +223,7 @@ get_rectangle_func(JSContext *context,
}
JSPropertySpec gjs_cairo_region_proto_props[] = {
- JS_PS_END
-};
+ JS_STRING_SYM_PS(toStringTag, "Region", JSPROP_READONLY), JS_PS_END};
JSFunctionSpec gjs_cairo_region_proto_funcs[] = {
JS_FN("union", union_func, 0, 0),
diff --git a/modules/cairo-solid-pattern.cpp b/modules/cairo-solid-pattern.cpp
index e03e420a..9db695f1 100644
--- a/modules/cairo-solid-pattern.cpp
+++ b/modules/cairo-solid-pattern.cpp
@@ -53,8 +53,7 @@ gjs_cairo_solid_pattern_finalize(JSFreeOp *fop,
}
JSPropertySpec gjs_cairo_solid_pattern_proto_props[] = {
- JS_PS_END
-};
+ JS_STRING_SYM_PS(toStringTag, "SolidPattern", JSPROP_READONLY), JS_PS_END};
GJS_JSAPI_RETURN_CONVENTION
static bool
diff --git a/modules/cairo-surface-pattern.cpp b/modules/cairo-surface-pattern.cpp
index 5c522d7d..7f43cc78 100644
--- a/modules/cairo-surface-pattern.cpp
+++ b/modules/cairo-surface-pattern.cpp
@@ -83,8 +83,8 @@ gjs_cairo_surface_pattern_finalize(JSFreeOp *fop,
}
JSPropertySpec gjs_cairo_surface_pattern_proto_props[] = {
- JS_PS_END
-};
+ JS_STRING_SYM_PS(toStringTag, "SurfacePattern", JSPROP_READONLY),
+ JS_PS_END};
GJS_JSAPI_RETURN_CONVENTION
static bool
diff --git a/modules/cairo-surface.cpp b/modules/cairo-surface.cpp
index 4f7560b4..2fe19373 100644
--- a/modules/cairo-surface.cpp
+++ b/modules/cairo-surface.cpp
@@ -56,8 +56,7 @@ static void gjs_cairo_surface_finalize(JSFreeOp*, JSObject* obj) {
/* Properties */
JSPropertySpec gjs_cairo_surface_proto_props[] = {
- JS_PS_END
-};
+ JS_STRING_SYM_PS(toStringTag, "Surface", JSPROP_READONLY), JS_PS_END};
/* Methods */
GJS_JSAPI_RETURN_CONVENTION
diff --git a/modules/cairo-svg-surface.cpp b/modules/cairo-svg-surface.cpp
index e620bfdb..ba9703a0 100644
--- a/modules/cairo-svg-surface.cpp
+++ b/modules/cairo-svg-surface.cpp
@@ -86,8 +86,7 @@ gjs_cairo_svg_surface_finalize(JSFreeOp *fop,
}
JSPropertySpec gjs_cairo_svg_surface_proto_props[] = {
- JS_PS_END
-};
+ JS_STRING_SYM_PS(toStringTag, "SVGSurface", JSPROP_READONLY), JS_PS_END};
JSFunctionSpec gjs_cairo_svg_surface_proto_funcs[] = {
JS_FS_END
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]