Line 0
Link Here
|
|
|
1 |
From c9cd7024140b837b5693d7c1bbaad1b0cd31cce6 Mon Sep 17 00:00:00 2001 |
2 |
From: Emmanuele Bassi <ebassi@gnome.org> |
3 |
Date: Fri, 31 Aug 2018 13:32:16 +0100 |
4 |
Subject: [PATCH] Depend on mozjs-60 |
5 |
|
6 |
This is the new ESR version of the Mozilla JS engine, superceding |
7 |
mozjs-52. |
8 |
--- |
9 |
configure.ac | 2 +- |
10 |
1 file changed, 1 insertion(+), 1 deletion(-) |
11 |
|
12 |
diff --git a/configure.ac b/configure.ac |
13 |
index 5c37e48..5cedb4e 100644 |
14 |
--- a/configure.ac |
15 |
+++ b/configure.ac |
16 |
@@ -79,7 +79,7 @@ PKG_CHECK_MODULES(GLIB, [gmodule-2.0 gio-unix-2.0 >= 2.30.0]) |
17 |
AC_SUBST(GLIB_CFLAGS) |
18 |
AC_SUBST(GLIB_LIBS) |
19 |
|
20 |
-PKG_CHECK_MODULES(LIBJS, [mozjs-52]) |
21 |
+PKG_CHECK_MODULES(LIBJS, [mozjs-60]) |
22 |
|
23 |
AC_SUBST(LIBJS_CFLAGS) |
24 |
AC_SUBST(LIBJS_CXXFLAGS) |
25 |
|
26 |
|
27 |
From dd00683e8781d230a45781d509d86ad676138564 Mon Sep 17 00:00:00 2001 |
28 |
From: Emmanuele Bassi <ebassi@gnome.org> |
29 |
Date: Fri, 31 Aug 2018 13:33:20 +0100 |
30 |
Subject: [PATCH] Port the JS authority to mozjs-60 |
31 |
|
32 |
API changes in mozjs that need to be reflected in the JS authority: |
33 |
|
34 |
- the JS::CompileOptions constructor and the JS::CompartmentOptions |
35 |
do not allow setting a JS version any more |
36 |
|
37 |
- do not use NULL comparisons for C++ objects |
38 |
|
39 |
- the resize() method for a vector has a return value that needs |
40 |
to be handled |
41 |
|
42 |
- JSClassOps has different fields |
43 |
--- |
44 |
.../polkitbackendjsauthority.cpp | 65 +++++++++---------- |
45 |
1 file changed, 32 insertions(+), 33 deletions(-) |
46 |
|
47 |
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp |
48 |
index 7602714..984a0f0 100644 |
49 |
--- a/src/polkitbackend/polkitbackendjsauthority.cpp |
50 |
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp |
51 |
@@ -150,18 +150,17 @@ G_DEFINE_TYPE (PolkitBackendJsAuthority, polkit_backend_js_authority, POLKIT_BAC |
52 |
/* ---------------------------------------------------------------------------------------------------- */ |
53 |
|
54 |
static const struct JSClassOps js_global_class_ops = { |
55 |
- NULL, |
56 |
- NULL, |
57 |
- NULL, |
58 |
- NULL, |
59 |
- NULL, |
60 |
- NULL, |
61 |
- NULL, |
62 |
- NULL, |
63 |
- NULL, |
64 |
- NULL, |
65 |
- NULL, |
66 |
- NULL |
67 |
+ nullptr, // addProperty |
68 |
+ nullptr, // deleteProperty |
69 |
+ nullptr, // enumerate |
70 |
+ nullptr, // newEnumerate |
71 |
+ nullptr, // resolve |
72 |
+ nullptr, // mayResolve |
73 |
+ nullptr, // finalize |
74 |
+ nullptr, // call |
75 |
+ nullptr, // hasInstance |
76 |
+ nullptr, // construct |
77 |
+ JS_GlobalObjectTraceHook |
78 |
}; |
79 |
|
80 |
static JSClass js_global_class = { |
81 |
@@ -172,18 +171,17 @@ static JSClass js_global_class = { |
82 |
|
83 |
/* ---------------------------------------------------------------------------------------------------- */ |
84 |
static const struct JSClassOps js_polkit_class_ops = { |
85 |
- NULL, |
86 |
- NULL, |
87 |
- NULL, |
88 |
- NULL, |
89 |
- NULL, |
90 |
- NULL, |
91 |
- NULL, |
92 |
- NULL, |
93 |
- NULL, |
94 |
- NULL, |
95 |
- NULL, |
96 |
- NULL |
97 |
+ nullptr, // addProperty |
98 |
+ nullptr, // deleteProperty |
99 |
+ nullptr, // enumerate |
100 |
+ nullptr, // newEnumerate |
101 |
+ nullptr, // resolve |
102 |
+ nullptr, // mayResolve |
103 |
+ nullptr, // finalize |
104 |
+ nullptr, // call |
105 |
+ nullptr, // hasInstance |
106 |
+ nullptr, // construct |
107 |
+ nullptr // trace |
108 |
}; |
109 |
|
110 |
static JSClass js_polkit_class = { |
111 |
@@ -469,19 +467,18 @@ polkit_backend_js_authority_constructed (GObject *object) |
112 |
|
113 |
{ |
114 |
JS::CompartmentOptions compart_opts; |
115 |
- compart_opts.behaviors().setVersion(JSVERSION_LATEST); |
116 |
+ |
117 |
JS::RootedObject global(authority->priv->cx); |
118 |
|
119 |
authority->priv->js_global = new JS::Heap<JSObject*> (JS_NewGlobalObject (authority->priv->cx, &js_global_class, NULL, JS::FireOnNewGlobalHook, compart_opts)); |
120 |
|
121 |
global = authority->priv->js_global->get (); |
122 |
- |
123 |
- if (global == NULL) |
124 |
+ if (!global) |
125 |
goto fail; |
126 |
|
127 |
authority->priv->ac = new JSAutoCompartment(authority->priv->cx, global); |
128 |
|
129 |
- if (authority->priv->ac == NULL) |
130 |
+ if (!authority->priv->ac) |
131 |
goto fail; |
132 |
|
133 |
if (!JS_InitStandardClasses (authority->priv->cx, global)) |
134 |
@@ -493,7 +490,7 @@ polkit_backend_js_authority_constructed (GObject *object) |
135 |
|
136 |
polkit = authority->priv->js_polkit->get (); |
137 |
|
138 |
- if (polkit == NULL) |
139 |
+ if (!polkit) |
140 |
goto fail; |
141 |
|
142 |
if (!JS_DefineProperty(authority->priv->cx, global, "polkit", polkit, JSPROP_ENUMERATE)) |
143 |
@@ -504,7 +501,7 @@ polkit_backend_js_authority_constructed (GObject *object) |
144 |
js_polkit_functions)) |
145 |
goto fail; |
146 |
|
147 |
- JS::CompileOptions options(authority->priv->cx, JSVERSION_UNKNOWN); |
148 |
+ JS::CompileOptions options(authority->priv->cx); |
149 |
JS::RootedValue rval(authority->priv->cx); |
150 |
if (!JS::Evaluate (authority->priv->cx, |
151 |
options, |
152 |
@@ -684,7 +681,9 @@ set_property_strv (PolkitBackendJsAuthority *authority, |
153 |
JS::AutoValueVector elems(authority->priv->cx); |
154 |
guint n; |
155 |
|
156 |
- elems.resize(value->len); |
157 |
+ if (!elems.resize(value->len)) |
158 |
+ g_error ("Unable to resize vector"); |
159 |
+ |
160 |
for (n = 0; n < value->len; n++) |
161 |
{ |
162 |
const char *c_string = (const char *) g_ptr_array_index(value, n); |
163 |
@@ -741,7 +740,7 @@ subject_to_jsval (PolkitBackendJsAuthority *authority, |
164 |
GError **error) |
165 |
{ |
166 |
gboolean ret = FALSE; |
167 |
- JS::CompileOptions options(authority->priv->cx, JSVERSION_UNKNOWN); |
168 |
+ JS::CompileOptions options(authority->priv->cx); |
169 |
const char *src; |
170 |
JS::RootedObject obj(authority->priv->cx); |
171 |
pid_t pid; |
172 |
@@ -868,7 +867,7 @@ action_and_details_to_jsval (PolkitBackendJsAuthority *authority, |
173 |
GError **error) |
174 |
{ |
175 |
gboolean ret = FALSE; |
176 |
- JS::CompileOptions options(authority->priv->cx, JSVERSION_UNKNOWN); |
177 |
+ JS::CompileOptions options(authority->priv->cx); |
178 |
const char *src; |
179 |
JS::RootedObject obj(authority->priv->cx); |
180 |
gchar **keys; |